[Cogl] [PATCH] cogl-gst: allocate textures synchronously
Robert Bragg
robert at sixbynine.org
Fri Mar 14 11:19:31 PDT 2014
From: Robert Bragg <robert at linux.intel.com>
This is an update of the same patch I sent back in January. At the time
we decided we could simplify the code to use
cogl_texture_2d_[sliced_]new_from_data() to avoid the intermediate
CoglBitmap, but since then the upload code has changed to require a call
to cogl_texture_set_premultiplied() which must be called before a texture
is allocated and so it turns out we can't really simplify this code.
--- >8 ---
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.
---
cogl-gst/cogl-gst-video-sink.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/cogl-gst/cogl-gst-video-sink.c b/cogl-gst/cogl-gst-video-sink.c
index 9a8eace..e8baee3 100644
--- a/cogl-gst/cogl-gst-video-sink.c
+++ b/cogl-gst/cogl-gst-video-sink.c
@@ -455,7 +455,10 @@ 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;
@@ -469,12 +472,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;
}
--
1.9.0
More information about the Cogl
mailing list