[banshee] [libbanshee] Updated Clutter video sink to latest master
- From: Aaron Bockover <abock src gnome org>
- To: svn-commits-list gnome org
- Subject: [banshee] [libbanshee] Updated Clutter video sink to latest master
- Date: Fri, 19 Jun 2009 15:46:26 -0400 (EDT)
commit 10a1ce08e9c234adeb7ca245049bca703c07ee30
Author: Aaron Bockover <abockover novell com>
Date: Fri Jun 19 15:49:57 2009 -0400
[libbanshee] Updated Clutter video sink to latest master
libbanshee/clutter-gst-video-sink.c | 151 +++++++++++------------------------
1 files changed, 46 insertions(+), 105 deletions(-)
---
diff --git a/libbanshee/clutter-gst-video-sink.c b/libbanshee/clutter-gst-video-sink.c
index c20fbd7..d6eb6a3 100644
--- a/libbanshee/clutter-gst-video-sink.c
+++ b/libbanshee/clutter-gst-video-sink.c
@@ -138,20 +138,12 @@ typedef void (*GLGENPROGRAMSPROC)(GLsizei n, GLuint *programs);
typedef void (*GLBINDPROGRAMPROC)(GLenum target, GLint program);
typedef void (*GLPROGRAMSTRINGPROC)(GLenum target, GLenum format, GLsizei len,
const void *string);
-/* multi-texturing */
-typedef void (*GLACTIVETEXTUREPROC)(GLenum unit);
-typedef void (*GLMULTITEXCOORD2FPROC)(GLenum target, GLfloat s, GLfloat t);
-
typedef struct _ClutterGstSymbols
{
/* GL_ARB_fragment_program */
GLGENPROGRAMSPROC glGenProgramsARB;
GLBINDPROGRAMPROC glBindProgramARB;
GLPROGRAMSTRINGPROC glProgramStringARB;
-
- /* multi-texturing */
- GLACTIVETEXTUREPROC glActiveTextureARB;
- GLMULTITEXCOORD2FPROC glMultiTexCoord2fARB;
} ClutterGstSymbols;
/*
@@ -207,7 +199,6 @@ struct _ClutterGstVideoSinkPrivate
gboolean shaders_init;
ClutterGstSymbols syms; /* extra OpenGL functions */
- GLUNIFORM1IPROC glUniform1iARB;
GSList *renderers;
GstCaps *caps;
@@ -425,8 +416,6 @@ static ClutterGstRenderer rgb32_renderer =
NULL,
};
-#ifdef CLUTTER_COGL_HAS_GL
-
/*
* YV12
*
@@ -445,11 +434,11 @@ clutter_gst_yv12_glsl_init (ClutterActor *actor,
cogl_program_use (priv->program);
location = cogl_program_get_uniform_location (priv->program, "ytex");
- priv->glUniform1iARB (location, 0);
+ cogl_program_uniform_1i (location, 0);
location = cogl_program_get_uniform_location (priv->program, "utex");
- priv->glUniform1iARB (location, 1);
+ cogl_program_uniform_1i (location, 1);
location = cogl_program_get_uniform_location (priv->program, "vtex");
- priv->glUniform1iARB (location, 2);
+ cogl_program_uniform_1i (location, 2);
cogl_program_use (COGL_INVALID_HANDLE);
}
@@ -462,15 +451,12 @@ clutter_gst_yv12_upload (ClutterGstVideoSink *sink,
CoglHandle y_tex = cogl_texture_new_from_data (priv->width,
priv->height,
- -1,
- COGL_TEXTURE_NONE,
+ COGL_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_G_8,
COGL_PIXEL_FORMAT_G_8,
priv->width,
GST_BUFFER_DATA (buffer));
- cogl_texture_set_filters (y_tex,
- COGL_TEXTURE_FILTER_LINEAR,
- COGL_TEXTURE_FILTER_LINEAR);
+
clutter_texture_set_cogl_texture (priv->texture, y_tex);
cogl_texture_unref (y_tex);
@@ -480,33 +466,24 @@ clutter_gst_yv12_upload (ClutterGstVideoSink *sink,
if (priv->v_tex)
cogl_texture_unref (priv->v_tex);
- priv->v_tex = cogl_texture_new_from_data (priv->width/2,
- priv->height/2,
- -1,
- COGL_TEXTURE_NONE,
+ priv->v_tex = cogl_texture_new_from_data (priv->width / 2,
+ priv->height / 2,
+ COGL_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_G_8,
COGL_PIXEL_FORMAT_G_8,
- priv->width/2,
+ priv->width / 2,
GST_BUFFER_DATA (buffer) +
(priv->width * priv->height));
- cogl_texture_set_filters (priv->v_tex,
- COGL_TEXTURE_FILTER_LINEAR,
- COGL_TEXTURE_FILTER_LINEAR);
-
- priv->u_tex =
- cogl_texture_new_from_data (priv->width/2,
- priv->height/2,
- -1,
- COGL_TEXTURE_NONE,
- COGL_PIXEL_FORMAT_G_8,
- COGL_PIXEL_FORMAT_G_8,
- priv->width/2,
- GST_BUFFER_DATA (buffer) +
- (priv->width * priv->height) +
- (priv->width/2 * priv->height/2));
- cogl_texture_set_filters (priv->u_tex,
- COGL_TEXTURE_FILTER_LINEAR,
- COGL_TEXTURE_FILTER_LINEAR);
+
+ priv->u_tex = cogl_texture_new_from_data (priv->width / 2,
+ priv->height / 2,
+ COGL_TEXTURE_NO_SLICING,
+ COGL_PIXEL_FORMAT_G_8,
+ COGL_PIXEL_FORMAT_G_8,
+ priv->width / 2,
+ GST_BUFFER_DATA (buffer)
+ + (priv->width * priv->height)
+ + (priv->width / 2 * priv->height / 2));
}
static void
@@ -514,40 +491,27 @@ clutter_gst_yv12_paint (ClutterActor *actor,
ClutterGstVideoSink *sink)
{
ClutterGstVideoSinkPrivate *priv = sink->priv;
- GLuint texture;
+ CoglHandle material;
- /* Bind the U and V textures in texture units 1 and 2 */
- if (priv->u_tex)
- {
- cogl_texture_get_gl_texture (priv->u_tex, &texture, NULL);
- priv->syms.glActiveTextureARB (GL_TEXTURE1);
- glEnable (GL_TEXTURE_2D);
- glBindTexture (GL_TEXTURE_2D, texture);
- }
+ material = clutter_texture_get_cogl_material (CLUTTER_TEXTURE (actor));
+ /* Bind the U and V textures in layers 1 and 2 */
+ if (priv->u_tex)
+ cogl_material_set_layer (material, 1, priv->u_tex);
if (priv->v_tex)
- {
- cogl_texture_get_gl_texture (priv->v_tex, &texture, NULL);
- priv->syms.glActiveTextureARB (GL_TEXTURE2);
- glEnable (GL_TEXTURE_2D);
- glBindTexture (GL_TEXTURE_2D, texture);
- }
-
- priv->syms.glActiveTextureARB (GL_TEXTURE0_ARB);
+ cogl_material_set_layer (material, 2, priv->v_tex);
}
static void
clutter_gst_yv12_glsl_post_paint (ClutterActor *actor,
ClutterGstVideoSink *sink)
{
- ClutterGstVideoSinkPrivate *priv = sink->priv;
+ CoglHandle material;
- /* Disable the extra texture units */
- priv->syms.glActiveTextureARB (GL_TEXTURE1);
- glDisable (GL_TEXTURE_2D);
- priv->syms.glActiveTextureARB (GL_TEXTURE2);
- glDisable (GL_TEXTURE_2D);
- priv->syms.glActiveTextureARB (GL_TEXTURE0);
+ /* Remove the extra layers */
+ material = clutter_texture_get_cogl_material (CLUTTER_TEXTURE (actor));
+ cogl_material_remove_layer (material, 1);
+ cogl_material_remove_layer (material, 2);
}
static ClutterGstRenderer yv12_glsl_renderer =
@@ -587,14 +551,12 @@ static void
clutter_gst_yv12_fp_post_paint (ClutterActor *actor,
ClutterGstVideoSink *sink)
{
- ClutterGstVideoSinkPrivate *priv = sink->priv;
+ CoglHandle material;
- /* Disable the extra texture units */
- priv->syms.glActiveTextureARB (GL_TEXTURE1);
- glDisable (GL_TEXTURE_2D);
- priv->syms.glActiveTextureARB (GL_TEXTURE2);
- glDisable (GL_TEXTURE_2D);
- priv->syms.glActiveTextureARB (GL_TEXTURE0);
+ /* Remove the extra layers */
+ material = clutter_texture_get_cogl_material (CLUTTER_TEXTURE (actor));
+ cogl_material_remove_layer (material, 1);
+ cogl_material_remove_layer (material, 2);
/* Disable the shader */
glDisable (GL_FRAGMENT_PROGRAM_ARB);
@@ -631,11 +593,11 @@ clutter_gst_i420_glsl_init (ClutterActor *actor,
cogl_program_use (priv->program);
location = cogl_program_get_uniform_location (priv->program, "ytex");
- priv->glUniform1iARB (location, 0);
+ cogl_program_uniform_1i (location, 0);
location = cogl_program_get_uniform_location (priv->program, "vtex");
- priv->glUniform1iARB (location, 1);
+ cogl_program_uniform_1i (location, 1);
location = cogl_program_get_uniform_location (priv->program, "utex");
- priv->glUniform1iARB (location, 2);
+ cogl_program_uniform_1i (location, 2);
cogl_program_use (COGL_INVALID_HANDLE);
}
@@ -685,8 +647,6 @@ static ClutterGstRenderer i420_fp_renderer =
clutter_gst_yv12_fp_post_paint,
};
-#endif /* CLUTTER_COGL_HAS_GL */
-
/*
* AYUV
*
@@ -736,7 +696,7 @@ clutter_gst_build_renderers_list (ClutterGstSymbols *syms)
{
GSList *list = NULL;
const gchar *gl_extensions;
- GLint nb_texture_units;
+ GLint nb_texture_units = 0;
gint features = 0, i;
/* The order of the list of renderers is important. They will be prepended
* to a GSList and we'll iterate over that list to choose the first matching
@@ -756,23 +716,11 @@ clutter_gst_build_renderers_list (ClutterGstSymbols *syms)
/* get the features */
gl_extensions = (const gchar*) glGetString (GL_EXTENSIONS);
- if (cogl_check_extension ("GL_ARB_multitexture", gl_extensions))
- {
- /* we need 3 texture units for planar YUV */
- glGetIntegerv (GL_MAX_TEXTURE_UNITS_ARB, &nb_texture_units);
- syms->glActiveTextureARB = (GLACTIVETEXTUREPROC)
- cogl_get_proc_address ("glActiveTextureARB");
- syms->glMultiTexCoord2fARB = (GLMULTITEXCOORD2FPROC)
- cogl_get_proc_address ("glMultiTexCoord2fARB");
+ glGetIntegerv (GL_MAX_TEXTURE_UNITS, &nb_texture_units);
- if (nb_texture_units >= 3 &&
- syms->glActiveTextureARB &&
- syms->glMultiTexCoord2fARB)
- {
- features |= CLUTTER_GST_MULTI_TEXTURE;
- }
- }
+ if (nb_texture_units >= 3)
+ features |= CLUTTER_GST_MULTI_TEXTURE;
if (cogl_check_extension ("GL_ARB_fragment_program", gl_extensions))
{
@@ -834,7 +782,7 @@ clutter_gst_build_caps (GSList *renderers)
return caps;
}
-ClutterGstRenderer *
+static ClutterGstRenderer *
clutter_gst_find_renderer_by_format (ClutterGstVideoSink *sink,
ClutterGstVideoFormat format)
{
@@ -952,11 +900,6 @@ clutter_gst_video_sink_init (ClutterGstVideoSink *sink,
priv->use_shaders = TRUE;
priv->renderers = clutter_gst_build_renderers_list (&priv->syms);
priv->caps = clutter_gst_build_caps (priv->renderers);
-
-#ifdef CLUTTER_COGL_HAS_GL
- priv->glUniform1iARB = (GLUNIFORM1IPROC)
- cogl_get_proc_address ("glUniform1iARB");
-#endif
}
static GstFlowReturn
@@ -1054,7 +997,6 @@ clutter_gst_video_sink_set_caps (GstBaseSink *bsink,
else
priv->par_n = priv->par_d = 1;
-#if CLUTTER_COGL_HAS_GL
ret = gst_structure_get_fourcc (structure, "format", &fourcc);
if (ret && (fourcc == GST_MAKE_FOURCC ('Y', 'V', '1', '2')))
{
@@ -1070,14 +1012,13 @@ clutter_gst_video_sink_set_caps (GstBaseSink *bsink,
priv->bgr = FALSE;
}
else
-#endif
{
- guint32 width;
+ guint32 mask;
gst_structure_get_int (structure, "red_mask", &red_mask);
gst_structure_get_int (structure, "blue_mask", &blue_mask);
- width = red_mask | blue_mask;
- if (width < 0x1000000)
+ mask = red_mask | blue_mask;
+ if (mask < 0x1000000)
{
priv->format = CLUTTER_GST_RGB24;
priv->bgr = (red_mask == 0xff0000) ? FALSE : TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]