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
This commit is contained in:
subhransu mohanty 2018-12-12 15:30:16 +09:00 committed by Hermet Park
parent fb6bf7bef9
commit cbf5a3245e

View 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);
}
}