diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2023-05-12 15:08:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-12 15:08:03 +0200 |
commit | 2ac4e3bb30517998916bb6b81b7b76788276038c (patch) | |
tree | 245bf4614ff38f3b0fcac813c1dde8c39b57732d /thirdparty/thorvg/src/lib/tvgSceneImpl.h | |
parent | fdf66b3472e5ca254a4f90c32f26c4702d46828b (diff) | |
parent | fa8b32cbd4503e73a840bd1a1dd32d2a88cc3f45 (diff) |
Merge pull request #76998 from akien-mga/4.0-cherrypicks
Cherry-picks for the 4.0 branch (future 4.0.3) - 4th batch
Diffstat (limited to 'thirdparty/thorvg/src/lib/tvgSceneImpl.h')
-rw-r--r-- | thirdparty/thorvg/src/lib/tvgSceneImpl.h | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/thirdparty/thorvg/src/lib/tvgSceneImpl.h b/thirdparty/thorvg/src/lib/tvgSceneImpl.h index b6c68262c6..9ce4d0b37d 100644 --- a/thirdparty/thorvg/src/lib/tvgSceneImpl.h +++ b/thirdparty/thorvg/src/lib/tvgSceneImpl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 - 2022 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (c) 2020 - 2023 the ThorVG project. All rights reserved. * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -19,6 +19,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ + #ifndef _TVG_SCENE_IMPL_H_ #define _TVG_SCENE_IMPL_H_ @@ -60,6 +61,7 @@ struct Scene::Impl Array<Paint*> paints; uint8_t opacity; //for composition RenderMethod* renderer = nullptr; //keep it for explicit clear + RenderData rd = nullptr; Scene* scene = nullptr; Impl(Scene* s) : scene(s) @@ -79,9 +81,11 @@ struct Scene::Impl (*paint)->pImpl->dispose(renderer); } + auto ret = renderer.dispose(rd); this->renderer = nullptr; + this->rd = nullptr; - return true; + return ret; } bool needComposition(uint32_t opacity) @@ -101,23 +105,29 @@ struct Scene::Impl return false; } - void* update(RenderMethod &renderer, const RenderTransform* transform, uint32_t opacity, Array<RenderData>& clips, RenderUpdateFlag flag) + RenderData update(RenderMethod &renderer, const RenderTransform* transform, uint32_t opacity, Array<RenderData>& clips, RenderUpdateFlag flag, bool clipper) { /* Overriding opacity value. If this scene is half-translucent, It must do intermeidate composition with that opacity value. */ this->opacity = static_cast<uint8_t>(opacity); if (needComposition(opacity)) opacity = 255; - for (auto paint = paints.data; paint < (paints.data + paints.count); ++paint) { - (*paint)->pImpl->update(renderer, transform, opacity, clips, static_cast<uint32_t>(flag)); - } - - /* FXIME: it requires to return list of children engine data - This is necessary for scene composition */ - this->renderer = &renderer; - return nullptr; + if (clipper) { + Array<RenderData> rds; + rds.reserve(paints.count); + for (auto paint = paints.data; paint < (paints.data + paints.count); ++paint) { + rds.push((*paint)->pImpl->update(renderer, transform, opacity, clips, flag, true)); + } + rd = renderer.prepare(rds, rd, transform, opacity, clips, flag); + return rd; + } else { + for (auto paint = paints.data; paint < (paints.data + paints.count); ++paint) { + (*paint)->pImpl->update(renderer, transform, opacity, clips, flag, false); + } + return nullptr; + } } bool render(RenderMethod& renderer) @@ -125,7 +135,7 @@ struct Scene::Impl Compositor* cmp = nullptr; if (needComposition(opacity)) { - cmp = renderer.target(bounds(renderer)); + cmp = renderer.target(bounds(renderer), renderer.colorSpace()); renderer.beginComposite(cmp, CompositeMethod::None, opacity); } |