summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsubhransu mohanty <sub.mohanty@samsung.com>2018-01-16 10:41:38 +0900
committersubhransu mohanty <sub.mohanty@samsung.com>2018-04-12 13:51:53 +0900
commit058fdd2fbbe2d126d396f320b7d56a4ac8a320fe (patch)
treeb3892f6d96d265c157ad6802acd200fe5d484b70
parentc35fb0e1052b71a43a780a91f21020809f482409 (diff)
lottie: moved lottiemodel to include folder
-rw-r--r--ssg/example/main.cpp212
-rw-r--r--ssg/include/lottiemodel.h (renamed from ssg/src/lottie/lottiemodel.h)11
-rw-r--r--ssg/include/sgjson.h4
-rw-r--r--ssg/src/lottie/lottiemodel.cpp1
-rw-r--r--ssg/src/lottie/lottieparser.cpp27
5 files changed, 138 insertions, 117 deletions
diff --git a/ssg/example/main.cpp b/ssg/example/main.cpp
index ceb1a5246d..2e470d7d71 100644
--- a/ssg/example/main.cpp
+++ b/ssg/example/main.cpp
@@ -9,12 +9,6 @@
9 * @endverbatim 9 * @endverbatim
10 */ 10 */
11 11
12//#ifdef HAVE_CONFIG_H
13//#include "config.h"
14//#else
15//#define PACKAGE_EXAMPLES_DIR "."
16//#endif
17
18#define WIDTH 800 12#define WIDTH 800
19#define HEIGHT 600 13#define HEIGHT 600
20 14
@@ -34,41 +28,91 @@
34 28
35#include <math.h> 29#include <math.h>
36#include <Eina.h> 30#include <Eina.h>
31#include "lottiemodel.h"
37 32
38static Evas_Object *background = NULL; 33#include<iostream>
39static Evas_Object *vg = NULL; 34using namespace std;
40static Efl_VG *batman = NULL; 35#include"sgregion.h"
41 36#include"sgmatrix.h"
42static int animation_position = 0; 37#include"sgpath.h"
43static Ecore_Animator *animation = NULL; 38#include"ftraster_p.h"
44 39#include"sgelapsedtimer.h"
45static Efl_VG **batmans_vg = NULL; 40#include"sgdebug.h"
46static const char *batmans_path[] = { 41#include "sgjson.h"
47 "M 256,213 C 245,181 206,187 234,262 147,181 169,71.2 233,18 220,56 235,81 283,88 285,78.7 286,69.3 288,60 289,61.3 290,62.7 291,64 291,64 297,63 300,63 303,63 309,64 309,64 310,62.7 311,61.3 312,60 314,69.3 315,78.7 317,88 365,82 380,56 367,18 431,71 453,181 366,262 394,187 356,181 344,213 328,185 309,184 300,284 291,184 272,185 256,213 Z", 42#include<iostream>
48 "M 212,220 C 197,171 156,153 123,221 109,157 120,109 159,63.6 190,114 234,115 254,89.8 260,82.3 268,69.6 270,60.3 273,66.5 275,71.6 280,75.6 286,79.5 294,79.8 300,79.8 306,79.8 314,79.5 320,75.6 325,71.6 327,66.5 330,60.3 332,69.6 340,82.3 346,89.8 366,115 410,114 441,63.6 480,109 491,157 477,221 444,153 403,171 388,220 366,188 316,200 300,248 284,200 234,188 212,220 Z", 43#include<fstream>
49 "M 213,222 C 219,150 165,139 130,183 125,123 171,73.8 247,51.6 205,78 236,108 280,102 281,90.3 282,79 286,68.2 287,72 288,75.8 289,79.7 293,79.7 296,79.7 300,79.7 304,79.7 307,79.7 311,79.7 312,75.8 313,72 314,68.2 318,79 319,90.3 320,102 364,108 395,78 353,51.6 429,73.8 475,123 470,183 435,139 381,150 387,222 364,176 315,172 300,248 285,172 236,176 213,222 Z", 44#include<sstream>
50 "M 218,231 C 191,238 165,252 140,266 144,209 156,153 193,93.7 218,106 249,105 280,102 282,90.3 284,78.6 289,67.8 290,71.6 291,75.8 292,79.7 292,79.7 297,79.7 300,79.7 303,79.7 308,79.7 308,79.7 309,75.8 310,71.6 311,67.8 316,78.6 318,90.3 320,102 351,105 382,106 407,93.7 444,153 456,209 460,266 435,252 409,238 382,231 355,224 328,223 300,223 272,223 245,224 218,231 Z", 45
51 "M 258,243 C 220,201 221,220 253,281 154,243 150,108 229,61.9 242,83 257,98.1 275,110 278,88 282,65.8 285,43.6 287,49.9 288,56.2 290,62.5 293,62.7 297,62.9 300,62.9 303,62.9 307,62.7 310,62.5 312,56.2 313,49.9 315,43.6 318,65.8 322,88 325,110 343,98.1 358,83 371,61.9 450,108 446,243 347,281 379,220 380,201 342,243 330,187 329,202 300,271 271,202 270,187 258,243 Z", 46
52 "M 235,210 C 214,139 143,145 183,229 108,175 135,70.1 242,48.3 190,85.6 245,142 278,95.5 281,80.2 281,62.7 284,48.7 287,53.9 287,59.1 289,64.5 292,64.7 297,64.2 300,64.2 303,64.2 308,64.7 311,64.5 313,59.1 313,53.9 316,48.7 319,62.7 319,80.2 322,95.5 355,142 410,85.6 358,48.3 465,70.1 492,175 417,229 457,145 386,139 365,210 357,147 309,190 300,271 291,190 243,147 235,210 Z", 47class VGDrawable {
53 "M 249,157 C 214,157 201,203 273,255 157,221 157,69 274,32.8 188,87.2 211,140 256,140 291,140 289,128 291,98.1 293,107 293,116 295,125 297,125 298,125 300,125 302,125 305,125 305,125 307,116 307,107 309,98.1 311,128 309,140 344,140 389,140 412,87.2 326,32.8 443,69 443,221 327,255 399,203 386,157 351,157 317,157 300,195 300,238 300,195 283,157 249,157 Z", 48public:
54 "M 264,212 C 213,138 150,171 232,244 101,217 112,55.1 257,36.9 182,86.6 222,106 266,106 285,106 284,66.7 286,36.8 288,42.6 289,48.4 291,54.2 291,54.2 297,54.2 300,54.2 303,54.2 309,54.2 309,54.2 311,48.4 312,42.6 314,36.8 316,66.7 315,106 334,106 378,106 418,86.6 343,36.9 488,55.1 499,217 368,244 450,171 387,138 336,212 354,161 300,163 300,249 300,163 246,161 264,212 Z", 49 VGDrawable(std::shared_ptr<LottieObject> model):mModelData(model), drawable(nullptr){}
55 "M 223,217 C 194,153 165,168 133,219 143,158 161,99.2 189,38.4 214,69.8 241,84.7 272,86.2 272,70.2 273,53.5 273,37.5 275,47.9 278,58.4 280,68.8 287,64.9 292,62.4 300,62.4 308,62.4 313,64.9 320,68.8 322,58.4 325,47.9 327,37.5 327,53.5 328,70.2 328,86.2 359,84.7 386,69.8 411,38.4 439,99.2 457,158 467,219 435,168 406,153 377,217 350,162 319,176 300,245 281,176 250,162 223,217 Z", 50 void update(Efl_VG *parent);
56 "M 231,185 C 186,159 161,180 190,215 86.2,180 92.6,99.6 211,68.9 195,112 254,141 279,96.7 279,83.2 279,69.8 279,56.3 283,63.6 288,70.8 292,78.1 295,78.1 297,78.1 300,78.1 303,78.1 305,78.1 308,78.1 312,70.8 317,63.6 321,56.3 321,69.8 321,83.2 321,96.7 346,141 405,112 389,68.9 507,99.6 514,180 410,215 439,180 414,159 369,185 351,165 324,167 300,216 276,167 249,165 231,185 Z", 51public:
57 "M 194,146 C 192,107 164,76.4 136,45.6 166,55.7 196,65.7 226,75.8 238,107 265,163 279,136 282,130 281,108 281,94.8 285,103 288,111 293,115 295,116 298,117 300,117 302,117 305,116 307,115 312,111 315,103 319,94.8 319,108 318,130 321,136 335,163 362,107 374,75.8 404,65.7 434,55.7 464,45.6 436,76.4 408,107 406,146 355,158 323,189 300,231 277,189 245,158 194,146 Z", 52 std::shared_ptr<LottieObject> mModelData;
58 "M 209,182 C 184,132 176,138 113,161 140,136 168,111 196,86.5 221,104 247,115 278,115 281,99.9 285,85.5 287,70.2 289,78.5 292,88.4 294,96.7 296,96.7 298,96.7 300,96.7 302,96.7 304,96.7 306,96.7 308,88.4 311,78.5 313,70.2 315,85.5 319,99.9 322,115 353,115 379,104 404,86.5 432,111 460,136 487,161 424,138 416,132 391,182 332,150 341,161 300,214 259,161 268,150 209,182 Z", 53 std::vector<std::unique_ptr<VGDrawable>> mChildren;
59 "M 198,171 C 189,131 150,120 113,140 142,104 182,74.4 249,70.2 208,89 248,125 278,106 285,101 286,93.5 286,74.2 288,78.1 291,81.5 294,83.2 296,84.2 298,84.7 300,84.7 302,84.7 304,84.2 306,83.2 309,81.5 312,78.1 314,74.2 314,93.5 315,101 322,106 352,125 392,89 351,70.2 418,74.4 458,104 487,140 450,120 411,131 402,171 357,147 322,171 300,214 278,171 243,147 198,171 Z", 54 Efl_VG *drawable;
60 "M 202,170 C 188,115 157,108 124,105 146,84.3 171,71.5 199,70.2 211,98.6 243,103 277,106 279,99.3 281,92.6 283,86 285,91.9 287,97.9 290,104 293,104 297,104 300,104 303,104 307,104 310,104 313,97.9 315,91.9 317,86 319,92.6 321,99.3 323,106 357,103 389,98.6 401,70.2 429,71.5 454,84.3 476,105 443,108 412,115 398,170 349,157 318,175 300,214 282,175 251,157 202,170 Z",
61 "M 220,179 C 200,127 150,130 123,175 122,110 160,85.1 201,64 208,99.2 243,111 268,92.9 278,86.1 284,68.2 287,40.7 289,49.6 292,58.4 294,67.3 296,67.3 298,67.3 300,67.3 302,67.3 304,67.3 306,67.3 308,58.4 311,49.6 313,40.7 316,68.2 322,86.1 332,92.9 357,111 392,99.3 399,64 440,85.1 478,110 477,175 450,130 400,127 380,179 355,155 305,208 300,247 295,208 245,155 220,179 Z",
62 "M 166,154 C 179,119 154,95.4 114,79.3 155,79.1 197,78.9 239,78.7 242,103 250,109 283,109 289,109 290,93.9 291,83.7 292,88.3 292,92.9 293,97.5 295,97.5 298,97.5 300,97.5 302,97.5 305,97.5 307,97.5 308,92.9 308,88.3 309,83.7 310,93.9 311,109 317,109 350,109 358,103 361,78.7 403,78.9 445,79.1 486,79.3 446,95.4 421,119 434,154 377,151 320,151 300,207 280,151 223,151 166,154 Z",
63}; 55};
64 56
65static void 57void VGDrawable::update(Efl_VG *parent)
66_on_delete(Ecore_Evas *ee EINA_UNUSED)
67{ 58{
68 ecore_animator_del(animation); 59 if (!drawable) {
69 ecore_main_loop_quit(); 60 switch (mModelData->type()) {
61 case LottieObject::Type::Composition:
62 case LottieObject::Type::Layer:
63 case LottieObject::Type::ShapeGroup:
64 case LottieObject::Type::Transform:
65 case LottieObject::Type::Repeater:
66 drawable = evas_vg_container_add(parent);
67 break;
68 case LottieObject::Type::Ellipse:
69 case LottieObject::Type::Rect:
70 case LottieObject::Type::Shape:
71 drawable = evas_vg_shape_add(parent);
72 break;
73 default:
74 break;
75 }
76 for(auto &child : mChildren) {
77 child->update(drawable);
78 }
79 }
80
81 switch (mModelData->type()) {
82 case LottieObject::Type::Composition:
83 case LottieObject::Type::Layer:
84 case LottieObject::Type::ShapeGroup:
85 case LottieObject::Type::Transform:
86 case LottieObject::Type::Repeater:
87 drawable = evas_vg_container_add(parent);
88 break;
89 case LottieObject::Type::Ellipse:
90 case LottieObject::Type::Rect:
91 case LottieObject::Type::Shape:
92 drawable = evas_vg_shape_add(parent);
93 break;
94 default:
95 break;
96 }
70} 97}
71 98
99
100std::unique_ptr<VGDrawable>
101createCustomTree(std::shared_ptr<LottieObject> model)
102{
103 std::unique_ptr<VGDrawable> obj(new VGDrawable(model));
104 if (model->hasChildren()) {
105 LottieGroupObject *group = static_cast<LottieGroupObject *>(model.get());
106 for (auto child : group->mChildren) {
107 obj->mChildren.push_back(createCustomTree(child));
108 }
109 }
110 return obj;
111}
112
113static Evas_Object *background = NULL;
114static Evas_Object *vg = NULL;
115
72static void 116static void
73_on_resize(Ecore_Evas *ee) 117_on_resize(Ecore_Evas *ee)
74{ 118{
@@ -79,25 +123,6 @@ _on_resize(Ecore_Evas *ee)
79 evas_object_resize(vg, w, h); 123 evas_object_resize(vg, w, h);
80} 124}
81 125
82static Eina_Bool
83_animator(void *data EINA_UNUSED, double pos)
84{
85 int next = (animation_position + 1) % (sizeof (batmans_path) / sizeof (batmans_path[0]));
86
87 evas_vg_shape_interpolate(batman,
88 batmans_vg[animation_position],
89 batmans_vg[next],
90 ecore_animator_pos_map(pos, ECORE_POS_MAP_SINUSOIDAL, 0.0, 0.0));
91
92 if (pos == 1.0)
93 {
94 animation_position = next;
95 animation = ecore_animator_timeline_add(1, _animator, NULL);
96 }
97
98 return EINA_TRUE;
99}
100
101int 126int
102main(void) 127main(void)
103{ 128{
@@ -113,7 +138,6 @@ main(void)
113 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); 138 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
114 if (!ee) return -1; 139 if (!ee) return -1;
115 140
116 ecore_evas_callback_delete_request_set(ee, _on_delete);
117 ecore_evas_callback_resize_set(ee, _on_resize); 141 ecore_evas_callback_resize_set(ee, _on_resize);
118 ecore_evas_show(ee); 142 ecore_evas_show(ee);
119 143
@@ -127,29 +151,6 @@ main(void)
127 151
128 _on_resize(ee); 152 _on_resize(ee);
129 153
130 batmans_vg = (Efl_VG**)(malloc(sizeof (Efl_VG*) *
131 sizeof (batmans_path) / sizeof (batmans_path[0])));
132 if (!batmans_vg) return -1;
133
134 for (i = 0; i < sizeof (batmans_path) / sizeof (batmans_path[0]); i++)
135 {
136 batmans_vg[i] = evas_vg_shape_add(NULL);
137 evas_vg_node_color_set(batmans_vg[i], 0, 0, 0, 255);
138 evas_vg_shape_stroke_color_set(batmans_vg[i], 128, 10,10, 128);
139 evas_vg_shape_stroke_width_set(batmans_vg[i], 4.0);
140 evas_vg_shape_stroke_join_set(batmans_vg[i], EFL_GFX_JOIN_MITER);
141 if(i % 2)
142 {
143 evas_vg_shape_stroke_color_set(batmans_vg[i], 10, 10,128, 128);
144 evas_vg_shape_stroke_width_set(batmans_vg[i], 2.0);
145 evas_vg_node_color_set(batmans_vg[i], 120, 120, 120, 255);
146 evas_vg_shape_stroke_join_set(batmans_vg[i], EFL_GFX_JOIN_ROUND);
147 }
148 evas_vg_shape_append_svg_path(batmans_vg[i], batmans_path[i]);
149 }
150
151 animation = ecore_animator_timeline_add(1, _animator, NULL);
152
153 root = evas_vg_container_add(NULL); 154 root = evas_vg_container_add(NULL);
154 155
155 evas_object_vg_root_node_set(vg, root); 156 evas_object_vg_root_node_set(vg, root);
@@ -166,11 +167,22 @@ main(void)
166 evas_vg_shape_stroke_width_set(circle, 1); 167 evas_vg_shape_stroke_width_set(circle, 1);
167 evas_vg_shape_stroke_color_set(circle, 255, 0, 0, 255); 168 evas_vg_shape_stroke_color_set(circle, 255, 0, 0, 255);
168 169
169 batman = evas_vg_shape_add(root); 170 std::string filepath = DEMO_DIR;
170 evas_vg_node_color_set(batman, 0, 0, 0, 255); 171 filepath += "LightBulb.json";
171 evas_vg_node_origin_set(batman, 100, 150); 172 initialize(GuaranteedLogger(), "/tmp/", "ssglog", 1);
172 evas_vg_shape_append_move_to(batman, 256, 213); 173 set_log_level(LogLevel::INFO);
173 evas_vg_shape_dup(batman, batmans_vg[0]); 174 //SGJson json;
175 std::ifstream file;
176 file.open(filepath);
177 std::stringstream buffer;
178 buffer << file.rdbuf();
179 //std::cout <<"file size = "<< buffer.str().size()<<std::endl;
180 //std::cout << buffer.str().data();
181 SGJson json(buffer.str().data());
182 file.close();
183 std::cout<<"sizeof float :"<<sizeof(float)<<" size of double :"<<sizeof(double)<<std::endl;
184
185 std::unique_ptr<VGDrawable> DrawableRoot = createCustomTree(json.mComposition);
174 186
175 ecore_main_loop_begin(); 187 ecore_main_loop_begin();
176 188
@@ -179,36 +191,6 @@ main(void)
179} 191}
180 192
181 193
182/*
183#include<iostream>
184using namespace std;
185#include"sgregion.h"
186#include"sgmatrix.h"
187#include"sgpath.h"
188#include"ftraster_p.h"
189#include"sgelapsedtimer.h"
190#include"sgdebug.h"
191#include "sgjson.h"
192#include<iostream>
193#include<fstream>
194#include<sstream>
195 194
196int main() 195
197{ 196
198 std::string filepath = DEMO_DIR;
199 filepath += "LightBulb.json";
200 initialize(GuaranteedLogger(), "/tmp/", "ssglog", 1);
201 set_log_level(LogLevel::INFO);
202 //SGJson json;
203 std::ifstream file;
204 file.open(filepath);
205 std::stringstream buffer;
206 buffer << file.rdbuf();
207 //std::cout <<"file size = "<< buffer.str().size()<<std::endl;
208 //std::cout << buffer.str().data();
209 SGJson json(buffer.str().data());
210 file.close();
211 std::cout<<"sizeof float :"<<sizeof(float)<<" size of double :"<<sizeof(double)<<std::endl;
212 return 0;
213}
214*/
diff --git a/ssg/src/lottie/lottiemodel.h b/ssg/include/lottiemodel.h
index 7e0d8a471d..713adcc90c 100644
--- a/ssg/src/lottie/lottiemodel.h
+++ b/ssg/include/lottiemodel.h
@@ -131,6 +131,7 @@ public:
131 LottieObject(LottieObject::Type type): mStatic(true), mType(type){} 131 LottieObject(LottieObject::Type type): mStatic(true), mType(type){}
132 bool isStatic() {return mStatic;} 132 bool isStatic() {return mStatic;}
133 void setStatic(bool value) {mStatic = value;} 133 void setStatic(bool value) {mStatic = value;}
134 virtual bool hasChildren() {return false;}
134public: 135public:
135 bool mStatic; 136 bool mStatic;
136 LottieObject::Type mType; 137 LottieObject::Type mType;
@@ -140,6 +141,7 @@ class LottieGroupObject: public LottieObject
140{ 141{
141public: 142public:
142 LottieGroupObject(LottieObject::Type type):LottieObject(type){} 143 LottieGroupObject(LottieObject::Type type):LottieObject(type){}
144 virtual bool hasChildren() {return true;}
143public: 145public:
144 std::vector<std::shared_ptr<LottieObject>> mChildren; 146 std::vector<std::shared_ptr<LottieObject>> mChildren;
145}; 147};
@@ -350,6 +352,13 @@ public:
350 std::shared_ptr<LottieObject> mTransform; 352 std::shared_ptr<LottieObject> mTransform;
351}; 353};
352 354
353 355class LottieDrawable
356{
357public:
358 LottieDrawable(std::shared_ptr<LottieObject> model):mModelData(model){}
359public:
360 std::shared_ptr<LottieObject> mModelData;
361 std::vector<std::unique_ptr<LottieDrawable>> mChildren;
362};
354 363
355#endif // LOTTIEMODEL_H 364#endif // LOTTIEMODEL_H
diff --git a/ssg/include/sgjson.h b/ssg/include/sgjson.h
index c242c770a0..679aa0e1a7 100644
--- a/ssg/include/sgjson.h
+++ b/ssg/include/sgjson.h
@@ -1,9 +1,13 @@
1#ifndef SGJSON_H 1#ifndef SGJSON_H
2#define SGJSON_H 2#define SGJSON_H
3
4#include "lottiemodel.h"
3class SGJson 5class SGJson
4{ 6{
5public: 7public:
6 SGJson(){} 8 SGJson(){}
7 SGJson(const char *data); 9 SGJson(const char *data);
10public:
11 std::shared_ptr<LottieComposition> mComposition;
8}; 12};
9#endif // SGJSON_H 13#endif // SGJSON_H
diff --git a/ssg/src/lottie/lottiemodel.cpp b/ssg/src/lottie/lottiemodel.cpp
index 6c58e470a7..21c21e893b 100644
--- a/ssg/src/lottie/lottiemodel.cpp
+++ b/ssg/src/lottie/lottiemodel.cpp
@@ -213,4 +213,3 @@ void LottieShape::process(bool closed)
213 if (mShapeData) 213 if (mShapeData)
214 mShapeData.get()->process(closed); 214 mShapeData.get()->process(closed);
215} 215}
216
diff --git a/ssg/src/lottie/lottieparser.cpp b/ssg/src/lottie/lottieparser.cpp
index 2081d54ee3..bb3c34bf86 100644
--- a/ssg/src/lottie/lottieparser.cpp
+++ b/ssg/src/lottie/lottieparser.cpp
@@ -1093,6 +1093,7 @@ void LottieParser::parseKeyFrame(LottieAnimInfo<T> &obj)
1093 SGPointF inTangent; 1093 SGPointF inTangent;
1094 SGPointF outTangent; 1094 SGPointF outTangent;
1095 const char *interpolatorKey = nullptr; 1095 const char *interpolatorKey = nullptr;
1096 bool hold = false;
1096 while (const char* key = NextObjectKey()) { 1097 while (const char* key = NextObjectKey()) {
1097 if (0 == strcmp(key, "i")) { 1098 if (0 == strcmp(key, "i")) {
1098 inTangent = parseInperpolatorPoint(); 1099 inTangent = parseInperpolatorPoint();
@@ -1126,6 +1127,9 @@ void LottieParser::parseKeyFrame(LottieAnimInfo<T> &obj)
1126 keyframe.mPathKeyFrame = true; 1127 keyframe.mPathKeyFrame = true;
1127 getValue(keyframe.mOutTangent); 1128 getValue(keyframe.mOutTangent);
1128 continue; 1129 continue;
1130 } else if (0 == strcmp(key, "h")) {
1131 hold = true;
1132 continue;
1129 } else { 1133 } else {
1130#ifdef DEBUG_PARSER 1134#ifdef DEBUG_PARSER
1131 sgDebug<<"key frame property skipped = "<<key; 1135 sgDebug<<"key frame property skipped = "<<key;
@@ -1139,6 +1143,13 @@ void LottieParser::parseKeyFrame(LottieAnimInfo<T> &obj)
1139 obj.mKeyFrames.back().mEndFrame = keyframe.mStartFrame; 1143 obj.mKeyFrames.back().mEndFrame = keyframe.mStartFrame;
1140 } 1144 }
1141 1145
1146 if (hold) {
1147 interpolatorKey = "hold_interpolator";
1148 inTangent = SGPointF();
1149 outTangent = SGPointF();
1150 keyframe.mEndValue = keyframe.mStartValue;
1151 }
1152
1142 // Try to find the interpolator from cache 1153 // Try to find the interpolator from cache
1143 if (interpolatorKey) { 1154 if (interpolatorKey) {
1144 auto search = compRef->mInterpolatorCache.find(interpolatorKey); 1155 auto search = compRef->mInterpolatorCache.find(interpolatorKey);
@@ -1293,6 +1304,20 @@ public:
1293 } 1304 }
1294}; 1305};
1295 1306
1307
1308std::unique_ptr<LottieDrawable>
1309createDrawableTree(std::shared_ptr<LottieObject> model)
1310{
1311 std::unique_ptr<LottieDrawable> obj(new LottieDrawable(model));
1312 if (model->hasChildren()) {
1313 LottieGroupObject *group = static_cast<LottieGroupObject *>(model.get());
1314 for (auto child : group->mChildren) {
1315 obj->mChildren.push_back(createDrawableTree(child));
1316 }
1317 }
1318 return obj;
1319}
1320
1296SGJson::SGJson(const char *data) 1321SGJson::SGJson(const char *data)
1297{ 1322{
1298 SGElapsedTimer t; 1323 SGElapsedTimer t;
@@ -1318,6 +1343,8 @@ SGJson::SGJson(const char *data)
1318//#endif 1343//#endif
1319 sgDebug<<" "; 1344 sgDebug<<" ";
1320 sgCritical<<"Parsing time = "<<t.elapsed()<<" ms"; 1345 sgCritical<<"Parsing time = "<<t.elapsed()<<" ms";
1346 std::unique_ptr<LottieDrawable> drawable = createDrawableTree(comp);
1347 mComposition = comp;
1321} 1348}
1322 1349
1323RAPIDJSON_DIAG_POP 1350RAPIDJSON_DIAG_POP