Evas GL: Fix crash with dynamic hint set using tbm surface
authorJoogab Yun <joogab.yun@samsung.com>
Wed, 11 Nov 2015 05:29:55 +0000 (14:29 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Wed, 11 Nov 2015 05:38:07 +0000 (14:38 +0900)
Summary:
if device support sec_tbm_surface, but doesn't support the EGL_NATIVE_SURFACE_TIZEN
then below api called cause crash!
evas_object_image_content_hint_set(o, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
evas_object_image_alpha_set(o, 0);

1. evas_object_image_content_hint_set(o, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);

 [evas_gl_image.c]
        if (im->im)
          {
             if (evas_cache2_image_cached(&im->im->cache_entry))
               evas_cache2_image_close(&im->im->cache_entry);
             else
               evas_cache_image_drop(&im->im->cache_entry);
             im->im = NULL;  // im->im now NULL!!!
          }

        im->tex = evas_gl_common_texture_dynamic_new(im->gc, im); // im->tex also NULL!!

im->text also NULL!! because If driver does not support the EGL_NATIVE_SURFACE_TIZEN
then below code return NULL at _pool_tex_dynamic_new();

  pt->dyn.img = secsym_eglCreateImage(egldisplay,
                                      EGL_NO_CONTEXT,
                                      EGL_NATIVE_SURFACE_TIZEN,
                                      pt->dyn.buffer, attr);

2. evas_object_image_alpha_set(o, 0);

 [gl_generic/evas_engine.c]
static void * eng_image_alpha_set()
{
  now im->im and im->tex are null so crash happend at eng_image_alpha_set()
}

bug fixed in case of the tbm surface create fails so device cannot support the dynamic hit set,

Test Plan: experdite

Reviewers: jpeg, cedric, spacegrapher

Subscribers: dkdk, scholb.kim, wonsik

Differential Revision: https://phab.enlightenment.org/D3318

src/modules/evas/engines/gl_common/evas_gl_image.c

index 2d8d936..6646a29 100644 (file)
@@ -622,6 +622,10 @@ evas_gl_common_image_content_hint_set(Evas_GL_Image *im, int hint)
      }
    if (im->content_hint == EVAS_IMAGE_CONTENT_HINT_DYNAMIC)
      {
+        Evas_GL_Texture *tex;
+        tex = evas_gl_common_texture_dynamic_new(im->gc, im);
+        if (!tex) return;
+
         if (im->cs.data)
           {
              if (!im->cs.no_free) free(im->cs.data);
@@ -650,7 +654,7 @@ evas_gl_common_image_content_hint_set(Evas_GL_Image *im, int hint)
              evas_gl_common_texture_free(im->tex, EINA_TRUE);
              im->tex = NULL;
           }
-        im->tex = evas_gl_common_texture_dynamic_new(im->gc, im);
+        im->tex = tex;
         im->tex_only = 1;
      }
    else