From cbf5a3245eb6e5275da2dd353b5edfd5b2422e8a Mon Sep 17 00:00:00 2001 From: subhransu mohanty Date: Wed, 12 Dec 2018 15:30:16 +0900 Subject: [PATCH] lottie/render: optimize rendering by passing rle clip to painter instead of creating a new rle. 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 | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/lottie/lottieitem.cpp b/src/lottie/lottieitem.cpp index 621f64c..0ea95e1 100644 --- a/src/lottie/lottieitem.cpp +++ b/src/lottie/lottieitem.cpp @@ -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); } } -- 2.34.1