summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsubhransu mohanty <sub.mohanty@samsung.com>2018-07-11 12:13:07 +0900
committersubhransu mohanty <sub.mohanty@samsung.com>2018-07-11 12:13:07 +0900
commit742bc0222e822faed5ae995d616da563c242bc93 (patch)
tree3e44083d01f19c532d3c22c2bf84bc317a64a2c2
parentbfbd98b29368778eaa5893d7c46614a3c8d8d1cd (diff)
lottie: folder reorg part 2
-rw-r--r--include/sggradient.h77
-rw-r--r--include/sgnode.h227
-rw-r--r--include/sgrenderer.h62
-rw-r--r--src/ftraster/ftraster_p.h (renamed from include/ftraster_p.h)2
-rw-r--r--src/lottie/lottiemodel.h (renamed from include/lottiemodel.h)2
-rw-r--r--src/lottie/lottieparser.cpp2
-rw-r--r--src/vector/vbrush.h (renamed from include/vbrush.h)0
-rw-r--r--src/vector/vdrawhelper.h2
-rw-r--r--src/vector/velapsedtimer.cpp2
-rw-r--r--src/vector/velapsedtimer.h (renamed from include/sgelapsedtimer.h)0
-rw-r--r--src/vector/vinterpolator.cpp2
-rw-r--r--src/vector/vinterpolator.h (renamed from include/sginterpolator.h)0
-rw-r--r--src/vector/vmatrix.h2
-rw-r--r--src/vector/vpainter.h2
-rw-r--r--src/vector/vregion.cpp2
-rw-r--r--src/vector/vregion.h (renamed from include/sgregion.h)0
-rw-r--r--src/vector/vrle.cpp4
-rw-r--r--src/vector/vrle.h (renamed from include/sgrle.h)0
-rw-r--r--test/testsgregion.cpp2
19 files changed, 12 insertions, 378 deletions
diff --git a/include/sggradient.h b/include/sggradient.h
deleted file mode 100644
index e62c197..0000000
--- a/include/sggradient.h
+++ /dev/null
@@ -1,77 +0,0 @@
1#ifndef SGGRADIENT_H
2#define SGGRADIENT_H
3
4#include "vglobal.h"
5#include<vector>
6
7class SGGradientStop
8{
9 SGGradientStop(double pos, const SGColor &color):m_pos(pos), m_color(color){}
10 inline double position(){return m_pos;}
11 inline double color(){return m_color;}
12public:
13 double m_pos;
14 SGColor m_color;
15};
16
17typedef std::vector<SGGradientStop> SGGradientStops;
18
19class SGGradient
20{
21public:
22 enum class SpreadMode {
23 Pad,
24 Repeat,
25 Reflect
26 };
27 SpreadMode spread() const;
28 void setSpread(SpreadMode mode);
29private:
30 SpreadMode m_spread;
31 SGGradientStops m_stops;
32};
33
34class SGLinearGradient : public SGGradient
35{
36 public:
37 double x1() const;
38 void setX1(double v);
39 double y1() const;
40 void setY1(double v);
41 double x2() const;
42 void setX2(double v);
43 double y2() const;
44 void setY2(double v);
45private:
46 double m_X1, m_Y1;
47 double m_X2, m_Y2;
48};
49
50class SGRadialGradient : public SGGradient
51{
52 public:
53 double centerX() const;
54 void setCenterX(double v);
55
56 double centerY() const;
57 void setCenterY(double v);
58
59 double centerRadius() const;
60 void setCenterRadius(double v);
61
62 double focalX() const;
63 void setFocalX(double v);
64
65 double focalY() const;
66 void setFocalY(double v);
67
68 double focalRadius() const;
69 void setFocalRadius(double v);
70private:
71 double m_centerX, m_centerY;
72 double m_focalX, m_focalY;
73 double m_centerRadius = 0;
74 double m_focalRadius = 0;
75};
76
77#endif // SGGRADIENT_H
diff --git a/include/sgnode.h b/include/sgnode.h
deleted file mode 100644
index d73d404..0000000
--- a/include/sgnode.h
+++ /dev/null
@@ -1,227 +0,0 @@
1#ifndef SGNODE_H
2#define SGNODE_H
3
4#include<vglobal.h>
5#include<sgregion.h>
6#include<vmatrix.h>
7#include<vector>
8
9class SGGeometry;
10class SGRect;
11class SGRenderer;
12class SGNodeVisitor;
13class SG_EXPORT SGNode
14{
15public:
16 enum class NodeType {
17 Basic,
18 Geometry,
19 Transform,
20 Clip,
21 Opacity,
22 Root,
23 };
24
25 enum class Flag {
26 // Lower 16 bites reserved for general node
27 OwnedByParent = 0x0001,
28 UsePreprocess = 0x0002,
29 // 0x00ff0000 bits reserved for node subclasses
30 OwnsGeometry = 0x00010000,
31 IsVisitableNode = 0x01000000
32 };
33 typedef sgFlag<Flag> NodeFlag;
34 enum class DirtyState {
35 SubtreeBlocked = 0x0080,
36 Matrix = 0x0100,
37 NodeAdded = 0x0400,
38 NodeRemoved = 0x0800,
39 Geometry = 0x1000,
40 Material = 0x2000,
41 Opacity = 0x4000,
42 ForceUpdate = 0x8000,
43 UsePreprocess = 0x0002,
44 PropagationMask = Matrix
45 | NodeAdded
46 | Opacity
47 | ForceUpdate
48
49 };
50 typedef sgFlag<DirtyState> DirtyFlag;
51 SGNode();
52 virtual ~SGNode();
53
54 SGNode *parent() const { return m_parent; }
55
56 void removeChildNode(SGNode *node);
57 void removeAllChildNodes();
58 void prependChildNode(SGNode *node);
59 void appendChildNode(SGNode *node);
60 void insertChildNodeBefore(SGNode *node, SGNode *before);
61 void insertChildNodeAfter(SGNode *node, SGNode *after);
62 void reparentChildNodesTo(SGNode *newParent);
63
64 int childCount() const;
65 SGNode *childAtIndex(int i) const;
66 SGNode *firstChild() const { return m_firstChild; }
67 SGNode *lastChild() const { return m_lastChild; }
68 SGNode *nextSibling() const { return m_nextSibling; }
69 SGNode* previousSibling() const { return m_previousSibling; }
70
71 inline NodeType type() const { return m_type; }
72
73 void markDirty(DirtyFlag flags);
74
75 virtual bool isSubtreeBlocked() const;
76
77 NodeFlag flags() const { return m_nodeFlags; }
78 void setFlag(NodeFlag, bool = true);
79 void setFlags(NodeFlag, bool = true);
80
81 virtual void preprocess() { }
82 virtual void accept(SGNodeVisitor *){}
83protected:
84 SGNode(NodeType type);
85private:
86 friend class SGRootNode;
87 friend class SGRenderer;
88
89 void init();
90 void destroy();
91
92 SGNode *m_parent;
93 NodeType m_type;
94 SGNode *m_firstChild;
95 SGNode *m_lastChild;
96 SGNode *m_nextSibling;
97 SGNode *m_previousSibling;
98 int m_subtreeRenderableCount;
99
100 NodeFlag m_nodeFlags;
101};
102
103class SGClipNode;
104
105class SG_EXPORT SGBasicGeometryNode : public SGNode
106{
107public:
108 ~SGBasicGeometryNode();
109
110 void setGeometry(SGGeometry *geometry);
111 const SGGeometry *geometry() const { return m_geometry; }
112 SGGeometry *geometry() { return m_geometry; }
113
114 const SGMatrix *matrix() const { return m_matrix; }
115 const SGClipNode *clipList() const { return m_clip_list; }
116
117 void setRendererMatrix(const SGMatrix *m) { m_matrix = m; }
118 void setRendererClipList(const SGClipNode *c) { m_clip_list = c; }
119
120protected:
121 SGBasicGeometryNode(NodeType type);
122
123private:
124 friend class SGNodeUpdater;
125
126 SGGeometry *m_geometry;
127
128 int m_reserved_start_index;
129 int m_reserved_end_index;
130
131 const SGMatrix *m_matrix;
132 const SGClipNode *m_clip_list;
133};
134
135class SG_EXPORT SGGeometryNode : public SGBasicGeometryNode
136{
137public:
138 SGGeometryNode();
139 ~SGGeometryNode();
140
141 void setRenderOrder(int order);
142 int renderOrder() const { return m_render_order; }
143
144 void setInheritedOpacity(double opacity);
145 double inheritedOpacity() const { return m_opacity; }
146 void accept(SGNodeVisitor *visitor) override;
147private:
148 friend class SGNodeUpdater;
149
150 int m_render_order;
151
152 double m_opacity;
153};
154
155class SG_EXPORT SGClipNode : public SGBasicGeometryNode
156{
157public:
158 SGClipNode();
159 ~SGClipNode();
160
161 void setIsRectangular(bool rectHint);
162 bool isRectangular() const { return m_is_rectangular; }
163
164 void setClipRect(const SGRect &);
165 SGRect clipRect() const { return m_clip_rect; }
166 void accept(SGNodeVisitor *visitor) override;
167private:
168 bool m_is_rectangular;
169
170 SGRect m_clip_rect;
171};
172
173class SG_EXPORT SGTransformNode : public SGNode
174{
175public:
176 SGTransformNode();
177 ~SGTransformNode();
178
179 void setMatrix(const SGMatrix &matrix);
180 const SGMatrix &matrix() const { return m_matrix; }
181
182 void setCombinedMatrix(const SGMatrix &matrix);
183 const SGMatrix &combinedMatrix() const { return m_combined_matrix; }
184 void accept(SGNodeVisitor *visitor) override;
185private:
186 SGMatrix m_matrix;
187 SGMatrix m_combined_matrix;
188};
189
190class SG_EXPORT SGRootNode : public SGNode
191{
192public:
193 SGRootNode();
194 ~SGRootNode();
195 void accept(SGNodeVisitor *visitor) override;
196private:
197 void notifyNodeChange(SGNode *node, DirtyFlag flags);
198
199 friend class SGNode;
200 friend class SGGeometryNode;
201 friend class SGRenderer;
202
203 std::vector<SGRenderer *> m_renderers;
204};
205
206
207class SG_EXPORT SGOpacityNode : public SGNode
208{
209public:
210 SGOpacityNode();
211 ~SGOpacityNode();
212
213 void setOpacity(double opacity);
214 double opacity() const { return m_opacity; }
215
216 void setCombinedOpacity(double opacity);
217 double combinedOpacity() const { return m_combined_opacity; }
218
219 bool isSubtreeBlocked() const override;
220 void accept(SGNodeVisitor *visitor) override;
221private:
222 double m_opacity;
223 double m_combined_opacity;
224};
225
226
227#endif //SGNODE_H
diff --git a/include/sgrenderer.h b/include/sgrenderer.h
deleted file mode 100644
index 3229c57..0000000
--- a/include/sgrenderer.h
+++ /dev/null
@@ -1,62 +0,0 @@
1#ifndef SGRENDERER_H
2#define SGRENDERER_H
3
4#include<unordered_set>
5
6#include"vglobal.h"
7#include"sgnode.h"
8
9class SGRenderContext;
10class SGRendererPrivate;
11class SGNodeUpdater;
12
13class SG_EXPORT SGRenderer
14{
15public:
16 enum ClearModeBit
17 {
18 ClearColorBuffer = 0x0001,
19 ClearDepthBuffer = 0x0002,
20 ClearStencilBuffer = 0x0004
21 };
22 typedef sgFlag<ClearModeBit> ClearMode;
23
24 SGRenderer(SGRenderContext *context);
25 virtual ~SGRenderer();
26
27 void setRootNode(SGRootNode *node);
28 SGRootNode *rootNode() const;
29 void setDeviceRect(const SGRect &rect);
30 SGRect deviceRect() const;
31
32 void setViewportRect(const SGRect &rect);
33 SGRect viewportRect() const;
34
35// void setProjectionMatrix(const SGMatrix &matrix);
36// SGMatrix projectionMatrix() const;
37
38// void setClearColor(const QColor &color);
39// QColor clearColor() const;
40
41// void setClearMode(ClearMode mode);
42// ClearMode clearMode() const;
43 SGNodeUpdater *nodeUpdater() const;
44 void setNodeUpdater(SGNodeUpdater *updater);
45
46 virtual void renderScene();
47
48protected:
49 explicit SGRenderer();
50 virtual void nodeChanged(SGNode *node, SGNode::DirtyFlag flag) = 0;
51 virtual void render() = 0;
52 virtual void preprocess();
53 void addNodesToPreprocess(SGNode *node);
54 void removeNodesToPreprocess(SGNode *node);
55
56private:
57 friend class SGRendererPrivate;
58 friend class SGRootNode;
59 SGRendererPrivate *d;
60};
61
62#endif // SGRENDERER_H
diff --git a/include/ftraster_p.h b/src/ftraster/ftraster_p.h
index 0453cf3..0934f47 100644
--- a/include/ftraster_p.h
+++ b/src/ftraster/ftraster_p.h
@@ -1,6 +1,6 @@
1#ifndef FTRASTER_P_H 1#ifndef FTRASTER_P_H
2#define FTRASTER_P_H 2#define FTRASTER_P_H
3#include"sgrle.h" 3#include"vrle.h"
4#include<future> 4#include<future>
5 5
6struct FTOutline; 6struct FTOutline;
diff --git a/include/lottiemodel.h b/src/lottie/lottiemodel.h
index 4b3a027..d60d408 100644
--- a/include/lottiemodel.h
+++ b/src/lottie/lottiemodel.h
@@ -6,7 +6,7 @@
6#include<unordered_map> 6#include<unordered_map>
7#include"vpoint.h" 7#include"vpoint.h"
8#include"vrect.h" 8#include"vrect.h"
9#include"sginterpolator.h" 9#include"vinterpolator.h"
10#include"vmatrix.h" 10#include"vmatrix.h"
11#include"vbezier.h" 11#include"vbezier.h"
12#include"vbrush.h" 12#include"vbrush.h"
diff --git a/src/lottie/lottieparser.cpp b/src/lottie/lottieparser.cpp
index 842c02a..8227a33 100644
--- a/src/lottie/lottieparser.cpp
+++ b/src/lottie/lottieparser.cpp
@@ -37,7 +37,7 @@
37#include "rapidjson/document.h" 37#include "rapidjson/document.h"
38#include <iostream> 38#include <iostream>
39#include "lottiemodel.h" 39#include "lottiemodel.h"
40#include"sgelapsedtimer.h" 40#include"velapsedtimer.h"
41 41
42 42
43RAPIDJSON_DIAG_PUSH 43RAPIDJSON_DIAG_PUSH
diff --git a/include/vbrush.h b/src/vector/vbrush.h
index 1432537..1432537 100644
--- a/include/vbrush.h
+++ b/src/vector/vbrush.h
diff --git a/src/vector/vdrawhelper.h b/src/vector/vdrawhelper.h
index 651ac2b..102f6d6 100644
--- a/src/vector/vdrawhelper.h
+++ b/src/vector/vdrawhelper.h
@@ -3,7 +3,7 @@
3 3
4#include"vrect.h" 4#include"vrect.h"
5#include"vbrush.h" 5#include"vbrush.h"
6#include"sgrle.h" 6#include"vrle.h"
7#include"vpainter.h" 7#include"vpainter.h"
8#include"vbitmap.h" 8#include"vbitmap.h"
9#include"assert.h" 9#include"assert.h"
diff --git a/src/vector/velapsedtimer.cpp b/src/vector/velapsedtimer.cpp
index a063a46..441f7ac 100644
--- a/src/vector/velapsedtimer.cpp
+++ b/src/vector/velapsedtimer.cpp
@@ -1,4 +1,4 @@
1#include"sgelapsedtimer.h" 1#include"velapsedtimer.h"
2 2
3void SGElapsedTimer::start() 3void SGElapsedTimer::start()
4{ 4{
diff --git a/include/sgelapsedtimer.h b/src/vector/velapsedtimer.h
index d3449fa..d3449fa 100644
--- a/include/sgelapsedtimer.h
+++ b/src/vector/velapsedtimer.h
diff --git a/src/vector/vinterpolator.cpp b/src/vector/vinterpolator.cpp
index c301aaf..763bb02 100644
--- a/src/vector/vinterpolator.cpp
+++ b/src/vector/vinterpolator.cpp
@@ -1,4 +1,4 @@
1#include"sginterpolator.h" 1#include"vinterpolator.h"
2#include<cmath> 2#include<cmath>
3 3
4#define NEWTON_ITERATIONS 4 4#define NEWTON_ITERATIONS 4
diff --git a/include/sginterpolator.h b/src/vector/vinterpolator.h
index 8293233..8293233 100644
--- a/include/sginterpolator.h
+++ b/src/vector/vinterpolator.h
diff --git a/src/vector/vmatrix.h b/src/vector/vmatrix.h
index 9eefc61..6015fe9 100644
--- a/src/vector/vmatrix.h
+++ b/src/vector/vmatrix.h
@@ -1,7 +1,7 @@
1#ifndef SGMATRIX_H 1#ifndef SGMATRIX_H
2#define SGMATRIX_H 2#define SGMATRIX_H
3#include"vpoint.h" 3#include"vpoint.h"
4#include "sgregion.h" 4#include "vregion.h"
5#include "vglobal.h" 5#include "vglobal.h"
6 6
7struct SGMatrixData; 7struct SGMatrixData;
diff --git a/src/vector/vpainter.h b/src/vector/vpainter.h
index dcab96c..0716a35 100644
--- a/src/vector/vpainter.h
+++ b/src/vector/vpainter.h
@@ -2,7 +2,7 @@
2#define VPAINTER_H 2#define VPAINTER_H
3 3
4#include"vpoint.h" 4#include"vpoint.h"
5#include"sgrle.h" 5#include"vrle.h"
6#include"vbrush.h" 6#include"vbrush.h"
7 7
8class VBitmap; 8class VBitmap;
diff --git a/src/vector/vregion.cpp b/src/vector/vregion.cpp
index 33a2b25..0c0a1af 100644
--- a/src/vector/vregion.cpp
+++ b/src/vector/vregion.cpp
@@ -2039,7 +2039,7 @@ PREFIX (_extents) (region_type_t * region)
2039 2039
2040typedef region_type_t SGRegionPrivate; 2040typedef region_type_t SGRegionPrivate;
2041 2041
2042#include "sgregion.h" 2042#include "vregion.h"
2043 2043
2044static SGRegionPrivate regionPrivate = {{0,0,0,0}, NULL}; 2044static SGRegionPrivate regionPrivate = {{0,0,0,0}, NULL};
2045const SGRegion::SGRegionData SGRegion::shared_empty = {RefCount(-1), &regionPrivate}; 2045const SGRegion::SGRegionData SGRegion::shared_empty = {RefCount(-1), &regionPrivate};
diff --git a/include/sgregion.h b/src/vector/vregion.h
index 9df4e94..9df4e94 100644
--- a/include/sgregion.h
+++ b/src/vector/vregion.h
diff --git a/src/vector/vrle.cpp b/src/vector/vrle.cpp
index dc91465..cc7dd99 100644
--- a/src/vector/vrle.cpp
+++ b/src/vector/vrle.cpp
@@ -1,4 +1,4 @@
1#include "sgrle.h" 1#include "vrle.h"
2#include"vglobal.h" 2#include"vglobal.h"
3#include<vrect.h> 3#include<vrect.h>
4#include<cstdlib> 4#include<cstdlib>
@@ -6,7 +6,7 @@
6#include<array> 6#include<array>
7#include<algorithm> 7#include<algorithm>
8#include"vdebug.h" 8#include"vdebug.h"
9#include"sgregion.h" 9#include"vregion.h"
10 10
11struct SGRleHelper 11struct SGRleHelper
12{ 12{
diff --git a/include/sgrle.h b/src/vector/vrle.h
index d538a92..d538a92 100644
--- a/include/sgrle.h
+++ b/src/vector/vrle.h
diff --git a/test/testsgregion.cpp b/test/testsgregion.cpp
index 9e1ec68..02ed10b 100644
--- a/test/testsgregion.cpp
+++ b/test/testsgregion.cpp
@@ -1,5 +1,5 @@
1#include <gtest/gtest.h> 1#include <gtest/gtest.h>
2#include"sgregion.h" 2#include"vregion.h"
3#include"vdebug.h" 3#include"vdebug.h"
4#include"vpoint.h" 4#include"vpoint.h"
5class SGRegionTest : public ::testing::Test { 5class SGRegionTest : public ::testing::Test {