[gtk/wip/otte/color-profiles: 25/38] texture: Add a ::color-profile property
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/color-profiles: 25/38] texture: Add a ::color-profile property
- Date: Sat, 25 Sep 2021 00:47:55 +0000 (UTC)
commit f2db69a6ed4c18ce7a553034709815d5298e4313
Author: Benjamin Otte <otte redhat com>
Date: Mon Sep 20 09:44:32 2021 +0200
texture: Add a ::color-profile property
Returns the associated color profile. For now, this is always sRGB.
gdk/gdktexture.c | 82 +++++++++++++++++++++++++++++++++++++++----------
gdk/gdktexture.h | 2 ++
gdk/gdktextureprivate.h | 1 +
3 files changed, 68 insertions(+), 17 deletions(-)
---
diff --git a/gdk/gdktexture.c b/gdk/gdktexture.c
index b79b671a53..975e6c5f9a 100644
--- a/gdk/gdktexture.c
+++ b/gdk/gdktexture.c
@@ -40,6 +40,7 @@
#include "gdktextureprivate.h"
+#include "gdkcolorprofile.h"
#include "gdkintl.h"
#include "gdkmemorytextureprivate.h"
#include "gdkpaintable.h"
@@ -60,8 +61,9 @@ gtk_snapshot_append_texture (GdkSnapshot *snapshot,
enum {
PROP_0,
- PROP_WIDTH,
+ PROP_COLOR_PROFILE,
PROP_HEIGHT,
+ PROP_WIDTH,
N_PROPS
};
@@ -262,14 +264,20 @@ gdk_texture_set_property (GObject *gobject,
switch (prop_id)
{
- case PROP_WIDTH:
- self->width = g_value_get_int (value);
+ case PROP_COLOR_PROFILE:
+ self->color_profile = g_value_dup_object (value);
+ if (self->color_profile == NULL)
+ self->color_profile = g_object_ref (gdk_color_profile_get_srgb ());
break;
case PROP_HEIGHT:
self->height = g_value_get_int (value);
break;
+ case PROP_WIDTH:
+ self->width = g_value_get_int (value);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
@@ -286,14 +294,18 @@ gdk_texture_get_property (GObject *gobject,
switch (prop_id)
{
- case PROP_WIDTH:
- g_value_set_int (value, self->width);
+ case PROP_COLOR_PROFILE:
+ g_value_set_object (value, self->color_profile);
break;
case PROP_HEIGHT:
g_value_set_int (value, self->height);
break;
+ case PROP_WIDTH:
+ g_value_set_int (value, self->width);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
@@ -306,6 +318,7 @@ gdk_texture_dispose (GObject *object)
GdkTexture *self = GDK_TEXTURE (object);
gdk_texture_clear_render_data (self);
+ g_clear_object (&self->color_profile);
G_OBJECT_CLASS (gdk_texture_parent_class)->dispose (object);
}
@@ -324,14 +337,31 @@ gdk_texture_class_init (GdkTextureClass *klass)
gobject_class->dispose = gdk_texture_dispose;
/**
- * GdkTexture:width: (attributes org.gtk.Property.get=gdk_texture_get_width)
+ * GdkTexture:color-profile: (attributes org.gtk.Property.get=gdk_texture_get_color_profile)
*
- * The width of the texture, in pixels.
+ * The color profile associated with texture.
+ *
+ * Since: 4.6
*/
- properties[PROP_WIDTH] =
- g_param_spec_int ("width",
- "Width",
- "The width of the texture",
+ properties[PROP_COLOR_PROFILE] =
+ g_param_spec_object ("color-profile",
+ P_("Color Profile"),
+ P_("The associated color profile"),
+ GDK_TYPE_COLOR_PROFILE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS |
+ G_PARAM_EXPLICIT_NOTIFY);
+
+ /**
+ * GdkTexture:height: (attributes org.gtk.Property.get=gdk_texture_get_height)
+ *
+ * The height of the texture, in pixels.
+ */
+ properties[PROP_HEIGHT] =
+ g_param_spec_int ("height",
+ P_("Height"),
+ P_("The height of the texture"),
1,
G_MAXINT,
1,
@@ -341,14 +371,14 @@ gdk_texture_class_init (GdkTextureClass *klass)
G_PARAM_EXPLICIT_NOTIFY);
/**
- * GdkTexture:height: (attributes org.gtk.Property.get=gdk_texture_get_height)
+ * GdkTexture:width: (attributes org.gtk.Property.get=gdk_texture_get_width)
*
- * The height of the texture, in pixels.
+ * The width of the texture, in pixels.
*/
- properties[PROP_HEIGHT] =
- g_param_spec_int ("height",
- "Height",
- "The height of the texture",
+ properties[PROP_WIDTH] =
+ g_param_spec_int ("width",
+ P_("Width"),
+ P_("The width of the texture"),
1,
G_MAXINT,
1,
@@ -692,6 +722,24 @@ gdk_texture_get_height (GdkTexture *texture)
return texture->height;
}
+/**
+ * gdk_texture_get_color_profile: (attributes org.gtk.Method.get_property=color-profile)
+ * @texture: a `GdkTexture`
+ *
+ * Returns the color profile associsated with @texture.
+ *
+ * Returns: the color profile of the `GdkTexture`
+ *
+ * Since: 4.6
+ */
+GdkColorProfile *
+gdk_texture_get_color_profile (GdkTexture *texture)
+{
+ g_return_val_if_fail (GDK_IS_TEXTURE (texture), 0);
+
+ return texture->color_profile;
+}
+
cairo_surface_t *
gdk_texture_download_surface (GdkTexture *texture)
{
diff --git a/gdk/gdktexture.h b/gdk/gdktexture.h
index 6a62c9fe50..1ab22e6ae3 100644
--- a/gdk/gdktexture.h
+++ b/gdk/gdktexture.h
@@ -84,6 +84,8 @@ GDK_AVAILABLE_IN_ALL
int gdk_texture_get_width (GdkTexture *texture) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
int gdk_texture_get_height (GdkTexture *texture) G_GNUC_PURE;
+GDK_AVAILABLE_IN_4_6
+GdkColorProfile * gdk_texture_get_color_profile (GdkTexture *texture) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
void gdk_texture_download (GdkTexture *texture,
diff --git a/gdk/gdktextureprivate.h b/gdk/gdktextureprivate.h
index 814ed5d92c..324e0f94f3 100644
--- a/gdk/gdktextureprivate.h
+++ b/gdk/gdktextureprivate.h
@@ -15,6 +15,7 @@ struct _GdkTexture
int width;
int height;
+ GdkColorProfile *color_profile;
gpointer render_key;
gpointer render_data;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]