summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2014-01-10 20:44:00 +0000
committerRobert Bragg <robert.bragg@intel.com>2014-03-20 17:34:04 +0000
commit9f8ab5d809662cbe7e78c7b46fe0af55704fd516 (patch)
treef6a9366da1fb2f5334511cc63b4765945880918e
parentad9db72f7410da6888d15232d1644d3f676831fe (diff)
downloadcogl-9f8ab5d809662cbe7e78c7b46fe0af55704fd516.tar.gz
cogl-gst: allocate textures synchronously
This makes sure video textures being uploaded via video_texture_new_from_data are allocated before the function returns. This function create a CoglBitmap to wrap the data from gstreamer and by allowing cogl to allocate the texture lazily it's possible that the data being pointed to by the bitmap won't remain valid until we actually come to allocate the texture. Note: we don't simply use cogl_texture_2d_[sliced_]new_from_data() here because we need to be able to call cogl_texture_set_premultiplied() before allocating the texture. Reviewed-by: Neil Roberts <neil@linux.intel.com>
-rw-r--r--cogl-gst/cogl-gst-video-sink.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/cogl-gst/cogl-gst-video-sink.c b/cogl-gst/cogl-gst-video-sink.c
index 2d02a353..418b76a7 100644
--- a/cogl-gst/cogl-gst-video-sink.c
+++ b/cogl-gst/cogl-gst-video-sink.c
@@ -455,10 +455,15 @@ video_texture_new_from_data (CoglContext *ctx,
cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC))
{
tex = cogl_texture_2d_new_from_bitmap (bitmap);
- if (!tex)
+
+ cogl_texture_set_premultiplied (tex, FALSE);
+
+ if (!cogl_texture_allocate (tex, &internal_error))
{
cogl_error_free (internal_error);
internal_error = NULL;
+ cogl_object_unref (tex);
+ tex = NULL;
}
}
else
@@ -469,12 +474,14 @@ video_texture_new_from_data (CoglContext *ctx,
/* Otherwise create a sliced texture */
tex = cogl_texture_2d_sliced_new_from_bitmap (bitmap,
-1); /* no maximum waste */
+
+ cogl_texture_set_premultiplied (tex, FALSE);
+
+ cogl_texture_allocate (tex, NULL);
}
cogl_object_unref (bitmap);
- cogl_texture_set_premultiplied (tex, FALSE);
-
return tex;
}