[gtk/wip/otte/color-profiles: 38/38] API: Add GdkSurface::color-profile
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/color-profiles: 38/38] API: Add GdkSurface::color-profile
- Date: Sat, 25 Sep 2021 00:48:15 +0000 (UTC)
commit 6204dec23ffecefdc1b82c991fa4d7abde03a96a
Author: Benjamin Otte <otte redhat com>
Date: Sat Sep 25 02:00:02 2021 +0200
API: Add GdkSurface::color-profile
Unused so far, but there's a private setter for backends and a public
readable property for code.
gdk/gdksurface.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++--
gdk/gdksurface.h | 18 +++++++++-------
gdk/gdksurfaceprivate.h | 2 ++
3 files changed, 66 insertions(+), 10 deletions(-)
---
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 5569d9cb98..c53ed89fe1 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -30,6 +30,7 @@
#include "gdksurface.h"
#include "gdk-private.h"
+#include "gdkcolorprofile.h"
#include "gdkcontentprovider.h"
#include "gdkdeviceprivate.h"
#include "gdkdisplayprivate.h"
@@ -73,13 +74,14 @@ enum {
enum {
PROP_0,
+ PROP_COLOR_PROFILE,
PROP_CURSOR,
PROP_DISPLAY,
PROP_FRAME_CLOCK,
- PROP_MAPPED,
- PROP_WIDTH,
PROP_HEIGHT,
+ PROP_MAPPED,
PROP_SCALE_FACTOR,
+ PROP_WIDTH,
LAST_PROP
};
@@ -487,6 +489,24 @@ gdk_surface_class_init (GdkSurfaceClass *klass)
klass->beep = gdk_surface_real_beep;
+ /**
+ * GdkSurface:color-profile: (attributes org.gtk.Property.get=gdk_surface_get_color_profile)
+ *
+ * The preferred color profile for rendering to the surface
+ *
+ * This profile is negotiated between GTK and the compositor.
+ *
+ * The profile may change as the surface gets moved around - for example to different
+ * monitors or when the compositor gets reconfigured. As long as the surface isn't show, the
+ * profile may not represent the actual color profile that is going to be used.
+ */
+ properties[PROP_COLOR_PROFILE] =
+ g_param_spec_object ("color-profile",
+ P_("Color profile"),
+ P_("The preferred color profile of the surface"),
+ GDK_TYPE_COLOR_PROFILE,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
/**
* GdkSurface:cursor: (attributes org.gtk.Property.get=gdk_surface_get_cursor
org.gtk.Property.set=gdk_surface_set_cursor)
*
@@ -771,6 +791,10 @@ gdk_surface_get_property (GObject *object,
switch (prop_id)
{
+ case PROP_COLOR_PROFILE:
+ g_value_set_object (value, gdk_surface_get_color_profile (surface));
+ break;
+
case PROP_CURSOR:
g_value_set_object (value, gdk_surface_get_cursor (surface));
break;
@@ -1970,6 +1994,34 @@ gdk_surface_get_height (GdkSurface *surface)
return surface->height;
}
+void
+gdk_surface_set_color_profile (GdkSurface *self,
+ GdkColorProfile *color_profile)
+{
+ if (gdk_color_profile_equal (self->color_profile, color_profile))
+ return;
+
+ g_set_object (&self->color_profile, color_profile);
+
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_COLOR_PROFILE]);
+}
+
+/**
+ * gdk_surface_get_color_profile: (attributes org.gtk.Method.get_property=color-profile)
+ * @self: a `GdkSurface`
+ *
+ * Returns the preferred color profile for rendering to the given @surface.
+ *
+ * Returns: (transfer none): The color profile of @surface
+ */
+GdkColorProfile *
+gdk_surface_get_color_profile (GdkSurface *self)
+{
+ g_return_val_if_fail (GDK_IS_SURFACE (self), gdk_color_profile_get_srgb ());
+
+ return self->color_profile;
+}
+
/*
* gdk_surface_get_origin:
* @surface: a `GdkSurface`
diff --git a/gdk/gdksurface.h b/gdk/gdksurface.h
index 4e083ec07b..7e946f2bcb 100644
--- a/gdk/gdksurface.h
+++ b/gdk/gdksurface.h
@@ -86,17 +86,19 @@ GDK_AVAILABLE_IN_ALL
GdkCursor *gdk_surface_get_device_cursor (GdkSurface *surface,
GdkDevice *device);
GDK_AVAILABLE_IN_ALL
-int gdk_surface_get_width (GdkSurface *surface);
+int gdk_surface_get_width (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
-int gdk_surface_get_height (GdkSurface *surface);
+int gdk_surface_get_height (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
-gboolean gdk_surface_translate_coordinates (GdkSurface *from,
- GdkSurface *to,
- double *x,
- double *y);
-
+int gdk_surface_get_scale_factor (GdkSurface *surface);
+GDK_AVAILABLE_IN_4_6
+GdkColorProfile * gdk_surface_get_color_profile (GdkSurface *self);
GDK_AVAILABLE_IN_ALL
-int gdk_surface_get_scale_factor (GdkSurface *surface);
+gboolean gdk_surface_translate_coordinates (GdkSurface *from,
+ GdkSurface *to,
+ double *x,
+ double *y);
+
GDK_AVAILABLE_IN_ALL
gboolean gdk_surface_get_device_position (GdkSurface *surface,
diff --git a/gdk/gdksurfaceprivate.h b/gdk/gdksurfaceprivate.h
index 4c826f96f2..566871c274 100644
--- a/gdk/gdksurfaceprivate.h
+++ b/gdk/gdksurfaceprivate.h
@@ -174,6 +174,8 @@ void gdk_surface_set_state (GdkSurface *surface,
void gdk_surface_set_is_mapped (GdkSurface *surface,
gboolean is_mapped);
+void gdk_surface_set_color_profile (GdkSurface *self,
+ GdkColorProfile *color_profile);
GdkMonitor * gdk_surface_get_layout_monitor (GdkSurface *surface,
GdkPopupLayout *layout,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]