From 777f82555f7f7f035522cdfdee96164911c8c20c Mon Sep 17 00:00:00 2001 From: Joogab Yun Date: Tue, 22 Aug 2017 16:08:22 +0900 Subject: [PATCH] [evas_gl] evas : save the orient value when doing image_data_get() 1. evas_object_orient_set(image1, 90) 2. buffer = evas_object_image_data_get(image1); 3. evas_object_image_data_set(image2, buffer); we need an orient value of image1 for image2, so we keep orient value of image1 at image_data_get() Change-Id: I9daab94ba9de55690bf70bf8172b0593af21a3de --- .../engines/gl_generic/Evas_Engine_GL_Generic.h | 6 +++ src/modules/evas/engines/gl_generic/evas_engine.c | 48 +++++++++++++++++++++- .../Evas_Engine_Software_Generic.h | 5 +++ 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/src/modules/evas/engines/gl_generic/Evas_Engine_GL_Generic.h b/src/modules/evas/engines/gl_generic/Evas_Engine_GL_Generic.h index e5743ee..b8388a25 100644 --- a/src/modules/evas/engines/gl_generic/Evas_Engine_GL_Generic.h +++ b/src/modules/evas/engines/gl_generic/Evas_Engine_GL_Generic.h @@ -8,6 +8,7 @@ typedef struct _Render_Engine_GL_Generic Render_Engine_GL_Generic; typedef struct _Context_3D Context_3D; +typedef struct _Evas_Object_Image_Data_Entry Evas_Object_Image_Data_Entry; typedef void (*Window_Use)(Outbuf *ob); typedef Evas_Engine_GL_Context *(*Window_GL_Context_Get)(Outbuf *ob); @@ -38,6 +39,11 @@ struct _Render_Engine_GL_Generic Eina_Bool evgl_initted : 1; }; +struct _Evas_Object_Image_Data_Entry +{ + Evas_Image_Orient orient; +}; + static inline Eina_Bool evas_render_engine_gl_generic_init(Render_Engine_GL_Generic *re, Outbuf *ob, diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c index b991700..03c7bbb 100644 --- a/src/modules/evas/engines/gl_generic/evas_engine.c +++ b/src/modules/evas/engines/gl_generic/evas_engine.c @@ -688,12 +688,20 @@ _rotate_image_data(Render_Engine_GL_Generic *re, Evas_GL_Image *im1) return im2; } +static void +_image_data_entry_del_cb(void *data) +{ + Evas_Object_Image_Data_Entry *data_entry = data; + if (data_entry) free(data_entry); +} + static void * eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, int *err, Eina_Bool *tofree) { Render_Engine_GL_Generic *re = data; Evas_GL_Image *im_new = NULL; Evas_GL_Image *im = image; + Evas_Object_Image_Data_Entry *data_entry = NULL; int error; *image_data = NULL; @@ -712,6 +720,9 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, i if ((tofree != NULL) && im->im && (im->orient != EVAS_IMAGE_ORIENT_NONE)) goto rotate_image; + if (!re->software.image_entry_hash && im->orient != EVAS_IMAGE_ORIENT_NONE) + re->software.image_entry_hash = eina_hash_pointer_new(_image_data_entry_del_cb); + #ifdef GL_GLES re->window_use(re->software.ob); @@ -865,12 +876,25 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, i if (err) *err = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED; return NULL; } + im_new->orient = im->orient; evas_gl_common_image_free(im); im = im_new; } else evas_gl_common_image_dirty(im, 0, 0, 0, 0); } + + if (re->software.image_entry_hash) + { + data_entry = calloc(1, sizeof(Evas_Object_Image_Data_Entry)); + if (data_entry) + { + data_entry->orient = im->orient; + Evas_Object_Image_Data_Entry *old_entry = eina_hash_set(re->software.image_entry_hash, im->im->image.data, data_entry); + if (old_entry) free(old_entry); + } + } + *image_data = im->im->image.data; break; case EVAS_COLORSPACE_YCBCR422P601_PL: @@ -961,10 +985,32 @@ eng_image_data_put(void *data, void *image, DATA32 *image_data) case EVAS_COLORSPACE_ARGB8888: if ((!im->im) || (image_data != im->im->image.data)) { - im2 = eng_image_new_from_data(data, im->w, im->h, image_data, + Evas_Object_Image_Data_Entry *data_entry = NULL; + int width, height; + width = im->w; + height = im->h; + if (re->software.image_entry_hash) + { + data_entry = eina_hash_find(re->software.image_entry_hash, image_data); + if (data_entry) + { + if (data_entry->orient == EVAS_IMAGE_ORIENT_90 || + data_entry->orient == EVAS_IMAGE_ORIENT_270 || + data_entry->orient == EVAS_IMAGE_FLIP_TRANSPOSE || + data_entry->orient == EVAS_IMAGE_FLIP_TRANSVERSE) + { + width = im->h; + height = im->w; + } + } + } + + im2 = eng_image_new_from_data(data, width, height, image_data, eng_image_alpha_get(data, image), eng_image_colorspace_get(data, image)); if (!im2) return im; + if (data_entry) + im2->orient = data_entry->orient; evas_gl_common_image_free(im); im = im2; } diff --git a/src/modules/evas/engines/software_generic/Evas_Engine_Software_Generic.h b/src/modules/evas/engines/software_generic/Evas_Engine_Software_Generic.h index 179dae7..15ce97c 100644 --- a/src/modules/evas/engines/software_generic/Evas_Engine_Software_Generic.h +++ b/src/modules/evas/engines/software_generic/Evas_Engine_Software_Generic.h @@ -81,6 +81,8 @@ struct _Render_Engine_Software_Generic unsigned char end : 1; unsigned char lost_back : 1; unsigned char tile_strict : 1; + + Eina_Hash *image_entry_hash; }; static inline Eina_Bool @@ -146,6 +148,9 @@ evas_render_engine_software_generic_clean(Render_Engine_Software_Generic *re) if (re->rects_prev[2]) evas_common_tilebuf_free_render_rects(re->rects_prev[2]); if (re->rects_prev[3]) evas_common_tilebuf_free_render_rects(re->rects_prev[3]); + if (re->image_entry_hash) eina_hash_free(re->image_entry_hash); + + memset(re, 0, sizeof (Render_Engine_Software_Generic)); } -- 2.7.4