aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/evas/canvas/evas_vg_gradient_linear.c
blob: c1d8ffc46134bae1f7a4a188157b2fdec73d107c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include "evas_common_private.h"
#include "evas_private.h"

#include "evas_vg_private.h"

#include <strings.h>

#define MY_CLASS EVAS_VG_GRADIENT_LINEAR_CLASS

typedef struct _Evas_VG_Gradient_Linear_Data Evas_VG_Gradient_Linear_Data;
struct _Evas_VG_Gradient_Linear_Data
{
   struct {
      double x, y;
   } start, end;
};

static void
_evas_vg_gradient_linear_efl_gfx_gradient_linear_start_set(Eo *obj EINA_UNUSED,
                                                           Evas_VG_Gradient_Linear_Data *pd,
                                                           double x, double y)
{
   pd->start.x = x;
   pd->start.y = y;

   _evas_vg_node_changed(obj);
}

static void
_evas_vg_gradient_linear_efl_gfx_gradient_linear_start_get(Eo *obj EINA_UNUSED,
                                                           Evas_VG_Gradient_Linear_Data *pd,
                                                           double *x, double *y)
{
   if (x) *x = pd->start.x;
   if (y) *y = pd->start.y;
}

static void
_evas_vg_gradient_linear_efl_gfx_gradient_linear_end_set(Eo *obj EINA_UNUSED,
                                                         Evas_VG_Gradient_Linear_Data *pd,
                                                         double x, double y)
{
   pd->end.x = x;
   pd->end.y = y;

   _evas_vg_node_changed(obj);
}

static void
_evas_vg_gradient_linear_efl_gfx_gradient_linear_end_get(Eo *obj EINA_UNUSED,
                                                         Evas_VG_Gradient_Linear_Data *pd,
                                                         double *x, double *y)
{
   if (x) *x = pd->end.x;
   if (y) *y = pd->end.y;
}

static void
_evas_vg_gradient_linear_render_pre(Eo *obj,
                                    Eina_Matrix3 *parent,
                                    Ector_Surface *s,
                                    void *data,
                                    Evas_VG_Node_Data *nd)
{
   Evas_VG_Gradient_Linear_Data *pd = data;
   Evas_VG_Gradient_Data *gd;

   if (!nd->changed) return ;
   nd->changed = EINA_FALSE;

   gd = eo_data_scope_get(obj, EVAS_VG_GRADIENT_CLASS);
   EVAS_VG_COMPUTE_MATRIX(current, parent, nd);

   if (!nd->renderer)
     {
        eo_do(s, nd->renderer = ector_surface_renderer_factory_new(ECTOR_RENDERER_GENERIC_GRADIENT_LINEAR_CLASS));
     }

   eo_do(nd->renderer,
         ector_renderer_transformation_set(current),
         ector_renderer_origin_set(nd->x, nd->y),
         ector_renderer_color_set(nd->r, nd->g, nd->b, nd->a),
         ector_renderer_visibility_set(nd->visibility),
         efl_gfx_gradient_stop_set(gd->colors, gd->colors_count),
         efl_gfx_gradient_spread_set(gd->s),
         efl_gfx_gradient_linear_start_set(pd->start.x, pd->start.y),
         efl_gfx_gradient_linear_end_set(pd->end.x, pd->end.y),
         ector_renderer_prepare());
}

static void
_evas_vg_gradient_linear_eo_base_constructor(Eo *obj,
                                             Evas_VG_Gradient_Linear_Data *pd)
{
   Evas_VG_Node_Data *nd;

   eo_do_super(obj, MY_CLASS, eo_constructor());

   nd = eo_data_scope_get(obj, EVAS_VG_NODE_CLASS);
   nd->render_pre = _evas_vg_gradient_linear_render_pre;
   nd->data = pd;
}

void
_evas_vg_gradient_linear_eo_base_destructor(Eo *obj, Evas_VG_Gradient_Linear_Data *pd EINA_UNUSED)
{
   eo_do_super(obj, MY_CLASS, eo_destructor());
}

#include "evas_vg_gradient_linear.eo.c"