lottie/render: don't redraw stroke/dash if there is no change

It will improve performance.

Change-Id: I3764d126d7eae19d009d72998247789e620205a1
This commit is contained in:
Youngbok Shin
2018-08-03 17:46:02 +09:00
committed by Subhransu Mohanty
parent 10cb2bda92
commit 296534e3c0
2 changed files with 20 additions and 0 deletions

View File

@@ -31,6 +31,10 @@ VRle VDrawable::rle()
void VDrawable::setStrokeInfo(CapStyle cap, JoinStyle join, float meterLimit,
float strokeWidth)
{
if ((mStroke.cap == cap) && (mStroke.join == join) &&
vCompare(mStroke.meterLimit, meterLimit) && vCompare(mStroke.width, strokeWidth))
return;
mStroke.enable = true;
mStroke.cap = cap;
mStroke.join = join;
@@ -41,6 +45,21 @@ void VDrawable::setStrokeInfo(CapStyle cap, JoinStyle join, float meterLimit,
void VDrawable::setDashInfo(float *array, int size)
{
bool hasChanged = false;
if (mStroke.dashArraySize == size) {
for (int i = 0; i < size; i++) {
if (!vCompare(mStroke.dashArray[i], array[i])) {
hasChanged = true;
break;
}
}
} else {
hasChanged = true;
}
if (!hasChanged) return;
mStroke.dashArray = array;
mStroke.dashArraySize = size;
mFlag |= DirtyState::Path;