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.
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user