common picture: tiny optimization.

Currently Picture doesn't allow to change the image source.
Thus reloading is not non-sense.
This commit is contained in:
Hermet Park 2023-04-27 18:34:16 +09:00
parent c710af2560
commit 9fb66973f0
2 changed files with 10 additions and 9 deletions

View file

@ -107,7 +107,7 @@ Result Picture::size(float* w, float* h) const noexcept
const uint32_t* Picture::data(uint32_t* w, uint32_t* h) const noexcept
{
//Try it, If not loaded yet.
pImpl->reload();
pImpl->load();
if (pImpl->loader) {
if (w) *w = static_cast<uint32_t>(pImpl->loader->w);

View file

@ -85,7 +85,7 @@ struct Picture::Impl
return ret;
}
uint32_t reload()
uint32_t load()
{
if (loader) {
if (!paint) {
@ -103,10 +103,11 @@ struct Picture::Impl
if (paint) return RenderUpdateFlag::None;
}
}
free(surface);
if ((surface = loader->bitmap().release())) {
loader->close();
return RenderUpdateFlag::Image;
if (!surface) {
if ((surface = loader->bitmap().release())) {
loader->close();
return RenderUpdateFlag::Image;
}
}
}
return RenderUpdateFlag::None;
@ -128,7 +129,7 @@ struct Picture::Impl
RenderData update(RenderMethod &renderer, const RenderTransform* pTransform, uint32_t opacity, Array<RenderData>& clips, RenderUpdateFlag pFlag, bool clipper)
{
auto flag = reload();
auto flag = load();
if (surface) {
auto transform = resizeTransform(pTransform);
@ -265,7 +266,7 @@ struct Picture::Impl
Paint* duplicate()
{
reload();
load();
auto ret = Picture::gen();
@ -297,7 +298,7 @@ struct Picture::Impl
Iterator* iterator()
{
reload();
load();
return new PictureIterator(paint);
}
};