renderer/loader: code refactoring.

Removed internal unique_ptr usage for a more compact size.
This commit is contained in:
Hermet Park 2023-12-29 14:31:51 +09:00
parent 4997f55e6c
commit 60282f51f8
14 changed files with 20 additions and 20 deletions

View file

@ -147,7 +147,7 @@ bool JpgLoader::read()
} }
unique_ptr<Surface> JpgLoader::bitmap() Surface* JpgLoader::bitmap()
{ {
if (!image) return nullptr; if (!image) return nullptr;
@ -162,5 +162,5 @@ unique_ptr<Surface> JpgLoader::bitmap()
surface->premultiplied = true; surface->premultiplied = true;
surface->owner = true; surface->owner = true;
return unique_ptr<Surface>(surface); return surface;
} }

View file

@ -38,7 +38,7 @@ public:
bool open(const char* data, uint32_t size, bool copy) override; bool open(const char* data, uint32_t size, bool copy) override;
bool read() override; bool read() override;
unique_ptr<Surface> bitmap() override; Surface* bitmap() override;
private: private:
void clear(); void clear();

View file

@ -106,7 +106,7 @@ bool PngLoader::read()
} }
unique_ptr<Surface> PngLoader::bitmap() Surface* PngLoader::bitmap()
{ {
if (!content) return nullptr; if (!content) return nullptr;
@ -121,5 +121,5 @@ unique_ptr<Surface> PngLoader::bitmap()
surface->owner = true; surface->owner = true;
surface->premultiplied = false; surface->premultiplied = false;
return unique_ptr<Surface>(surface); return surface;
} }

View file

@ -36,7 +36,7 @@ public:
bool open(const char* data, uint32_t size, bool copy) override; bool open(const char* data, uint32_t size, bool copy) override;
bool read() override; bool read() override;
unique_ptr<Surface> bitmap() override; Surface* bitmap() override;
private: private:
void clear(); void clear();

View file

@ -126,7 +126,7 @@ bool WebpLoader::read()
} }
unique_ptr<Surface> WebpLoader::bitmap() Surface* WebpLoader::bitmap()
{ {
this->done(); this->done();
@ -142,5 +142,5 @@ unique_ptr<Surface> WebpLoader::bitmap()
surface->channelSize = sizeof(uint32_t); surface->channelSize = sizeof(uint32_t);
surface->premultiplied = false; surface->premultiplied = false;
surface->owner = true; surface->owner = true;
return unique_ptr<Surface>(surface); return surface;
} }

View file

@ -36,7 +36,7 @@ public:
bool open(const char* data, uint32_t size, bool copy) override; bool open(const char* data, uint32_t size, bool copy) override;
bool read() override; bool read() override;
unique_ptr<Surface> bitmap() override; Surface* bitmap() override;
private: private:
void run(unsigned tid) override; void run(unsigned tid) override;

View file

@ -125,7 +125,7 @@ bool JpgLoader::close()
} }
unique_ptr<Surface> JpgLoader::bitmap() Surface* JpgLoader::bitmap()
{ {
this->done(); this->done();
@ -142,5 +142,5 @@ unique_ptr<Surface> JpgLoader::bitmap()
surface->premultiplied = true; surface->premultiplied = true;
surface->owner = true; surface->owner = true;
return unique_ptr<Surface>(surface); return surface;
} }

View file

@ -47,7 +47,7 @@ public:
bool read() override; bool read() override;
bool close() override; bool close() override;
unique_ptr<Surface> bitmap() override; Surface* bitmap() override;
}; };
#endif //_TVG_JPG_LOADER_H_ #endif //_TVG_JPG_LOADER_H_

View file

@ -140,7 +140,7 @@ bool PngLoader::read()
} }
unique_ptr<Surface> PngLoader::bitmap() Surface* PngLoader::bitmap()
{ {
this->done(); this->done();
@ -157,5 +157,5 @@ unique_ptr<Surface> PngLoader::bitmap()
surface->premultiplied = false; surface->premultiplied = false;
surface->owner = true; surface->owner = true;
return unique_ptr<Surface>(surface); return surface;
} }

View file

@ -46,7 +46,7 @@ public:
bool open(const char* data, uint32_t size, bool copy) override; bool open(const char* data, uint32_t size, bool copy) override;
bool read() override; bool read() override;
unique_ptr<Surface> bitmap() override; Surface* bitmap() override;
}; };
#endif //_TVG_PNG_LOADER_H_ #endif //_TVG_PNG_LOADER_H_

View file

@ -78,7 +78,7 @@ bool RawLoader::read()
} }
unique_ptr<Surface> RawLoader::bitmap() Surface* RawLoader::bitmap()
{ {
if (!content) return nullptr; if (!content) return nullptr;
@ -93,5 +93,5 @@ unique_ptr<Surface> RawLoader::bitmap()
surface->premultiplied = true; surface->premultiplied = true;
surface->owner = true; surface->owner = true;
return unique_ptr<Surface>(surface); return surface;
} }

View file

@ -36,7 +36,7 @@ public:
bool open(const uint32_t* data, uint32_t w, uint32_t h, bool copy); bool open(const uint32_t* data, uint32_t w, uint32_t h, bool copy);
bool read() override; bool read() override;
unique_ptr<Surface> bitmap() override; Surface* bitmap() override;
}; };

View file

@ -74,7 +74,7 @@ struct ImageLoader : LoadModule
ImageLoader(FileType type) : LoadModule(type) {} ImageLoader(FileType type) : LoadModule(type) {}
virtual bool animatable() { return false; } //true if this loader supports animation. 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; } virtual Paint* paint() { return nullptr; }
}; };

View file

@ -45,7 +45,7 @@ RenderUpdateFlag Picture::Impl::load()
} else loader->sync(); } else loader->sync();
if (!surface) { if (!surface) {
if ((surface = loader->bitmap().release())) { if ((surface = loader->bitmap())) {
return RenderUpdateFlag::Image; return RenderUpdateFlag::Image;
} }
} }