From a3a306f605a1e4d0ddf0bbee550cfbcf96ab9230 Mon Sep 17 00:00:00 2001 From: Subhransu Mohanty Date: Tue, 18 Aug 2020 13:10:40 +0900 Subject: [PATCH] render: fix issue with mask opacity handling --- src/lottie/lottieitem.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/lottie/lottieitem.cpp b/src/lottie/lottieitem.cpp index 4f93794..5fdf28b 100644 --- a/src/lottie/lottieitem.cpp +++ b/src/lottie/lottieitem.cpp @@ -173,32 +173,38 @@ bool renderer::Composition::render(const rlottie::Surface &surface) void renderer::Mask::update(int frameNo, const VMatrix &parentMatrix, float /*parentAlpha*/, const DirtyFlag &flag) { + bool dirtyPath = false; + if (flag.testFlag(DirtyFlagBit::None) && mData->isStatic()) return; if (mData->mShape.isStatic()) { if (mLocalPath.empty()) { + dirtyPath = true; mData->mShape.value(frameNo, mLocalPath); } } else { + dirtyPath = true; mData->mShape.value(frameNo, mLocalPath); } /* mask item dosen't inherit opacity */ mCombinedAlpha = mData->opacity(frameNo); - mFinalPath.clone(mLocalPath); - mFinalPath.transform(parentMatrix); - - mRasterRequest = true; + if ( flag.testFlag(DirtyFlagBit::Matrix) || dirtyPath ) { + mFinalPath.clone(mLocalPath); + mFinalPath.transform(parentMatrix); + mRasterRequest = true; + } } VRle renderer::Mask::rle() { - if (mRasterRequest) { - mRasterRequest = false; - if (!vCompare(mCombinedAlpha, 1.0f)) - mRasterizer.rle() *= uchar(mCombinedAlpha * 255); + if (!vCompare(mCombinedAlpha, 1.0f)) { + VRle obj = mRasterizer.rle(); + obj *= uchar(mCombinedAlpha * 255); + return obj; + } else { + return mRasterizer.rle(); } - return mRasterizer.rle(); } void renderer::Mask::preprocess(const VRect &clip) -- 2.34.1