[evas_gl] The orient set behavior was different between gl-backend and 74/136174/2
authorJoogab Yun <joogab.yun@samsung.com>
Tue, 27 Jun 2017 09:36:38 +0000 (18:36 +0900)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Thu, 29 Jun 2017 00:36:14 +0000 (00:36 +0000)
sw-backend.
 - Gl-backend is the rotation relative to the previous orientation
 - SW-backend is the rotation relative to the first orientation
 changes the behavior based on sw-backend

Change-Id: I050ef5dde7e1447a9ea06eada4cf07adfc4ded0c

src/modules/evas/engines/gl_common/evas_gl_common.h
src/modules/evas/engines/gl_generic/evas_engine.c

index 15d8a08..45c45fd 100644 (file)
@@ -475,7 +475,6 @@ struct _Evas_GL_Image
    unsigned char    direct : 1; // evas gl direct renderable
    /*Disable generate atlas for texture unit, EINA_FALSE by default*/
    Eina_Bool        disable_atlas : 1;
-   Eina_Bool rotated : 1; // check eng_image_orient_set() called
 };
 
 struct _Evas_GL_Font_Texture
index 90b9c26..6d9f8cc 100644 (file)
@@ -709,19 +709,8 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, i
    if (im->native.data)
      return im;
 
-   if (im->im && im->rotated)
-     {
-        im_new = _rotate_image_data(data, image);
-        if (!im_new)
-          {
-             if (err) *err = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
-             return im;
-          }
-
-        *image_data = im_new->im->image.data;
-        if (tofree) *tofree = EINA_TRUE;
-        return im_new;
-     }
+   if ((tofree != NULL) && im->im && (im->orient != EVAS_IMAGE_ORIENT_NONE))
+     goto rotate_image;
 
 #ifdef GL_GLES
    re->window_use(re->software.ob);
@@ -833,11 +822,15 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, i
 
    if (!im->im)
      {
-        // FIXME: Should we create an FBO and draw the texture there, to then read it back?
+        if (tofree)
+          goto rotate_image;
+        else
+          {
         ERR("GL image has no source data, failed to get pixel data");
         if (err) *err = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
         return NULL;
      }
+     }
 
 #ifdef EVAS_CSERVE2
    if (evas_cserve2_use_get() && evas_cache2_image_cached(&im->im->cache_entry))
@@ -845,6 +838,13 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, i
    else
 #endif
      error = evas_cache_image_load_data(&im->im->cache_entry);
+
+   if (error != EVAS_LOAD_ERROR_NONE)
+     {
+        if (tofree)
+          goto rotate_image;
+     }
+
    evas_gl_common_image_alloc_ensure(im);
    switch (im->cs.space)
      {
@@ -893,6 +893,19 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, i
      }
    if (err) *err = error;
    return im;
+
+rotate_image:
+   // rotate data for image save
+   im_new = _rotate_image_data(data, image);
+   if (!im_new)
+     {
+        if (err) *err = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
+        ERR("Image rotation failed.");
+        return im;
+     }
+   *tofree = EINA_TRUE;
+   *image_data = im_new->im->image.data;
+   return im_new;
 }
 
 static void *
@@ -1022,7 +1035,6 @@ eng_image_orient_set(void *data, void *image, Evas_Image_Orient orient)
    im_new->cached = EINA_FALSE;
 
    im_new->orient = orient;
-   im_new->rotated = EINA_TRUE;
 
    evas_gl_common_image_free(im);
    return im_new;