discomfitor pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=0231800b60c7bab5162db8c04b815b884ecd36ab

commit 0231800b60c7bab5162db8c04b815b884ecd36ab
Author: Mike Blumenkrantz <zm...@osg.samsung.com>
Date:   Thu May 5 10:45:04 2016 -0400

    evas: add internal functions for unsetting+regenerating image data
    
    in the event that the global gl context changes, all engine image data
    must be destroyed and then re-created in order to continue rendering
    successfully
---
 src/lib/evas/canvas/evas_main.c     | 112 ++++++++++++++++++++++++++++++++++++
 src/lib/evas/include/evas_private.h |   2 +
 2 files changed, 114 insertions(+)

diff --git a/src/lib/evas/canvas/evas_main.c b/src/lib/evas/canvas/evas_main.c
index 87061b6..2f7fd0c 100644
--- a/src/lib/evas/canvas/evas_main.c
+++ b/src/lib/evas/canvas/evas_main.c
@@ -5,6 +5,10 @@
 #include "evas_cs2_private.h"
 #endif
 
+#include "evas_image_private.h"
+#include "evas_polygon_private.h"
+#include "evas_vg_private.h"
+
 #define MY_CLASS EVAS_CANVAS_CLASS
 
 #ifdef LKDEBUG
@@ -711,4 +715,112 @@ evas_language_reinit(void)
    evas_common_language_reinit();
 }
 
+static void
+_image_data_unset(Evas_Object_Protected_Data *obj, Eina_List **list)
+{
+   if (obj->is_smart)
+     {
+        Evas_Object_Protected_Data *obj2;
+
+        EINA_INLIST_FOREACH(evas_object_smart_members_get_direct(obj->object), 
obj2)
+          _image_data_unset(obj2, list);
+        return;
+     }
+#define CHECK(TYPE, STRUCT, FREE) \
+   if (eo_isa(obj->object, TYPE))\
+     {\
+        STRUCT *data = eo_data_scope_get(obj->object, TYPE);\
+        FREE; \
+        data->engine_data = NULL;\
+     }
+   CHECK(EVAS_IMAGE_CLASS, Evas_Image_Data,
+         ENFN->image_free(ENDT, data->engine_data))
+   else CHECK(EFL_CANVAS_IMAGE_CLASS, Evas_Image_Data,
+         ENFN->image_free(ENDT, data->engine_data))
+   else CHECK(EFL_CANVAS_SCENE3D_CLASS, Evas_Image_Data,
+         ENFN->image_free(ENDT, data->engine_data))
+   else CHECK(EVAS_VG_CLASS, Evas_VG_Data,
+        obj->layer->evas->engine.func->ector_free(data->engine_data))
+   else CHECK(EFL_CANVAS_POLYGON_CLASS, Efl_Canvas_Polygon_Data,
+        data->engine_data =
+          
obj->layer->evas->engine.func->polygon_points_clear(obj->layer->evas->engine.data.output,
+                                                              
obj->layer->evas->engine.data.context,
+                                                              
data->engine_data))
+   else CHECK(EVAS_CANVAS3D_TEXTURE_CLASS, Evas_Canvas3D_Texture_Data,
+        if (obj->layer->evas->engine.func->texture_free)
+          
obj->layer->evas->engine.func->texture_free(obj->layer->evas->engine.data.output,
 data->engine_data))
+   else return;
+#undef CHECK
+   evas_object_ref(obj->object);
+   *list = eina_list_append(*list, obj->object);
+}
+
+EAPI Eina_List *
+_evas_canvas_image_data_unset(Evas *eo_e)
+{
+   Evas_Public_Data *e = eo_data_scope_get(eo_e, MY_CLASS);
+   Evas_Layer *lay;
+   Eina_List *list = NULL;
+
+   EINA_INLIST_FOREACH(e->layers, lay)
+     {
+        Evas_Object_Protected_Data *o;
+        EINA_INLIST_FOREACH(lay->objects, o)
+          {
+             if (!o->delete_me)
+               _image_data_unset(o, &list);
+          }
+     }
+   return list;
+}
+
+static void
+_image_image_data_regenerate(Evas_Object *eo_obj, Evas_Object_Protected_Data 
*obj, Evas_Image_Data *data)
+{
+   unsigned int orient = data->cur->orient;
+
+   _evas_image_load(eo_obj, obj, data);
+   EINA_COW_IMAGE_STATE_WRITE_BEGIN(data, state_write)
+     {
+        state_write->has_alpha = !state_write->has_alpha;
+        state_write->orient = -1;
+     }
+   EINA_COW_IMAGE_STATE_WRITE_END(data, state_write);
+   evas_object_image_alpha_set(eo_obj, !data->cur->has_alpha);
+   _evas_image_orientation_set(eo_obj, data, orient);
+}
+
+static void
+_image_data_regenerate(Evas_Object *eo_obj)
+{
+   Evas_Object_Protected_Data *obj;
+
+   obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
+   evas_object_change(eo_obj, obj);
+#define CHECK(TYPE, STRUCT, REGEN) \
+   if (eo_isa(eo_obj, TYPE))\
+     {\
+        STRUCT *data = eo_data_scope_get(eo_obj, TYPE);\
+        REGEN; \
+     }
+   CHECK(EVAS_IMAGE_CLASS, Evas_Image_Data, 
_image_image_data_regenerate(eo_obj, obj, data))
+   else CHECK(EFL_CANVAS_IMAGE_CLASS, Evas_Image_Data, 
_image_image_data_regenerate(eo_obj, obj, data))
+   else CHECK(EFL_CANVAS_SCENE3D_CLASS, Evas_Image_Data, 
_image_image_data_regenerate(eo_obj, obj, data))
+   //else CHECK(EVAS_VG_CLASS, Evas_VG_Data,)
+   //else CHECK(EFL_CANVAS_POLYGON_CLASS, Efl_Canvas_Polygon_Data,)
+   //else CHECK(EVAS_CANVAS3D_TEXTURE_CLASS, Evas_Canvas3D_Texture_Data,
+}
+
+EAPI void
+_evas_canvas_image_data_regenerate(Eina_List *list)
+{
+   Evas_Object *eo_obj;
+
+   EINA_LIST_FREE(list, eo_obj)
+     {
+        _image_data_regenerate(eo_obj);
+        evas_object_unref(eo_obj);
+     }
+}
+
 #include "canvas/evas_canvas.eo.c"
diff --git a/src/lib/evas/include/evas_private.h 
b/src/lib/evas/include/evas_private.h
index 438bfb8..b8d5f9c 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -1914,6 +1914,8 @@ void _evas_unwalk(Evas_Public_Data *e_pd);
 EAPI int _evas_module_engine_inherit(Evas_Func *funcs, char *name);
 EAPI const char *_evas_module_libdir_get(void);
 const char *_evas_module_datadir_get(void);
+EAPI Eina_List *_evas_canvas_image_data_unset(Evas *eo_e);
+EAPI void _evas_canvas_image_data_regenerate(Eina_List *list);
 
 Eina_Bool evas_render_mapped(Evas_Public_Data *e, Evas_Object *obj,
                              Evas_Object_Protected_Data *source_pd,

-- 


Reply via email to