mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
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:
parent
c710af2560
commit
9fb66973f0
2 changed files with 10 additions and 9 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue