cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=291c3e32af106531e4203ea4c2c69af786e0a34d

commit 291c3e32af106531e4203ea4c2c69af786e0a34d
Author: Subhransu Mohanty <sub.moha...@samsung.com>
Date:   Tue Aug 25 15:32:35 2015 +0900

    evas: create ector surface per engine instance.
    
    Signed-off-by: Cedric BAIL <ced...@osg.samsung.com>
---
 src/lib/evas/canvas/evas_main.c                    | 10 ++++
 src/lib/evas/canvas/evas_object_vg.c               | 19 +++----
 src/lib/evas/include/evas_private.h                | 12 +++--
 src/modules/evas/engines/gl_generic/evas_engine.c  | 53 ++++++++++---------
 .../evas/engines/software_generic/evas_engine.c    | 61 ++++++++++++----------
 5 files changed, 89 insertions(+), 66 deletions(-)

diff --git a/src/lib/evas/canvas/evas_main.c b/src/lib/evas/canvas/evas_main.c
index 5e7e6ee..1fa4d32 100644
--- a/src/lib/evas/canvas/evas_main.c
+++ b/src/lib/evas/canvas/evas_main.c
@@ -278,6 +278,8 @@ _evas_canvas_eo_base_destructor(Eo *eo_e, Evas_Public_Data 
*e)
 
    if (e->engine.func)
      {
+        e->engine.func->ector_destroy(e->engine.data.output,
+                                      e->engine.ector);
         e->engine.func->context_free(e->engine.data.output,
                                      e->engine.data.context);
         e->engine.func->output_free(e->engine.data.output);
@@ -693,4 +695,12 @@ _evas_canvas_evas_common_interface_evas_get(Eo *eo_e, 
Evas_Public_Data *e EINA_U
    return (Evas *)eo_e;
 }
 
+Ector_Surface *
+evas_ector_get(Evas_Public_Data *e)
+{
+   if (!e->engine.ector)
+     e->engine.ector = e->engine.func->ector_create(e->engine.data.output);
+   return e->engine.ector;
+}
+
 #include "canvas/evas_canvas.eo.c"
diff --git a/src/lib/evas/canvas/evas_object_vg.c 
b/src/lib/evas/canvas/evas_object_vg.c
index 628ade6..e50d787 100644
--- a/src/lib/evas/canvas/evas_object_vg.c
+++ b/src/lib/evas/canvas/evas_object_vg.c
@@ -194,7 +194,7 @@ evas_object_vg_render(Evas_Object *eo_obj EINA_UNUSED,
                       int x, int y, Eina_Bool do_async)
 {
    Evas_VG_Data *vd = type_private_data;
-
+   Ector_Surface *ector = evas_ector_get(obj->layer->evas);
    // FIXME: Set context (that should affect Ector_Surface) and
    // then call Ector_Renderer render from bottom to top. Get the
    // Ector_Surface that match the output from Evas engine API.
@@ -219,14 +219,15 @@ evas_object_vg_render(Evas_Object *eo_obj EINA_UNUSED,
                                                          obj->cur->anti_alias);
    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,
+   obj->layer->evas->engine.func->ector_begin(output, context,
+                                              ector, surface,
                                               obj->cur->geometry.x + x, 
obj->cur->geometry.y + y,
                                               do_async);
    _evas_vg_render(obj, vd,
                    output, context, surface,
                    vd->root, NULL,
                    do_async);
-   obj->layer->evas->engine.func->ector_end(output, context, surface, 
do_async);
+   obj->layer->evas->engine.func->ector_end(output, context, ector, surface, 
do_async);
 }
 
 static void
@@ -236,7 +237,6 @@ evas_object_vg_render_pre(Evas_Object *eo_obj,
 {
    Evas_VG_Data *vd = type_private_data;
    Efl_VG_Base_Data *rnd;
-   Evas_Public_Data *e = obj->layer->evas;
    int is_v, was_v;
    Ector_Surface *s;
 
@@ -258,17 +258,18 @@ evas_object_vg_render_pre(Evas_Object *eo_obj,
                                             obj->cur->clipper,
                                             obj->cur->clipper->private_data);
      }
+
+   // FIXME: handle damage only on changed renderer.
+   s = evas_ector_get(obj->layer->evas);
+   if (vd->root && s)
+     _evas_vg_render_pre(vd->root, s, NULL);
+
    /* now figure what changed and add draw rects */
    /* if it just became visible or invisible */
    is_v = evas_object_is_visible(eo_obj, obj);
    was_v = evas_object_was_visible(eo_obj,obj);
    if (!(is_v | was_v)) goto done;
 
-   // FIXME: handle damage only on changed renderer.
-   s = e->engine.func->ector_get(e->engine.data.output);
-   if (vd->root && s)
-     _evas_vg_render_pre(vd->root, s, NULL);
-
    // FIXME: for now the walking Evas_VG_Node tree doesn't trigger any damage
    // So just forcing it here if necessary
    rnd = eo_data_scope_get(vd->root, EFL_VG_BASE_CLASS);
diff --git a/src/lib/evas/include/evas_private.h 
b/src/lib/evas/include/evas_private.h
index e74ba01..e5d5889 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -784,7 +784,7 @@ struct _Evas_Public_Data
    struct {
       Evas_Module *module;
       Evas_Func *func;
-      Ector_Surface *surface;
+      Ector_Surface *ector;
       struct {
          void *output;
 
@@ -1437,10 +1437,11 @@ struct _Evas_Func
    void  (*texture_image_set)            (void *data, void *texture, void 
*image);
    void *(*texture_image_get)            (void *data, void *texture);
 
-   Ector_Surface *(*ector_get)           (void *data);
-   void  (*ector_begin)                  (void *data, void *context, void 
*surface, int x, int y, Eina_Bool do_async);
+   Ector_Surface *(*ector_create)        (void *data);
+   void  (*ector_destroy)                (void *data, Ector_Surface *surface);
+   void  (*ector_begin)                  (void *data, void *context, 
Ector_Surface *ector, 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);
+   void  (*ector_end)                    (void *data, void *context, 
Ector_Surface *ector, void *surface, Eina_Bool do_async);
 };
 
 struct _Evas_Image_Save_Func
@@ -1778,6 +1779,9 @@ void _evas_canvas3d_eet_file_free(void);
 void evas_filter_init(void);
 void evas_filter_shutdown(void);
 
+/* Ector */
+Ector_Surface *evas_ector_get(Evas_Public_Data *evas);
+
 /* Temporary save/load functions */
 void evas_common_load_model_from_file(Evas_Canvas3D_Mesh *model, const char 
*file);
 void evas_common_load_model_from_eina_file(Evas_Canvas3D_Mesh *model, const 
Eina_File *file);
diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c 
b/src/modules/evas/engines/gl_generic/evas_engine.c
index 44f0689..5d5603b 100644
--- a/src/modules/evas/engines/gl_generic/evas_engine.c
+++ b/src/modules/evas/engines/gl_generic/evas_engine.c
@@ -2370,29 +2370,31 @@ eng_texture_image_get(void *data EINA_UNUSED, void 
*texture)
    return e3d_texture_get((E3D_Texture *)texture);
 }
 
-static Ector_Surface *_software_ector = NULL;
 static Eina_Bool use_cairo;
 
 static Ector_Surface *
-eng_ector_get(void *data EINA_UNUSED)
+eng_ector_create(void *data EINA_UNUSED)
 {
-   if (!_software_ector)
+   Ector_Surface *ector;
+   const char *ector_backend;
+   ector_backend = getenv("ECTOR_BACKEND");
+   if (ector_backend && !strcasecmp(ector_backend, "default"))
      {
-        const char *ector_backend;
-
-        ector_backend = getenv("ECTOR_BACKEND");
-        if (ector_backend && !strcasecmp(ector_backend, "default"))
-          {
-             _software_ector = eo_add(ECTOR_SOFTWARE_SURFACE_CLASS, NULL);
-             use_cairo = EINA_FALSE;
-          }
-        else
-          {
-             _software_ector = eo_add(ECTOR_CAIRO_SOFTWARE_SURFACE_CLASS, 
NULL);
-             use_cairo = EINA_TRUE;
-          }
+        ector = eo_add(ECTOR_SOFTWARE_SURFACE_CLASS, NULL);
+        use_cairo = EINA_FALSE;
      }
-   return _software_ector;
+   else
+     {
+        ector = eo_add(ECTOR_CAIRO_SOFTWARE_SURFACE_CLASS, NULL);
+        use_cairo = EINA_TRUE;
+     }
+   return ector;
+}
+
+static void
+eng_ector_destroy(void *data EINA_UNUSED, Ector_Surface *ector)
+{
+   if (ector) eo_del(ector);
 }
 
 static Ector_Rop
@@ -2479,7 +2481,8 @@ eng_ector_renderer_draw(void *data, void *context, void 
*surface, Ector_Renderer
 static void *software_buffer = NULL;
 
 static void
-eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, void 
*surface, int x, int y, Eina_Bool do_async EINA_UNUSED)
+eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, 
Ector_Surface *ector,
+                void *surface, int x, int y, Eina_Bool do_async EINA_UNUSED)
 {
    Evas_Engine_GL_Context *gl_context;
    Render_Engine_GL_Generic *re = data;
@@ -2496,20 +2499,21 @@ eng_ector_begin(void *data EINA_UNUSED, void *context 
EINA_UNUSED, void *surface
    memset(software_buffer, 0, sizeof (unsigned int) * w * h);
    if (use_cairo)
      {
-        eo_do(_software_ector,
+        eo_do(ector,
               ector_cairo_software_surface_set(software_buffer, w, h),
               ector_surface_reference_point_set(x, y));
      }
    else
      {
-        eo_do(_software_ector,
+        eo_do(ector,
               ector_software_surface_set(software_buffer, w, h),
               ector_surface_reference_point_set(x, y));
      }
 }
 
 static void
-eng_ector_end(void *data, void *context EINA_UNUSED, void *surface 
EINA_UNUSED, Eina_Bool do_async EINA_UNUSED)
+eng_ector_end(void *data, void *context EINA_UNUSED, Ector_Surface *ector,
+              void *surface EINA_UNUSED, Eina_Bool do_async EINA_UNUSED)
 {
    Evas_Engine_GL_Context *gl_context;
    Render_Engine_GL_Generic *re = data;
@@ -2523,12 +2527,12 @@ eng_ector_end(void *data, void *context EINA_UNUSED, 
void *surface EINA_UNUSED,
 
    if (use_cairo)
      {
-        eo_do(_software_ector,
+        eo_do(ector,
               ector_cairo_software_surface_set(NULL, 0, 0));
      }
    else
      {
-        eo_do(_software_ector,
+        eo_do(ector,
               ector_software_surface_set(NULL, 0, 0));
      }
 
@@ -2697,7 +2701,8 @@ module_open(Evas_Module *em)
    ORD(texture_image_set);
    ORD(texture_image_get);
 
-   ORD(ector_get);
+   ORD(ector_create);
+   ORD(ector_destroy);
    ORD(ector_begin);
    ORD(ector_renderer_draw);
    ORD(ector_end);
diff --git a/src/modules/evas/engines/software_generic/evas_engine.c 
b/src/modules/evas/engines/software_generic/evas_engine.c
index 3df3aaf..4b221dd 100644
--- a/src/modules/evas/engines/software_generic/evas_engine.c
+++ b/src/modules/evas/engines/software_generic/evas_engine.c
@@ -402,6 +402,7 @@ struct _Evas_Thread_Command_Ector
 
 struct _Evas_Thread_Command_Ector_Surface
 {
+   Ector_Surface *ector;
    void *surface;
    int x, y;
 };
@@ -3519,29 +3520,31 @@ eng_output_idle_flush(void *data)
    if (re->outbuf_idle_flush) re->outbuf_idle_flush(re->ob);
 }
 
-static Ector_Surface *_software_ector = NULL;
 static Eina_Bool use_cairo;
 
 static Ector_Surface *
-eng_ector_get(void *data EINA_UNUSED)
+eng_ector_create(void *data EINA_UNUSED)
 {
-   if (!_software_ector)
+   Ector_Surface *ector;
+   const char *ector_backend;
+   ector_backend = getenv("ECTOR_BACKEND");
+   if (ector_backend && !strcasecmp(ector_backend, "default"))
      {
-        const char *ector_backend;
-
-        ector_backend = getenv("ECTOR_BACKEND");
-        if (ector_backend && !strcasecmp(ector_backend, "default"))
-          {
-             _software_ector = eo_add(ECTOR_SOFTWARE_SURFACE_CLASS, NULL);
-             use_cairo = EINA_FALSE;
-          }
-        else
-          {
-             _software_ector = eo_add(ECTOR_CAIRO_SOFTWARE_SURFACE_CLASS, 
NULL);
-             use_cairo = EINA_TRUE;
-          }
+        ector = eo_add(ECTOR_SOFTWARE_SURFACE_CLASS, NULL);
+        use_cairo = EINA_FALSE;
+     }
+   else
+     {
+        ector = eo_add(ECTOR_CAIRO_SOFTWARE_SURFACE_CLASS, NULL);
+        use_cairo = EINA_TRUE;
      }
-   return _software_ector;
+   return ector;
+}
+
+static void
+eng_ector_destroy(void *data EINA_UNUSED, Ector_Surface *ector)
+{
+   if (ector) eo_del(ector);
 }
 
 static Ector_Rop
@@ -3695,13 +3698,13 @@ _draw_thread_ector_surface_set(void *data)
 
    if (use_cairo)
      {
-        eo_do(_software_ector,
+        eo_do(ector_surface->ector,
               ector_cairo_software_surface_set(pixels, w, h),
               ector_surface_reference_point_set(x, y));
      }
    else
      {
-        eo_do(_software_ector,
+        eo_do(ector_surface->ector,
               ector_software_surface_set(pixels, w, h),
               ector_surface_reference_point_set(x, y));
      }
@@ -3710,7 +3713,7 @@ _draw_thread_ector_surface_set(void *data)
 }
 
 static void
-eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, void 
*surface, int x, int y, Eina_Bool do_async)
+eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, 
Ector_Surface *ector, void *surface, int x, int y, Eina_Bool do_async)
 {
    if (do_async)
      {
@@ -3719,6 +3722,7 @@ eng_ector_begin(void *data EINA_UNUSED, void *context 
EINA_UNUSED, void *surface
         nes = eina_mempool_malloc(_mp_command_ector_surface, sizeof 
(Evas_Thread_Command_Ector_Surface));
         if (!nes) return ;
 
+        nes->ector = ector;
         nes->surface = surface;
         nes->x = x;
         nes->y = y;
@@ -3738,13 +3742,13 @@ eng_ector_begin(void *data EINA_UNUSED, void *context 
EINA_UNUSED, void *surface
 
         if (use_cairo)
           {
-             eo_do(_software_ector,
+             eo_do(ector,
                    ector_cairo_software_surface_set(pixels, w, h),
                    ector_surface_reference_point_set(x, y));
           }
         else
           {
-             eo_do(_software_ector,
+             eo_do(ector,
                    ector_software_surface_set(pixels, w, h),
                    ector_surface_reference_point_set(x, y));
           }
@@ -3752,7 +3756,7 @@ eng_ector_begin(void *data EINA_UNUSED, void *context 
EINA_UNUSED, void *surface
 }
 
 static void
-eng_ector_end(void *data EINA_UNUSED, void *context EINA_UNUSED, void *surface 
EINA_UNUSED, Eina_Bool do_async)
+eng_ector_end(void *data EINA_UNUSED, void *context EINA_UNUSED, Ector_Surface 
*ector, void *surface EINA_UNUSED, Eina_Bool do_async)
 {
    if (do_async)
      {
@@ -3761,6 +3765,7 @@ eng_ector_end(void *data EINA_UNUSED, void *context 
EINA_UNUSED, void *surface E
         nes = eina_mempool_malloc(_mp_command_ector_surface, sizeof 
(Evas_Thread_Command_Ector_Surface));
         if (!nes) return ;
 
+        nes->ector = ector;
         nes->surface = NULL;
 
         evas_thread_cmd_enqueue(_draw_thread_ector_surface_set, nes);
@@ -3769,12 +3774,12 @@ eng_ector_end(void *data EINA_UNUSED, void *context 
EINA_UNUSED, void *surface E
      {
         if (use_cairo)
           {
-             eo_do(_software_ector,
+             eo_do(ector,
                    ector_cairo_software_surface_set(NULL, 0, 0));
           }
         else
           {
-             eo_do(_software_ector,
+             eo_do(ector,
                    ector_software_surface_set(NULL, 0, 0));
           }
 
@@ -3964,7 +3969,8 @@ static Evas_Func func =
      NULL, // eng_texture_filter_get
      NULL, // eng_texture_image_set
      NULL, // eng_texture_image_get
-     eng_ector_get,
+     eng_ector_create,
+     eng_ector_destroy,
      eng_ector_begin,
      eng_ector_renderer_draw,
      eng_ector_end
@@ -5063,9 +5069,6 @@ Eina_Bool evas_engine_software_generic_init(void)
 // Time to destroy the ector context
 void evas_engine_software_generic_shutdown(void)
 {
-   if (_software_ector) eo_del(_software_ector);
-   _software_ector = NULL;
-
    evas_module_unregister(&evas_modapi, EVAS_MODULE_TYPE_ENGINE);
 }
 

-- 


Reply via email to