YaGL: Fix incorrect texture object release 29/45329/1
authorVasiliy Ulyanov <v.ulyanov@samsung.com>
Mon, 1 Jun 2015 06:54:06 +0000 (09:54 +0300)
committerjinhyung.jo <jinhyung.jo@samsung.com>
Tue, 4 Aug 2015 08:27:13 +0000 (17:27 +0900)
EGL_KHR_gl_texture_2D_image: texture object is acquired in
yagl_gles_image_wrap_tex(...). Hence the release should be performed
in the corresponding destructor (i.e. yagl_gles_image_destroy(...)).

Change-Id: I92aaf0a4368201453e022859f4c52cdeb103af06
Signed-off-by: Vasiliy Ulyanov <v.ulyanov@samsung.com>
EGL/yagl_onscreen_image_gl_texture_2d.c
EGL/yagl_onscreen_image_gl_texture_2d.h
GLES_common/yagl_gles_image.c
GLES_common/yagl_gles_image.h
GLESv1_CM/yagl_gles1_interface.c
GLESv2/yagl_gles2_interface.c
include/yagl_client_interface.h

index ede3b1c22118912efbeb865654d637202a4cb753..340b5f1aacd7b6af40ed53679044e1d6278be818 100644 (file)
@@ -46,8 +46,6 @@ static void yagl_onscreen_image_gl_texture_2d_destroy(struct yagl_ref *ref)
 {
     struct yagl_onscreen_image_gl_texture_2d *image = (struct yagl_onscreen_image_gl_texture_2d *)ref;
 
-    yagl_object_release(image->texture_obj);
-
     yagl_image_cleanup(&image->base);
 
     yagl_free(image);
@@ -62,14 +60,12 @@ struct yagl_onscreen_image_gl_texture_2d
 {
     struct yagl_client_image *client_image;
     struct yagl_onscreen_image_gl_texture_2d *image;
-    struct yagl_object *texture_obj = NULL;
 
     image = yagl_malloc0(sizeof(*image));
 
     client_image = iface->wrap_texture(iface,
                                        ctx->client_ctx,
-                                       texture,
-                                       &texture_obj);
+                                       texture);
 
     if (!client_image) {
         yagl_set_error(EGL_BAD_PARAMETER);
@@ -86,15 +82,9 @@ struct yagl_onscreen_image_gl_texture_2d
 
     image->base.update = &yagl_onscreen_image_gl_texture_2d_update;
 
-    image->texture_obj = texture_obj;
-
     return image;
 
 fail:
-    if (texture_obj) {
-        yagl_object_release(texture_obj);
-    }
-
     yagl_free(image);
 
     return NULL;
index 16b12450d31f55565ca168aa90c64f5174f40063..6e43b37d5b74094f2de5bd178da2c09022532561 100644 (file)
@@ -43,8 +43,6 @@ struct yagl_client_interface;
 struct yagl_onscreen_image_gl_texture_2d
 {
     struct yagl_image base;
-
-    struct yagl_object *texture_obj;
 };
 
 struct yagl_onscreen_image_gl_texture_2d
index ffb95a6f7e9453161b2c38e05c9acf8c4ebdb252..7139f36db05ada01ac57b667beae8f9f8106bbf1 100644 (file)
@@ -59,7 +59,9 @@ static void yagl_gles_image_destroy(struct yagl_ref *ref)
 {
     struct yagl_gles_image *image = (struct yagl_gles_image*)ref;
 
-    if (image->own_tex) {
+    if (image->texture_obj) {
+        yagl_gles_texture_release(image->texture_obj);
+    } else {
         yagl_host_glDeleteObjects(&image->tex_global_name, 1);
     }
 
@@ -79,14 +81,12 @@ struct yagl_gles_image *yagl_gles_image_create(yagl_object_name tex_global_name)
     image->base.update = &yagl_gles_image_update;
 
     image->tex_global_name = tex_global_name;
-    image->own_tex = 1;
 
     return image;
 }
 
 struct yagl_gles_image *yagl_gles_image_wrap_tex(struct yagl_client_context *ctx,
-                                                 yagl_object_name tex_local_name,
-                                                 struct yagl_object **obj)
+                                                 yagl_object_name tex_local_name)
 {
     struct yagl_gles_texture *texture_obj;
     struct yagl_gles_image *image;
@@ -106,9 +106,7 @@ struct yagl_gles_image *yagl_gles_image_wrap_tex(struct yagl_client_context *ctx
     image->base.update = &yagl_gles_image_update;
 
     image->tex_global_name = texture_obj->global_name;
-    image->own_tex = 0;
-
-    *obj = &texture_obj->base;
+    image->texture_obj = texture_obj;
 
     return image;
 
index 431eb790105142181836d569008c6c4e2c9d7d8a..83436f40bb79928d34f885b5d91e21710ec1cf25 100644 (file)
@@ -37,6 +37,7 @@
 #include "yagl_types.h"
 #include "yagl_client_image.h"
 
+struct yagl_gles_texture;
 struct yagl_client_context;
 
 struct yagl_gles_image
@@ -45,14 +46,16 @@ struct yagl_gles_image
 
     yagl_object_name tex_global_name;
 
-    int own_tex;
+    /*
+     * Non-NULL if the image wraps this texture object
+     */
+    struct yagl_gles_texture *texture_obj;
 };
 
 struct yagl_gles_image *yagl_gles_image_create(yagl_object_name tex_global_name);
 
 struct yagl_gles_image *yagl_gles_image_wrap_tex(struct yagl_client_context *ctx,
-                                                 yagl_object_name tex_local_name,
-                                                 struct yagl_object **obj);
+                                                 yagl_object_name tex_local_name);
 
 /*
  * Passing NULL won't hurt, this is for convenience.
index 0d7315686635e7110da6df006b3b176f5b06f93c..b8bcdfb4a6b97ebb3c6df7305d139614ecf4abde 100644 (file)
@@ -55,10 +55,9 @@ static struct yagl_client_image
 static struct yagl_client_image
     *yagl_gles1_wrap_texture(struct yagl_client_interface *iface,
                              struct yagl_client_context *ctx,
-                             yagl_object_name tex_local_name,
-                             struct yagl_object **texture_obj)
+                             yagl_object_name tex_local_name)
 {
-    return &yagl_gles_image_wrap_tex(ctx,tex_local_name, texture_obj)->base;
+    return &yagl_gles_image_wrap_tex(ctx,tex_local_name)->base;
 }
 
 static void yagl_gles1_release_tex_image(struct yagl_client_interface *iface,
index 4b24e099628c9159a2d197cceb5f4da3b22cb876..ab17f7af18ff5d40f7d27079db7829a5dd49b9a9 100644 (file)
@@ -63,10 +63,9 @@ static struct yagl_client_image
 static struct yagl_client_image
     *yagl_gles2_wrap_texture(struct yagl_client_interface *iface,
                              struct yagl_client_context *ctx,
-                             yagl_object_name tex_local_name,
-                             struct yagl_object **texture_obj)
+                             yagl_object_name tex_local_name)
 {
-    return &yagl_gles_image_wrap_tex(ctx, tex_local_name, texture_obj)->base;
+    return &yagl_gles_image_wrap_tex(ctx, tex_local_name)->base;
 }
 
 static void yagl_gles2_release_tex_image(struct yagl_client_interface *iface,
index 62fb3dfe66d3dd64e6f72d1e2fdb66ad7c77e199..1bd0502d73a82436a1566f857a21336391c895b0 100644 (file)
@@ -39,7 +39,6 @@
 struct yagl_client_context;
 struct yagl_client_image;
 struct yagl_sharegroup;
-struct yagl_object;
 
 struct yagl_client_interface
 {
@@ -54,8 +53,7 @@ struct yagl_client_interface
     struct yagl_client_image
         *(*wrap_texture)(struct yagl_client_interface */*iface*/,
                          struct yagl_client_context */*ctx*/,
-                         yagl_object_name /*tex_local_name*/,
-                         struct yagl_object **/*obj*/);
+                         yagl_object_name /*tex_local_name*/);
 
     void (*release_tex_image)(struct yagl_client_interface */*iface*/,
                               void */*cookie*/);