summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2016-05-05 10:45:04 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2016-05-05 10:49:31 -0400
commit0231800b60c7bab5162db8c04b815b884ecd36ab (patch)
tree12176b9c759f293fcb10b3f56bf46f813f4fcaf4
parentbdfbd4a4e1e40f6e58f5f1f559418a59766041f8 (diff)
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
-rw-r--r--src/lib/evas/canvas/evas_main.c112
-rw-r--r--src/lib/evas/include/evas_private.h2
2 files changed, 114 insertions, 0 deletions
diff --git a/src/lib/evas/canvas/evas_main.c b/src/lib/evas/canvas/evas_main.c
index 87061b6be2..2f7fd0c8aa 100644
--- a/src/lib/evas/canvas/evas_main.c
+++ b/src/lib/evas/canvas/evas_main.c
@@ -5,6 +5,10 @@
5#include "evas_cs2_private.h" 5#include "evas_cs2_private.h"
6#endif 6#endif
7 7
8#include "evas_image_private.h"
9#include "evas_polygon_private.h"
10#include "evas_vg_private.h"
11
8#define MY_CLASS EVAS_CANVAS_CLASS 12#define MY_CLASS EVAS_CANVAS_CLASS
9 13
10#ifdef LKDEBUG 14#ifdef LKDEBUG
@@ -711,4 +715,112 @@ evas_language_reinit(void)
711 evas_common_language_reinit(); 715 evas_common_language_reinit();
712} 716}
713 717
718static void
719_image_data_unset(Evas_Object_Protected_Data *obj, Eina_List **list)
720{
721 if (obj->is_smart)
722 {
723 Evas_Object_Protected_Data *obj2;
724
725 EINA_INLIST_FOREACH(evas_object_smart_members_get_direct(obj->object), obj2)
726 _image_data_unset(obj2, list);
727 return;
728 }
729#define CHECK(TYPE, STRUCT, FREE) \
730 if (eo_isa(obj->object, TYPE))\
731 {\
732 STRUCT *data = eo_data_scope_get(obj->object, TYPE);\
733 FREE; \
734 data->engine_data = NULL;\
735 }
736 CHECK(EVAS_IMAGE_CLASS, Evas_Image_Data,
737 ENFN->image_free(ENDT, data->engine_data))
738 else CHECK(EFL_CANVAS_IMAGE_CLASS, Evas_Image_Data,
739 ENFN->image_free(ENDT, data->engine_data))
740 else CHECK(EFL_CANVAS_SCENE3D_CLASS, Evas_Image_Data,
741 ENFN->image_free(ENDT, data->engine_data))
742 else CHECK(EVAS_VG_CLASS, Evas_VG_Data,
743 obj->layer->evas->engine.func->ector_free(data->engine_data))
744 else CHECK(EFL_CANVAS_POLYGON_CLASS, Efl_Canvas_Polygon_Data,
745 data->engine_data =
746 obj->layer->evas->engine.func->polygon_points_clear(obj->layer->evas->engine.data.output,
747 obj->layer->evas->engine.data.context,
748 data->engine_data))
749 else CHECK(EVAS_CANVAS3D_TEXTURE_CLASS, Evas_Canvas3D_Texture_Data,
750 if (obj->layer->evas->engine.func->texture_free)
751 obj->layer->evas->engine.func->texture_free(obj->layer->evas->engine.data.output, data->engine_data))
752 else return;
753#undef CHECK
754 evas_object_ref(obj->object);
755 *list = eina_list_append(*list, obj->object);
756}
757
758EAPI Eina_List *
759_evas_canvas_image_data_unset(Evas *eo_e)
760{
761 Evas_Public_Data *e = eo_data_scope_get(eo_e, MY_CLASS);
762 Evas_Layer *lay;
763 Eina_List *list = NULL;
764
765 EINA_INLIST_FOREACH(e->layers, lay)
766 {
767 Evas_Object_Protected_Data *o;
768 EINA_INLIST_FOREACH(lay->objects, o)
769 {
770 if (!o->delete_me)
771 _image_data_unset(o, &list);
772 }
773 }
774 return list;
775}
776
777static void
778_image_image_data_regenerate(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *data)
779{
780 unsigned int orient = data->cur->orient;
781
782 _evas_image_load(eo_obj, obj, data);
783 EINA_COW_IMAGE_STATE_WRITE_BEGIN(data, state_write)
784 {
785 state_write->has_alpha = !state_write->has_alpha;
786 state_write->orient = -1;
787 }
788 EINA_COW_IMAGE_STATE_WRITE_END(data, state_write);
789 evas_object_image_alpha_set(eo_obj, !data->cur->has_alpha);
790 _evas_image_orientation_set(eo_obj, data, orient);
791}
792
793static void
794_image_data_regenerate(Evas_Object *eo_obj)
795{
796 Evas_Object_Protected_Data *obj;
797
798 obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
799 evas_object_change(eo_obj, obj);
800#define CHECK(TYPE, STRUCT, REGEN) \
801 if (eo_isa(eo_obj, TYPE))\
802 {\
803 STRUCT *data = eo_data_scope_get(eo_obj, TYPE);\
804 REGEN; \
805 }
806 CHECK(EVAS_IMAGE_CLASS, Evas_Image_Data, _image_image_data_regenerate(eo_obj, obj, data))
807 else CHECK(EFL_CANVAS_IMAGE_CLASS, Evas_Image_Data, _image_image_data_regenerate(eo_obj, obj, data))
808 else CHECK(EFL_CANVAS_SCENE3D_CLASS, Evas_Image_Data, _image_image_data_regenerate(eo_obj, obj, data))
809 //else CHECK(EVAS_VG_CLASS, Evas_VG_Data,)
810 //else CHECK(EFL_CANVAS_POLYGON_CLASS, Efl_Canvas_Polygon_Data,)
811 //else CHECK(EVAS_CANVAS3D_TEXTURE_CLASS, Evas_Canvas3D_Texture_Data,
812}
813
814EAPI void
815_evas_canvas_image_data_regenerate(Eina_List *list)
816{
817 Evas_Object *eo_obj;
818
819 EINA_LIST_FREE(list, eo_obj)
820 {
821 _image_data_regenerate(eo_obj);
822 evas_object_unref(eo_obj);
823 }
824}
825
714#include "canvas/evas_canvas.eo.c" 826#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 438bfb8b1a..b8d5f9c1a2 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);
1914EAPI int _evas_module_engine_inherit(Evas_Func *funcs, char *name); 1914EAPI int _evas_module_engine_inherit(Evas_Func *funcs, char *name);
1915EAPI const char *_evas_module_libdir_get(void); 1915EAPI const char *_evas_module_libdir_get(void);
1916const char *_evas_module_datadir_get(void); 1916const char *_evas_module_datadir_get(void);
1917EAPI Eina_List *_evas_canvas_image_data_unset(Evas *eo_e);
1918EAPI void _evas_canvas_image_data_regenerate(Eina_List *list);
1917 1919
1918Eina_Bool evas_render_mapped(Evas_Public_Data *e, Evas_Object *obj, 1920Eina_Bool evas_render_mapped(Evas_Public_Data *e, Evas_Object *obj,
1919 Evas_Object_Protected_Data *source_pd, 1921 Evas_Object_Protected_Data *source_pd,