mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-08 09:40:10 +00:00
gl texture: color state support
This commit is contained in:
parent
77da45a173
commit
0ee8ca43d1
@ -511,7 +511,7 @@ gdk_gl_texture_new_from_builder (GdkGLTextureBuilder *builder,
|
||||
self = g_object_new (GDK_TYPE_GL_TEXTURE,
|
||||
"width", gdk_gl_texture_builder_get_width (builder),
|
||||
"height", gdk_gl_texture_builder_get_height (builder),
|
||||
"color-state", GDK_COLOR_STATE_SRGB,
|
||||
"color-state", gdk_gl_texture_builder_get_color_state (builder),
|
||||
NULL);
|
||||
|
||||
self->context = g_object_ref (gdk_gl_texture_builder_get_context (builder));
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "gdkenumtypes.h"
|
||||
#include "gdkglcontext.h"
|
||||
#include "gdkcolorstate.h"
|
||||
#include "gdkgltextureprivate.h"
|
||||
|
||||
#include <cairo-gobject.h>
|
||||
@ -38,6 +39,7 @@ struct _GdkGLTextureBuilder
|
||||
GdkMemoryFormat format;
|
||||
gboolean has_mipmap;
|
||||
gpointer sync;
|
||||
GdkColorState *color_state;
|
||||
|
||||
GdkTexture *update_texture;
|
||||
cairo_region_t *update_region;
|
||||
@ -75,6 +77,7 @@ enum
|
||||
PROP_HEIGHT,
|
||||
PROP_ID,
|
||||
PROP_SYNC,
|
||||
PROP_COLOR_STATE,
|
||||
PROP_UPDATE_REGION,
|
||||
PROP_UPDATE_TEXTURE,
|
||||
PROP_WIDTH,
|
||||
@ -95,6 +98,7 @@ gdk_gl_texture_builder_dispose (GObject *object)
|
||||
|
||||
g_clear_object (&self->update_texture);
|
||||
g_clear_pointer (&self->update_region, cairo_region_destroy);
|
||||
g_clear_pointer (&self->color_state, gdk_color_state_unref);
|
||||
|
||||
G_OBJECT_CLASS (gdk_gl_texture_builder_parent_class)->dispose (object);
|
||||
}
|
||||
@ -133,6 +137,10 @@ gdk_gl_texture_builder_get_property (GObject *object,
|
||||
g_value_set_pointer (value, self->sync);
|
||||
break;
|
||||
|
||||
case PROP_COLOR_STATE:
|
||||
g_value_set_boxed (value, self->color_state);
|
||||
break;
|
||||
|
||||
case PROP_UPDATE_REGION:
|
||||
g_value_set_boxed (value, self->update_region);
|
||||
break;
|
||||
@ -185,6 +193,10 @@ gdk_gl_texture_builder_set_property (GObject *object,
|
||||
gdk_gl_texture_builder_set_sync (self, g_value_get_pointer (value));
|
||||
break;
|
||||
|
||||
case PROP_COLOR_STATE:
|
||||
gdk_gl_texture_builder_set_color_state (self, g_value_get_boxed (value));
|
||||
break;
|
||||
|
||||
case PROP_UPDATE_REGION:
|
||||
gdk_gl_texture_builder_set_update_region (self, g_value_get_boxed (value));
|
||||
break;
|
||||
@ -286,6 +298,18 @@ gdk_gl_texture_builder_class_init (GdkGLTextureBuilderClass *klass)
|
||||
g_param_spec_pointer ("sync", NULL, NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkGLTextureBuilder:color-state:
|
||||
*
|
||||
* The color state of the texture.
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
properties[PROP_COLOR_STATE] =
|
||||
g_param_spec_boxed ("color-state", NULL, NULL,
|
||||
GDK_TYPE_COLOR_STATE,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GdkGLTextureBuilder:update-region: (attributes org.gtk.Property.get=gdk_gl_texture_builder_get_update_region org.gtk.Property.set=gdk_gl_texture_builder_set_update_region)
|
||||
*
|
||||
@ -329,6 +353,7 @@ static void
|
||||
gdk_gl_texture_builder_init (GdkGLTextureBuilder *self)
|
||||
{
|
||||
self->format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
|
||||
self->color_state = gdk_color_state_ref (gdk_color_state_get_srgb ());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -616,6 +641,51 @@ gdk_gl_texture_builder_set_sync (GdkGLTextureBuilder *self,
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SYNC]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_get_color_state: (attributes org.gtk.Method.get_property=color-state)
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
*
|
||||
* Gets the color state previously set via gdk_gl_texture_builder_set_color_state().
|
||||
*
|
||||
* Returns: the color state
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
GdkColorState *
|
||||
gdk_gl_texture_builder_get_color_state (GdkGLTextureBuilder *self)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self), NULL);
|
||||
|
||||
return self->color_state;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_set_color_state: (attributes org.gtk.Method.set_property=color-state)
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
* @color_state: a `GdkColorState`
|
||||
*
|
||||
* Sets the color state for the texture.
|
||||
*
|
||||
* By default, the sRGB colorstate is used. If you don't know what
|
||||
* colorstates are, this is probably the right thing.
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
void
|
||||
gdk_gl_texture_builder_set_color_state (GdkGLTextureBuilder *self,
|
||||
GdkColorState *color_state)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_GL_TEXTURE_BUILDER (self));
|
||||
g_return_if_fail (color_state != NULL);
|
||||
|
||||
if (gdk_color_state_equal (self->color_state, color_state))
|
||||
return;
|
||||
|
||||
g_clear_pointer (&self->color_state, gdk_color_state_unref);
|
||||
self->color_state = gdk_color_state_ref (color_state);
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_COLOR_STATE]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_texture_builder_get_format: (attributes org.gtk.Method.get_property=format)
|
||||
* @self: a `GdkGLTextureBuilder`
|
||||
|
@ -76,6 +76,12 @@ GDK_AVAILABLE_IN_4_12
|
||||
void gdk_gl_texture_builder_set_sync (GdkGLTextureBuilder *self,
|
||||
gpointer sync);
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GdkColorState * gdk_gl_texture_builder_get_color_state (GdkGLTextureBuilder *self);
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
void gdk_gl_texture_builder_set_color_state (GdkGLTextureBuilder *self,
|
||||
GdkColorState *color_state);
|
||||
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
GdkTexture * gdk_gl_texture_builder_get_update_texture (GdkGLTextureBuilder *self) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
|
Loading…
Reference in New Issue
Block a user