summaryrefslogtreecommitdiff
path: root/src/lib/ector/ector_renderer_gradient.c
blob: 8ba3ba3fec978d365c2a48f64ea7d795ebd55a43 (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
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

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

#include "ector_private.h"

#define MY_CLASS ECTOR_RENDERER_GRADIENT_MIXIN

static void
_ector_renderer_gradient_efl_gfx_gradient_stop_set(Eo *obj EINA_UNUSED,
                                                                Ector_Renderer_Gradient_Data *pd,
                                                                const Efl_Gfx_Gradient_Stop *colors,
                                                                unsigned int length)
{
   pd->colors = realloc(pd->colors, length * sizeof(Efl_Gfx_Gradient_Stop));
   if (!pd->colors)
     {
        pd->colors_count = 0;
        return ;
     }

   memcpy(pd->colors, colors, length * sizeof(Efl_Gfx_Gradient_Stop));
   pd->colors_count = length;
}

static void
_ector_renderer_gradient_efl_gfx_gradient_stop_get(const Eo *obj EINA_UNUSED,
                                                                Ector_Renderer_Gradient_Data *pd,
                                                                const Efl_Gfx_Gradient_Stop **colors,
                                                                unsigned int *length)
{
   if (colors) *colors = pd->colors;
   if (length) *length = pd->colors_count;
}

static void
_ector_renderer_gradient_efl_gfx_gradient_spread_set(Eo *obj EINA_UNUSED,
                                                                  Ector_Renderer_Gradient_Data *pd,
                                                                  Efl_Gfx_Gradient_Spread s)
{
   pd->s = s;
}

static Efl_Gfx_Gradient_Spread
_ector_renderer_gradient_efl_gfx_gradient_spread_get(const Eo *obj EINA_UNUSED,
                                                                  Ector_Renderer_Gradient_Data *pd)
{
   return pd->s;
}

static void
_ector_renderer_gradient_efl_object_invalidate(Eo *obj EINA_UNUSED,
                                               Ector_Renderer_Gradient_Data *pd)
{
   if (pd->colors) free(pd->colors);
}

#include "ector_renderer_gradient.eo.c"