[gtk/matthiasc/color-profile-rebased: 18/22] API: Add a new constructor for GL textures
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/color-profile-rebased: 18/22] API: Add a new constructor for GL textures
- Date: Mon, 9 May 2022 01:48:46 +0000 (UTC)
commit 6c8c7263a4156de0f8ebc078a8f5b0cded009eec
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Oct 3 16:03:14 2021 -0400
API: Add a new constructor for GL textures
Add a constructor that lets us provide more information
about the content of a GL texture, such as the color
profile, and whether it is premultiplied or flipped.
gdk/gdkgltexture.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++
gdk/gdkgltexture.h | 22 +++++++++++++++++++++
gdk/gdkgltextureprivate.h | 1 +
3 files changed, 72 insertions(+)
---
diff --git a/gdk/gdkgltexture.c b/gdk/gdkgltexture.c
index ac261665ce..4014202982 100644
--- a/gdk/gdkgltexture.c
+++ b/gdk/gdkgltexture.c
@@ -25,6 +25,7 @@
#include "gdkmemoryformatprivate.h"
#include "gdkmemorytextureprivate.h"
#include "gdktextureprivate.h"
+#include "gdkcolorprofile.h"
#include <epoxy/gl.h>
@@ -38,6 +39,7 @@ struct _GdkGLTexture {
GdkTexture parent_instance;
GdkGLContext *context;
+ GdkGLTextureFlags flags;
guint id;
GdkTexture *saved;
@@ -280,6 +282,12 @@ gdk_gl_texture_get_id (GdkGLTexture *self)
return self->id;
}
+GdkGLTextureFlags
+gdk_gl_texture_get_flags (GdkGLTexture *self)
+{
+ return self->flags;
+}
+
/**
* gdk_gl_texture_release:
* @self: a `GdkTexture` wrapping a GL texture
@@ -444,6 +452,45 @@ gdk_gl_texture_new (GdkGLContext *context,
int height,
GDestroyNotify destroy,
gpointer data)
+{
+ return gdk_gl_texture_new_with_color_profile (context, id,
+ width, height,
+ GDK_GL_TEXTURE_PREMULTIPLIED,
+ gdk_color_profile_get_srgb (),
+ destroy, data);
+}
+
+/**
+ * gdk_gl_texture_new_with_color_profile:
+ * @context: a `GdkGLContext`
+ * @id: the ID of a texture that was created with @context
+ * @width: the nominal width of the texture
+ * @height: the nominal height of the texture
+ * @flags: flags that describe the content of the texture
+ * @color_profile: the `GdkColorProfile` for the content of the texture
+ * @destroy: a destroy notify that will be called when the GL resources
+ * are released
+ * @data: data that gets passed to @destroy
+ *
+ * Creates a new texture for an existing GL texture with a given color profile.
+ *
+ * Note that the GL texture must not be modified until @destroy is called,
+ * which will happen when the GdkTexture object is finalized, or due to
+ * an explicit call of [method@Gdk.GLTexture.release].
+ *
+ * Return value: (transfer full): A newly-created `GdkTexture`
+ *
+ * Since: 4.8
+ */
+GdkTexture *
+gdk_gl_texture_new_with_color_profile (GdkGLContext *context,
+ guint id,
+ int width,
+ int height,
+ GdkGLTextureFlags flags,
+ GdkColorProfile *color_profile,
+ GDestroyNotify destroy,
+ gpointer data)
{
GdkGLTexture *self;
@@ -455,10 +502,12 @@ gdk_gl_texture_new (GdkGLContext *context,
self = g_object_new (GDK_TYPE_GL_TEXTURE,
"width", width,
"height", height,
+ "color-profile", color_profile,
NULL);
self->context = g_object_ref (context);
self->id = id;
+ self->flags = flags;
self->destroy = destroy;
self->data = data;
diff --git a/gdk/gdkgltexture.h b/gdk/gdkgltexture.h
index 54e4fee7e7..6ee77910dd 100644
--- a/gdk/gdkgltexture.h
+++ b/gdk/gdkgltexture.h
@@ -49,6 +49,28 @@ GdkTexture * gdk_gl_texture_new (GdkGLContext
GDestroyNotify destroy,
gpointer data);
+/**
+ * GdkGLTextureFlags:
+ * @GDK_GL_TEXTURE_FLAGS_PREMULTIPLIED: The alpha in the data is not premultiplied
+ * @GDK_GL_TEXTURE_FLAGS_FLIPPED: The data has the origin at the bottom
+ *
+ * Flags that describe the content of a GL texture.
+ */
+typedef enum {
+ GDK_GL_TEXTURE_PREMULTIPLIED = 1 << 0,
+ GDK_GL_TEXTURE_FLIPPED = 1 << 1,
+} GdkGLTextureFlags;
+
+GDK_AVAILABLE_IN_4_8
+GdkTexture * gdk_gl_texture_new_with_color_profile (GdkGLContext *context,
+ guint id,
+ int width,
+ int height,
+ GdkGLTextureFlags flags,
+ GdkColorProfile *color_profile,
+ GDestroyNotify destroy,
+ gpointer data);
+
GDK_AVAILABLE_IN_ALL
void gdk_gl_texture_release (GdkGLTexture *self);
diff --git a/gdk/gdkgltextureprivate.h b/gdk/gdkgltextureprivate.h
index 06035eea07..9906d878df 100644
--- a/gdk/gdkgltextureprivate.h
+++ b/gdk/gdkgltextureprivate.h
@@ -9,6 +9,7 @@ G_BEGIN_DECLS
GdkGLContext * gdk_gl_texture_get_context (GdkGLTexture *self);
guint gdk_gl_texture_get_id (GdkGLTexture *self);
+GdkGLTextureFlags gdk_gl_texture_get_flags (GdkGLTexture *self);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]