summaryrefslogtreecommitdiff
path: root/gst-libs
diff options
context:
space:
mode:
authorNicolas Dufresne <nicolas.dufresne@collabora.co.uk>2015-08-08 14:45:42 -0400
committerNicolas Dufresne <nicolas.dufresne@collabora.co.uk>2015-08-08 16:32:53 -0400
commitd6baf8dcc7bcc3799a6b7e2e54691b59e5f793d9 (patch)
tree72cd0ec1626f0319451daea55d80f95174eae12a /gst-libs
parent6b8cf8419d8ea80081de8150a6b1c3cf763c4d69 (diff)
downloadgstreamer-plugins-bad-d6baf8dcc7bcc3799a6b7e2e54691b59e5f793d9.tar.gz
gloverlaycompositor: Add shader to convert BGRA/ARGB -> RGBA
Depending on the bytes order we will get BGRA (little) and ARGB (big) from the composition overlay buffer while our GL code expects RGBA. Add a fragment shader that do this conversion. https://bugzilla.gnome.org/show_bug.cgi?id=752842
Diffstat (limited to 'gst-libs')
-rw-r--r--gst-libs/gst/gl/gstgloverlaycompositor.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/gst-libs/gst/gl/gstgloverlaycompositor.c b/gst-libs/gst/gl/gstgloverlaycompositor.c
index 5c6b02b3c..7efef3f13 100644
--- a/gst-libs/gst/gl/gstgloverlaycompositor.c
+++ b/gst-libs/gst/gl/gstgloverlaycompositor.c
@@ -44,6 +44,24 @@ typedef struct _GstGLCompositionOverlayClass GstGLCompositionOverlayClass;
static GType gst_gl_composition_overlay_get_type (void);
+/* *INDENT-OFF* */
+const gchar *fragment_shader =
+ "#ifdef GL_ES\n"
+ "precision mediump float;\n"
+ "#endif\n"
+ "varying vec2 v_texcoord;\n"
+ "uniform sampler2D tex;\n"
+ "void main(void)\n"
+ "{\n"
+ " vec4 t = texture2D(tex, v_texcoord);\n"
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+ " gl_FragColor = t.bgra;\n"
+#else
+ " gl_FragColor = t.gbar;\n"
+#endif
+ "}";
+/* *INDENT-ON* */
+
struct _GstGLCompositionOverlay
{
GstObject parent;
@@ -408,8 +426,8 @@ gst_gl_overlay_compositor_init_gl (GstGLContext * context,
GstGLOverlayCompositor *compositor =
(GstGLOverlayCompositor *) compositor_pointer;
- if (!gst_gl_shader_compile_with_default_vf_and_check
- (compositor->shader, &compositor->position_attrib,
+ if (!gst_gl_shader_compile_with_default_v_and_check (compositor->shader,
+ fragment_shader, &compositor->position_attrib,
&compositor->texcoord_attrib)) {
GST_ERROR ("could not initialize shader.");
}