summaryrefslogtreecommitdiff
path: root/src/static_libs
diff options
context:
space:
mode:
authorJunsuChoi <jsuya.choi@samsung.com>2019-04-19 15:07:11 +0900
committerHermet Park <hermetpark@gmail.com>2019-04-19 15:07:12 +0900
commit41152dc29e77ed55d9611d1f6d63dc9b33ca392b (patch)
tree7467c47e3da59b72429cc5e979e01c873d470c1e /src/static_libs
parent5403af9629a9cc6805e26ade38ea95c2e0bbdb31 (diff)
vg_common_svg : Implement gradientTransform property of linearGradient
Summary: Svg parser gets transformation matrix information from svg. If there is a matrix, calculate matrix operations on the start and end points of the gradient. TODO: We should implement gradientTransform of radialGradient. Test Plan: N/A Reviewers: Hermet, smohanty Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D8663
Diffstat (limited to 'src/static_libs')
-rw-r--r--src/static_libs/vg_common/vg_common.h1
-rw-r--r--src/static_libs/vg_common/vg_common_svg.c28
2 files changed, 29 insertions, 0 deletions
diff --git a/src/static_libs/vg_common/vg_common.h b/src/static_libs/vg_common/vg_common.h
index b1dfa7d..3dc102c 100644
--- a/src/static_libs/vg_common/vg_common.h
+++ b/src/static_libs/vg_common/vg_common.h
@@ -206,6 +206,7 @@ struct _Svg_Style_Gradient
206 Eina_List *stops; // Efl_Gfx_Gradient_Stop 206 Eina_List *stops; // Efl_Gfx_Gradient_Stop
207 Svg_Radial_Gradient *radial; 207 Svg_Radial_Gradient *radial;
208 Svg_Linear_Gradient *linear; 208 Svg_Linear_Gradient *linear;
209 Eina_Matrix3 *transform;
209 Eina_Bool use_percentage; 210 Eina_Bool use_percentage;
210}; 211};
211 212
diff --git a/src/static_libs/vg_common/vg_common_svg.c b/src/static_libs/vg_common/vg_common_svg.c
index 9f26453..51f27ba 100644
--- a/src/static_libs/vg_common/vg_common_svg.c
+++ b/src/static_libs/vg_common/vg_common_svg.c
@@ -481,6 +481,7 @@ _svg_style_gradient_free(Svg_Style_Gradient *grad)
481 eina_stringshare_del(grad->ref); 481 eina_stringshare_del(grad->ref);
482 free(grad->radial); 482 free(grad->radial);
483 free(grad->linear); 483 free(grad->linear);
484 if (grad->transform) free(grad->transform);
484 485
485 EINA_LIST_FREE(grad->stops, stop) 486 EINA_LIST_FREE(grad->stops, stop)
486 { 487 {
@@ -576,6 +577,33 @@ _apply_gradient_property(Svg_Style_Gradient *g, Efl_VG *vg, Efl_VG *parent, Vg_F
576 g->linear->x2 = g->linear->x2 * r.w + r.x; 577 g->linear->x2 = g->linear->x2 * r.w + r.x;
577 g->linear->y2 = g->linear->y2 * r.h + r.y; 578 g->linear->y2 = g->linear->y2 * r.h + r.y;
578 } 579 }
580
581 if (g->transform)
582 {
583 double cy = ((double) r.h) * 0.5 + r.y;
584 double cx = ((double) r.w) * 0.5 + r.x;
585
586 //Calc start point
587 eina_matrix3_identity(&m);
588 eina_matrix3_translate(&m, g->linear->x1 - cx, g->linear->y1 - cy);
589 eina_matrix3_multiply_copy(&m, g->transform , &m);
590 eina_matrix3_translate(&m, cx, cy);
591
592 eina_matrix3_values_get(&m, NULL, NULL, &g->linear->x1,
593 NULL, NULL, &g->linear->y1,
594 NULL, NULL, NULL);
595
596 //Calc end point
597 eina_matrix3_identity(&m);
598 eina_matrix3_translate(&m, g->linear->x2 - cx, g->linear->y2 - cy);
599 eina_matrix3_multiply_copy(&m, g->transform , &m);
600 eina_matrix3_translate(&m, cx, cy);
601
602 eina_matrix3_values_get(&m, NULL, NULL, &g->linear->x2,
603 NULL, NULL, &g->linear->y2,
604 NULL, NULL, NULL);
605 }
606
579 efl_gfx_gradient_linear_start_set(grad_obj, g->linear->x1, g->linear->y1); 607 efl_gfx_gradient_linear_start_set(grad_obj, g->linear->x1, g->linear->y1);
580 efl_gfx_gradient_linear_end_set(grad_obj, g->linear->x2, g->linear->y2); 608 efl_gfx_gradient_linear_end_set(grad_obj, g->linear->x2, g->linear->y2);
581 } 609 }