summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-12-08 17:29:54 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-01-05 15:43:43 +0900
commit7a8879ba8bf5d9aec15428f94222222eea6c0e2e (patch)
tree0ccf55e8242dff190ec53d27aa4ac42308dbea88
parent85f23d96e7072f09ab73ab698047c3c172974b5e (diff)
ector: add engine-specific evas image buffer wrapper
Since Evas still relies entirely on Image_Entry and Evas_GL_Image, we will need an engine-specific wrapper object creating a Buffer around an existing cached image. Currently only SW support is implemented. GL will be more fun to do (with glReadPixels and whatnot).
-rw-r--r--src/Makefile_Evas.am18
-rw-r--r--src/lib/ector/ector_buffer.h5
-rw-r--r--src/lib/ector/ector_surface.h2
-rw-r--r--src/lib/ector/software/ector_software_buffer.c10
-rw-r--r--src/lib/evas/include/evas_ector_buffer.eo16
-rw-r--r--src/lib/evas/include/evas_private.h1
-rw-r--r--src/modules/evas/engines/gl_generic/evas_engine.c15
-rw-r--r--src/modules/evas/engines/software_generic/evas_ector_software_buffer.c97
-rw-r--r--src/modules/evas/engines/software_generic/evas_ector_software_buffer.eo12
-rw-r--r--src/modules/evas/engines/software_generic/evas_engine.c17
10 files changed, 188 insertions, 5 deletions
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index be24ba5b6a..2c58f88997 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -42,6 +42,7 @@ evas_eolian_files = \
42 lib/evas/canvas/efl_vg_gradient_radial.eo \ 42 lib/evas/canvas/efl_vg_gradient_radial.eo \
43 lib/evas/canvas/efl_vg_gradient_linear.eo \ 43 lib/evas/canvas/efl_vg_gradient_linear.eo \
44 lib/evas/canvas/evas_filter.eo \ 44 lib/evas/canvas/evas_filter.eo \
45 lib/evas/include/evas_ector_buffer.eo \
45 $(NULL) 46 $(NULL)
46 47
47evas_eolian_type_files = \ 48evas_eolian_type_files = \
@@ -356,6 +357,7 @@ lib_evas_libevas_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
356-I$(top_srcdir)/src/static_libs/libunibreak \ 357-I$(top_srcdir)/src/static_libs/libunibreak \
357-I$(top_srcdir)/src/static_libs/draw \ 358-I$(top_srcdir)/src/static_libs/draw \
358-I$(top_builddir)/src/lib/evas/canvas \ 359-I$(top_builddir)/src/lib/evas/canvas \
360-I$(top_builddir)/src/lib/evas/include \
359-I$(top_builddir)/src/modules/evas/engines/software_generic \ 361-I$(top_builddir)/src/modules/evas/engines/software_generic \
360-I$(top_builddir)/src/modules/evas/engines/gl_generic \ 362-I$(top_builddir)/src/modules/evas/engines/gl_generic \
361-DPACKAGE_BIN_DIR=\"$(bindir)\" \ 363-DPACKAGE_BIN_DIR=\"$(bindir)\" \
@@ -562,11 +564,25 @@ lib/evas/filters/blur/blur_box_rgba_i386.c \
562lib/evas/filters/blur/blur_box_rgba_sse3.c \ 564lib/evas/filters/blur/blur_box_rgba_sse3.c \
563lib/evas/filters/blur/blur_box_rgba_neon.c 565lib/evas/filters/blur/blur_box_rgba_neon.c
564 566
567
568### Engine Ector stuff
569
570EXTRA_DIST += \
571modules/evas/engines/software_generic/evas_ector_software_buffer.eo
572
573
565### Engines 574### Engines
566 575
567if EVAS_STATIC_BUILD_SOFTWARE_GENERIC 576if EVAS_STATIC_BUILD_SOFTWARE_GENERIC
568lib_evas_libevas_la_SOURCES += modules/evas/engines/software_generic/evas_engine.c modules/evas/engines/software_generic/Evas_Engine_Software_Generic.h 577BUILT_SOURCES += \
578 modules/evas/engines/software_generic/evas_ector_software_buffer.eo.c \
579 modules/evas/engines/software_generic/evas_ector_software_buffer.eo.h
580lib_evas_libevas_la_SOURCES += \
581 modules/evas/engines/software_generic/evas_engine.c \
582 modules/evas/engines/software_generic/Evas_Engine_Software_Generic.h \
583 modules/evas/engines/software_generic/evas_ector_software_buffer.c
569lib_evas_libevas_la_LIBADD += 584lib_evas_libevas_la_LIBADD +=
585lib_evas_libevas_la_CPPFLAGS += -I$(top_srcdir)/src/lib/ector
570else 586else
571enginesoftwaregenericpkgdir = $(libdir)/evas/modules/engines/software_generic/$(MODULE_ARCH) 587enginesoftwaregenericpkgdir = $(libdir)/evas/modules/engines/software_generic/$(MODULE_ARCH)
572enginesoftwaregenericpkg_LTLIBRARIES = modules/evas/engines/software_generic/module.la 588enginesoftwaregenericpkg_LTLIBRARIES = modules/evas/engines/software_generic/module.la
diff --git a/src/lib/ector/ector_buffer.h b/src/lib/ector/ector_buffer.h
index 1047482679..afa6f288c5 100644
--- a/src/lib/ector/ector_buffer.h
+++ b/src/lib/ector/ector_buffer.h
@@ -18,6 +18,7 @@ typedef struct _Ector_Generic_Buffer_Data
18 unsigned int w, h; 18 unsigned int w, h;
19 unsigned char l, r, t, b; 19 unsigned char l, r, t, b;
20 Efl_Gfx_Colorspace cspace; 20 Efl_Gfx_Colorspace cspace;
21 Eina_Bool immutable : 1; // pixels_set is forbidden
21} Ector_Generic_Buffer_Data; 22} Ector_Generic_Buffer_Data;
22 23
23typedef struct _Ector_Software_Buffer_Base_Data 24typedef struct _Ector_Software_Buffer_Base_Data
@@ -30,9 +31,9 @@ typedef struct _Ector_Software_Buffer_Base_Data
30 unsigned int stride; 31 unsigned int stride;
31 unsigned int pixel_size; // in bytes 32 unsigned int pixel_size; // in bytes
32 unsigned int map_count; 33 unsigned int map_count;
33 Eina_Bool writable : 1; 34 Eina_Bool writable : 1; // pixels can be written to
34 Eina_Bool nofree : 1; // pixel data should not be free()'ed 35 Eina_Bool nofree : 1; // pixel data should not be free()'ed
35 Eina_Bool span_free : 1; 36 Eina_Bool span_free : 1; // FIXME
36} Ector_Software_Buffer_Base_Data; 37} Ector_Software_Buffer_Base_Data;
37 38
38#endif 39#endif
diff --git a/src/lib/ector/ector_surface.h b/src/lib/ector/ector_surface.h
index 0cc5a32e34..98e4bf0b9c 100644
--- a/src/lib/ector/ector_surface.h
+++ b/src/lib/ector/ector_surface.h
@@ -1,7 +1,7 @@
1#ifndef ECTOR_SURFACE_H 1#ifndef ECTOR_SURFACE_H
2#define ECTOR_SURFACE_H 2#define ECTOR_SURFACE_H
3 3
4#include "ector_generic_buffer.eo.h" 4#include "ector_buffer.h"
5#include "ector_generic_surface.eo.h" 5#include "ector_generic_surface.eo.h"
6 6
7#endif 7#endif
diff --git a/src/lib/ector/software/ector_software_buffer.c b/src/lib/ector/software/ector_software_buffer.c
index 89a2cc1995..26c1329cda 100644
--- a/src/lib/ector/software/ector_software_buffer.c
+++ b/src/lib/ector/software/ector_software_buffer.c
@@ -72,8 +72,16 @@ _ector_software_buffer_base_ector_generic_buffer_pixels_set(Eo *obj, Ector_Softw
72 unsigned char l, unsigned char r, 72 unsigned char l, unsigned char r,
73 unsigned char t, unsigned char b) 73 unsigned char t, unsigned char b)
74{ 74{
75 unsigned px;
76
77 if (pd->generic->immutable)
78 {
79 ERR("This buffer is immutable.");
80 return EINA_FALSE;
81 }
82
75 // safety check 83 // safety check
76 unsigned px = _min_stride_calc(1, cspace); 84 px = _min_stride_calc(1, cspace);
77 if (px && ((unsigned long long)(uintptr_t)pixels) & (px - 1)) 85 if (px && ((unsigned long long)(uintptr_t)pixels) & (px - 1))
78 ERR("Pixel data is not aligned to %u bytes!", px); 86 ERR("Pixel data is not aligned to %u bytes!", px);
79 87
diff --git a/src/lib/evas/include/evas_ector_buffer.eo b/src/lib/evas/include/evas_ector_buffer.eo
new file mode 100644
index 0000000000..7dbb5e0842
--- /dev/null
+++ b/src/lib/evas/include/evas_ector_buffer.eo
@@ -0,0 +1,16 @@
1/* Note: only for internal C API */
2
3interface Evas.Ector.Buffer
4{
5 legacy_prefix: null;
6 methods {
7 @property engine_image {
8 get {}
9 set { [[This Buffer will hold a reference to the evas image struct.]] }
10 values {
11 evas: Evas *; [[The current Evas.]]
12 image: void *; [[The engine-specific image struct.]]
13 }
14 }
15 }
16}
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h
index b6f8c89d63..854d99d7db 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -1450,6 +1450,7 @@ struct _Evas_Func
1450 1450
1451 Ector_Surface *(*ector_create) (void *data); 1451 Ector_Surface *(*ector_create) (void *data);
1452 void (*ector_destroy) (void *data, Ector_Surface *surface); 1452 void (*ector_destroy) (void *data, Ector_Surface *surface);
1453 Ector_Buffer *(*ector_buffer_new) (void *data, Evas *e, void *engine_image); // free it with eo_del
1453 void (*ector_begin) (void *data, void *context, Ector_Surface *ector, void *surface, void *engine_data, int x, int y, Eina_Bool do_async); 1454 void (*ector_begin) (void *data, void *context, Ector_Surface *ector, void *surface, void *engine_data, int x, int y, Eina_Bool do_async);
1454 void (*ector_renderer_draw) (void *data, void *context, void *surface, void *engine_data, Ector_Renderer *r, Eina_Array *clips, Eina_Bool do_async); 1455 void (*ector_renderer_draw) (void *data, void *context, void *surface, void *engine_data, Ector_Renderer *r, Eina_Array *clips, Eina_Bool do_async);
1455 void (*ector_end) (void *data, void *context, Ector_Surface *ector, void *surface, void *engine_data, Eina_Bool do_async); 1456 void (*ector_end) (void *data, void *context, Ector_Surface *ector, void *surface, void *engine_data, Eina_Bool do_async);
diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c
index f67ffda148..a052958637 100644
--- a/src/modules/evas/engines/gl_generic/evas_engine.c
+++ b/src/modules/evas/engines/gl_generic/evas_engine.c
@@ -2458,6 +2458,20 @@ eng_ector_destroy(void *data EINA_UNUSED, Ector_Surface *ector)
2458 if (ector) eo_del(ector); 2458 if (ector) eo_del(ector);
2459} 2459}
2460 2460
2461static Ector_Buffer *
2462eng_ector_buffer_new(void *data EINA_UNUSED, Evas *e, void *engine_image)
2463{
2464 Evas_GL_Image *im = engine_image;
2465 Ector_Buffer *buf = NULL;
2466
2467 if (!im) return NULL;
2468
2469#warning FIXME: implement me
2470 (void) e;
2471
2472 return buf;
2473}
2474
2461static Efl_Gfx_Render_Op 2475static Efl_Gfx_Render_Op
2462_evas_render_op_to_ector_rop(Evas_Render_Op op) 2476_evas_render_op_to_ector_rop(Evas_Render_Op op)
2463{ 2477{
@@ -2799,6 +2813,7 @@ module_open(Evas_Module *em)
2799 2813
2800 ORD(ector_create); 2814 ORD(ector_create);
2801 ORD(ector_destroy); 2815 ORD(ector_destroy);
2816 ORD(ector_buffer_new);
2802 ORD(ector_begin); 2817 ORD(ector_begin);
2803 ORD(ector_renderer_draw); 2818 ORD(ector_renderer_draw);
2804 ORD(ector_end); 2819 ORD(ector_end);
diff --git a/src/modules/evas/engines/software_generic/evas_ector_software_buffer.c b/src/modules/evas/engines/software_generic/evas_ector_software_buffer.c
new file mode 100644
index 0000000000..3d45862653
--- /dev/null
+++ b/src/modules/evas/engines/software_generic/evas_ector_software_buffer.c
@@ -0,0 +1,97 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <software/Ector_Software.h>
6#include "evas_common_private.h"
7#include "evas_private.h"
8#include "draw.h"
9
10#include "evas_ector_buffer.eo.h"
11#include "evas_ector_software_buffer.eo.h"
12
13#define MY_CLASS EVAS_ECTOR_SOFTWARE_BUFFER_CLASS
14
15typedef struct {
16 Ector_Software_Buffer_Base_Data *base;
17 Evas *evas;
18 Image_Entry *ie;
19} Evas_Ector_Software_Buffer_Data;
20
21#define ENFN e->engine.func
22#define ENDT e->engine.data.output
23
24EOLIAN static void
25_evas_ector_software_buffer_evas_ector_buffer_engine_image_set(Eo *obj, Evas_Ector_Software_Buffer_Data *pd,
26 Evas *evas, void *image)
27{
28 Evas_Public_Data *e = eo_data_scope_get(evas, EVAS_CANVAS_CLASS);
29 Image_Entry *ie = image;
30 RGBA_Image *im;
31 Eina_Bool b;
32
33 if (eo_do_ret(obj, b, eo_finalized_get()))
34 {
35 CRI("engine_image must be set at construction time only");
36 return;
37 }
38
39 im = (RGBA_Image *) ie;
40 if (!im->image.data)
41 {
42 CRI("image has no pixels yet");
43 return;
44 }
45
46 pd->evas = eo_xref(evas, obj);
47 pd->ie = ENFN->image_ref(ENDT, ie);
48 if (!pd->ie) return;
49
50 eo_do(obj, ector_buffer_pixels_set(im->image.data,
51 im->cache_entry.w, im->cache_entry.h, 0,
52 _evas_to_gfx_render_op(im->cache_entry.space),
53 EINA_TRUE, 0, 0, 0, 0));
54}
55
56EOLIAN static void
57_evas_ector_software_buffer_evas_ector_buffer_engine_image_get(Eo *obj EINA_UNUSED,
58 Evas_Ector_Software_Buffer_Data *pd,
59 Evas **evas, void **image)
60{
61 if (evas) *evas = pd->evas;
62 if (image) *image = pd->ie;
63}
64
65EOLIAN static Eo *
66_evas_ector_software_buffer_eo_base_constructor(Eo *obj, Evas_Ector_Software_Buffer_Data *pd)
67{
68 eo_do_super(obj, MY_CLASS, obj = eo_constructor());
69 pd->base = eo_data_xref(obj, ECTOR_SOFTWARE_BUFFER_BASE_MIXIN, obj);
70 return obj;
71}
72
73EOLIAN static Eo *
74_evas_ector_software_buffer_eo_base_finalize(Eo *obj, Evas_Ector_Software_Buffer_Data *pd)
75{
76 if (!pd->ie)
77 {
78 CRI("engine_image must be set at construction time only");
79 return NULL;
80 }
81 pd->base->generic->immutable = EINA_TRUE;
82 return eo_do_super_ret(obj, MY_CLASS, obj, eo_finalize());
83}
84
85EOLIAN static void
86_evas_ector_software_buffer_eo_base_destructor(Eo *obj, Evas_Ector_Software_Buffer_Data *pd)
87{
88 Evas_Public_Data *e = eo_data_scope_get(pd->evas, EVAS_CANVAS_CLASS);
89
90 eo_data_xunref(obj, pd->base, obj);
91 ENFN->image_free(ENDT, pd->ie);
92 eo_xunref(pd->evas, obj);
93 eo_do_super(obj, MY_CLASS, eo_destructor());
94}
95
96#include "evas_ector_buffer.eo.c"
97#include "evas_ector_software_buffer.eo.c"
diff --git a/src/modules/evas/engines/software_generic/evas_ector_software_buffer.eo b/src/modules/evas/engines/software_generic/evas_ector_software_buffer.eo
new file mode 100644
index 0000000000..f6a1a200d3
--- /dev/null
+++ b/src/modules/evas/engines/software_generic/evas_ector_software_buffer.eo
@@ -0,0 +1,12 @@
1class Evas.Ector.Software.Buffer (Ector.Software.Buffer, Evas.Ector.Buffer)
2{
3 [[A buffer object wrapping an existing Evas Image_Entry.]]
4 legacy_prefix: null;
5 implements {
6 Eo.Base.constructor;
7 Eo.Base.finalize;
8 Eo.Base.destructor;
9 Evas.Ector.Buffer.engine_image.set;
10 Evas.Ector.Buffer.engine_image.get;
11 }
12}
diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c
index b71399f04f..22967ad14d 100644
--- a/src/modules/evas/engines/software_generic/evas_engine.c
+++ b/src/modules/evas/engines/software_generic/evas_engine.c
@@ -9,6 +9,8 @@
9 9
10#include <software/Ector_Software.h> 10#include <software/Ector_Software.h>
11#include "cairo/Ector_Cairo.h" 11#include "cairo/Ector_Cairo.h"
12#include "evas_ector_buffer.eo.h"
13#include "evas_ector_software_buffer.eo.h"
12 14
13#if defined HAVE_DLSYM && ! defined _WIN32 15#if defined HAVE_DLSYM && ! defined _WIN32
14# include <dlfcn.h> /* dlopen,dlclose,etc */ 16# include <dlfcn.h> /* dlopen,dlclose,etc */
@@ -3755,6 +3757,20 @@ eng_ector_destroy(void *data EINA_UNUSED, Ector_Surface *ector)
3755 if (ector) eo_del(ector); 3757 if (ector) eo_del(ector);
3756} 3758}
3757 3759
3760static Ector_Buffer *
3761eng_ector_buffer_new(void *data EINA_UNUSED, Evas *e, void *engine_image)
3762{
3763 Image_Entry *ie = engine_image;
3764 Ector_Buffer *buf = NULL;
3765
3766 if (!ie) return NULL;
3767
3768 buf = eo_add(EVAS_ECTOR_SOFTWARE_BUFFER_CLASS, e,
3769 evas_ector_buffer_engine_image_set(e, ie));
3770
3771 return buf;
3772}
3773
3758static Efl_Gfx_Render_Op 3774static Efl_Gfx_Render_Op
3759_evas_render_op_to_ector_rop(Evas_Render_Op op) 3775_evas_render_op_to_ector_rop(Evas_Render_Op op)
3760{ 3776{
@@ -4166,6 +4182,7 @@ static Evas_Func func =
4166 NULL, // eng_texture_image_get 4182 NULL, // eng_texture_image_get
4167 eng_ector_create, 4183 eng_ector_create,
4168 eng_ector_destroy, 4184 eng_ector_destroy,
4185 eng_ector_buffer_new,
4169 eng_ector_begin, 4186 eng_ector_begin,
4170 eng_ector_renderer_draw, 4187 eng_ector_renderer_draw,
4171 eng_ector_end, 4188 eng_ector_end,