lottie/optimization: optimize rendering when layer has clipper and mask
authorsubhransu mohanty <sub.mohanty@samsung.com>
Thu, 19 Sep 2019 07:56:46 +0000 (16:56 +0900)
committerJongmin Lee <jm105.lee@samsung.com>
Sun, 22 Sep 2019 21:53:45 +0000 (06:53 +0900)
When layer has clipper and mask we create a temporary rle in each frame rendering
by avoiding the extra Rle object avoids memory allocation and speeds up rendering.

src/lottie/lottieitem.cpp
src/lottie/lottieitem.h

index cdab800..cdcf541 100644 (file)
@@ -484,11 +484,8 @@ void LOTCompLayerItem::renderHelper(VPainter *painter, const VRle &inheritMask,
     }
 
     if (mClipper) {
-        if (mask.empty()) {
-            mask = mClipper->rle();
-        } else {
-            mask = mClipper->rle() & mask;
-        }
+        mask = mClipper->rle(mask);
+        if (mask.empty()) return;
     }
 
     LOTLayerItem *matte = nullptr;
@@ -570,9 +567,14 @@ void LOTClipperItem::update(const VMatrix &matrix)
     mRasterizer.rasterize(mPath);
 }
 
-VRle LOTClipperItem::rle()
+VRle LOTClipperItem::rle(const VRle& mask)
 {
-    return mRasterizer.rle();
+    if (mask.empty())
+        return mRasterizer.rle();
+
+    mMaskedRle.clone(mask);
+    mMaskedRle &= mRasterizer.rle();
+    return mMaskedRle;
 }
 
 void LOTCompLayerItem::updateContent()
index 22bdf35..53fee5c 100644 (file)
@@ -89,10 +89,11 @@ class LOTClipperItem
 public:
     explicit LOTClipperItem(VSize size): mSize(size){}
     void update(const VMatrix &matrix);
-    VRle rle();
+    VRle rle(const VRle& mask);
 public:
     VSize                    mSize;
     VPath                    mPath;
+    VRle                     mMaskedRle;
     VRasterizer              mRasterizer;
 };