[gtk/matthiasc/color-profile-rebased: 3/46] API: Add a GdkTexture::color-profile property
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/color-profile-rebased: 3/46] API: Add a GdkTexture::color-profile property
- Date: Tue, 10 May 2022 13:15:48 +0000 (UTC)
commit 4ac6fb72fcd91db603242e2176842925d546d916
Author: Benjamin Otte <otte redhat com>
Date: Mon Sep 20 09:44:32 2021 +0200
API: Add a GdkTexture::color-profile property
Returns the associated color profile. For now, this is always sRGB.
gdk/gdktexture.c | 86 ++++++++++++++++++++++++++++++++++++++-----------
gdk/gdktexture.h | 2 ++
gdk/gdktextureprivate.h | 1 +
3 files changed, 70 insertions(+), 19 deletions(-)
---
diff --git a/gdk/gdktexture.c b/gdk/gdktexture.c
index c8d7730c6d..6beea11431 100644
--- a/gdk/gdktexture.c
+++ b/gdk/gdktexture.c
@@ -39,6 +39,7 @@
#include "gdktextureprivate.h"
+#include "gdkcolorprofile.h"
#include "gdkintl.h"
#include "gdkmemorytextureprivate.h"
#include "gdkpaintable.h"
@@ -59,8 +60,9 @@ gtk_snapshot_append_texture (GdkSnapshot *snapshot,
enum {
PROP_0,
- PROP_WIDTH,
+ PROP_COLOR_PROFILE,
PROP_HEIGHT,
+ PROP_WIDTH,
N_PROPS
};
@@ -239,14 +241,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;
@@ -263,14 +271,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;
@@ -283,6 +295,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);
}
@@ -299,14 +312,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.8
*/
- 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,
@@ -316,14 +346,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,
@@ -365,7 +395,7 @@ gdk_texture_new_for_surface (cairo_surface_t *surface)
* cairo_image_surface_get_stride (surface),
(GDestroyNotify) cairo_surface_destroy,
cairo_surface_reference (surface));
-
+
texture = gdk_memory_texture_new (cairo_image_surface_get_width (surface),
cairo_image_surface_get_height (surface),
GDK_MEMORY_DEFAULT,
@@ -669,6 +699,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: (transfer none): the color profile of the `GdkTexture`
+ *
+ * Since: 4.8
+ */
+GdkColorProfile *
+gdk_texture_get_color_profile (GdkTexture *texture)
+{
+ g_return_val_if_fail (GDK_IS_TEXTURE (texture), 0);
+
+ return texture->color_profile;
+}
+
void
gdk_texture_do_download (GdkTexture *texture,
GdkMemoryFormat format,
@@ -755,7 +803,7 @@ gdk_texture_set_render_data (GdkTexture *self,
GDestroyNotify notify)
{
g_return_val_if_fail (data != NULL, FALSE);
-
+
if (self->render_key != NULL)
return FALSE;
diff --git a/gdk/gdktexture.h b/gdk/gdktexture.h
index 531ae3bbde..b56849279b 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_8
+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 fd9f78053e..42b6a16266 100644
--- a/gdk/gdktextureprivate.h
+++ b/gdk/gdktextureprivate.h
@@ -18,6 +18,7 @@ struct _GdkTexture
GdkMemoryFormat format;
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]