summaryrefslogtreecommitdiff
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
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
-rw-r--r--src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c9
-rw-r--r--src/static_libs/vg_common/vg_common.h1
-rw-r--r--src/static_libs/vg_common/vg_common_svg.c28
3 files changed, 38 insertions, 0 deletions
diff --git a/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c b/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c
index 97a7215776..9c63d0bdbd 100644
--- a/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c
+++ b/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c
@@ -1521,6 +1521,11 @@ _clone_gradient(Svg_Style_Gradient *from)
1521 grad->spread = from->spread; 1521 grad->spread = from->spread;
1522 grad->use_percentage = from->use_percentage; 1522 grad->use_percentage = from->use_percentage;
1523 grad->user_space = from->user_space; 1523 grad->user_space = from->user_space;
1524 if (from->transform)
1525 {
1526 grad->transform = calloc(1, sizeof(Eina_Matrix3));
1527 eina_matrix3_copy(grad->transform, from->transform);
1528 }
1524 grad->stops = _clone_grad_stops(from->stops); 1529 grad->stops = _clone_grad_stops(from->stops);
1525 if (grad->type == SVG_LINEAR_GRADIENT) 1530 if (grad->type == SVG_LINEAR_GRADIENT)
1526 { 1531 {
@@ -1961,6 +1966,10 @@ _attr_parse_linear_gradient_node(void *data, const char *key, const char *value)
1961 { 1966 {
1962 grad->user_space = EINA_TRUE; 1967 grad->user_space = EINA_TRUE;
1963 } 1968 }
1969 else if (!strcmp(key, "gradientTransform"))
1970 {
1971 grad->transform = _parse_transformation_matrix(value);
1972 }
1964 1973
1965 return EINA_TRUE; 1974 return EINA_TRUE;
1966} 1975}
diff --git a/src/static_libs/vg_common/vg_common.h b/src/static_libs/vg_common/vg_common.h
index b1dfa7d7f9..3dc102c635 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 9f26453abc..51f27bace4 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 }