summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2014-02-19 17:26:02 +0000
committerNeil Roberts <neil@linux.intel.com>2014-02-20 16:05:08 +0000
commitdd7b1d53dbb6bf16323403433528c63ffeffc331 (patch)
treed21f6968f08d05c3a41a6a041e8c1540905c1d1e
parent7bf0fe9df8c36a9f07158121a04bb4feb6531fe8 (diff)
downloadcogl-dd7b1d53dbb6bf16323403433528c63ffeffc331.tar.gz
Allocate immediately in _cogl_egl_texture_2d_new_from_image
The _cogl_egl_texture_2d_new_from_image function has a CoglError argument which implies that it is unlike the other texture constructors and returns errors immediately rather than having a delayed-allocation mechanism. cogl_wayland_texture_2d_new_from_buffer which calls it is also like this. We can't rely on delayed-allocation semantics for this without changing the applications because the texture needs to be allocated before the corresponding EGLImage is destroyed. This patch just makes it immediately allocate. A better patch might be to remove the error argument to make it obvious that there are delayed-allocation semantics and then fix all of the applications. This was breaking Cogland and Mutter. Reviewed-by: Robert Bragg <robert@linux.intel.com> (cherry picked from commit 0206c03d54823b2f6cbb2aa420d07a4db9bcd8a3)
-rw-r--r--cogl/cogl-texture-2d.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/cogl/cogl-texture-2d.c b/cogl/cogl-texture-2d.c
index 2c8e780b..62b89560 100644
--- a/cogl/cogl-texture-2d.c
+++ b/cogl/cogl-texture-2d.c
@@ -234,6 +234,7 @@ _cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
CoglError **error)
{
CoglTextureLoader *loader;
+ CoglTexture2D *tex;
_COGL_RETURN_VAL_IF_FAIL (_cogl_context_get_winsys (ctx)->constraints &
COGL_RENDERER_CONSTRAINT_USES_EGL,
@@ -251,7 +252,15 @@ _cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
loader->src.egl_image.height = height;
loader->src.egl_image.format = format;
- return _cogl_texture_2d_create_base (ctx, width, height, format, loader);
+ tex = _cogl_texture_2d_create_base (ctx, width, height, format, loader);
+
+ if (!cogl_texture_allocate (COGL_TEXTURE (tex), error))
+ {
+ cogl_object_unref (tex);
+ return NULL;
+ }
+
+ return tex;
}
#endif /* defined (COGL_HAS_EGL_SUPPORT) && defined (EGL_KHR_image_base) */