| 1 |
/* |
| 2 |
* Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. |
| 3 |
* |
| 4 |
* This library is free software; you can redistribute it and/or |
| 5 |
* modify it under the terms of the GNU Lesser General Public |
| 6 |
* License as published by the Free Software Foundation; either |
| 7 |
* version 2.1 of the License, or (at your option) any later version. |
| 8 |
* |
| 9 |
* This library is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
* Lesser General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU Lesser General Public |
| 15 |
* License along with this library; if not, write to the Free Software |
| 16 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 |
*/ |
| 18 |
|
| 19 |
#ifndef LOTTIEITEM_H |
| 20 |
#define LOTTIEITEM_H |
| 21 |
|
| 22 |
#include<sstream> |
| 23 |
#include<memory> |
| 24 |
|
| 25 |
#include"lottieproxymodel.h" |
| 26 |
#include"vmatrix.h" |
| 27 |
#include"vpath.h" |
| 28 |
#include"vpoint.h" |
| 29 |
#include"vpathmesure.h" |
| 30 |
#include"rlottiecommon.h" |
| 31 |
#include"rlottie.h" |
| 32 |
#include"vpainter.h" |
| 33 |
#include"vdrawable.h" |
| 34 |
#include"lottiekeypath.h" |
| 35 |
#include"varenaalloc.h" |
| 36 |
|
| 37 |
V_USE_NAMESPACE |
| 38 |
|
| 39 |
enum class DirtyFlagBit : uchar |
| 40 |
{ |
| 41 |
None = 0x00, |
| 42 |
Matrix = 0x01, |
| 43 |
Alpha = 0x02, |
| 44 |
All = (Matrix | Alpha) |
| 45 |
}; |
| 46 |
|
| 47 |
class LOTLayerItem; |
| 48 |
class LOTMaskItem; |
| 49 |
class VDrawable; |
| 50 |
|
| 51 |
class LOTDrawable : public VDrawable |
| 52 |
{ |
| 53 |
public: |
| 54 |
void sync(); |
| 55 |
public: |
| 56 |
std::unique_ptr<LOTNode> mCNode{nullptr}; |
| 57 |
|
| 58 |
~LOTDrawable() { |
| 59 |
if (mCNode && mCNode->mGradient.stopPtr) |
| 60 |
free(mCNode->mGradient.stopPtr); |
| 61 |
} |
| 62 |
}; |
| 63 |
|
| 64 |
class LOTCompItem |
| 65 |
{ |
| 66 |
public: |
| 67 |
explicit LOTCompItem(LOTModel *model); |
| 68 |
bool update(int frameNo, const VSize &size, bool keepAspectRatio); |
| 69 |
VSize size() const { return mViewSize;} |
| 70 |
void buildRenderTree(); |
| 71 |
const LOTLayerNode * renderTree()const; |
| 72 |
bool render(const rlottie::Surface &surface); |
| 73 |
void setValue(const std::string &keypath, LOTVariant &value); |
| 74 |
private: |
| 75 |
VBitmap mSurface; |
| 76 |
VMatrix mScaleMatrix; |
| 77 |
VSize mViewSize; |
| 78 |
LOTCompositionData *mCompData{nullptr}; |
| 79 |
LOTLayerItem *mRootLayer{nullptr}; |
| 80 |
VArenaAlloc mAllocator{2048}; |
| 81 |
int mCurFrameNo; |
| 82 |
bool mKeepAspectRatio{true}; |
| 83 |
}; |
| 84 |
|
| 85 |
class LOTLayerMaskItem; |
| 86 |
|
| 87 |
class LOTClipperItem |
| 88 |
{ |
| 89 |
public: |
| 90 |
explicit LOTClipperItem(VSize size): mSize(size){} |
| 91 |
void update(const VMatrix &matrix); |
| 92 |
void preprocess(const VRect &clip); |
| 93 |
VRle rle(const VRle& mask); |
| 94 |
public: |
| 95 |
VSize mSize; |
| 96 |
VPath mPath; |
| 97 |
VRle mMaskedRle; |
| 98 |
VRasterizer mRasterizer; |
| 99 |
bool mRasterRequest{false}; |
| 100 |
}; |
| 101 |
|
| 102 |
typedef vFlag<DirtyFlagBit> DirtyFlag; |
| 103 |
|
| 104 |
struct LOTCApiData |
| 105 |
{ |
| 106 |
LOTCApiData(); |
| 107 |
LOTLayerNode mLayer; |
| 108 |
std::vector<LOTMask> mMasks; |
| 109 |
std::vector<LOTLayerNode *> mLayers; |
| 110 |
std::vector<LOTNode *> mCNodeList; |
| 111 |
}; |
| 112 |
|
| 113 |
template< class T> |
| 114 |
class VSpan |
| 115 |
{ |
| 116 |
public: |
| 117 |
using reference = T &; |
| 118 |
using pointer = T *; |
| 119 |
using const_pointer = T const *; |
| 120 |
using const_reference = T const &; |
| 121 |
using index_type = size_t; |
| 122 |
|
| 123 |
using iterator = pointer; |
| 124 |
using const_iterator = const_pointer; |
| 125 |
|
| 126 |
VSpan() = default; |
| 127 |
VSpan(pointer data, index_type size):_data(data), _size(size){} |
| 128 |
|
| 129 |
constexpr pointer data() const noexcept {return _data; } |
| 130 |
constexpr index_type size() const noexcept {return _size; } |
| 131 |
constexpr bool empty() const noexcept { return size() == 0 ;} |
| 132 |
constexpr iterator begin() const noexcept { return data(); } |
| 133 |
constexpr iterator end() const noexcept {return data() + size() ;} |
| 134 |
constexpr const_iterator cbegin() const noexcept {return data();} |
| 135 |
constexpr const_iterator cend() const noexcept { return data() + size();} |
| 136 |
constexpr reference operator[]( index_type idx ) const { return *( data() + idx );} |
| 137 |
|
| 138 |
private: |
| 139 |
pointer _data{nullptr}; |
| 140 |
index_type _size{0}; |
| 141 |
}; |
| 142 |
|
| 143 |
using DrawableList = VSpan<VDrawable *>; |
| 144 |
|
| 145 |
class LOTLayerItem |
| 146 |
{ |
| 147 |
public: |
| 148 |
virtual ~LOTLayerItem() = default; |
| 149 |
LOTLayerItem& operator=(LOTLayerItem&&) noexcept = delete; |
| 150 |
LOTLayerItem(LOTLayerData *layerData); |
| 151 |
int id() const {return mLayerData->id();} |
| 152 |
int parentId() const {return mLayerData->parentId();} |
| 153 |
void setParentLayer(LOTLayerItem *parent){mParentLayer = parent;} |
| 154 |
void setComplexContent(bool value) { mComplexContent = value;} |
| 155 |
bool complexContent() const {return mComplexContent;} |
| 156 |
virtual void update(int frameNo, const VMatrix &parentMatrix, float parentAlpha); |
| 157 |
VMatrix matrix(int frameNo) const; |
| 158 |
void preprocess(const VRect& clip); |
| 159 |
virtual DrawableList renderList(){ return {};} |
| 160 |
virtual void render(VPainter *painter, const VRle &mask, const VRle &matteRle); |
| 161 |
bool hasMatte() { if (mLayerData->mMatteType == MatteType::None) return false; return true; } |
| 162 |
MatteType matteType() const { return mLayerData->mMatteType;} |
| 163 |
bool visible() const; |
| 164 |
virtual void buildLayerNode(); |
| 165 |
LOTLayerNode& clayer() {return mCApiData->mLayer;} |
| 166 |
std::vector<LOTLayerNode *>& clayers() {return mCApiData->mLayers;} |
| 167 |
std::vector<LOTMask>& cmasks() {return mCApiData->mMasks;} |
| 168 |
std::vector<LOTNode *>& cnodes() {return mCApiData->mCNodeList;} |
| 169 |
const char* name() const {return mLayerData->name();} |
| 170 |
virtual bool resolveKeyPath(LOTKeyPath &keyPath, uint depth, LOTVariant &value); |
| 171 |
VBitmap& bitmap() {return mRenderBuffer;} |
| 172 |
protected: |
| 173 |
virtual void preprocessStage(const VRect& clip) = 0; |
| 174 |
virtual void updateContent() = 0; |
| 175 |
inline VMatrix combinedMatrix() const {return mCombinedMatrix;} |
| 176 |
inline int frameNo() const {return mFrameNo;} |
| 177 |
inline float combinedAlpha() const {return mCombinedAlpha;} |
| 178 |
inline bool isStatic() const {return mLayerData->isStatic();} |
| 179 |
float opacity(int frameNo) const {return mLayerData->opacity(frameNo);} |
| 180 |
inline DirtyFlag flag() const {return mDirtyFlag;} |
| 181 |
bool skipRendering() const {return (!visible() || vIsZero(combinedAlpha()));} |
| 182 |
protected: |
| 183 |
std::unique_ptr<LOTLayerMaskItem> mLayerMask; |
| 184 |
LOTLayerData *mLayerData{nullptr}; |
| 185 |
LOTLayerItem *mParentLayer{nullptr}; |
| 186 |
VMatrix mCombinedMatrix; |
| 187 |
VBitmap mRenderBuffer; |
| 188 |
float mCombinedAlpha{0.0}; |
| 189 |
int mFrameNo{-1}; |
| 190 |
DirtyFlag mDirtyFlag{DirtyFlagBit::All}; |
| 191 |
bool mComplexContent{false}; |
| 192 |
std::unique_ptr<LOTCApiData> mCApiData; |
| 193 |
}; |
| 194 |
|
| 195 |
class LOTCompLayerItem: public LOTLayerItem |
| 196 |
{ |
| 197 |
public: |
| 198 |
explicit LOTCompLayerItem(LOTLayerData *layerData, VArenaAlloc* allocator); |
| 199 |
|
| 200 |
void render(VPainter *painter, const VRle &mask, const VRle &matteRle) final; |
| 201 |
void buildLayerNode() final; |
| 202 |
bool resolveKeyPath(LOTKeyPath &keyPath, uint depth, LOTVariant &value) override; |
| 203 |
protected: |
| 204 |
void preprocessStage(const VRect& clip) final; |
| 205 |
void updateContent() final; |
| 206 |
private: |
| 207 |
void renderHelper(VPainter *painter, const VRle &mask, const VRle &matteRle); |
| 208 |
void renderMatteLayer(VPainter *painter, const VRle &inheritMask, const VRle &matteRle, |
| 209 |
LOTLayerItem *layer, LOTLayerItem *src); |
| 210 |
private: |
| 211 |
std::vector<LOTLayerItem*> mLayers; |
| 212 |
std::unique_ptr<LOTClipperItem> mClipper; |
| 213 |
}; |
| 214 |
|
| 215 |
class LOTSolidLayerItem: public LOTLayerItem |
| 216 |
{ |
| 217 |
public: |
| 218 |
explicit LOTSolidLayerItem(LOTLayerData *layerData); |
| 219 |
void buildLayerNode() final; |
| 220 |
DrawableList renderList() final; |
| 221 |
protected: |
| 222 |
void preprocessStage(const VRect& clip) final; |
| 223 |
void updateContent() final; |
| 224 |
private: |
| 225 |
LOTDrawable mRenderNode; |
| 226 |
VDrawable *mDrawableList{nullptr}; //to work with the Span api |
| 227 |
}; |
| 228 |
|
| 229 |
class LOTContentItem; |
| 230 |
class LOTContentGroupItem; |
| 231 |
class LOTShapeLayerItem: public LOTLayerItem |
| 232 |
{ |
| 233 |
public: |
| 234 |
explicit LOTShapeLayerItem(LOTLayerData *layerData, VArenaAlloc* allocator); |
| 235 |
DrawableList renderList() final; |
| 236 |
void buildLayerNode() final; |
| 237 |
bool resolveKeyPath(LOTKeyPath &keyPath, uint depth, LOTVariant &value) override; |
| 238 |
protected: |
| 239 |
void preprocessStage(const VRect& clip) final; |
| 240 |
void updateContent() final; |
| 241 |
std::vector<VDrawable *> mDrawableList; |
| 242 |
LOTContentGroupItem *mRoot{nullptr}; |
| 243 |
}; |
| 244 |
|
| 245 |
class LOTNullLayerItem: public LOTLayerItem |
| 246 |
{ |
| 247 |
public: |
| 248 |
explicit LOTNullLayerItem(LOTLayerData *layerData); |
| 249 |
protected: |
| 250 |
void preprocessStage(const VRect&) final {} |
| 251 |
void updateContent() final; |
| 252 |
}; |
| 253 |
|
| 254 |
class LOTImageLayerItem: public LOTLayerItem |
| 255 |
{ |
| 256 |
public: |
| 257 |
explicit LOTImageLayerItem(LOTLayerData *layerData); |
| 258 |
void buildLayerNode() final; |
| 259 |
DrawableList renderList() final; |
| 260 |
protected: |
| 261 |
void preprocessStage(const VRect& clip) final; |
| 262 |
void updateContent() final; |
| 263 |
private: |
| 264 |
LOTDrawable mRenderNode; |
| 265 |
VTexture mTexture; |
| 266 |
VDrawable *mDrawableList{nullptr}; //to work with the Span api |
| 267 |
}; |
| 268 |
|
| 269 |
class LOTMaskItem |
| 270 |
{ |
| 271 |
public: |
| 272 |
explicit LOTMaskItem(LOTMaskData *data): mData(data){} |
| 273 |
void update(int frameNo, const VMatrix &parentMatrix, float parentAlpha, const DirtyFlag &flag); |
| 274 |
LOTMaskData::Mode maskMode() const { return mData->mMode;} |
| 275 |
VRle rle(); |
| 276 |
void preprocess(const VRect &clip); |
| 277 |
public: |
| 278 |
LOTMaskData *mData{nullptr}; |
| 279 |
VPath mLocalPath; |
| 280 |
VPath mFinalPath; |
| 281 |
VRasterizer mRasterizer; |
| 282 |
float mCombinedAlpha{0}; |
| 283 |
bool mRasterRequest{false}; |
| 284 |
}; |
| 285 |
|
| 286 |
/* |
| 287 |
* Handels mask property of a layer item |
| 288 |
*/ |
| 289 |
class LOTLayerMaskItem |
| 290 |
{ |
| 291 |
public: |
| 292 |
explicit LOTLayerMaskItem(LOTLayerData *layerData); |
| 293 |
void update(int frameNo, const VMatrix &parentMatrix, float parentAlpha, const DirtyFlag &flag); |
| 294 |
bool isStatic() const {return mStatic;} |
| 295 |
VRle maskRle(const VRect &clipRect); |
| 296 |
void preprocess(const VRect &clip); |
| 297 |
public: |
| 298 |
std::vector<LOTMaskItem> mMasks; |
| 299 |
VRle mRle; |
| 300 |
bool mStatic{true}; |
| 301 |
bool mDirty{true}; |
| 302 |
}; |
| 303 |
|
| 304 |
class LOTPathDataItem; |
| 305 |
class LOTPaintDataItem; |
| 306 |
class LOTTrimItem; |
| 307 |
|
| 308 |
enum class ContentType : uchar |
| 309 |
{ |
| 310 |
Unknown, |
| 311 |
Group, |
| 312 |
Path, |
| 313 |
Paint, |
| 314 |
Trim |
| 315 |
}; |
| 316 |
|
| 317 |
class LOTContentGroupItem; |
| 318 |
class LOTContentItem |
| 319 |
{ |
| 320 |
public: |
| 321 |
virtual ~LOTContentItem() = default; |
| 322 |
LOTContentItem& operator=(LOTContentItem&&) noexcept = delete; |
| 323 |
virtual void update(int frameNo, const VMatrix &parentMatrix, float parentAlpha, const DirtyFlag &flag) = 0; virtual void renderList(std::vector<VDrawable *> &){} |
| 324 |
virtual bool resolveKeyPath(LOTKeyPath &, uint, LOTVariant &) {return false;} |
| 325 |
virtual ContentType type() const {return ContentType::Unknown;} |
| 326 |
}; |
| 327 |
|
| 328 |
class LOTContentGroupItem: public LOTContentItem |
| 329 |
{ |
| 330 |
public: |
| 331 |
LOTContentGroupItem() = default; |
| 332 |
explicit LOTContentGroupItem(LOTGroupData *data, VArenaAlloc* allocator); |
| 333 |
void addChildren(LOTGroupData *data, VArenaAlloc* allocator); |
| 334 |
void update(int frameNo, const VMatrix &parentMatrix, float parentAlpha, const DirtyFlag &flag) override; |
| 335 |
void applyTrim(); |
| 336 |
void processTrimItems(std::vector<LOTPathDataItem *> &list); |
| 337 |
void processPaintItems(std::vector<LOTPathDataItem *> &list); |
| 338 |
void renderList(std::vector<VDrawable *> &list) override; |
| 339 |
ContentType type() const final {return ContentType::Group;} |
| 340 |
const VMatrix & matrix() const { return mMatrix;} |
| 341 |
const char* name() const |
| 342 |
{ |
| 343 |
static const char* TAG = "__"; |
| 344 |
return mModel.hasModel() ? mModel.name() : TAG; |
| 345 |
} |
| 346 |
bool resolveKeyPath(LOTKeyPath &keyPath, uint depth, LOTVariant &value) override; |
| 347 |
protected: |
| 348 |
std::vector<LOTContentItem*> mContents; |
| 349 |
VMatrix mMatrix; |
| 350 |
private: |
| 351 |
LOTProxyModel<LOTGroupData> mModel; |
| 352 |
}; |
| 353 |
|
| 354 |
class LOTPathDataItem : public LOTContentItem |
| 355 |
{ |
| 356 |
public: |
| 357 |
LOTPathDataItem(bool staticPath): mStaticPath(staticPath){} |
| 358 |
void update(int frameNo, const VMatrix &parentMatrix, float parentAlpha, const DirtyFlag &flag) final; |
| 359 |
ContentType type() const final {return ContentType::Path;} |
| 360 |
bool dirty() const {return mDirtyPath;} |
| 361 |
const VPath &localPath() const {return mTemp;} |
| 362 |
void finalPath(VPath& result); |
| 363 |
void updatePath(const VPath &path) {mTemp = path; mDirtyPath = true;} |
| 364 |
bool staticPath() const { return mStaticPath; } |
| 365 |
void setParent(LOTContentGroupItem *parent) {mParent = parent;} |
| 366 |
LOTContentGroupItem *parent() const {return mParent;} |
| 367 |
protected: |
| 368 |
virtual void updatePath(VPath& path, int frameNo) = 0; |
| 369 |
virtual bool hasChanged(int prevFrame, int curFrame) = 0; |
| 370 |
private: |
| 371 |
bool hasChanged(int frameNo) { |
| 372 |
int prevFrame = mFrameNo; |
| 373 |
mFrameNo = frameNo; |
| 374 |
if (prevFrame == -1) return true; |
| 375 |
if (mStaticPath || |
| 376 |
(prevFrame == frameNo)) return false; |
| 377 |
return hasChanged(prevFrame, frameNo); |
| 378 |
} |
| 379 |
LOTContentGroupItem *mParent{nullptr}; |
| 380 |
VPath mLocalPath; |
| 381 |
VPath mTemp; |
| 382 |
int mFrameNo{-1}; |
| 383 |
bool mDirtyPath{true}; |
| 384 |
bool mStaticPath; |
| 385 |
}; |
| 386 |
|
| 387 |
class LOTRectItem: public LOTPathDataItem |
| 388 |
{ |
| 389 |
public: |
| 390 |
explicit LOTRectItem(LOTRectData *data); |
| 391 |
protected: |
| 392 |
void updatePath(VPath& path, int frameNo) final; |
| 393 |
LOTRectData *mData{nullptr}; |
| 394 |
|
| 395 |
bool hasChanged(int prevFrame, int curFrame) final { |
| 396 |
return (mData->mPos.changed(prevFrame, curFrame) || |
| 397 |
mData->mSize.changed(prevFrame, curFrame) || |
| 398 |
mData->mRound.changed(prevFrame, curFrame)); |
| 399 |
} |
| 400 |
}; |
| 401 |
|
| 402 |
class LOTEllipseItem: public LOTPathDataItem |
| 403 |
{ |
| 404 |
public: |
| 405 |
explicit LOTEllipseItem(LOTEllipseData *data); |
| 406 |
private: |
| 407 |
void updatePath(VPath& path, int frameNo) final; |
| 408 |
LOTEllipseData *mData{nullptr}; |
| 409 |
bool hasChanged(int prevFrame, int curFrame) final { |
| 410 |
return (mData->mPos.changed(prevFrame, curFrame) || |
| 411 |
mData->mSize.changed(prevFrame, curFrame)); |
| 412 |
} |
| 413 |
}; |
| 414 |
|
| 415 |
class LOTShapeItem: public LOTPathDataItem |
| 416 |
{ |
| 417 |
public: |
| 418 |
explicit LOTShapeItem(LOTShapeData *data); |
| 419 |
private: |
| 420 |
void updatePath(VPath& path, int frameNo) final; |
| 421 |
LOTShapeData *mData{nullptr}; |
| 422 |
bool hasChanged(int prevFrame, int curFrame) final { |
| 423 |
return mData->mShape.changed(prevFrame, curFrame); |
| 424 |
} |
| 425 |
}; |
| 426 |
|
| 427 |
class LOTPolystarItem: public LOTPathDataItem |
| 428 |
{ |
| 429 |
public: |
| 430 |
explicit LOTPolystarItem(LOTPolystarData *data); |
| 431 |
private: |
| 432 |
void updatePath(VPath& path, int frameNo) final; |
| 433 |
LOTPolystarData *mData{nullptr}; |
| 434 |
|
| 435 |
bool hasChanged(int prevFrame, int curFrame) final { |
| 436 |
return (mData->mPos.changed(prevFrame, curFrame) || |
| 437 |
mData->mPointCount.changed(prevFrame, curFrame) || |
| 438 |
mData->mInnerRadius.changed(prevFrame, curFrame) || |
| 439 |
mData->mOuterRadius.changed(prevFrame, curFrame) || |
| 440 |
mData->mInnerRoundness.changed(prevFrame, curFrame) || |
| 441 |
mData->mOuterRoundness.changed(prevFrame, curFrame) || |
| 442 |
mData->mRotation.changed(prevFrame, curFrame)); |
| 443 |
} |
| 444 |
}; |
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
class LOTPaintDataItem : public LOTContentItem |
| 449 |
{ |
| 450 |
public: |
| 451 |
LOTPaintDataItem(bool staticContent); |
| 452 |
void addPathItems(std::vector<LOTPathDataItem *> &list, size_t startOffset); |
| 453 |
void update(int frameNo, const VMatrix &parentMatrix, float parentAlpha, const DirtyFlag &flag) override; |
| 454 |
void renderList(std::vector<VDrawable *> &list) final; |
| 455 |
ContentType type() const final {return ContentType::Paint;} |
| 456 |
protected: |
| 457 |
virtual bool updateContent(int frameNo, const VMatrix &matrix, float alpha) = 0; |
| 458 |
private: |
| 459 |
void updateRenderNode(); |
| 460 |
protected: |
| 461 |
std::vector<LOTPathDataItem *> mPathItems; |
| 462 |
LOTDrawable mDrawable; |
| 463 |
VPath mPath; |
| 464 |
DirtyFlag mFlag; |
| 465 |
bool mStaticContent; |
| 466 |
bool mRenderNodeUpdate{true}; |
| 467 |
bool mContentToRender{true}; |
| 468 |
}; |
| 469 |
|
| 470 |
class LOTFillItem : public LOTPaintDataItem |
| 471 |
{ |
| 472 |
public: |
| 473 |
explicit LOTFillItem(LOTFillData *data); |
| 474 |
protected: |
| 475 |
bool updateContent(int frameNo, const VMatrix &matrix, float alpha) final; |
| 476 |
bool resolveKeyPath(LOTKeyPath &keyPath, uint depth, LOTVariant &value) final; |
| 477 |
private: |
| 478 |
LOTProxyModel<LOTFillData> mModel; |
| 479 |
}; |
| 480 |
|
| 481 |
class LOTGFillItem : public LOTPaintDataItem |
| 482 |
{ |
| 483 |
public: |
| 484 |
explicit LOTGFillItem(LOTGFillData *data); |
| 485 |
protected: |
| 486 |
bool updateContent(int frameNo, const VMatrix &matrix, float alpha) final; |
| 487 |
private: |
| 488 |
LOTGFillData *mData{nullptr}; |
| 489 |
std::unique_ptr<VGradient> mGradient; |
| 490 |
}; |
| 491 |
|
| 492 |
class LOTStrokeItem : public LOTPaintDataItem |
| 493 |
{ |
| 494 |
public: |
| 495 |
explicit LOTStrokeItem(LOTStrokeData *data); |
| 496 |
protected: |
| 497 |
bool updateContent(int frameNo, const VMatrix &matrix, float alpha) final; |
| 498 |
bool resolveKeyPath(LOTKeyPath &keyPath, uint depth, LOTVariant &value) final; |
| 499 |
private: |
| 500 |
LOTProxyModel<LOTStrokeData> mModel; |
| 501 |
}; |
| 502 |
|
| 503 |
class LOTGStrokeItem : public LOTPaintDataItem |
| 504 |
{ |
| 505 |
public: |
| 506 |
explicit LOTGStrokeItem(LOTGStrokeData *data); |
| 507 |
protected: |
| 508 |
bool updateContent(int frameNo, const VMatrix &matrix, float alpha) final; |
| 509 |
private: |
| 510 |
LOTGStrokeData *mData{nullptr}; |
| 511 |
std::unique_ptr<VGradient> mGradient; |
| 512 |
}; |
| 513 |
|
| 514 |
|
| 515 |
// Trim Item |
| 516 |
|
| 517 |
class LOTTrimItem : public LOTContentItem |
| 518 |
{ |
| 519 |
public: |
| 520 |
explicit LOTTrimItem(LOTTrimData *data); |
| 521 |
void update(int frameNo, const VMatrix &parentMatrix, float parentAlpha, const DirtyFlag &flag) final; |
| 522 |
ContentType type() const final {return ContentType::Trim;} |
| 523 |
void update(); |
| 524 |
void addPathItems(std::vector<LOTPathDataItem *> &list, size_t startOffset); |
| 525 |
private: |
| 526 |
bool pathDirty() const { |
| 527 |
for (auto &i : mPathItems) { |
| 528 |
if (i->dirty()) |
| 529 |
return true; |
| 530 |
} |
| 531 |
return false; |
| 532 |
} |
| 533 |
struct Cache { |
| 534 |
int mFrameNo{-1}; |
| 535 |
LOTTrimData::Segment mSegment{}; |
| 536 |
}; |
| 537 |
Cache mCache; |
| 538 |
std::vector<LOTPathDataItem *> mPathItems; |
| 539 |
LOTTrimData *mData{nullptr}; |
| 540 |
VPathMesure mPathMesure; |
| 541 |
bool mDirty{true}; |
| 542 |
}; |
| 543 |
|
| 544 |
class LOTRepeaterItem : public LOTContentGroupItem |
| 545 |
{ |
| 546 |
public: |
| 547 |
explicit LOTRepeaterItem(LOTRepeaterData *data, VArenaAlloc* allocator); |
| 548 |
void update(int frameNo, const VMatrix &parentMatrix, float parentAlpha, const DirtyFlag &flag) final; |
| 549 |
void renderList(std::vector<VDrawable *> &list) final; |
| 550 |
private: |
| 551 |
LOTRepeaterData *mRepeaterData{nullptr}; |
| 552 |
bool mHidden{false}; |
| 553 |
int mCopies{0}; |
| 554 |
}; |
| 555 |
|
| 556 |
|
| 557 |
#endif // LOTTIEITEM_H |
| 558 |
|
| 559 |
|