rlottie: optimize matte rendering when both src and matte are invisible
authorsubhransu mohanty <sub.mohanty@samsung.com>
Mon, 3 Jun 2019 00:12:50 +0000 (09:12 +0900)
committerHermet Park <hermetpark@gmail.com>
Wed, 19 Jun 2019 04:34:23 +0000 (13:34 +0900)
src/lottie/lottieitem.cpp
src/vector/vdrawable.cpp

index aa30000..e0a9f33 100644 (file)
@@ -597,26 +597,18 @@ void LOTCompLayerItem::render(VPainter *painter, const VRle &inheritMask, const
         }
     }
 
-    LOTLayerItem *matteLayer = nullptr;
+    LOTLayerItem *matte = nullptr;
     for (const auto &layer : mLayers) {
         if (layer->hasMatte()) {
-            if (matteLayer) {
-                vWarning << "two consecutive layer has matter : not supported";
-            }
-            matteLayer = layer.get();
-            continue;
-        }
-
-        if (layer->visible()) {
-            if (matteLayer) {
-                if (matteLayer->visible())
-                    renderMatteLayer(painter, mask, matteRle, matteLayer, layer.get());
+            matte = layer.get();
+        } else {
+            if (matte && matte->visible() && layer->visible()) {
+                renderMatteLayer(painter, mask, matteRle, matte, layer.get());
             } else {
                 layer->render(painter, mask, matteRle);
             }
+            matte = nullptr;
         }
-
-        matteLayer = nullptr;
     }
 }
 
@@ -710,8 +702,19 @@ void LOTCompLayerItem::renderList(std::vector<VDrawable *> &list)
 {
     if (!visible()) return;
 
+    LOTLayerItem *matte = nullptr;
     for (const auto &layer : mLayers) {
-        layer->renderList(list);
+        if (layer->hasMatte()) {
+            matte = layer.get();
+        } else {
+            if (matte && matte->visible() && layer->visible()) {
+                layer->renderList(list);
+                matte->renderList(list);
+            } else {
+                layer->renderList(list);
+            }
+            matte = nullptr;
+        }
     }
 }
 
index 575d6cd..dc933f5 100644 (file)
@@ -41,7 +41,8 @@ void VDrawable::preprocess(const VRect &clip)
             VRaster::generateFillInfo(mRleFuture,
                 std::move(mPath), std::move(mRle), mFillRule, clip);
         }
-        mRle = VRle();
+        mRle = {};
+        mPath = {};
         mFlag &= ~DirtyFlag(DirtyState::Path);
     }
 }