[gnome-desktop/wip/wayland-display: 2/2] GnomeRR: restore support for gamma ramps
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-desktop/wip/wayland-display: 2/2] GnomeRR: restore support for gamma ramps
- Date: Fri, 26 Jul 2013 15:18:42 +0000 (UTC)
commit 4456f6dd77ce0c2097d46c8cfa825f4cb6cc2e0a
Author: Giovanni Campagna <gcampagn redhat com>
Date: Fri Jul 26 14:22:37 2013 +0200
GnomeRR: restore support for gamma ramps
The color panel of control center needs it.
Note: the color panel and color g-s-d plugins will have different
changes for wayland support, but they still need the code in the
XRandR case.
libgnome-desktop/gnome-rr.c | 79 +++++++++++++++++++++++++++++++++++++++++++
libgnome-desktop/gnome-rr.h | 19 +----------
libgnome-desktop/xrandr.xml | 37 +++++++++++++++++++-
3 files changed, 116 insertions(+), 19 deletions(-)
---
diff --git a/libgnome-desktop/gnome-rr.c b/libgnome-desktop/gnome-rr.c
index 5249e17..03b64d0 100644
--- a/libgnome-desktop/gnome-rr.c
+++ b/libgnome-desktop/gnome-rr.c
@@ -1697,3 +1697,82 @@ _gnome_rr_screen_apply_configuration (GnomeRRScreen *screen,
crtcs, outputs,
NULL, error);
}
+
+gboolean
+gnome_rr_crtc_set_gamma (GnomeRRCrtc *crtc,
+ int size,
+ unsigned short *red,
+ unsigned short *green,
+ unsigned short *blue)
+{
+ GBytes *red_bytes, *green_bytes, *blue_bytes;
+ GVariant *red_v, *green_v, *blue_v;
+ gboolean ok;
+
+ red_bytes = g_bytes_new (red, size * sizeof (unsigned short));
+ green_bytes = g_bytes_new (green, size * sizeof (unsigned short));
+ blue_bytes = g_bytes_new (blue, size * sizeof (unsigned short));
+
+ red_v = g_variant_new_from_bytes (G_VARIANT_TYPE ("aq"),
+ red_bytes, TRUE);
+ green_v = g_variant_new_from_bytes (G_VARIANT_TYPE ("aq"),
+ green_bytes, TRUE);
+ blue_v = g_variant_new_from_bytes (G_VARIANT_TYPE ("aq"),
+ blue_bytes, TRUE);
+
+ ok = meta_dbus_display_config_call_set_crtc_gamma_sync (crtc->info->screen->priv->proxy,
+ crtc->info->serial,
+ crtc->id,
+ red_v,
+ green_v,
+ blue_v,
+ NULL, NULL);
+
+ g_bytes_unref (red_bytes);
+ g_bytes_unref (green_bytes);
+ g_bytes_unref (blue_bytes);
+ /* The variant above are floating, no need to free them */
+
+ return ok;
+}
+
+gboolean
+gnome_rr_crtc_get_gamma (GnomeRRCrtc *crtc,
+ int *size,
+ unsigned short **red,
+ unsigned short **green,
+ unsigned short **blue)
+{
+ GBytes *red_bytes, *green_bytes, *blue_bytes;
+ GVariant *red_v, *green_v, *blue_v;
+ gboolean ok;
+ gsize dummy;
+
+ ok = meta_dbus_display_config_call_get_crtc_gamma_sync (crtc->info->screen->priv->proxy,
+ crtc->info->serial,
+ crtc->id,
+ &red_v,
+ &green_v,
+ &blue_v,
+ NULL, NULL);
+ if (!ok)
+ return FALSE;
+
+ red_bytes = g_variant_get_data_as_bytes (red_v);
+ green_bytes = g_variant_get_data_as_bytes (green_v);
+ blue_bytes = g_variant_get_data_as_bytes (blue_v);
+
+ /* Unref the variant early so that the bytes hold the only reference to
+ the data and we don't need to copy
+ */
+ g_variant_unref (red_v);
+ g_variant_unref (green_v);
+ g_variant_unref (blue_v);
+
+ *size = g_bytes_get_size (red_bytes) / sizeof (unsigned short);
+ *red = g_bytes_unref_to_data (red_bytes, &dummy);
+ *green = g_bytes_unref_to_data (green_bytes, &dummy);
+ *blue = g_bytes_unref_to_data (blue_bytes, &dummy);
+
+ return TRUE;
+}
diff --git a/libgnome-desktop/gnome-rr.h b/libgnome-desktop/gnome-rr.h
index 316e088..328bf71 100644
--- a/libgnome-desktop/gnome-rr.h
+++ b/libgnome-desktop/gnome-rr.h
@@ -183,32 +183,15 @@ GnomeRRRotation gnome_rr_crtc_get_rotations (GnomeRRCrtc *crtc)
gboolean gnome_rr_crtc_supports_rotation (GnomeRRCrtc *crtc,
GnomeRRRotation rotation);
-#if 0 /* gamma support */
gboolean gnome_rr_crtc_get_gamma (GnomeRRCrtc *crtc,
int *size,
unsigned short **red,
unsigned short **green,
unsigned short **blue);
-void gnome_rr_crtc_set_gamma (GnomeRRCrtc *crtc,
+gboolean gnome_rr_crtc_set_gamma (GnomeRRCrtc *crtc,
int size,
unsigned short *red,
unsigned short *green,
unsigned short *blue);
-#endif
-
-#if 0 /* configuration writing */
-void gnome_rr_screen_set_primary_output (GnomeRRScreen *screen,
- GnomeRROutput *output);
-
-gboolean gnome_rr_crtc_set_config_with_time (GnomeRRCrtc *crtc,
- guint32 timestamp,
- int x,
- int y,
- GnomeRRMode *mode,
- GnomeRRRotation rotation,
- GnomeRROutput **outputs,
- int n_outputs,
- GError **error);
-#endif
#endif /* GNOME_RR_H */
diff --git a/libgnome-desktop/xrandr.xml b/libgnome-desktop/xrandr.xml
index f7abefd..fc57de8 100644
--- a/libgnome-desktop/xrandr.xml
+++ b/libgnome-desktop/xrandr.xml
@@ -62,7 +62,6 @@
CRTC; they are not necessarily reflected in
the hardware.
No property is specified in this version of the API.
- FIXME: gamma?
Note: all geometry information refers to the untransformed
display.
@@ -209,6 +208,42 @@
</method>
<!--
+ GetCrtcGamma:
+ @serial: configuration serial
+ @crtc: API id of the crtc
+ @red: red gamma ramp
+ @green: green gamma ramp
+ @blue: blue gamma ramp
+
+ Requests the current gamma ramps of @crtc.
+ -->
+ <method name="GetCrtcGamma">
+ <arg name="serial" direction="in" type="u" />
+ <arg name="crtc" direction="in" type="u" />
+ <arg name="red" direction="out" type="aq" />
+ <arg name="green" direction="out" type="aq" />
+ <arg name="blue" direction="out" type="aq" />
+ </method>
+
+ <!--
+ SetCrtcGamma:
+ @serial: configuration serial
+ @crtc: API id of the crtc
+ @red: red gamma ramp
+ @green: green gamma ramp
+ @blue: blue gamma ramp
+
+ Changes the gamma ramps of @crtc.
+ -->
+ <method name="SetCrtcGamma">
+ <arg name="serial" direction="in" type="u" />
+ <arg name="crtc" direction="in" type="u" />
+ <arg name="red" direction="in" type="aq" />
+ <arg name="green" direction="in" type="aq" />
+ <arg name="blue" direction="in" type="aq" />
+ </method>
+
+ <!--
PowerSaveMode:
Contains the current power saving mode for the screen, and
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]