diff options
author | Gwenole Beauchesne <gwenole.beauchesne@intel.com> | 2013-07-22 14:00:39 +0200 |
---|---|---|
committer | Lionel Landwerlin <llandwerlin@gmail.com> | 2013-07-22 17:10:25 +0100 |
commit | 96f7b15624147dd9fcfec16f14e6824dc329f973 (patch) | |
tree | fa41e9c426305b2ab70607557baa61f4731d4545 | |
parent | 652ab502a68e8eb32328780f8ba68e82562532dc (diff) | |
download | clutter-gst-96f7b15624147dd9fcfec16f14e6824dc329f973.tar.gz |
video-sink: clean up creation of HW decoder resources.
Create the underlying cogl texture when creating the video converter,
i.e. the first time clutter_gst_hw_upload() is entered.
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
-rw-r--r-- | clutter-gst/clutter-gst-video-sink.c | 68 |
1 files changed, 47 insertions, 21 deletions
diff --git a/clutter-gst/clutter-gst-video-sink.c b/clutter-gst/clutter-gst-video-sink.c index 1a93f8f..acf47d0 100644 --- a/clutter-gst/clutter-gst-video-sink.c +++ b/clutter-gst/clutter-gst-video-sink.c @@ -1062,23 +1062,58 @@ static ClutterGstRenderer ayuv_glsl_renderer = { */ #ifdef HAVE_HW_DECODER_SUPPORT -static void -clutter_gst_hw_init (ClutterGstVideoSink * sink) +static gboolean +clutter_gst_hw_set_texture (ClutterGstVideoSink * sink, CoglTexture * tex) { - ClutterGstVideoSinkPrivate *priv = sink->priv; - CoglHandle tex; + ClutterGstVideoSinkPrivate * const priv = sink->priv; CoglHandle material; - /* Default texture is 1x1, let's replace it with one big enough. */ - tex = cogl_texture_new_with_size (priv->info.width, priv->info.height, - CLUTTER_GST_TEXTURE_FLAGS, COGL_PIXEL_FORMAT_BGRA_8888); - material = cogl_material_new (); + if (!material) + return FALSE; cogl_material_set_layer (material, 0, tex); clutter_texture_set_cogl_material (priv->texture, material); cogl_object_unref (tex); cogl_object_unref (material); + return TRUE; +} + +static gboolean +clutter_gst_hw_init_texture (ClutterGstVideoSink * sink, + GstSurfaceMeta * surface, GstBuffer * buffer) +{ + ClutterGstVideoSinkPrivate * const priv = sink->priv; + CoglHandle tex; + unsigned int gl_texture; + unsigned int gl_target; + GValue value = { 0 }; + + /* Default texture is 1x1, let's replace it with one big enough. */ + tex = cogl_texture_new_with_size (priv->info.width, priv->info.height, + CLUTTER_GST_TEXTURE_FLAGS, COGL_PIXEL_FORMAT_BGRA_8888); + if (!tex) + return FALSE; + + if (!clutter_gst_hw_set_texture (sink, tex)) + { + cogl_object_unref (tex); + return FALSE; + } + + cogl_texture_get_gl_texture (tex, &gl_texture, &gl_target); + + g_value_init (&value, G_TYPE_UINT); + g_value_set_uint (&value, gl_texture); + + priv->converter = + gst_surface_meta_create_converter (surface, "opengl", &value); + return priv->converter != NULL; +} + +static void +clutter_gst_hw_init (ClutterGstVideoSink * sink) +{ } static void @@ -1100,19 +1135,10 @@ clutter_gst_hw_upload (ClutterGstVideoSink * sink, GstBuffer * buffer) g_return_val_if_fail (surface != NULL, FALSE); if (G_UNLIKELY (priv->converter == NULL)) { - CoglHandle tex; - unsigned int gl_texture; - unsigned int gl_target; - GValue value = { 0 }; - - tex = clutter_texture_get_cogl_texture (priv->texture); - cogl_texture_get_gl_texture (tex, &gl_texture, &gl_target); - - g_value_init (&value, G_TYPE_UINT); - g_value_set_uint (&value, gl_texture); - - priv->converter = - gst_surface_meta_create_converter (surface, "opengl", &value); + do { + if (clutter_gst_hw_init_texture (sink, surface, buffer)) + break; + } while (0); g_return_val_if_fail (priv->converter, FALSE); } |