From 95004fcf34fc29025e052458c40f9929ac69f313 Mon Sep 17 00:00:00 2001 From: subhransu mohanty Date: Thu, 19 Jul 2018 10:06:05 +0900 Subject: [PATCH] lottie/model: refactored path direction handling. Change-Id: I6a41f72e3635f3ad91f188d99868b3e8e44d3174 --- src/lottie/lottieitem.cpp | 17 ++++------------- src/lottie/lottieitem.h | 1 - src/lottie/lottiemodel.h | 5 +++-- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/lottie/lottieitem.cpp b/src/lottie/lottieitem.cpp index c4129ca..54fe487 100644 --- a/src/lottie/lottieitem.cpp +++ b/src/lottie/lottieitem.cpp @@ -655,15 +655,6 @@ void LOTShapeLayerItem::renderList(std::vector &list) mRoot->renderList(list); } -VPath::Direction LOTContentItem::direction(bool isCW) -{ - if (isCW) - return VPath::Direction::CW; - else - return VPath::Direction::CCW; -} - - LOTContentGroupItem::LOTContentGroupItem(LOTShapeGroupData *data):mData(data) { addChildren(mData); @@ -813,7 +804,7 @@ VPath LOTRectItem::getPath(int frameNo) VRectF r(pos.x() - size.x()/2, pos.y() - size.y()/2, size.x(), size.y()); VPath path; - path.addRoundRect(r, radius, radius, direction(mData->isDirectionCW())); + path.addRoundRect(r, radius, radius, mData->direction()); return path; } @@ -830,7 +821,7 @@ VPath LOTEllipseItem::getPath(int frameNo) VRectF r(pos.x() - size.x()/2, pos.y() - size.y()/2, size.x(), size.y()); VPath path; - path.addOval(r, direction(mData->isDirectionCW())); + path.addOval(r, mData->direction()); return path; } @@ -884,11 +875,11 @@ VPath LOTPolystarItem::getPath(int frameNo) path.addPolystarStar(0.0, 0.0, 0.0, points, innerRadius, outerRadius, innerRoundness, outerRoundness, - direction(mData->isDirectionCW())); + mData->direction()); } else { path.addPolystarPolygon(0.0, 0.0, 0.0, points, outerRadius, outerRoundness, - direction(mData->isDirectionCW())); + mData->direction()); } m.translate(pos.x(), pos.y()).rotate(rotation); diff --git a/src/lottie/lottieitem.h b/src/lottie/lottieitem.h index 58f302d..88d0b25 100644 --- a/src/lottie/lottieitem.h +++ b/src/lottie/lottieitem.h @@ -215,7 +215,6 @@ public: virtual ~LOTContentItem(){} virtual void update(int frameNo, const VMatrix &parentMatrix, float parentAlpha, const DirtyFlag &flag) = 0; virtual void renderList(std::vector &list){} - VPath::Direction direction(bool isCW); }; class LOTContentGroupItem: public LOTContentItem diff --git a/src/lottie/lottiemodel.h b/src/lottie/lottiemodel.h index e6c5d9d..fc3475e 100644 --- a/src/lottie/lottiemodel.h +++ b/src/lottie/lottiemodel.h @@ -608,8 +608,9 @@ public: class LOTPath : public LOTData { public: - LOTPath(LOTData::Type type):LOTData(type), mDirection(3){} - bool isDirectionCW() const { return ((mDirection == 3) ? false : true );} + LOTPath(LOTData::Type type):LOTData(type), mDirection(1){} + VPath::Direction direction() { if (mDirection == 3) return VPath::Direction::CCW; + else return VPath::Direction::CW;} public: int mDirection; std::vector> mPathOperations; -- 2.34.1