From: subhransu mohanty Date: Fri, 9 Nov 2018 01:50:00 +0000 (+0900) Subject: lottie: update LOTNode with the gradient stop value. X-Git-Tag: submit/tizen/20181129.071502~34 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c3a7b9f53f050b25bff1ac680748b67cd9c38bff;p=platform%2Fcore%2Fuifw%2Flottie-player.git lottie: update LOTNode with the gradient stop value. Change-Id: I85f882418d66341f2667428e293364e2cd916a9e --- diff --git a/inc/lottiecommon.h b/inc/lottiecommon.h index 22400e6..dd65f9b 100644 --- a/inc/lottiecommon.h +++ b/inc/lottiecommon.h @@ -71,6 +71,12 @@ typedef enum GradientRadial } LOTGradientType; +typedef struct +{ + float pos; + unsigned char r, g, b, a; +}GradientStop; + typedef struct LOTNode { #define ChangeFlagNone 0x0000 @@ -101,6 +107,8 @@ typedef struct LOTNode { struct { LOTGradientType type; + GradientStop *stopPtr; + unsigned int stopCount; struct { float x, y; } start, end, center, focal; diff --git a/src/lottie/lottieitem.cpp b/src/lottie/lottieitem.cpp index cb7a2ad..bf9ffac 100644 --- a/src/lottie/lottieitem.cpp +++ b/src/lottie/lottieitem.cpp @@ -992,9 +992,34 @@ void LOTRepeaterItem::update(int /*frameNo*/, const VMatrix &/*parentMatrix*/, void LOTRepeaterItem::renderList(std::vector &/*list*/) {} +static void updateGStops(LOTNode *n, const VGradient *grad) +{ + if (grad->mStops.size() != n->mGradient.stopCount) { + if (n->mGradient.stopCount) + free(n->mGradient.stopPtr); + n->mGradient.stopCount = grad->mStops.size(); + n->mGradient.stopPtr = (GradientStop *) malloc(n->mGradient.stopCount * sizeof(GradientStop)); + } + + GradientStop *ptr = n->mGradient.stopPtr; + for (const auto &i : grad->mStops) { + ptr->pos = i.first; + ptr->a = i.second.alpha() * grad->alpha(); + ptr->r = i.second.red(); + ptr->g = i.second.green(); + ptr->b = i.second.blue(); + ptr++; + } + +} + void LOTDrawable::sync() { - if (!mCNode) mCNode = std::make_unique(); + if (!mCNode) { + mCNode = std::make_unique(); + mCNode->mGradient.stopPtr = nullptr; + mCNode->mGradient.stopCount = 0; + } mCNode->mFlag = ChangeFlagNone; if (mFlag & DirtyState::None) return; @@ -1077,6 +1102,7 @@ void LOTDrawable::sync() mCNode->mGradient.start.y = mBrush.mGradient->linear.y1; mCNode->mGradient.end.x = mBrush.mGradient->linear.x2; mCNode->mGradient.end.y = mBrush.mGradient->linear.y2; + updateGStops(mCNode.get(), mBrush.mGradient); break; case VBrush::Type::RadialGradient: mCNode->mType = LOTBrushType::BrushGradient; @@ -1087,6 +1113,7 @@ void LOTDrawable::sync() mCNode->mGradient.focal.y = mBrush.mGradient->radial.fy; mCNode->mGradient.cradius = mBrush.mGradient->radial.cradius; mCNode->mGradient.fradius = mBrush.mGradient->radial.fradius; + updateGStops(mCNode.get(), mBrush.mGradient); break; default: break;