diff --git a/src/lib/ector/cairo/ector_cairo_surface.c b/src/lib/ector/cairo/ector_cairo_surface.c index ff30135714..8e7b1043f6 100644 --- a/src/lib/ector/cairo/ector_cairo_surface.c +++ b/src/lib/ector/cairo/ector_cairo_surface.c @@ -67,6 +67,7 @@ _ector_cairo_surface_ector_generic_surface_renderer_factory_new(Eo *obj, typedef struct _cairo_surface_t cairo_surface_t; +static void (*cairo_translate)(cairo_t *cr, double tx, double ty) = NULL; static void (*cairo_destroy)(cairo_t *cr) = NULL; static cairo_surface_t *(*cairo_image_surface_create)(int format, int width, @@ -106,6 +107,18 @@ _ector_cairo_surface_context_get(Eo *obj EINA_UNUSED, return pd->cairo; } +static void +_ector_cairo_surface_ector_generic_surface_reference_point_set(Eo *obj EINA_UNUSED, + Ector_Cairo_Surface_Data *pd, + int x, int y) +{ + if (pd->cairo) + { + USE(obj, cairo_translate, ); + cairo_translate(pd->cairo, x, y); + } +} + static void _ector_cairo_surface_eo_base_constructor(Eo *obj, Ector_Cairo_Surface_Data *pd) diff --git a/src/lib/ector/cairo/ector_cairo_surface.eo b/src/lib/ector/cairo/ector_cairo_surface.eo index 10f6d9f30e..298c681d78 100644 --- a/src/lib/ector/cairo/ector_cairo_surface.eo +++ b/src/lib/ector/cairo/ector_cairo_surface.eo @@ -23,6 +23,7 @@ class Ector.Cairo.Surface (Ector.Generic.Surface) } implements { Ector.Generic.Surface.renderer_factory_new; + Ector.Generic.Surface.reference_point.set; Eo.Base.destructor; Eo.Base.constructor; } diff --git a/src/lib/ector/cairo/ector_renderer_cairo_base.c b/src/lib/ector/cairo/ector_renderer_cairo_base.c index 5e1c0606cc..190fb8a090 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_base.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_base.c @@ -138,7 +138,6 @@ _ector_renderer_cairo_base_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Base_Data *pd, Ector_Rop op, Eina_Array *clips EINA_UNUSED, - int x, int y, unsigned int mul_col) { double r, g, b, a; diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c index e00ed6d8c0..19f30558a3 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c @@ -68,7 +68,7 @@ _ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_prepare(Eo *ob static Eina_Bool _ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Gradient_Linear_Data *pd, - Ector_Rop op, Eina_Array *clips, int x, int y, unsigned int mul_col) + Ector_Rop op, Eina_Array *clips, unsigned int mul_col) { Ector_Renderer_Generic_Gradient_Linear_Data *gld; @@ -76,7 +76,7 @@ _ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_draw(Eo *obj, gld = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_LINEAR_MIXIN); if (!pd->pat || !gld) return EINA_FALSE; - eo_do_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS, ector_renderer_draw(op, clips, x, y, mul_col)); + eo_do_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS, ector_renderer_draw(op, clips, mul_col)); USE(obj, cairo_rectangle, EINA_FALSE); USE(obj, cairo_fill, EINA_FALSE); diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c index a219375f93..521b06da9e 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c @@ -72,7 +72,7 @@ _ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_prepare(Eo *ob // Clearly duplicated and should be in a common place... static Eina_Bool -_ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd, Ector_Rop op, Eina_Array *clips, int x, int y, unsigned int mul_col) +_ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd, Ector_Rop op, Eina_Array *clips, unsigned int mul_col) { Ector_Renderer_Generic_Gradient_Radial_Data *gld; @@ -80,7 +80,7 @@ _ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_draw(Eo *obj, gld = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_RADIAL_MIXIN); if (!pd->pat || !gld) return EINA_FALSE; - eo_do_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS, ector_renderer_draw(op, clips, x, y, mul_col)); + eo_do_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS, ector_renderer_draw(op, clips, mul_col)); USE(obj, cairo_arc, EINA_FALSE); USE(obj, cairo_fill, EINA_FALSE); diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c index a3fd1070c2..497c59d52f 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.c @@ -128,12 +128,12 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_R } static Eina_Bool -_ector_renderer_cairo_shape_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd, Ector_Rop op, Eina_Array *clips, int x, int y, unsigned int mul_col) +_ector_renderer_cairo_shape_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd, Ector_Rop op, Eina_Array *clips, unsigned int mul_col) { if (pd->path == NULL) return EINA_FALSE; // FIXME: find a way to set multiple clips - eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, ector_renderer_draw(op, clips, x, y, mul_col)); + eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, ector_renderer_draw(op, clips, mul_col)); USE(obj, cairo_new_path, EINA_FALSE); USE(obj, cairo_append_path, EINA_FALSE); diff --git a/src/lib/ector/ector_generic_surface.eo b/src/lib/ector/ector_generic_surface.eo index 18ebd47c60..42a5f3e8a3 100644 --- a/src/lib/ector/ector_generic_surface.eo +++ b/src/lib/ector/ector_generic_surface.eo @@ -14,6 +14,15 @@ abstract Ector.Generic.Surface (Eo.Base) int h; /*@ in */ } } + reference_point { + set { + /*@ This define where is (0,0) in pixels coordinate inside the surface */ + } + values { + int x; + int y; + } + } } methods { renderer_factory_new { @@ -35,5 +44,6 @@ abstract Ector.Generic.Surface (Eo.Base) } implements { @virtual .renderer_factory_new; + @virtual .reference_point.set; } } diff --git a/src/lib/ector/ector_renderer_generic_base.eo b/src/lib/ector/ector_renderer_generic_base.eo index 5e5d6aa3b9..50e7e94cdc 100644 --- a/src/lib/ector/ector_renderer_generic_base.eo +++ b/src/lib/ector/ector_renderer_generic_base.eo @@ -96,8 +96,6 @@ abstract Ector.Renderer.Generic.Base (Eo.Base) params { @in Ector_Rop op; @in array *clips; /*@ array of Eina_Rectangle clip */ - @in int x; - @in int y; @in uint mul_col; } } diff --git a/src/lib/ector/software/ector_renderer_software_gradient_linear.c b/src/lib/ector/software/ector_renderer_software_gradient_linear.c index 8bbf23d73a..a6e32b008b 100644 --- a/src/lib/ector/software/ector_renderer_software_gradient_linear.c +++ b/src/lib/ector/software/ector_renderer_software_gradient_linear.c @@ -57,7 +57,7 @@ static Eina_Bool _ector_renderer_software_gradient_linear_ector_renderer_generic_base_draw(Eo *obj EINA_UNUSED, Ector_Renderer_Software_Gradient_Data *pd EINA_UNUSED, Ector_Rop op EINA_UNUSED, Eina_Array *clips EINA_UNUSED, - int x EINA_UNUSED, int y EINA_UNUSED, unsigned int mul_col EINA_UNUSED) + unsigned int mul_col EINA_UNUSED) { return EINA_TRUE; } diff --git a/src/lib/ector/software/ector_renderer_software_gradient_radial.c b/src/lib/ector/software/ector_renderer_software_gradient_radial.c index 4bcf2a1594..41d24cbf11 100644 --- a/src/lib/ector/software/ector_renderer_software_gradient_radial.c +++ b/src/lib/ector/software/ector_renderer_software_gradient_radial.c @@ -66,7 +66,7 @@ static Eina_Bool _ector_renderer_software_gradient_radial_ector_renderer_generic_base_draw(Eo *obj EINA_UNUSED, Ector_Renderer_Software_Gradient_Data *pd EINA_UNUSED, Ector_Rop op EINA_UNUSED, Eina_Array *clips EINA_UNUSED, - int x EINA_UNUSED, int y EINA_UNUSED, unsigned int mul_col EINA_UNUSED) + unsigned int mul_col EINA_UNUSED) { return EINA_TRUE; } diff --git a/src/lib/ector/software/ector_renderer_software_shape.c b/src/lib/ector/software/ector_renderer_software_shape.c index cdecce9e87..8793c527cf 100644 --- a/src/lib/ector/software/ector_renderer_software_shape.c +++ b/src/lib/ector/software/ector_renderer_software_shape.c @@ -281,11 +281,13 @@ _ector_renderer_software_shape_ector_renderer_generic_base_prepare(Eo *obj, Ecto } static Eina_Bool -_ector_renderer_software_shape_ector_renderer_generic_base_draw(Eo *obj EINA_UNUSED, Ector_Renderer_Software_Shape_Data *pd, Ector_Rop op, Eina_Array *clips, int x, int y, unsigned int mul_col) +_ector_renderer_software_shape_ector_renderer_generic_base_draw(Eo *obj EINA_UNUSED, Ector_Renderer_Software_Shape_Data *pd, Ector_Rop op, Eina_Array *clips, unsigned int mul_col) { + int x, y; + // adjust the offset - x = x + (int)pd->base->origin.x; - y = y + (int)pd->base->origin.y; + x = pd->surface->x + (int)pd->base->origin.x; + y = pd->surface->y + (int)pd->base->origin.y; // fill the span_data structure ector_software_rasterizer_clip_rect_set(pd->surface->software, clips); diff --git a/src/lib/ector/software/ector_software_private.h b/src/lib/ector/software/ector_software_private.h index b43dcfea06..bf2adf6998 100644 --- a/src/lib/ector/software/ector_software_private.h +++ b/src/lib/ector/software/ector_software_private.h @@ -114,6 +114,8 @@ typedef struct _Software_Rasterizer struct _Ector_Software_Surface_Data { Software_Rasterizer *software; + int x; + int y; }; diff --git a/src/lib/ector/software/ector_software_surface.c b/src/lib/ector/software/ector_software_surface.c index e32477ecc0..1999feae68 100644 --- a/src/lib/ector/software/ector_software_surface.c +++ b/src/lib/ector/software/ector_software_surface.c @@ -90,5 +90,14 @@ _ector_software_surface_eo_base_destructor(Eo *obj EINA_UNUSED, eo_do_super(obj, ECTOR_SOFTWARE_SURFACE_CLASS, eo_destructor()); } +static void +_ector_software_surface_ector_generic_surface_reference_point_set(Eo *obj EINA_UNUSED, + Ector_Software_Surface_Data *pd, + int x, int y) +{ + pd->x = x; + pd->y = y; +} + #include "ector_software_surface.eo.c" #include "ector_renderer_software_base.eo.c" diff --git a/src/lib/ector/software/ector_software_surface.eo b/src/lib/ector/software/ector_software_surface.eo index 58a6a771f6..3ed863c0c8 100644 --- a/src/lib/ector/software/ector_software_surface.eo +++ b/src/lib/ector/software/ector_software_surface.eo @@ -27,6 +27,7 @@ class Ector.Software.Surface (Ector.Generic.Surface) implements { Ector.Generic.Surface.renderer_factory_new; + Ector.Generic.Surface.reference_point.set; Eo.Base.destructor; Eo.Base.constructor; } diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index 2336d9b6e5..fa682af234 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -126,7 +126,7 @@ _evas_vg_eo_base_constructor(Eo *eo_obj, Evas_VG_Data *pd) static void _evas_vg_render(Evas_Object_Protected_Data *obj, void *output, void *context, void *surface, Efl_VG *n, - Eina_Array *clips, int x, int y, Eina_Bool do_async) + Eina_Array *clips, Eina_Bool do_async) { Efl_VG_Container_Data *vd = eo_data_scope_get(n, EFL_VG_CONTAINER_CLASS); @@ -138,7 +138,7 @@ _evas_vg_render(Evas_Object_Protected_Data *obj, EINA_LIST_FOREACH(vd->children, l, child) _evas_vg_render(obj, output, context, surface, child, - clips, x, y, do_async); + clips, do_async); } else { @@ -146,7 +146,7 @@ _evas_vg_render(Evas_Object_Protected_Data *obj, nd = eo_data_scope_get(n, EFL_VG_BASE_CLASS); - obj->layer->evas->engine.func->ector_renderer_draw(output, context, surface, nd->renderer, clips, x, y, do_async); + obj->layer->evas->engine.func->ector_renderer_draw(output, context, surface, nd->renderer, clips, do_async); } } @@ -179,9 +179,10 @@ evas_object_vg_render(Evas_Object *eo_obj EINA_UNUSED, context); obj->layer->evas->engine.func->context_render_op_set(output, context, obj->cur->render_op); - obj->layer->evas->engine.func->ector_begin(output, context, surface, do_async); + obj->layer->evas->engine.func->ector_begin(output, context, surface, + obj->cur->geometry.x + x, obj->cur->geometry.y + y, + do_async); _evas_vg_render(obj, output, context, surface, vd->root, NULL, - obj->cur->geometry.x + x, obj->cur->geometry.y + y, do_async); obj->layer->evas->engine.func->ector_end(output, context, surface, do_async); } diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h index 9fb51b4dc9..e45565c9b2 100644 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h @@ -1368,8 +1368,8 @@ struct _Evas_Func void (*texture_image_set) (void *data, void *texture, void *image); Ector_Surface *(*ector_get) (void *data); - void (*ector_begin) (void *data, void *context, void *surface, Eina_Bool do_async); - void (*ector_renderer_draw) (void *data, void *context, void *surface, Ector_Renderer *r, Eina_Array *clips, int x, int y, Eina_Bool do_async); + void (*ector_begin) (void *data, void *context, void *surface, int x, int y, Eina_Bool do_async); + void (*ector_renderer_draw) (void *data, void *context, void *surface, Ector_Renderer *r, Eina_Array *clips, Eina_Bool do_async); void (*ector_end) (void *data, void *context, void *surface, 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 5865d4ba25..871ffbb67f 100644 --- a/src/modules/evas/engines/gl_generic/evas_engine.c +++ b/src/modules/evas/engines/gl_generic/evas_engine.c @@ -2132,7 +2132,7 @@ _evas_render_op_to_ector_rop(Evas_Render_Op op) } static void -eng_ector_renderer_draw(void *data, void *context EINA_UNUSED, void *surface, Ector_Renderer *renderer, Eina_Array *clips, int x, int y, Eina_Bool do_async EINA_UNUSED) +eng_ector_renderer_draw(void *data, void *context EINA_UNUSED, void *surface, Ector_Renderer *renderer, Eina_Array *clips, Eina_Bool do_async EINA_UNUSED) { Evas_GL_Image *dst = surface; Evas_Engine_GL_Context *gc; @@ -2186,8 +2186,6 @@ eng_ector_renderer_draw(void *data, void *context EINA_UNUSED, void *surface, Ec eo_do(renderer, ector_renderer_draw(_evas_render_op_to_ector_rop(gc->dc->render_op), c, - x, - y, // mul_col will be applied by GL during ector_end 0xffffffff)); @@ -2199,7 +2197,7 @@ eng_ector_renderer_draw(void *data, void *context EINA_UNUSED, void *surface, Ec static void *software_buffer = NULL; static void -eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, void *surface, Eina_Bool do_async EINA_UNUSED) +eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, void *surface, int x, int y, Eina_Bool do_async EINA_UNUSED) { Evas_Engine_GL_Context *gl_context; Render_Engine_GL_Generic *re = data; @@ -2216,12 +2214,14 @@ eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, void *surface if (use_cairo) { eo_do(_software_ector, - ector_cairo_software_surface_set(software_buffer, w, h)); + ector_cairo_software_surface_set(software_buffer, w, h), + ector_surface_reference_point_set(x, y)); } else { eo_do(_software_ector, - ector_software_surface_set(software_buffer, w, h)); + ector_software_surface_set(software_buffer, w, h), + ector_surface_reference_point_set(x, y)); } } diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c index 6323ba43ca..88475d6504 100644 --- a/src/modules/evas/engines/software_generic/evas_engine.c +++ b/src/modules/evas/engines/software_generic/evas_engine.c @@ -397,7 +397,6 @@ struct _Evas_Thread_Command_Ector DATA32 mul_col; Ector_Rop render_op; - int x, y; Eina_Bool free_it; }; @@ -405,6 +404,7 @@ struct _Evas_Thread_Command_Ector struct _Evas_Thread_Command_Ector_Surface { void *surface; + int x, y; }; Eina_Mempool *_mp_command_rect = NULL; @@ -3513,15 +3513,13 @@ _draw_thread_ector_draw(void *data) eo_do(ector->r, ector_renderer_draw(ector->render_op, ector->clips, - ector->x, - ector->y, ector->mul_col)); _draw_thread_ector_cleanup(ector); } static void -eng_ector_renderer_draw(void *data EINA_UNUSED, void *context, void *surface, Ector_Renderer *renderer, Eina_Array *clips, int x, int y, Eina_Bool do_async) +eng_ector_renderer_draw(void *data EINA_UNUSED, void *context, void *surface, Ector_Renderer *renderer, Eina_Array *clips, Eina_Bool do_async) { RGBA_Image *dst = surface; RGBA_Draw_Context *dc = context; @@ -3576,8 +3574,6 @@ eng_ector_renderer_draw(void *data EINA_UNUSED, void *context, void *surface, Ec ector.render_op = _evas_render_op_to_ector_rop(dc->render_op); ector.mul_col = ector_color_multiply(dc->mul.use ? dc->mul.col : 0xffffffff, dc->col.col);; - ector.x = x; - ector.y = y; ector.free_it = EINA_FALSE; if (do_async) @@ -3610,23 +3606,29 @@ _draw_thread_ector_surface_set(void *data) void *pixels = NULL; unsigned int w = 0; unsigned int h = 0; + unsigned int x = 0; + unsigned int y = 0; if (surface) { pixels = evas_cache_image_pixels(&surface->cache_entry); w = surface->cache_entry.w; h = surface->cache_entry.h; + x = ector_surface->x; + y = ector_surface->y; } if (use_cairo) { eo_do(_software_ector, - ector_cairo_software_surface_set(pixels, w, h)); + ector_cairo_software_surface_set(pixels, w, h), + ector_surface_reference_point_set(x, y)); } else { eo_do(_software_ector, - ector_software_surface_set(pixels, w, h)); + ector_software_surface_set(pixels, w, h), + ector_surface_reference_point_set(x, y)); } evas_common_cpu_end_opt(); @@ -3635,7 +3637,7 @@ _draw_thread_ector_surface_set(void *data) } static void -eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, void *surface, Eina_Bool do_async) +eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, void *surface, int x, int y, Eina_Bool do_async) { if (do_async) { @@ -3645,6 +3647,8 @@ eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, void *surface if (!nes) return ; nes->surface = surface; + nes->x = x; + nes->y = y; evas_thread_cmd_enqueue(_draw_thread_ector_surface_set, nes); } @@ -3659,8 +3663,18 @@ eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, void *surface w = sf->cache_entry.w; h = sf->cache_entry.h; - eo_do(_software_ector, - ector_cairo_software_surface_set(pixels, w, h)); + if (use_cairo) + { + eo_do(_software_ector, + ector_cairo_software_surface_set(pixels, w, h), + ector_surface_reference_point_set(x, y)); + } + else + { + eo_do(_software_ector, + ector_software_surface_set(pixels, w, h), + ector_surface_reference_point_set(x, y)); + } } }