lottie/optimization: efficient member packing in the VDrawable object.
[platform/core/uifw/lottie-player.git] / src / vector / vdrawable.h
1 #ifndef VDRAWABLE_H
2 #define VDRAWABLE_H
3 #include <future>
4 #include "vbrush.h"
5 #include "vpath.h"
6 #include "vrle.h"
7
8 class VDrawable {
9 public:
10     enum class DirtyState {
11         None = 0x00000000,
12         Path = 0x00000001,
13         Stroke = 0x00000010,
14         Brush = 0x00000100,
15         All = (None | Path | Stroke | Brush)
16     };
17     enum class Type : unsigned char{
18         Fill,
19         Stroke,
20     };
21     typedef vFlag<DirtyState> DirtyFlag;
22     VDrawable() = default;
23     void setPath(const VPath &path);
24     void setFillRule(FillRule rule) { mFillRule = rule; }
25     void setBrush(const VBrush &brush) { mBrush = brush; }
26     void setStrokeInfo(CapStyle cap, JoinStyle join, float meterLimit,
27                        float strokeWidth);
28     void setDashInfo(float *array, uint size);
29     void preprocess();
30     VRle rle();
31
32 public:
33     struct StrokeInfo {
34         std::vector<float> mDash;
35         float              width{0.0};
36         float              meterLimit{10};
37         bool               enable{false};
38         CapStyle           cap{CapStyle::Flat};
39         JoinStyle          join{JoinStyle::Bevel};
40     };
41     VBrush            mBrush;
42     VPath             mPath;
43     std::future<VRle> mRleTask;
44     VRle              mRle;
45     StrokeInfo        mStroke;
46     DirtyFlag         mFlag{DirtyState::All};
47     FillRule          mFillRule{FillRule::Winding};
48     VDrawable::Type   mType{Type::Fill};
49 };
50
51 #endif  // VDRAWABLE_H