From 4bcea3eada67332b61e175adabbcbe6dd07563f8 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Thu, 3 Dec 2015 15:10:18 +0900 Subject: [PATCH] Ector: Move cairo surface back to ector The original plan was to have two different surfaces for GL and SW, but this is probably not going to happen anytime soon. So, move the implementation back to lib/ector. This avoid a file duplication. --- src/Makefile_Ector.am | 3 +- src/Makefile_Evas.am | 16 +-- src/lib/ector/cairo/Ector_Cairo.h | 1 + .../ector/cairo}/ector_cairo_software_surface.c | 11 +- .../ector/cairo}/ector_cairo_software_surface.eo | 0 src/lib/ector/ector_buffer.h | 5 + .../gl_generic/ector_cairo_software_surface.eo | 11 -- src/modules/evas/engines/gl_generic/evas_engine.c | 3 +- .../ector_cairo_software_surface.c | 127 --------------------- .../evas/engines/software_generic/evas_engine.c | 3 +- 10 files changed, 14 insertions(+), 166 deletions(-) rename src/{modules/evas/engines/gl_generic => lib/ector/cairo}/ector_cairo_software_surface.c (96%) rename src/{modules/evas/engines/software_generic => lib/ector/cairo}/ector_cairo_software_surface.eo (100%) delete mode 100644 src/modules/evas/engines/gl_generic/ector_cairo_software_surface.eo delete mode 100644 src/modules/evas/engines/software_generic/ector_cairo_software_surface.c diff --git a/src/Makefile_Ector.am b/src/Makefile_Ector.am index 0f50260..1855b17 100644 --- a/src/Makefile_Ector.am +++ b/src/Makefile_Ector.am @@ -14,6 +14,7 @@ ector_eolian_generic_h = $(ector_eolian_files_generic:%.eo=%.eo.h) # Handle cairo backend ector_eolian_files_cairo = \ lib/ector/cairo/ector_cairo_surface.eo \ + lib/ector/cairo/ector_cairo_software_surface.eo \ lib/ector/cairo/ector_renderer_cairo_base.eo \ lib/ector/cairo/ector_renderer_cairo_shape.eo \ lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo \ @@ -85,6 +86,7 @@ lib/ector/cairo/ector_renderer_cairo_gradient_linear.c \ lib/ector/cairo/ector_renderer_cairo_gradient_radial.c \ lib/ector/cairo/ector_renderer_cairo_shape.c \ lib/ector/cairo/ector_renderer_cairo_base.c \ +lib/ector/cairo/ector_cairo_software_surface.c \ lib/ector/cairo/ector_cairo_surface.c installed_ectorcairoheadersdir = $(includedir)/ector-@VMAJ@/cairo @@ -166,7 +168,6 @@ EXTRA_DIST += \ lib/ector/ector_private.h \ lib/ector/ector_buffer.h \ lib/ector/cairo/ector_cairo_private.h \ -lib/ector/software/ector_drawhelper_private.h \ lib/ector/software/ector_software_private.h \ static_libs/freetype/sw_ft_math.h \ static_libs/freetype/sw_ft_raster.h \ diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index 2f04c3c..8f234af 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -555,19 +555,10 @@ lib/evas/filters/blur/blur_box_rgba_i386.c \ lib/evas/filters/blur/blur_box_rgba_sse3.c \ lib/evas/filters/blur/blur_box_rgba_neon.c -### Vector surface helper - -EXTRA_DIST += \ -modules/evas/engines/software_generic/ector_cairo_software_surface.eo \ -modules/evas/engines/gl_generic/ector_cairo_software_surface.eo - ### Engines if EVAS_STATIC_BUILD_SOFTWARE_GENERIC -BUILT_SOURCES += \ -modules/evas/engines/software_generic/ector_cairo_software_surface.eo.c \ -modules/evas/engines/software_generic/ector_cairo_software_surface.eo.h -lib_evas_libevas_la_SOURCES += modules/evas/engines/software_generic/evas_engine.c modules/evas/engines/software_generic/ector_cairo_software_surface.c modules/evas/engines/software_generic/Evas_Engine_Software_Generic.h +lib_evas_libevas_la_SOURCES += modules/evas/engines/software_generic/evas_engine.c modules/evas/engines/software_generic/Evas_Engine_Software_Generic.h lib_evas_libevas_la_LIBADD += else enginesoftwaregenericpkgdir = $(libdir)/evas/modules/engines/software_generic/$(MODULE_ARCH) @@ -656,10 +647,6 @@ endif endif if BUILD_ENGINE_GL_COMMON -BUILT_SOURCES += \ -modules/evas/engines/gl_generic/ector_cairo_software_surface.eo.c \ -modules/evas/engines/gl_generic/ector_cairo_software_surface.eo.h - GL_COMMON_SOURCES = \ modules/evas/engines/gl_common/evas_gl_private.h \ modules/evas/engines/gl_common/evas_gl_common.h \ @@ -740,7 +727,6 @@ modules/evas/engines/gl_common/shader_3d/evas_gl_3d_shaders.x: modules/evas/engi GL_GENERIC_SOURCES = \ modules/evas/engines/gl_generic/evas_engine.c \ -modules/evas/engines/gl_generic/ector_cairo_software_surface.c \ modules/evas/engines/gl_generic/Evas_Engine_GL_Generic.h if EVAS_STATIC_BUILD_GL_COMMON diff --git a/src/lib/ector/cairo/Ector_Cairo.h b/src/lib/ector/cairo/Ector_Cairo.h index 351a2f5..f45dfd0 100644 --- a/src/lib/ector/cairo/Ector_Cairo.h +++ b/src/lib/ector/cairo/Ector_Cairo.h @@ -13,6 +13,7 @@ typedef Eo Ector_Cairo_Surface; typedef struct _cairo_t cairo_t; #include "cairo/ector_cairo_surface.eo.h" +#include "cairo/ector_cairo_software_surface.eo.h" #include "cairo/ector_renderer_cairo_base.eo.h" #include "cairo/ector_renderer_cairo_shape.eo.h" #include "cairo/ector_renderer_cairo_gradient_linear.eo.h" diff --git a/src/modules/evas/engines/gl_generic/ector_cairo_software_surface.c b/src/lib/ector/cairo/ector_cairo_software_surface.c similarity index 96% rename from src/modules/evas/engines/gl_generic/ector_cairo_software_surface.c rename to src/lib/ector/cairo/ector_cairo_software_surface.c index 2d4658a..1cc7daf 100644 --- a/src/modules/evas/engines/gl_generic/ector_cairo_software_surface.c +++ b/src/lib/ector/cairo/ector_cairo_software_surface.c @@ -2,15 +2,10 @@ #include "config.h" /* so that EAPI in Evas.h is correctly defined */ #endif -#include - -#include +#include "Ector_Cairo.h" +#include "ector_private.h" #include - -#include "evas_common_private.h" -#include "evas_private.h" #include "ector_cairo_software_surface.eo.h" -#include "ector_buffer.h" #define MY_CLASS ECTOR_CAIRO_SOFTWARE_SURFACE_CLASS @@ -94,7 +89,7 @@ _ector_cairo_software_surface_ector_generic_buffer_pixels_set(Eo *obj, Ector_Cai } end: - evas_common_cpu_end_opt(); + /* evas_common_cpu_end_opt(); // do we need this? */ eo_do(obj, ector_cairo_surface_context_set(ctx)); return ok; } diff --git a/src/modules/evas/engines/software_generic/ector_cairo_software_surface.eo b/src/lib/ector/cairo/ector_cairo_software_surface.eo similarity index 100% rename from src/modules/evas/engines/software_generic/ector_cairo_software_surface.eo rename to src/lib/ector/cairo/ector_cairo_software_surface.eo diff --git a/src/lib/ector/ector_buffer.h b/src/lib/ector/ector_buffer.h index 41a75cb..3c40990 100644 --- a/src/lib/ector/ector_buffer.h +++ b/src/lib/ector/ector_buffer.h @@ -1,3 +1,6 @@ +#ifndef ECTOR_BUFFER_H +#define ECTOR_BUFFER_H + #include #include "ector_generic_buffer.eo.h" @@ -25,3 +28,5 @@ typedef struct _Ector_Software_Buffer_Base_Data Eina_Bool nofree : 1; // pixel data should not be free()'ed Eina_Bool span_free : 1; } Ector_Software_Buffer_Base_Data; + +#endif diff --git a/src/modules/evas/engines/gl_generic/ector_cairo_software_surface.eo b/src/modules/evas/engines/gl_generic/ector_cairo_software_surface.eo deleted file mode 100644 index 8d4e789..0000000 --- a/src/modules/evas/engines/gl_generic/ector_cairo_software_surface.eo +++ /dev/null @@ -1,11 +0,0 @@ -class Ector.Cairo_Software.Surface (Ector.Cairo.Surface, Ector.Software.Buffer.Base) -{ - eo_prefix: ector_cairo_software_surface; - legacy_prefix: null; - methods {} - implements { - Ector.Generic.Buffer.pixels_set; - Eo.Base.constructor; - Eo.Base.destructor; - } -} diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c index 3a97b7d..03429d2 100644 --- a/src/modules/evas/engines/gl_generic/evas_engine.c +++ b/src/modules/evas/engines/gl_generic/evas_engine.c @@ -2,8 +2,7 @@ #include "evas_gl_core_private.h" #include "software/Ector_Software.h" - -#include "ector_cairo_software_surface.eo.h" +#include "cairo/Ector_Cairo.h" #ifdef HAVE_DLSYM # include /* dlopen,dlclose,etc */ diff --git a/src/modules/evas/engines/software_generic/ector_cairo_software_surface.c b/src/modules/evas/engines/software_generic/ector_cairo_software_surface.c deleted file mode 100644 index 2d4658a..0000000 --- a/src/modules/evas/engines/software_generic/ector_cairo_software_surface.c +++ /dev/null @@ -1,127 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" /* so that EAPI in Evas.h is correctly defined */ -#endif - -#include - -#include -#include - -#include "evas_common_private.h" -#include "evas_private.h" -#include "ector_cairo_software_surface.eo.h" -#include "ector_buffer.h" - -#define MY_CLASS ECTOR_CAIRO_SOFTWARE_SURFACE_CLASS - -#define USE(Obj, Sym, Error) \ - if (!Sym) Sym = _ector_cairo_symbol_get(Obj, #Sym); \ - if (!Sym) return Error; - -static inline void * -_ector_cairo_symbol_get(Eo *ector_surface, const char *name) -{ - void *sym; - - eo_do(ector_surface, - sym = ector_cairo_surface_symbol_get(name)); - return sym; -} - -typedef struct _cairo_surface_t cairo_surface_t; -typedef enum { - CAIRO_FORMAT_INVALID = -1, - CAIRO_FORMAT_ARGB32 = 0, - CAIRO_FORMAT_RGB24 = 1, - CAIRO_FORMAT_A8 = 2, - CAIRO_FORMAT_A1 = 3, - CAIRO_FORMAT_RGB16_565 = 4, - CAIRO_FORMAT_RGB30 = 5 -} cairo_format_t; - -static cairo_surface_t *(*cairo_image_surface_create_for_data)(unsigned char *data, - cairo_format_t format, - int width, - int height, - int stride) = NULL; -static void (*cairo_surface_destroy)(cairo_surface_t *surface) = NULL; -static cairo_t *(*cairo_create)(cairo_surface_t *target) = NULL; -static void (*cairo_destroy)(cairo_t *cr) = NULL; - -typedef struct _Ector_Cairo_Software_Surface_Data Ector_Cairo_Software_Surface_Data; -struct _Ector_Cairo_Software_Surface_Data -{ - cairo_surface_t *surface; - Ector_Software_Buffer_Base_Data *base; -}; - -EOLIAN static Eina_Bool -_ector_cairo_software_surface_ector_generic_buffer_pixels_set(Eo *obj, Ector_Cairo_Software_Surface_Data *pd, - void *pixels, int width, int height, int stride, - Efl_Gfx_Colorspace cspace, Eina_Bool writable, - unsigned char l, unsigned char r, unsigned char t, unsigned char b) -{ - cairo_t *ctx = NULL; - Eina_Bool ok = EINA_FALSE; - - if ((cspace != EFL_GFX_COLORSPACE_ARGB8888) || !writable) - { - ERR("Unsupported surface type!"); - return EINA_FALSE; - } - - USE(obj, cairo_image_surface_create_for_data, EINA_FALSE); - USE(obj, cairo_surface_destroy, EINA_FALSE); - USE(obj, cairo_create, EINA_FALSE); - USE(obj, cairo_destroy, EINA_FALSE); - - if (pd->surface) - cairo_surface_destroy(pd->surface); - pd->surface = NULL; - - eo_do_super(obj, MY_CLASS, - ok = ector_buffer_pixels_set(pixels, width, height, stride, - cspace, writable, l, r, t, b)); - - if (ok && pixels) - { - pd->surface = cairo_image_surface_create_for_data(pixels, - CAIRO_FORMAT_ARGB32, - width, height, pd->base->stride); - if (!pd->surface) goto end; - - ctx = cairo_create(pd->surface); - } - - end: - evas_common_cpu_end_opt(); - eo_do(obj, ector_cairo_surface_context_set(ctx)); - return ok; -} - -void -_ector_cairo_software_surface_surface_get(Eo *obj EINA_UNUSED, Ector_Cairo_Software_Surface_Data *pd, void **pixels, unsigned int *width, unsigned int *height) -{ - if (pixels) *pixels = pd->base->pixels.u8; - if (width) *width = pd->base->generic->w; - if (height) *height = pd->base->generic->h; -} - -static Eo_Base * -_ector_cairo_software_surface_eo_base_constructor(Eo *obj, Ector_Cairo_Software_Surface_Data *pd) -{ - eo_do_super(obj, MY_CLASS, obj = eo_constructor()); - pd->base = eo_data_ref(obj, ECTOR_SOFTWARE_BUFFER_BASE_MIXIN); - pd->base->generic = eo_data_ref(obj, ECTOR_GENERIC_BUFFER_MIXIN); - pd->base->generic->eo = obj; - return obj; -} - -EOLIAN static void -_ector_cairo_software_surface_eo_base_destructor(Eo *obj, Ector_Cairo_Software_Surface_Data *pd) -{ - eo_data_unref(obj, pd->base); - eo_do_super(obj, MY_CLASS, eo_destructor()); -} - -#include "ector_cairo_software_surface.eo.c" diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c index 7589d24..73334c2 100644 --- a/src/modules/evas/engines/software_generic/evas_engine.c +++ b/src/modules/evas/engines/software_generic/evas_engine.c @@ -8,8 +8,7 @@ #include "region.h" #include - -#include "ector_cairo_software_surface.eo.h" +#include "cairo/Ector_Cairo.h" #ifdef HAVE_DLSYM # include /* dlopen,dlclose,etc */ -- 2.7.4