mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +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
|
const uint32_t* Picture::data(uint32_t* w, uint32_t* h) const noexcept
|
||||||
{
|
{
|
||||||
//Try it, If not loaded yet.
|
//Try it, If not loaded yet.
|
||||||
pImpl->reload();
|
pImpl->load();
|
||||||
|
|
||||||
if (pImpl->loader) {
|
if (pImpl->loader) {
|
||||||
if (w) *w = static_cast<uint32_t>(pImpl->loader->w);
|
if (w) *w = static_cast<uint32_t>(pImpl->loader->w);
|
||||||
|
|
|
@ -85,7 +85,7 @@ struct Picture::Impl
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t reload()
|
uint32_t load()
|
||||||
{
|
{
|
||||||
if (loader) {
|
if (loader) {
|
||||||
if (!paint) {
|
if (!paint) {
|
||||||
|
@ -103,12 +103,13 @@ struct Picture::Impl
|
||||||
if (paint) return RenderUpdateFlag::None;
|
if (paint) return RenderUpdateFlag::None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(surface);
|
if (!surface) {
|
||||||
if ((surface = loader->bitmap().release())) {
|
if ((surface = loader->bitmap().release())) {
|
||||||
loader->close();
|
loader->close();
|
||||||
return RenderUpdateFlag::Image;
|
return RenderUpdateFlag::Image;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return RenderUpdateFlag::None;
|
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)
|
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) {
|
if (surface) {
|
||||||
auto transform = resizeTransform(pTransform);
|
auto transform = resizeTransform(pTransform);
|
||||||
|
@ -265,7 +266,7 @@ struct Picture::Impl
|
||||||
|
|
||||||
Paint* duplicate()
|
Paint* duplicate()
|
||||||
{
|
{
|
||||||
reload();
|
load();
|
||||||
|
|
||||||
auto ret = Picture::gen();
|
auto ret = Picture::gen();
|
||||||
|
|
||||||
|
@ -297,7 +298,7 @@ struct Picture::Impl
|
||||||
|
|
||||||
Iterator* iterator()
|
Iterator* iterator()
|
||||||
{
|
{
|
||||||
reload();
|
load();
|
||||||
return new PictureIterator(paint);
|
return new PictureIterator(paint);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue