1 From 048db61bc6cf06b2554867f6dfb8e088eb3bf951 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Ren=C3=A9=20Stadler?= <rene.stadler@nokia.com>
3 Date: Mon, 21 Dec 2009 17:34:26 +0200
4 Subject: [PATCH] xvimagesink: add disable-colorkey property (Maemo specific)
7 sys/xvimage/xvimagesink.c | 57 +++++++++++++++++++++++++++++++++++++++++++-
8 sys/xvimage/xvimagesink.h | 4 +++
9 2 files changed, 59 insertions(+), 2 deletions(-)
11 diff --git a/sys/xvimage/xvimagesink.c b/sys/xvimage/xvimagesink.c
12 index 30368d5..63f7e77 100644
13 --- a/sys/xvimage/xvimagesink.c
14 +++ b/sys/xvimage/xvimagesink.c
15 @@ -188,7 +188,8 @@ enum
21 + PROP_DISABLE_COLORKEY
24 static GstVideoSinkClass *parent_class = NULL;
25 @@ -774,6 +775,7 @@ gst_xvimagesink_xvimage_put (GstXvImageSink * xvimagesink,
27 GstVideoRectangle result;
28 gboolean draw_border = FALSE;
29 + gboolean disable_colorkey;
31 /* We take the flow_lock. If expose is in there we don't want to run
32 concurrently from the data flow thread */
33 @@ -831,6 +833,16 @@ gst_xvimagesink_xvimage_put (GstXvImageSink * xvimagesink,
35 g_mutex_lock (xvimagesink->x_lock);
37 + disable_colorkey = g_atomic_int_get (&xvimagesink->disable_colorkey);
38 + if (G_UNLIKELY (disable_colorkey != xvimagesink->disable_colorkey_set)) {
39 + GST_LOG_OBJECT (xvimagesink, "Setting disable-colorkey to %d",
40 + (disable_colorkey ? 1 : 0));
41 + XvSetPortAttribute (xvimagesink->xcontext->disp,
42 + xvimagesink->xcontext->xv_port_id, xvimagesink->disable_colorkey_atom,
43 + disable_colorkey ? 1 : 0);
44 + xvimagesink->disable_colorkey_set = disable_colorkey;
47 if (draw_border && xvimagesink->draw_borders) {
48 gst_xvimagesink_xwindow_draw_borders (xvimagesink, xvimagesink->xwindow,
50 @@ -1431,18 +1443,20 @@ gst_xvimagesink_get_xv_support (GstXvImageSink * xvimagesink,
52 /* Set XV_AUTOPAINT_COLORKEY and XV_DOUBLE_BUFFER and XV_COLORKEY */
54 - int count, todo = 3;
55 + int count, todo = 4;
56 XvAttribute *const attr = XvQueryPortAttributes (xcontext->disp,
57 xcontext->xv_port_id, &count);
58 static const char autopaint[] = "XV_AUTOPAINT_COLORKEY";
59 static const char dbl_buffer[] = "XV_DOUBLE_BUFFER";
60 static const char colorkey[] = "XV_COLORKEY";
61 + static const char disable_colorkey[] = "XV_DISABLE_COLORKEY";
63 GST_DEBUG_OBJECT (xvimagesink, "Checking %d Xv port attributes", count);
65 xvimagesink->have_autopaint_colorkey = FALSE;
66 xvimagesink->have_double_buffer = FALSE;
67 xvimagesink->have_colorkey = FALSE;
68 + xvimagesink->have_disable_colorkey = FALSE;
70 for (i = 0; ((i < count) && todo); i++)
71 if (!strcmp (attr[i].name, autopaint)) {
72 @@ -1508,6 +1522,22 @@ gst_xvimagesink_get_xv_support (GstXvImageSink * xvimagesink,
75 xvimagesink->have_colorkey = TRUE;
76 + } else if (!strcmp (attr[i].name, disable_colorkey)) {
77 + const Atom atom = XInternAtom (xcontext->disp, disable_colorkey, False);
78 + gboolean disable_colorkey;
80 + GST_LOG_OBJECT (xvimagesink, "Setting disable-colorkey to %d",
81 + (xvimagesink->disable_colorkey ? 1 : 0));
83 + disable_colorkey = g_atomic_int_get (&xvimagesink->disable_colorkey);
84 + XvSetPortAttribute (xcontext->disp, xcontext->xv_port_id, atom,
85 + (disable_colorkey ? 1 : 0));
86 + xvimagesink->disable_colorkey_set = disable_colorkey;
89 + xvimagesink->have_disable_colorkey = TRUE;
91 + xvimagesink->disable_colorkey_atom = atom;
95 @@ -3291,6 +3321,10 @@ gst_xvimagesink_set_property (GObject * object, guint prop_id,
96 case PROP_DRAW_BORDERS:
97 xvimagesink->draw_borders = g_value_get_boolean (value);
99 + case PROP_DISABLE_COLORKEY:
100 + g_atomic_int_set (&xvimagesink->disable_colorkey,
101 + g_value_get_boolean (value));
104 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
106 @@ -3379,6 +3413,9 @@ gst_xvimagesink_get_property (GObject * object, guint prop_id,
108 g_value_set_uint64 (value, 0);
110 + case PROP_DISABLE_COLORKEY:
111 + g_value_set_boolean (value, xvimagesink->disable_colorkey);
114 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
116 @@ -3503,6 +3540,9 @@ gst_xvimagesink_init (GstXvImageSink * xvimagesink)
117 xvimagesink->par = NULL;
118 xvimagesink->handle_expose = TRUE;
119 xvimagesink->autopaint_colorkey = TRUE;
120 + xvimagesink->disable_colorkey = FALSE;
121 + xvimagesink->disable_colorkey_set = FALSE;
122 + xvimagesink->disable_colorkey_atom = None;
124 /* on 16bit displays this becomes r,g,b = 1,2,3
125 * on 24bit displays this becomes r,g,b = 8,8,16
126 @@ -3670,6 +3710,19 @@ gst_xvimagesink_class_init (GstXvImageSinkClass * klass)
127 "Height of the window", 0, G_MAXUINT64, 0,
128 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
131 + * GstXvImageSink:disable-colorkey
133 + * Whether to disable colorkeying (disabling has the same effect as painting
134 + * the color key everywhere).
136 + * This is a Maemo-specific property.
138 + g_object_class_install_property (gobject_class, PROP_DISABLE_COLORKEY,
139 + g_param_spec_boolean ("disable-colorkey", "Disable colorkeying",
140 + "Whether to disable colorkey", FALSE,
141 + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
143 gobject_class->finalize = gst_xvimagesink_finalize;
145 gstelement_class->change_state =
146 diff --git a/sys/xvimage/xvimagesink.h b/sys/xvimage/xvimagesink.h
147 index 0181018..ddc0e06 100644
148 --- a/sys/xvimage/xvimagesink.h
149 +++ b/sys/xvimage/xvimagesink.h
150 @@ -276,6 +276,9 @@ struct _GstXvImageSink {
151 /* port attributes */
152 gboolean autopaint_colorkey;
154 + gboolean disable_colorkey;
155 + gboolean disable_colorkey_set;
156 + Atom disable_colorkey_atom;
158 gboolean draw_borders;
160 @@ -283,6 +286,7 @@ struct _GstXvImageSink {
161 gboolean have_autopaint_colorkey;
162 gboolean have_colorkey;
163 gboolean have_double_buffer;
164 + gboolean have_disable_colorkey;
166 /* stream metadata */