summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunsuChoi <jsuya.choi@samsung.com>2019-07-22 13:37:47 +0900
committerHermet Park <hermetpark@gmail.com>2019-07-22 13:37:47 +0900
commit56ebaea1fe33258e3b489d3a8782dfaa1b904835 (patch)
treebf3265f3ac0228c1eb0362ec9c15fba490a26089
parent1ce14bc85d87ece9b2e50204f1834ec5a2d0f4a1 (diff)
Efl.Canvas.Vg : Implement Efl.Canvas.Vg.Image class
Summary: Implements a vector class that can support image. User can use this class to output an image with a vector object. Depends on D9218:Ector.Renderer : Implement Ector.Renderer.(Software).Image class Test Plan: N/A Reviewers: Hermet, smohanty, kimcinoo Reviewed By: Hermet Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9219
-rw-r--r--src/lib/evas/Evas_Eo.h1
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg_image.c114
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg_image.eo20
-rw-r--r--src/lib/evas/canvas/meson.build2
4 files changed, 137 insertions, 0 deletions
diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h
index f3bcb6eb32..4122ac7f15 100644
--- a/src/lib/evas/Evas_Eo.h
+++ b/src/lib/evas/Evas_Eo.h
@@ -452,6 +452,7 @@ typedef void (Evas_Canvas3D_Surface_Func)(Evas_Real *out_x,
452#include "canvas/efl_canvas_vg_node.eo.h" 452#include "canvas/efl_canvas_vg_node.eo.h"
453#include "canvas/efl_canvas_vg_container.eo.h" 453#include "canvas/efl_canvas_vg_container.eo.h"
454#include "canvas/efl_canvas_vg_shape.eo.h" 454#include "canvas/efl_canvas_vg_shape.eo.h"
455#include "canvas/efl_canvas_vg_image.eo.h"
455#include "canvas/efl_canvas_vg_gradient.eo.h" 456#include "canvas/efl_canvas_vg_gradient.eo.h"
456#include "canvas/efl_canvas_vg_gradient_linear.eo.h" 457#include "canvas/efl_canvas_vg_gradient_linear.eo.h"
457#include "canvas/efl_canvas_vg_gradient_radial.eo.h" 458#include "canvas/efl_canvas_vg_gradient_radial.eo.h"
diff --git a/src/lib/evas/canvas/efl_canvas_vg_image.c b/src/lib/evas/canvas/efl_canvas_vg_image.c
new file mode 100644
index 0000000000..1a72c69624
--- /dev/null
+++ b/src/lib/evas/canvas/efl_canvas_vg_image.c
@@ -0,0 +1,114 @@
1#include "evas_common_private.h"
2#include "evas_private.h"
3
4#include "evas_vg_private.h"
5
6#define MY_CLASS EFL_CANVAS_VG_IMAGE_CLASS
7
8typedef struct _Efl_Canvas_Vg_Image_Data Efl_Canvas_Vg_Image_Data;
9struct _Efl_Canvas_Vg_Image_Data
10{
11 Ector_Buffer *buffer;
12 void *image;
13 int w;
14 int h;
15};
16
17static void
18_efl_canvas_vg_image_render_pre(Evas_Object_Protected_Data *vg_pd,
19 Efl_VG *obj EINA_UNUSED,
20 Efl_Canvas_Vg_Node_Data *nd,
21 void *engine EINA_UNUSED, void *output EINA_UNUSED, void *context EINA_UNUSED,
22 Ector_Surface *surface,
23 Eina_Matrix3 *ptransform,
24 Ector_Buffer *mask,
25 int mask_op,
26 void *data)
27{
28 Efl_Canvas_Vg_Image_Data *pd = data;
29
30 if (nd->flags == EFL_GFX_CHANGE_FLAG_NONE) return;
31
32 nd->flags = EFL_GFX_CHANGE_FLAG_NONE;
33
34 EFL_CANVAS_VG_COMPUTE_MATRIX(ctransform, ptransform, nd);
35
36 if (!nd->renderer)
37 {
38 efl_domain_current_push(EFL_ID_DOMAIN_SHARED);
39 nd->renderer = ector_surface_renderer_factory_new(surface, ECTOR_RENDERER_IMAGE_MIXIN);
40 efl_domain_current_pop();
41 }
42
43 if (!pd->buffer && pd->image)
44 {
45 Evas_Object_Protected_Data *obj = vg_pd;
46 if (pd->buffer) efl_unref(pd->buffer);
47 pd->buffer = ENFN->ector_buffer_new(ENC, obj->layer->evas->evas,
48 pd->w, pd->h,
49 EFL_GFX_COLORSPACE_ARGB8888,
50 ECTOR_BUFFER_FLAG_DRAWABLE |
51 ECTOR_BUFFER_FLAG_CPU_READABLE |
52 ECTOR_BUFFER_FLAG_CPU_WRITABLE);
53 ector_buffer_pixels_set(pd->buffer, pd->image,
54 pd->w, pd->h, 0,
55 EFL_GFX_COLORSPACE_ARGB8888, EINA_TRUE);
56 }
57 ector_renderer_image_buffer_set(nd->renderer, pd->buffer);
58 ector_renderer_transformation_set(nd->renderer, ctransform);
59
60
61
62 ector_renderer_origin_set(nd->renderer, nd->x, nd->y);
63 ector_renderer_color_set(nd->renderer, nd->r, nd->g, nd->b, nd->a);
64 ector_renderer_visibility_set(nd->renderer, nd->visibility);
65
66 ector_renderer_mask_set(nd->renderer, mask, mask_op);
67 ector_renderer_prepare(nd->renderer);
68}
69
70static Eo *
71_efl_canvas_vg_image_efl_object_constructor(Eo *obj, Efl_Canvas_Vg_Image_Data *pd)
72{
73 Efl_Canvas_Vg_Node_Data *nd;
74
75 obj = efl_constructor(efl_super(obj, MY_CLASS));
76
77 nd = efl_data_scope_get(obj, EFL_CANVAS_VG_NODE_CLASS);
78 nd->render_pre = _efl_canvas_vg_image_render_pre;
79 nd->data = pd;
80
81 efl_gfx_color_set(obj , 255, 255, 255, 255);
82
83 return obj;
84}
85
86static void
87_efl_canvas_vg_image_efl_object_destructor(Eo *obj, Efl_Canvas_Vg_Image_Data *pd EINA_UNUSED)
88{
89 efl_destructor(efl_super(obj, MY_CLASS));
90 if (pd->buffer)
91 {
92 efl_unref(pd->buffer);
93 pd->buffer = NULL;
94 }
95}
96
97static void
98_efl_canvas_vg_image_data_set(Eo *obj EINA_UNUSED, Efl_Canvas_Vg_Image_Data *pd, void *data, int w, int h)
99{
100 if (!data || w <= 0 || h <= 0)
101 return;
102
103 if ((pd->image != data || pd->w != w || pd->h != h) && pd->buffer)
104 {
105 efl_unref(pd->buffer);
106 pd->buffer= NULL;
107 }
108
109 pd->image = data;
110 pd->w = w;
111 pd->h = h;
112}
113
114#include "efl_canvas_vg_image.eo.c"
diff --git a/src/lib/evas/canvas/efl_canvas_vg_image.eo b/src/lib/evas/canvas/efl_canvas_vg_image.eo
new file mode 100644
index 0000000000..2c593d425e
--- /dev/null
+++ b/src/lib/evas/canvas/efl_canvas_vg_image.eo
@@ -0,0 +1,20 @@
1class @beta Efl.Canvas.Vg.Image extends Efl.Canvas.Vg.Node implements Efl.Gfx.Image
2{
3 [[Efl vector graphics image class]]
4 methods {
5 @property data {
6 [[Set image data]]
7 set {
8 }
9 values {
10 pixels: void_ptr; [[Image pixels data. The pixel data type is 32bit RGBA]]
11 w : int;
12 h : int;
13 }
14 }
15 }
16 implements {
17 Efl.Object.constructor;
18 Efl.Object.destructor;
19 }
20}
diff --git a/src/lib/evas/canvas/meson.build b/src/lib/evas/canvas/meson.build
index 3d1849b1a5..f285316844 100644
--- a/src/lib/evas/canvas/meson.build
+++ b/src/lib/evas/canvas/meson.build
@@ -43,6 +43,7 @@ pub_eo_files = [
43 'efl_canvas_vg_node.eo', 43 'efl_canvas_vg_node.eo',
44 'efl_canvas_vg_container.eo', 44 'efl_canvas_vg_container.eo',
45 'efl_canvas_vg_shape.eo', 45 'efl_canvas_vg_shape.eo',
46 'efl_canvas_vg_image.eo',
46 'efl_canvas_vg_gradient.eo', 47 'efl_canvas_vg_gradient.eo',
47 'efl_canvas_vg_gradient_radial.eo', 48 'efl_canvas_vg_gradient_radial.eo',
48 'efl_canvas_vg_gradient_linear.eo', 49 'efl_canvas_vg_gradient_linear.eo',
@@ -184,6 +185,7 @@ evas_src += files([
184 'efl_canvas_vg_gradient_radial.c', 185 'efl_canvas_vg_gradient_radial.c',
185 'efl_canvas_vg_utils.c', 186 'efl_canvas_vg_utils.c',
186 'efl_canvas_vg_shape.c', 187 'efl_canvas_vg_shape.c',
188 'efl_canvas_vg_image.c',
187 'evas_filter_mixin.c', 189 'evas_filter_mixin.c',
188 'evas_canvas3d_object.c', 190 'evas_canvas3d_object.c',
189 'evas_canvas3d_scene.c', 191 'evas_canvas3d_scene.c',