lottie/render: optimize rendering by passing rle clip to painter instead of creating... 78/195278/2
authorsubhransu mohanty <sub.mohanty@samsung.com>
Wed, 12 Dec 2018 06:30:16 +0000 (15:30 +0900)
committerHermet Park <chuneon.park@samsung.com>
Thu, 13 Dec 2018 06:26:42 +0000 (06:26 +0000)
Rle operations usually generate new rle which means memory allocation.
by using drawRle() with clip version we can avoid the intermediate rle generation.

Change-Id: I8b3010b1dfc296ee9288631d7b5df1ac4265210b

src/lottie/lottieitem.cpp

index 621f64c..0ea95e1 100644 (file)
@@ -278,18 +278,27 @@ void LOTLayerItem::render(VPainter *painter, const VRle &inheritMask, const VRle
     for (auto &i : mDrawableList) {
         painter->setBrush(i->mBrush);
         VRle rle = i->rle();
-        if (!mask.empty()) rle = rle & mask;
+        if (matteRle.empty()) {
+            if (mask.empty()) {
+                // no mask no matte
+                painter->drawRle(VPoint(), rle);
+            } else {
+                // only mask
+                painter->drawRle(rle, mask);
+            }
 
-        if (rle.empty()) continue;
+        } else {
+            if (!mask.empty()) rle = rle & mask;
 
-        if (!matteRle.empty()) {
+            if (rle.empty()) continue;
             if (matteType() == MatteType::AlphaInv) {
                 rle = rle - matteRle;
+                painter->drawRle(VPoint(), rle);
             } else {
-                rle = rle & matteRle;
+                // render with matteRle as clip.
+                painter->drawRle(rle, matteRle);
             }
         }
-        painter->drawRle(VPoint(), rle);
     }
 }