diff options
author | Hermet Park <hermetpark@gmail.com> | 2018-06-14 19:51:13 +0900 |
---|---|---|
committer | Hermet Park <hermetpark@gmail.com> | 2018-06-14 20:02:15 +0900 |
commit | a7e4c6703937fba7c1c5bafc7dcad7f321495288 (patch) | |
tree | 61b5ab55eb270fa13818b5a256b3eeecf63e931d /src/lib/efl/interfaces | |
parent | a5f0e2ecdfd5446b75758b1eb7f2d2767afd6f3d (diff) |
evas vg: fix broken morphing(interpolation)
efl_gfx_path itself took care of efl_gfx_shape data but its heirarchy was
conceptually wrong. Even efl_gfx_shape is mixing the efl_gfx_path...
Damend design...
Some of derived classes of efl_gfx_path (i.e. Vg.Node and Vg.Container) are
none of the Path acutally. They are just mixing Path's interpolation interface.
So, Here patch changes VG.Node to stop calling the super's interpolate method
and Vg.Shape to call both super -gfx_shape and vg_node- interpolate method.
@fix T6996
Diffstat (limited to 'src/lib/efl/interfaces')
-rw-r--r-- | src/lib/efl/interfaces/efl_gfx_path.c | 120 | ||||
-rw-r--r-- | src/lib/efl/interfaces/efl_gfx_shape.c | 50 |
2 files changed, 59 insertions, 111 deletions
diff --git a/src/lib/efl/interfaces/efl_gfx_path.c b/src/lib/efl/interfaces/efl_gfx_path.c index 7a4f6da03b..ca3a842b99 100644 --- a/src/lib/efl/interfaces/efl_gfx_path.c +++ b/src/lib/efl/interfaces/efl_gfx_path.c | |||
@@ -281,83 +281,49 @@ interpolatei(int from, int to, double pos_map) | |||
281 | return (from * (1.0 - pos_map)) + (to * pos_map); | 281 | return (from * (1.0 - pos_map)) + (to * pos_map); |
282 | } | 282 | } |
283 | 283 | ||
284 | typedef struct _Efl_Gfx_Property Efl_Gfx_Property; | ||
285 | struct _Efl_Gfx_Property | ||
286 | { | ||
287 | double scale; | ||
288 | double w; | ||
289 | double centered; | ||
290 | |||
291 | Efl_Gfx_Cap c; | ||
292 | Efl_Gfx_Join j; | ||
293 | |||
294 | const Efl_Gfx_Dash *dash; | ||
295 | unsigned int dash_length; | ||
296 | |||
297 | int r, g, b, a; | ||
298 | int fr, fg, fb, fa; | ||
299 | }; | ||
300 | |||
301 | static inline void | ||
302 | _efl_gfx_property_get(const Eo *obj, Efl_Gfx_Property *property) | ||
303 | { | ||
304 | |||
305 | property->scale = efl_gfx_shape_stroke_scale_get(obj); | ||
306 | efl_gfx_shape_stroke_color_get(obj, &property->r, &property->g, &property->b, &property->a); | ||
307 | efl_gfx_color_get(obj, &property->fr, &property->fg, &property->fb, &property->fa); | ||
308 | property->w = efl_gfx_shape_stroke_width_get(obj); | ||
309 | property->centered = efl_gfx_shape_stroke_location_get(obj); | ||
310 | efl_gfx_shape_stroke_dash_get(obj, &property->dash, &property->dash_length); | ||
311 | property->c = efl_gfx_shape_stroke_cap_get(obj); | ||
312 | property->j = efl_gfx_shape_stroke_join_get(obj); | ||
313 | } | ||
314 | |||
315 | |||
316 | |||
317 | static void _path_interpolation(Eo *obj, Efl_Gfx_Path_Data *pd, char *from, char *to, double pos); | 284 | static void _path_interpolation(Eo *obj, Efl_Gfx_Path_Data *pd, char *from, char *to, double pos); |
318 | static void _efl_gfx_path_reset(Eo *obj, Efl_Gfx_Path_Data *pd); | 285 | static void _efl_gfx_path_reset(Eo *obj, Efl_Gfx_Path_Data *pd); |
319 | 286 | ||
320 | EOLIAN static Eina_Bool | 287 | EOLIAN static Eina_Bool |
321 | _efl_gfx_path_interpolate(Eo *obj, Efl_Gfx_Path_Data *pd, | 288 | _efl_gfx_path_interpolate(Eo *obj, Efl_Gfx_Path_Data *pd, |
322 | const Eo *from, const Eo *to, double pos_map) | 289 | const Eo *from, const Eo *to, double pos_map) |
323 | { | 290 | { |
324 | Efl_Gfx_Path_Change_Event ev = { EFL_GFX_CHANGE_FLAG_PATH }; | 291 | Efl_Gfx_Path_Change_Event ev = { EFL_GFX_CHANGE_FLAG_PATH }; |
325 | Efl_Gfx_Path_Data *from_pd, *to_pd; | 292 | Efl_Gfx_Path_Data *from_pd, *to_pd; |
326 | Efl_Gfx_Path_Command *cmds; | 293 | Efl_Gfx_Path_Command *cmds; |
327 | Efl_Gfx_Property property_from, property_to; | 294 | double interv; //interpolated value |
328 | Efl_Gfx_Dash *dash = NULL; | ||
329 | double *pts; | 295 | double *pts; |
330 | unsigned int i, j; | ||
331 | 296 | ||
332 | from_pd = efl_data_scope_get(from, EFL_GFX_PATH_MIXIN); | ||
333 | to_pd = efl_data_scope_get(to, EFL_GFX_PATH_MIXIN); | ||
334 | if (!efl_isa(from, EFL_GFX_PATH_MIXIN) || !efl_isa(to, EFL_GFX_PATH_MIXIN)) | 297 | if (!efl_isa(from, EFL_GFX_PATH_MIXIN) || !efl_isa(to, EFL_GFX_PATH_MIXIN)) |
335 | return EINA_FALSE; | 298 | return EINA_FALSE; |
336 | if (pd == from_pd || pd == to_pd) return EINA_FALSE; | ||
337 | 299 | ||
300 | from_pd = efl_data_scope_get(from, EFL_GFX_PATH_MIXIN); | ||
301 | to_pd = efl_data_scope_get(to, EFL_GFX_PATH_MIXIN); | ||
338 | 302 | ||
339 | _efl_gfx_property_get(from, &property_from); | 303 | //just in case |
340 | _efl_gfx_property_get(to, &property_to); | 304 | if (pd == from_pd || pd == to_pd) return EINA_FALSE; |
341 | |||
342 | if (property_from.dash_length != property_to.dash_length) return EINA_FALSE; | ||
343 | 305 | ||
344 | if (from_pd->path_data && to_pd->path_data) | 306 | if (from_pd->path_data && to_pd->path_data) |
345 | { | 307 | { |
346 | _efl_gfx_path_reset(obj, pd); | 308 | _efl_gfx_path_reset(obj, pd); |
347 | _path_interpolation(obj, pd, from_pd->path_data, to_pd->path_data, pos_map); | 309 | _path_interpolation(obj, pd, |
310 | from_pd->path_data, to_pd->path_data, pos_map); | ||
348 | } | 311 | } |
349 | else | 312 | else |
350 | { | 313 | { |
351 | if (!_efl_gfx_path_equal_commands_internal(from_pd, to_pd)) | 314 | if (!_efl_gfx_path_equal_commands_internal(from_pd, to_pd)) |
352 | return EINA_FALSE; | 315 | return EINA_FALSE; |
316 | |||
353 | cmds = realloc(pd->commands, | 317 | cmds = realloc(pd->commands, |
354 | sizeof (Efl_Gfx_Path_Command) * from_pd->commands_count); | 318 | sizeof(Efl_Gfx_Path_Command) * from_pd->commands_count); |
355 | if (!cmds && from_pd->commands_count) return EINA_FALSE; | 319 | if (!cmds && (from_pd->commands_count > 0)) return EINA_FALSE; |
320 | |||
356 | pd->commands = cmds; | 321 | pd->commands = cmds; |
357 | 322 | ||
358 | pts = realloc(pd->points, | 323 | pts = realloc(pd->points, |
359 | sizeof (double) * from_pd->points_count); | 324 | sizeof(double) * from_pd->points_count); |
360 | if (!pts && from_pd->points_count) return EINA_FALSE; | 325 | if (!pts && (from_pd->points_count > 0)) return EINA_FALSE; |
326 | |||
361 | pd->points = pts; | 327 | pd->points = pts; |
362 | 328 | ||
363 | if (cmds) | 329 | if (cmds) |
@@ -369,12 +335,12 @@ _efl_gfx_path_interpolate(Eo *obj, Efl_Gfx_Path_Data *pd, | |||
369 | { | 335 | { |
370 | double *to_pts = to_pd->points; | 336 | double *to_pts = to_pd->points; |
371 | double *from_pts = from_pd->points; | 337 | double *from_pts = from_pd->points; |
338 | int i, j; | ||
372 | 339 | ||
373 | for (i = 0; cmds[i] != EFL_GFX_PATH_COMMAND_TYPE_END; i++) | 340 | for (i = 0; cmds[i] != EFL_GFX_PATH_COMMAND_TYPE_END; i++) |
374 | for (j = 0; j < _efl_gfx_path_command_length(cmds[i]); j++) | 341 | for (j = 0; j < _efl_gfx_path_command_length(cmds[i]); j++) |
375 | { | 342 | { |
376 | *pts = interpolate(*from_pts, *to_pts, pos_map); | 343 | *pts = interpolate(*from_pts, *to_pts, pos_map); |
377 | |||
378 | pts++; | 344 | pts++; |
379 | from_pts++; | 345 | from_pts++; |
380 | to_pts++; | 346 | to_pts++; |
@@ -385,51 +351,23 @@ _efl_gfx_path_interpolate(Eo *obj, Efl_Gfx_Path_Data *pd, | |||
385 | pd->points_count = from_pd->points_count; | 351 | pd->points_count = from_pd->points_count; |
386 | pd->commands_count = from_pd->commands_count; | 352 | pd->commands_count = from_pd->commands_count; |
387 | 353 | ||
388 | pd->current.x = interpolate(from_pd->current.x, | 354 | interv = interpolate(from_pd->current.x, to_pd->current.x, pos_map); |
389 | to_pd->current.x, | 355 | pd->current.x = interv; |
390 | pos_map); | ||
391 | pd->current.y = interpolate(from_pd->current.y, | ||
392 | to_pd->current.y, | ||
393 | pos_map); | ||
394 | pd->current_ctrl.x = interpolate(from_pd->current_ctrl.x, | ||
395 | to_pd->current_ctrl.x, | ||
396 | pos_map); | ||
397 | pd->current_ctrl.y = interpolate(from_pd->current_ctrl.y, | ||
398 | to_pd->current_ctrl.y, | ||
399 | pos_map); | ||
400 | } | ||
401 | 356 | ||
402 | if (property_to.dash_length) | 357 | interv = interpolate(from_pd->current.y, to_pd->current.y, pos_map); |
403 | { | 358 | pd->current.y = interv; |
404 | dash = malloc(sizeof (Efl_Gfx_Dash) * property_to.dash_length); | ||
405 | if (!dash) return EINA_FALSE; | ||
406 | 359 | ||
407 | for (i = 0; i < property_to.dash_length; i++) | 360 | interv = interpolate(from_pd->current_ctrl.x, to_pd->current_ctrl.x, |
408 | { | 361 | pos_map); |
409 | dash[i].length = interpolate(property_from.dash[i].length, | 362 | pd->current_ctrl.x = interv; |
410 | property_to.dash[i].length, pos_map); | 363 | |
411 | dash[i].gap = interpolate(property_from.dash[i].gap, | 364 | interv = interpolate(from_pd->current_ctrl.y, to_pd->current_ctrl.y, |
412 | property_to.dash[i].gap, pos_map); | 365 | pos_map); |
413 | } | 366 | pd->current_ctrl.y = interv; |
414 | } | ||
415 | 367 | ||
368 | } | ||
416 | 369 | ||
417 | efl_gfx_shape_stroke_scale_set(obj, interpolate(property_from.scale, property_to.scale, pos_map)); | 370 | efl_event_callback_legacy_call(obj, EFL_GFX_PATH_EVENT_CHANGED, &ev); |
418 | efl_gfx_shape_stroke_color_set(obj, interpolatei(property_from.r, property_to.r, pos_map), | ||
419 | interpolatei(property_from.g, property_to.g, pos_map), | ||
420 | interpolatei(property_from.b, property_to.b, pos_map), | ||
421 | interpolatei(property_from.a, property_to.a, pos_map)); | ||
422 | efl_gfx_color_set(obj, interpolatei(property_from.fr, property_to.fr, pos_map), | ||
423 | interpolatei(property_from.fg, property_to.fg, pos_map), | ||
424 | interpolatei(property_from.fb, property_to.fb, pos_map), | ||
425 | interpolatei(property_from.fa, property_to.fa, pos_map)); | ||
426 | efl_gfx_shape_stroke_width_set(obj, interpolate(property_from.w, property_to.w, pos_map)); | ||
427 | efl_gfx_shape_stroke_location_set(obj, interpolate(property_from.centered, property_to.centered, pos_map)); | ||
428 | efl_gfx_shape_stroke_dash_set(obj, dash, property_to.dash_length); | ||
429 | efl_gfx_shape_stroke_cap_set(obj, pos_map < 0.5 ? property_from.c : property_to.c); | ||
430 | efl_gfx_shape_stroke_join_set(obj, pos_map < 0.5 ? property_from.j : property_to.j); | ||
431 | |||
432 | efl_event_callback_legacy_call(obj, EFL_GFX_PATH_EVENT_CHANGED, &ev); | ||
433 | 371 | ||
434 | return EINA_TRUE; | 372 | return EINA_TRUE; |
435 | } | 373 | } |
diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index 6ad08a1d1e..a6042f9de3 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c | |||
@@ -62,23 +62,29 @@ _efl_gfx_property_get(const Eo *obj, Efl_Gfx_Property *property) | |||
62 | 62 | ||
63 | EOLIAN static Eina_Bool | 63 | EOLIAN static Eina_Bool |
64 | _efl_gfx_shape_efl_gfx_path_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd, | 64 | _efl_gfx_shape_efl_gfx_path_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd, |
65 | const Eo *from, const Eo *to, double pos_map) | 65 | const Eo *from, const Eo *to, |
66 | double pos_map) | ||
66 | { | 67 | { |
67 | Efl_Gfx_Shape_Data *from_pd, *to_pd; | 68 | Efl_Gfx_Shape_Data *from_pd, *to_pd; |
68 | Efl_Gfx_Property property_from, property_to; | 69 | Efl_Gfx_Property property_from, property_to; |
69 | Efl_Gfx_Dash *dash = NULL; | 70 | Efl_Gfx_Dash *dash = NULL; |
71 | double interv; //interpolated value | ||
70 | unsigned int i; | 72 | unsigned int i; |
71 | 73 | ||
72 | from_pd = efl_data_scope_get(from, EFL_GFX_SHAPE_MIXIN); | ||
73 | to_pd = efl_data_scope_get(to, EFL_GFX_SHAPE_MIXIN); | ||
74 | if (!efl_isa(from, EFL_GFX_SHAPE_MIXIN) || !efl_isa(to, EFL_GFX_SHAPE_MIXIN)) | 74 | if (!efl_isa(from, EFL_GFX_SHAPE_MIXIN) || !efl_isa(to, EFL_GFX_SHAPE_MIXIN)) |
75 | return EINA_FALSE; | 75 | return EINA_FALSE; |
76 | |||
77 | from_pd = efl_data_scope_get(from, EFL_GFX_SHAPE_MIXIN); | ||
78 | to_pd = efl_data_scope_get(to, EFL_GFX_SHAPE_MIXIN); | ||
79 | |||
76 | if ((pd == from_pd) || (pd == to_pd)) return EINA_FALSE; | 80 | if ((pd == from_pd) || (pd == to_pd)) return EINA_FALSE; |
77 | 81 | ||
78 | _efl_gfx_property_get(from, &property_from); | 82 | _efl_gfx_property_get(from, &property_from); |
79 | _efl_gfx_property_get(to, &property_to); | 83 | _efl_gfx_property_get(to, &property_to); |
80 | 84 | ||
81 | if (property_from.dash_length != property_to.dash_length) return EINA_FALSE; | 85 | //Can be interpolated! |
86 | if (property_from.dash_length != property_to.dash_length) | ||
87 | return EINA_FALSE; | ||
82 | 88 | ||
83 | if (property_to.dash_length) | 89 | if (property_to.dash_length) |
84 | { | 90 | { |
@@ -94,35 +100,39 @@ _efl_gfx_shape_efl_gfx_path_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd, | |||
94 | } | 100 | } |
95 | } | 101 | } |
96 | 102 | ||
97 | efl_gfx_shape_stroke_scale_set(obj, interpolate(property_from.scale, | 103 | interv = interpolate(property_from.scale, property_to.scale, pos_map); |
98 | property_to.scale, pos_map)); | 104 | efl_gfx_shape_stroke_scale_set(obj, interv); |
105 | |||
99 | efl_gfx_shape_stroke_color_set(obj, | 106 | efl_gfx_shape_stroke_color_set(obj, |
100 | interpolatei(property_from.r, | 107 | interpolatei(property_from.r, property_to.r, |
101 | property_to.r, pos_map), | 108 | pos_map), |
102 | interpolatei(property_from.g, | 109 | interpolatei(property_from.g, property_to.g, |
103 | property_to.g, pos_map), | 110 | pos_map), |
104 | interpolatei(property_from.b, | 111 | interpolatei(property_from.b, property_to.b, |
105 | property_to.b, pos_map), | 112 | pos_map), |
106 | interpolatei(property_from.a, | 113 | interpolatei(property_from.a, property_to.a, |
107 | property_to.a, pos_map)); | 114 | pos_map)); |
115 | //Color is not a part of Path. Is it correct?... | ||
108 | efl_gfx_color_set(obj, | 116 | efl_gfx_color_set(obj, |
109 | interpolatei(property_from.fr, property_to.fr, pos_map), | 117 | interpolatei(property_from.fr, property_to.fr, pos_map), |
110 | interpolatei(property_from.fg, property_to.fg, pos_map), | 118 | interpolatei(property_from.fg, property_to.fg, pos_map), |
111 | interpolatei(property_from.fb, property_to.fb, pos_map), | 119 | interpolatei(property_from.fb, property_to.fb, pos_map), |
112 | interpolatei(property_from.fa, property_to.fa, pos_map)); | 120 | interpolatei(property_from.fa, property_to.fa, pos_map)); |
113 | 121 | ||
114 | efl_gfx_shape_stroke_width_set(obj, interpolate(property_from.w, | 122 | interv = interpolate(property_from.w, property_to.w, pos_map); |
115 | property_to.w, pos_map)); | 123 | efl_gfx_shape_stroke_width_set(obj, interv); |
116 | efl_gfx_shape_stroke_location_set(obj, interpolate(property_from.centered, | 124 | |
117 | property_to.centered, | 125 | interv = interpolate(property_from.centered, property_to.centered, pos_map); |
118 | pos_map)); | 126 | efl_gfx_shape_stroke_location_set(obj, interv); |
127 | |||
119 | efl_gfx_shape_stroke_dash_set(obj, dash, property_to.dash_length); | 128 | efl_gfx_shape_stroke_dash_set(obj, dash, property_to.dash_length); |
120 | efl_gfx_shape_stroke_cap_set(obj, (pos_map < 0.5) ? | 129 | efl_gfx_shape_stroke_cap_set(obj, (pos_map < 0.5) ? |
121 | property_from.c : property_to.c); | 130 | property_from.c : property_to.c); |
122 | efl_gfx_shape_stroke_join_set(obj, (pos_map < 0.5) ? | 131 | efl_gfx_shape_stroke_join_set(obj, (pos_map < 0.5) ? |
123 | property_from.j : property_to.j); | 132 | property_from.j : property_to.j); |
124 | 133 | ||
125 | return efl_gfx_path_interpolate(efl_super(obj, MY_CLASS), from, to, pos_map); | 134 | return efl_gfx_path_interpolate(efl_cast(obj, EFL_GFX_PATH_MIXIN), |
135 | from, to, pos_map); | ||
126 | } | 136 | } |
127 | 137 | ||
128 | EOLIAN static void | 138 | EOLIAN static void |