summaryrefslogtreecommitdiff
path: root/src/lib/ector/software/ector_renderer_software_gradient_linear.c
diff options
context:
space:
mode:
authorSubhransu Sekhar Mohanty <sub.mohanty@samsung.com>2015-04-03 16:31:45 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-04-03 16:31:45 +0200
commit891ec145857c717105deb2481d224174b1c966ac (patch)
tree57b2caa588b66f531cbb28b90be14acae6c7ad67 /src/lib/ector/software/ector_renderer_software_gradient_linear.c
parente99774946cf596b4527dcba92bbf17798eee9260 (diff)
ector: add software backend using FreeType rasterizer.
Diffstat (limited to 'src/lib/ector/software/ector_renderer_software_gradient_linear.c')
-rw-r--r--src/lib/ector/software/ector_renderer_software_gradient_linear.c109
1 files changed, 109 insertions, 0 deletions
diff --git a/src/lib/ector/software/ector_renderer_software_gradient_linear.c b/src/lib/ector/software/ector_renderer_software_gradient_linear.c
new file mode 100644
index 0000000000..8bbf23d73a
--- /dev/null
+++ b/src/lib/ector/software/ector_renderer_software_gradient_linear.c
@@ -0,0 +1,109 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <Eina.h>
6#include <Ector.h>
7#include <software/Ector_Software.h>
8
9#include "ector_private.h"
10#include "ector_software_private.h"
11
12
13static void
14_update_linear_data(Ector_Renderer_Software_Gradient_Data *gdata)
15{
16 update_color_table(gdata);
17 gdata->linear.x1 = gdata->gld->start.x;
18 gdata->linear.y1 = gdata->gld->start.y;
19
20 gdata->linear.x2 = gdata->gld->end.x;
21 gdata->linear.y2 = gdata->gld->end.y;
22
23 gdata->linear.dx = gdata->linear.x2 - gdata->linear.x1;
24 gdata->linear.dy = gdata->linear.y2 - gdata->linear.y1;
25 gdata->linear.l = gdata->linear.dx * gdata->linear.dx + gdata->linear.dy * gdata->linear.dy;
26 gdata->linear.off = 0;
27
28 if (gdata->linear.l != 0)
29 {
30 gdata->linear.dx /= gdata->linear.l;
31 gdata->linear.dy /= gdata->linear.l;
32 gdata->linear.off = -gdata->linear.dx * gdata->linear.x1 - gdata->linear.dy * gdata->linear.y1;
33 }
34}
35
36
37static Eina_Bool
38_ector_renderer_software_gradient_linear_ector_renderer_generic_base_prepare(Eo *obj,
39 Ector_Renderer_Software_Gradient_Data *pd)
40{
41 if (!pd->surface)
42 {
43 Eo *parent;
44
45 eo_do(obj, parent = eo_parent_get());
46 if (!parent) return EINA_FALSE;
47 pd->surface = eo_data_xref(parent, ECTOR_SOFTWARE_SURFACE_CLASS, obj);
48 }
49
50 _update_linear_data(pd);
51
52
53 return EINA_FALSE;
54}
55
56static Eina_Bool
57_ector_renderer_software_gradient_linear_ector_renderer_generic_base_draw(Eo *obj EINA_UNUSED,
58 Ector_Renderer_Software_Gradient_Data *pd EINA_UNUSED,
59 Ector_Rop op EINA_UNUSED, Eina_Array *clips EINA_UNUSED,
60 int x EINA_UNUSED, int y EINA_UNUSED, unsigned int mul_col EINA_UNUSED)
61{
62 return EINA_TRUE;
63}
64
65static Eina_Bool
66_ector_renderer_software_gradient_linear_ector_renderer_software_base_fill(Eo *obj EINA_UNUSED,
67 Ector_Renderer_Software_Gradient_Data *pd)
68{
69 ector_software_rasterizer_linear_gradient_set(pd->surface->software, pd);
70
71 return EINA_TRUE;
72}
73
74void
75_ector_renderer_software_gradient_linear_eo_base_constructor(Eo *obj,
76 Ector_Renderer_Software_Gradient_Data *pd)
77{
78 eo_do_super(obj, ECTOR_RENDERER_SOFTWARE_GRADIENT_LINEAR_CLASS, eo_constructor());
79 pd->gd = eo_data_xref(obj, ECTOR_RENDERER_GENERIC_GRADIENT_MIXIN, obj);
80 pd->gld = eo_data_xref(obj, ECTOR_RENDERER_GENERIC_GRADIENT_LINEAR_MIXIN, obj);
81}
82
83void
84_ector_renderer_software_gradient_linear_eo_base_destructor(Eo *obj,
85 Ector_Renderer_Software_Gradient_Data *pd)
86{
87 Eo *parent;
88
89 destroy_color_table(pd);
90
91 eo_do(obj, parent = eo_parent_get());
92 eo_data_xunref(parent, pd->surface, obj);
93
94 eo_data_xunref(obj, pd->gd, obj);
95 eo_data_xunref(obj, pd->gld, obj);
96
97 eo_do_super(obj, ECTOR_RENDERER_SOFTWARE_GRADIENT_LINEAR_CLASS, eo_destructor());
98}
99
100void
101_ector_renderer_software_gradient_linear_efl_gfx_gradient_base_stop_set(Eo *obj, Ector_Renderer_Software_Gradient_Data *pd, const Efl_Gfx_Gradient_Stop *colors, unsigned int length)
102{
103 eo_do_super(obj, ECTOR_RENDERER_SOFTWARE_GRADIENT_LINEAR_CLASS,
104 efl_gfx_gradient_stop_set(colors, length));
105
106 destroy_color_table(pd);
107}
108
109#include "ector_renderer_software_gradient_linear.eo.c"