[gtk/matthiasc/color-profiles: 120/140] texture: Add hdr api
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/color-profiles: 120/140] texture: Add hdr api
- Date: Sun, 3 Oct 2021 04:45:13 +0000 (UTC)
commit 52a671465406fa1e9e8c5576aebf042b9a7e605d
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Oct 1 16:20:56 2021 -0400
texture: Add hdr api
Add private api to find out if a texture should be
considered as HDR. For now, we consider float formats
and >8bit formats to be HDR.
gdk/gdkmemoryformat.c | 14 ++++++++++++++
gdk/gdkmemoryformatprivate.h | 1 +
gdk/gdkmemorytexture.c | 9 +++++++++
gdk/gdktexture.c | 14 ++++++++++++++
gdk/gdktextureprivate.h | 3 +++
5 files changed, 41 insertions(+)
---
diff --git a/gdk/gdkmemoryformat.c b/gdk/gdkmemoryformat.c
index 97fde93b86..182b3f37db 100644
--- a/gdk/gdkmemoryformat.c
+++ b/gdk/gdkmemoryformat.c
@@ -691,6 +691,20 @@ gdk_memory_format_gl_format (GdkMemoryFormat format,
return TRUE;
}
+gboolean
+gdk_memory_format_is_hdr (GdkMemoryFormat format)
+{
+ switch (memory_formats[format].gl.type)
+ {
+ case GL_FLOAT:
+ case GL_HALF_FLOAT:
+ case GL_UNSIGNED_SHORT:
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
+
static void
premultiply (float *rgba,
gsize n)
diff --git a/gdk/gdkmemoryformatprivate.h b/gdk/gdkmemoryformatprivate.h
index 348319c09b..fcaefd92b0 100644
--- a/gdk/gdkmemoryformatprivate.h
+++ b/gdk/gdkmemoryformatprivate.h
@@ -38,6 +38,7 @@ gboolean gdk_memory_format_gl_format (GdkMemoryFormat
guint *out_internal_format,
guint *out_format,
guint *out_type);
+gboolean gdk_memory_format_is_hdr (GdkMemoryFormat format);
void gdk_memory_convert (guchar *dest_data,
gsize dest_stride,
diff --git a/gdk/gdkmemorytexture.c b/gdk/gdkmemorytexture.c
index 4a5474bfe9..d436ed8969 100644
--- a/gdk/gdkmemorytexture.c
+++ b/gdk/gdkmemorytexture.c
@@ -101,6 +101,14 @@ gdk_memory_texture_download_float (GdkTexture *texture,
gdk_texture_get_height (texture));
}
+static gboolean
+gdk_memory_texture_is_hdr (GdkTexture *texture)
+{
+ GdkMemoryTexture *self = GDK_MEMORY_TEXTURE (texture);
+
+ return gdk_memory_format_is_hdr (self->format);
+}
+
static void
gdk_memory_texture_class_init (GdkMemoryTextureClass *klass)
{
@@ -110,6 +118,7 @@ gdk_memory_texture_class_init (GdkMemoryTextureClass *klass)
texture_class->download_texture = gdk_memory_texture_download_texture;
texture_class->download = gdk_memory_texture_download;
texture_class->download_float = gdk_memory_texture_download_float;
+ texture_class->is_hdr = gdk_memory_texture_is_hdr;
gobject_class->dispose = gdk_memory_texture_dispose;
}
diff --git a/gdk/gdktexture.c b/gdk/gdktexture.c
index 03b55a7fb6..e314634fc2 100644
--- a/gdk/gdktexture.c
+++ b/gdk/gdktexture.c
@@ -325,6 +325,12 @@ gdk_texture_dispose (GObject *object)
G_OBJECT_CLASS (gdk_texture_parent_class)->dispose (object);
}
+static gboolean
+gdk_texture_real_is_hdr (GdkTexture *texture)
+{
+ return FALSE;
+}
+
static void
gdk_texture_class_init (GdkTextureClass *klass)
{
@@ -333,6 +339,7 @@ gdk_texture_class_init (GdkTextureClass *klass)
klass->download_texture = gdk_texture_real_download_texture;
klass->download = gdk_texture_real_download;
klass->download_float = gdk_texture_real_download_float;
+ klass->is_hdr = gdk_texture_real_is_hdr;
gobject_class->set_property = gdk_texture_set_property;
gobject_class->get_property = gdk_texture_get_property;
@@ -1087,3 +1094,10 @@ gdk_texture_save_to_tiff_bytes (GdkTexture *texture)
return gdk_save_tiff (texture);
}
+gboolean
+gdk_texture_is_hdr (GdkTexture *texture)
+{
+ g_return_val_if_fail (GDK_IS_TEXTURE (texture), FALSE);
+
+ return GDK_TEXTURE_GET_CLASS (texture)->is_hdr (texture);
+}
diff --git a/gdk/gdktextureprivate.h b/gdk/gdktextureprivate.h
index 5c451ec8c8..760ea15702 100644
--- a/gdk/gdktextureprivate.h
+++ b/gdk/gdktextureprivate.h
@@ -34,10 +34,13 @@ struct _GdkTextureClass {
void (* download_float) (GdkTexture *texture,
float *data,
gsize stride);
+ gboolean (* is_hdr) (GdkTexture *texture);
};
gboolean gdk_texture_can_load (GBytes *bytes);
+gboolean gdk_texture_is_hdr (GdkTexture *self);
+
GdkTexture * gdk_texture_new_for_surface (cairo_surface_t *surface);
cairo_surface_t * gdk_texture_download_surface (GdkTexture *texture,
GdkColorProfile *color_profile);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]