[gtk/matthiasc/color-profile-rebased: 12/47] API: Add GdkSurface::color-space
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/color-profile-rebased: 12/47] API: Add GdkSurface::color-space
- Date: Wed, 28 Sep 2022 19:07:14 +0000 (UTC)
commit a4cb999113c79c7ab9de294e4b6f0bbfda7ec546
Author: Benjamin Otte <otte redhat com>
Date: Fri Sep 24 20:07:56 2021 +0200
API: Add GdkSurface::color-space
Unused so far, but there's a private setter for backends and a public
readable property for code.
gdk/gdksurface.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++--
gdk/gdksurface.h | 18 +++++++-------
gdk/gdksurfaceprivate.h | 3 +++
3 files changed, 73 insertions(+), 10 deletions(-)
---
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index d4251ed3ab..a60f2df354 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -30,6 +30,7 @@
#include "gdksurface.h"
#include "gdkprivate.h"
+#include "gdkcolorspace.h"
#include "gdkcontentprovider.h"
#include "gdkdeviceprivate.h"
#include "gdkdisplayprivate.h"
@@ -88,13 +89,14 @@ enum {
enum {
PROP_0,
+ PROP_COLOR_SPACE,
PROP_CURSOR,
PROP_DISPLAY,
PROP_FRAME_CLOCK,
- PROP_MAPPED,
- PROP_WIDTH,
PROP_HEIGHT,
+ PROP_MAPPED,
PROP_SCALE_FACTOR,
+ PROP_WIDTH,
LAST_PROP
};
@@ -485,6 +487,8 @@ gdk_surface_init (GdkSurface *surface)
surface->alpha = 255;
+ surface->color_space = g_object_ref (gdk_color_space_get_srgb ());
+
surface->device_cursor = g_hash_table_new_full (NULL, NULL,
NULL, g_object_unref);
}
@@ -500,6 +504,25 @@ gdk_surface_class_init (GdkSurfaceClass *klass)
klass->beep = gdk_surface_real_beep;
+ /**
+ * GdkSurface:color-space: (attributes org.gtk.Property.get=gdk_surface_get_color_space)
+ *
+ * The preferred color space for rendering to the surface
+ *
+ * This color space is negotiated between GTK and the compositor.
+ *
+ * The color space 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 shown, the color space may not represent the actual color
+ * space that is going to be used.
+ *
+ * Since: 4.10
+ */
+ properties[PROP_COLOR_SPACE] =
+ g_param_spec_object ("color-space", NULL, NULL,
+ GDK_TYPE_COLOR_SPACE,
+ 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)
*
@@ -718,6 +741,7 @@ gdk_surface_finalize (GObject *object)
g_clear_object (&surface->cursor);
g_clear_pointer (&surface->device_cursor, g_hash_table_destroy);
g_clear_pointer (&surface->devices_inside, g_list_free);
+ g_clear_object (&surface->color_space);
g_clear_object (&surface->display);
@@ -772,6 +796,10 @@ gdk_surface_get_property (GObject *object,
switch (prop_id)
{
+ case PROP_COLOR_SPACE:
+ g_value_set_object (value, gdk_surface_get_color_space (surface));
+ break;
+
case PROP_CURSOR:
g_value_set_object (value, gdk_surface_get_cursor (surface));
break;
@@ -2040,6 +2068,36 @@ gdk_surface_get_height (GdkSurface *surface)
return surface->height;
}
+void
+gdk_surface_set_color_space (GdkSurface *self,
+ GdkColorSpace *color_space)
+{
+ if (gdk_color_space_equal (self->color_space, color_space))
+ return;
+
+ g_set_object (&self->color_space, color_space);
+
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_COLOR_SPACE]);
+}
+
+/**
+ * gdk_surface_get_color_space: (attributes org.gtk.Method.get_property=color-space)
+ * @self: a `GdkSurface`
+ *
+ * Returns the preferred color space for rendering to the given @surface.
+ *
+ * Returns: (transfer none): The color space of @surface
+ *
+ * Since: 4.10
+ */
+GdkColorSpace *
+gdk_surface_get_color_space (GdkSurface *self)
+{
+ g_return_val_if_fail (GDK_IS_SURFACE (self), gdk_color_space_get_srgb ());
+
+ return self->color_space;
+}
+
/*
* gdk_surface_get_origin:
* @surface: a `GdkSurface`
diff --git a/gdk/gdksurface.h b/gdk/gdksurface.h
index 4e083ec07b..38b5bd4dfb 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_10
+GdkColorSpace * gdk_surface_get_color_space (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 c53368574d..39d7574834 100644
--- a/gdk/gdksurfaceprivate.h
+++ b/gdk/gdksurfaceprivate.h
@@ -52,6 +52,7 @@ struct _GdkSurface
int y;
GdkGLContext *gl_paint_context;
+ GdkColorSpace *color_space;
cairo_region_t *update_area;
guint update_freeze_count;
@@ -171,6 +172,8 @@ void gdk_surface_set_state (GdkSurface *surface,
void gdk_surface_set_is_mapped (GdkSurface *surface,
gboolean is_mapped);
+void gdk_surface_set_color_space (GdkSurface *self,
+ GdkColorSpace *color_space);
GdkMonitor * gdk_surface_get_layout_monitor (GdkSurface *surface,
GdkPopupLayout *layout,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]