mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +00:00
renderer/loader: code refactoring.
Removed internal unique_ptr usage for a more compact size.
This commit is contained in:
parent
4997f55e6c
commit
60282f51f8
14 changed files with 20 additions and 20 deletions
|
@ -147,7 +147,7 @@ bool JpgLoader::read()
|
|||
}
|
||||
|
||||
|
||||
unique_ptr<Surface> JpgLoader::bitmap()
|
||||
Surface* JpgLoader::bitmap()
|
||||
{
|
||||
if (!image) return nullptr;
|
||||
|
||||
|
@ -162,5 +162,5 @@ unique_ptr<Surface> JpgLoader::bitmap()
|
|||
surface->premultiplied = true;
|
||||
surface->owner = true;
|
||||
|
||||
return unique_ptr<Surface>(surface);
|
||||
return surface;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
bool open(const char* data, uint32_t size, bool copy) override;
|
||||
bool read() override;
|
||||
|
||||
unique_ptr<Surface> bitmap() override;
|
||||
Surface* bitmap() override;
|
||||
|
||||
private:
|
||||
void clear();
|
||||
|
|
|
@ -106,7 +106,7 @@ bool PngLoader::read()
|
|||
}
|
||||
|
||||
|
||||
unique_ptr<Surface> PngLoader::bitmap()
|
||||
Surface* PngLoader::bitmap()
|
||||
{
|
||||
if (!content) return nullptr;
|
||||
|
||||
|
@ -121,5 +121,5 @@ unique_ptr<Surface> PngLoader::bitmap()
|
|||
surface->owner = true;
|
||||
surface->premultiplied = false;
|
||||
|
||||
return unique_ptr<Surface>(surface);
|
||||
return surface;
|
||||
}
|
|
@ -36,7 +36,7 @@ public:
|
|||
bool open(const char* data, uint32_t size, bool copy) override;
|
||||
bool read() override;
|
||||
|
||||
unique_ptr<Surface> bitmap() override;
|
||||
Surface* bitmap() override;
|
||||
|
||||
private:
|
||||
void clear();
|
||||
|
|
|
@ -126,7 +126,7 @@ bool WebpLoader::read()
|
|||
}
|
||||
|
||||
|
||||
unique_ptr<Surface> WebpLoader::bitmap()
|
||||
Surface* WebpLoader::bitmap()
|
||||
{
|
||||
this->done();
|
||||
|
||||
|
@ -142,5 +142,5 @@ unique_ptr<Surface> WebpLoader::bitmap()
|
|||
surface->channelSize = sizeof(uint32_t);
|
||||
surface->premultiplied = false;
|
||||
surface->owner = true;
|
||||
return unique_ptr<Surface>(surface);
|
||||
return surface;
|
||||
}
|
|
@ -36,7 +36,7 @@ public:
|
|||
bool open(const char* data, uint32_t size, bool copy) override;
|
||||
bool read() override;
|
||||
|
||||
unique_ptr<Surface> bitmap() override;
|
||||
Surface* bitmap() override;
|
||||
|
||||
private:
|
||||
void run(unsigned tid) override;
|
||||
|
|
|
@ -125,7 +125,7 @@ bool JpgLoader::close()
|
|||
}
|
||||
|
||||
|
||||
unique_ptr<Surface> JpgLoader::bitmap()
|
||||
Surface* JpgLoader::bitmap()
|
||||
{
|
||||
this->done();
|
||||
|
||||
|
@ -142,5 +142,5 @@ unique_ptr<Surface> JpgLoader::bitmap()
|
|||
surface->premultiplied = true;
|
||||
surface->owner = true;
|
||||
|
||||
return unique_ptr<Surface>(surface);
|
||||
return surface;
|
||||
}
|
|
@ -47,7 +47,7 @@ public:
|
|||
bool read() override;
|
||||
bool close() override;
|
||||
|
||||
unique_ptr<Surface> bitmap() override;
|
||||
Surface* bitmap() override;
|
||||
};
|
||||
|
||||
#endif //_TVG_JPG_LOADER_H_
|
||||
|
|
|
@ -140,7 +140,7 @@ bool PngLoader::read()
|
|||
}
|
||||
|
||||
|
||||
unique_ptr<Surface> PngLoader::bitmap()
|
||||
Surface* PngLoader::bitmap()
|
||||
{
|
||||
this->done();
|
||||
|
||||
|
@ -157,5 +157,5 @@ unique_ptr<Surface> PngLoader::bitmap()
|
|||
surface->premultiplied = false;
|
||||
surface->owner = true;
|
||||
|
||||
return unique_ptr<Surface>(surface);
|
||||
return surface;
|
||||
}
|
|
@ -46,7 +46,7 @@ public:
|
|||
bool open(const char* data, uint32_t size, bool copy) override;
|
||||
bool read() override;
|
||||
|
||||
unique_ptr<Surface> bitmap() override;
|
||||
Surface* bitmap() override;
|
||||
};
|
||||
|
||||
#endif //_TVG_PNG_LOADER_H_
|
||||
|
|
|
@ -78,7 +78,7 @@ bool RawLoader::read()
|
|||
}
|
||||
|
||||
|
||||
unique_ptr<Surface> RawLoader::bitmap()
|
||||
Surface* RawLoader::bitmap()
|
||||
{
|
||||
if (!content) return nullptr;
|
||||
|
||||
|
@ -93,5 +93,5 @@ unique_ptr<Surface> RawLoader::bitmap()
|
|||
surface->premultiplied = true;
|
||||
surface->owner = true;
|
||||
|
||||
return unique_ptr<Surface>(surface);
|
||||
return surface;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
bool open(const uint32_t* data, uint32_t w, uint32_t h, bool copy);
|
||||
bool read() override;
|
||||
|
||||
unique_ptr<Surface> bitmap() override;
|
||||
Surface* bitmap() override;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ struct ImageLoader : LoadModule
|
|||
ImageLoader(FileType type) : LoadModule(type) {}
|
||||
|
||||
virtual bool animatable() { return false; } //true if this loader supports animation.
|
||||
virtual unique_ptr<Surface> bitmap() { return nullptr; }
|
||||
virtual Surface* bitmap() { return nullptr; }
|
||||
virtual Paint* paint() { return nullptr; }
|
||||
};
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ RenderUpdateFlag Picture::Impl::load()
|
|||
} else loader->sync();
|
||||
|
||||
if (!surface) {
|
||||
if ((surface = loader->bitmap().release())) {
|
||||
if ((surface = loader->bitmap())) {
|
||||
return RenderUpdateFlag::Image;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue