scene: fixing nested masking 13/313713/2
authorjoogab.yun <joogab.yun@samsung.com>
Mon, 1 Jul 2024 06:45:15 +0000 (15:45 +0900)
committerjoogab.yun <joogab.yun@samsung.com>
Tue, 2 Jul 2024 05:36:00 +0000 (14:36 +0900)
For any type of masking composition may be required.

Change-Id: Ieb731646098c87535bbe764b48018267f1dc9a92

src/lib/tvgScene.cpp
src/lib/tvgSceneImpl.h

index 54cbe52045bd94f9bb93a5571e442b76a726a427..feb45a9d221ef660caf8683d1883e9695aab179d 100644 (file)
@@ -26,7 +26,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<Scene::Impl>(pImpl));
index 5c07cb502f75121793fc14262b84df00346e0078..0d14be8bc4c5ba60d567fbd04ccfc7c8410ec55c 100644 (file)
@@ -62,6 +62,12 @@ struct Scene::Impl
     uint8_t opacity;                     //for composition
     RenderMethod* renderer = nullptr;    //keep it for explicit clear
 
+    Scene* scene = nullptr;
+
+    Impl(Scene* s) : scene(s)
+    {
+    }
+
     ~Impl()
     {
         for (auto paint = paints.data; paint < (paints.data + paints.count); ++paint) {
@@ -83,7 +89,14 @@ struct Scene::Impl
     bool needComposition(uint32_t opacity)
     {
         //Half translucent requires intermediate composition.
-        if (opacity == 255 || opacity == 0) return false;
+        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) return false;
 
         //If scene has several children or only scene, it may require composition.
         if (paints.count > 1) return true;