From 5c59c9aa715882d31c92e4d10c8a9b3e35f0ae78 Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Sun, 1 Jan 2023 20:05:18 +0100 Subject: [PATCH] scene: fixing nested masking For any type of masking composition may be required. @Issue: https://github.com/Samsung/thorvg/issues/1295 --- src/lib/tvgScene.cpp | 2 +- src/lib/tvgSceneImpl.h | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/lib/tvgScene.cpp b/src/lib/tvgScene.cpp index 0beec47b..9ed7d45d 100644 --- a/src/lib/tvgScene.cpp +++ b/src/lib/tvgScene.cpp @@ -25,7 +25,7 @@ /* External Class Implementation */ /************************************************************************/ -Scene::Scene() : pImpl(new Impl()) +Scene::Scene() : pImpl(new Impl(this)) { Paint::pImpl->id = TVG_CLASS_ID_SCENE; Paint::pImpl->method(new PaintMethod(pImpl)); diff --git a/src/lib/tvgSceneImpl.h b/src/lib/tvgSceneImpl.h index 6a7614c6..b6c68262 100644 --- a/src/lib/tvgSceneImpl.h +++ b/src/lib/tvgSceneImpl.h @@ -60,6 +60,11 @@ struct Scene::Impl Array paints; uint8_t opacity; //for composition RenderMethod* renderer = nullptr; //keep it for explicit clear + Scene* scene = nullptr; + + Impl(Scene* s) : scene(s) + { + } ~Impl() { @@ -81,8 +86,14 @@ struct Scene::Impl bool needComposition(uint32_t opacity) { + if (opacity == 0 || paints.count == 0) return false; + + //Masking may require composition (even if opacity == 255) + auto compMethod = scene->composite(nullptr); + if (compMethod != CompositeMethod::None && compMethod != CompositeMethod::ClipPath) return true; + //Half translucent requires intermediate composition. - if (opacity == 255 || opacity == 0) return false; + if (opacity == 255) return false; //If scene has several children or only scene, it may require composition. if (paints.count > 1) return true;