ector: add reference point to define (0, 0) and don't repeat the same value everywhere.
authorCedric BAIL <cedric@osg.samsung.com>
Fri, 3 Apr 2015 14:33:19 +0000 (16:33 +0200)
committerCedric BAIL <cedric@osg.samsung.com>
Fri, 3 Apr 2015 14:33:19 +0000 (16:33 +0200)
18 files changed:
src/lib/ector/cairo/ector_cairo_surface.c
src/lib/ector/cairo/ector_cairo_surface.eo
src/lib/ector/cairo/ector_renderer_cairo_base.c
src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c
src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c
src/lib/ector/cairo/ector_renderer_cairo_shape.c
src/lib/ector/ector_generic_surface.eo
src/lib/ector/ector_renderer_generic_base.eo
src/lib/ector/software/ector_renderer_software_gradient_linear.c
src/lib/ector/software/ector_renderer_software_gradient_radial.c
src/lib/ector/software/ector_renderer_software_shape.c
src/lib/ector/software/ector_software_private.h
src/lib/ector/software/ector_software_surface.c
src/lib/ector/software/ector_software_surface.eo
src/lib/evas/canvas/evas_object_vg.c
src/lib/evas/include/evas_private.h
src/modules/evas/engines/gl_generic/evas_engine.c
src/modules/evas/engines/software_generic/evas_engine.c

index ff3013571460c9f91c4aa46f7e67e2fb0ba03394..8e7b1043f61dd9b873e92aa74243fea7aef145fb 100644 (file)
@@ -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)
index 10f6d9f30ea75fa8874770009e956693000e18c0..298c681d7878ce124b5f2f85b9f780ff88bd4fee 100644 (file)
@@ -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;
    }
index 5e1c0606cc0f8a234353f2508568637e592930f2..190fb8a09039ad6fbb5edd31d98cc05d701e6cca 100644 (file)
@@ -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;
index e00ed6d8c0e003f2860ffa74e15982bea4e8b929..19f30558a3296c321129c11cfd4a9d9bfba1566e 100644 (file)
@@ -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);
index a219375f9354075b69a1b4636a1e129d08b849bb..521b06da9ed675d98e4fc67fecebffe0eef171ba 100644 (file)
@@ -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);
index a3fd1070c2b6cac6b2346a52f41503de1d7233e4..497c59d52f08c7bd1a62ec48fe89c66540f373d9 100644 (file)
@@ -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);
index 18ebd47c6060e51181393a2403d46a59c764c415..42a5f3e8a3cf7f9ecceee3fdc4348f8837d52988 100644 (file)
@@ -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;
    }
 }
index 5e5d6aa3b9a3b08b6a086b06762af97a47582994..50e7e94cdc5e846bb8ac4cb3b8e58fd7bfe4bda8 100644 (file)
@@ -96,8 +96,6 @@ abstract Ector.Renderer.Generic.Base (Eo.Base)
         params {
            @in Ector_Rop op;
            @in array<Eina_Rectangle *> *clips; /*@ array of Eina_Rectangle clip */
-           @in int x;
-           @in int y;
            @in uint mul_col;
         }
       }
index 8bbf23d73a8877fb04af8e054a758deb5b27849b..a6e32b008b1339b0428cd308737f439d9a433e32 100644 (file)
@@ -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;
 }
index 4bcf2a15941bdfb18f6a915110f94cf9cd33f74e..41d24cbf112e24055d9ce11af22e646cec48e38e 100644 (file)
@@ -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;
 }
index cdecce9e872dcdb9ee2c8a66cfb9d13d5a0cade4..8793c527cf1bcdd629bf40e2321dde00b730bfc1 100644 (file)
@@ -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);
index b43dcfea06902714b0283bb2299e5fcbec624063..bf2adf699895b68779464b6ef8a91732aa05bf09 100644 (file)
@@ -114,6 +114,8 @@ typedef struct _Software_Rasterizer
 struct _Ector_Software_Surface_Data
 {
    Software_Rasterizer *software;
+   int x;
+   int y;
 };
 
 
index e32477ecc0cc6622298209af0af9465f9158e5e0..1999feae686211fc370a28539f4104179e889732 100644 (file)
@@ -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"
index 58a6a771f61166ec5eacb44025c4748799939dfd..3ed863c0c8090303ddeaca89aca6cedd8e3702f2 100644 (file)
@@ -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;
    }
index 2336d9b6e5595d553f721031a4053bf7a009b4be..fa682af23409d22d1699d9db9cbdb63e6a862f68 100644 (file)
@@ -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);
 }
index 9fb51b4dc9c7d0371abd440e02b5e4dd99311547..e45565c9b280dbce6bf496a9a6629c670f35cb5b 100644 (file)
@@ -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);
 };
 
index 5865d4ba25f8ee1540af63b180f7987a976614a6..871ffbb67fbba602fac51acef74b4eb5554b3cb3 100644 (file)
@@ -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));
      }
 }
 
index 6323ba43ca76af19f712adc6316d5d7e9070be17..88475d6504542ad4ebab88f24d66a11e02d12de4 100644 (file)
@@ -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));
+          }
      }
 }