aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/ector/ector_renderer_base.c
blob: 40f365fbbe368047994c9a25c70f49e058ed2767 (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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <Eina.h>
#include <Ector.h>

#include "ector_private.h"

static void
_ector_renderer_generic_base_eo_base_destructor(Eo *obj, Ector_Renderer_Generic_Base_Data *pd)
{
   if (pd->m) free(pd->m);
   eo_super_eo_destructor(ECTOR_RENDERER_GENERIC_BASE_CLASS, obj);
}

static void
_ector_renderer_generic_base_transformation_set(Eo *obj EINA_UNUSED,
                                                Ector_Renderer_Generic_Base_Data *pd,
                                                const Eina_Matrix3 *m)
{
   if (!m)
     {
        free(pd->m);
        pd->m = NULL;
     }
   else
     {
        if (!pd->m) pd->m = malloc(sizeof (Eina_Matrix3));
        if (!pd->m) return ;

        memcpy(pd->m, m, sizeof (Eina_Matrix3));
     }
}

static const Eina_Matrix3 *
_ector_renderer_generic_base_transformation_get(Eo *obj EINA_UNUSED,
                                                Ector_Renderer_Generic_Base_Data *pd)
{
   return pd->m;
}

static void
_ector_renderer_generic_base_origin_set(Eo *obj EINA_UNUSED,
                                        Ector_Renderer_Generic_Base_Data *pd,
                                        double x, double y)
{
   pd->origin.x = x;
   pd->origin.y = y;
}

static void
_ector_renderer_generic_base_origin_get(Eo *obj EINA_UNUSED,
                                        Ector_Renderer_Generic_Base_Data *pd,
                                        double *x, double *y)
{
   if (x) *x = pd->origin.x;
   if (y) *y = pd->origin.y;
}

static void
_ector_renderer_generic_base_visibility_set(Eo *obj EINA_UNUSED,
                                            Ector_Renderer_Generic_Base_Data *pd,
                                            Eina_Bool v)
{
   pd->visibility = v;
}

static Eina_Bool
_ector_renderer_generic_base_visibility_get(Eo *obj EINA_UNUSED,
                                            Ector_Renderer_Generic_Base_Data *pd)
{
   return pd->visibility;
}

static void
_ector_renderer_generic_base_color_set(Eo *obj EINA_UNUSED,
                                       Ector_Renderer_Generic_Base_Data *pd,
                                       int r, int g, int b, int a)
{
   pd->color.r = r;
   pd->color.g = g;
   pd->color.b = b;
   pd->color.a = a;
}

static void
_ector_renderer_generic_base_color_get(Eo *obj EINA_UNUSED,
                                       Ector_Renderer_Generic_Base_Data *pd,
                                       int *r, int *g, int *b, int *a)
{
   if (r) *r = pd->color.r;
   if (g) *g = pd->color.g;
   if (b) *b = pd->color.b;
   if (a) *a = pd->color.a;
}

static void
_ector_renderer_generic_base_mask_set(Eo *obj EINA_UNUSED,
                                      Ector_Renderer_Generic_Base_Data *pd,
                                      Ector_Renderer *r)
{
   _ector_renderer_replace(&pd->mask, r);
}

static Ector_Renderer *
_ector_renderer_generic_base_mask_get(Eo *obj EINA_UNUSED,
                                      Ector_Renderer_Generic_Base_Data *pd)
{
   return pd->mask;
}

static void
_ector_renderer_generic_base_quality_set(Eo *obj EINA_UNUSED,
                                         Ector_Renderer_Generic_Base_Data *pd,
                                         Ector_Quality q)
{
   pd->q = q;
}

static Ector_Quality
_ector_renderer_generic_base_quality_get(Eo *obj EINA_UNUSED,
                                         Ector_Renderer_Generic_Base_Data *pd)
{
   return pd->q;
}

static Eina_Bool
_ector_renderer_generic_base_prepare(Eo *obj EINA_UNUSED,
                                     Ector_Renderer_Generic_Base_Data *pd)
{
   if (pd->mask)
     eo_do(pd->mask, ector_renderer_prepare(pd->mask));

   return EINA_TRUE;
}

static unsigned int
_ector_renderer_generic_base_crc_get(Eo *obj EINA_UNUSED,
                                     Ector_Renderer_Generic_Base_Data *pd)
{
   unsigned int crc;

   crc = eina_crc((void*) &pd->color, sizeof(pd->color), 0xffffffff, EINA_TRUE);
   crc = eina_crc((void*) &pd->q, sizeof(pd->q), crc, EINA_FALSE);
   crc = eina_crc((void*) &pd->origin, sizeof(pd->origin), crc, EINA_FALSE);

   if (pd->m) crc = eina_crc((void*) pd->m, sizeof(Eina_Matrix3), crc, EINA_FALSE);
   if (pd->mask) crc = _renderer_crc_get(pd->mask, crc);

   return crc;
}

#include "ector_renderer_generic_base.eo.c"