cogl/texture: Add a is-primitive property

Avoids accessing texture's private struct from sub-types.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4100>
This commit is contained in:
Bilal Elmoussaoui
2024-10-20 10:58:47 +02:00
committed by Marge Bot
parent cc3bf059e6
commit 80316eb1d6
6 changed files with 10 additions and 15 deletions

View File

@ -832,9 +832,6 @@ cogl_atlas_texture_class_init (CoglAtlasTextureClass *klass)
static void static void
cogl_atlas_texture_init (CoglAtlasTexture *self) cogl_atlas_texture_init (CoglAtlasTexture *self)
{ {
CoglTexture *texture = COGL_TEXTURE (self);
texture->is_primitive = FALSE;
} }
static CoglTexture * static CoglTexture *

View File

@ -383,9 +383,6 @@ cogl_sub_texture_class_init (CoglSubTextureClass *klass)
static void static void
cogl_sub_texture_init (CoglSubTexture *self) cogl_sub_texture_init (CoglSubTexture *self)
{ {
CoglTexture *texture = COGL_TEXTURE (self);
texture->is_primitive = FALSE;
} }
CoglTexture * CoglTexture *

View File

@ -1205,9 +1205,6 @@ cogl_texture_2d_sliced_class_init (CoglTexture2DSlicedClass *klass)
static void static void
cogl_texture_2d_sliced_init (CoglTexture2DSliced *self) cogl_texture_2d_sliced_init (CoglTexture2DSliced *self)
{ {
CoglTexture *texture = COGL_TEXTURE (self);
texture->is_primitive = FALSE;
} }
static CoglTexture * static CoglTexture *

View File

@ -85,6 +85,7 @@ _cogl_texture_2d_create_base (CoglContext *ctx,
"height", height, "height", height,
"loader", loader, "loader", loader,
"format", internal_format, "format", internal_format,
"is-primitive", TRUE,
NULL); NULL);
tex_2d->mipmaps_dirty = TRUE; tex_2d->mipmaps_dirty = TRUE;
tex_2d->auto_mipmap = TRUE; tex_2d->auto_mipmap = TRUE;
@ -346,9 +347,6 @@ cogl_texture_2d_class_init (CoglTexture2DClass *klass)
static void static void
cogl_texture_2d_init (CoglTexture2D *self) cogl_texture_2d_init (CoglTexture2D *self)
{ {
CoglTexture *texture = COGL_TEXTURE (self);
texture->is_primitive = TRUE;
} }
CoglTexture * CoglTexture *

View File

@ -70,6 +70,7 @@ enum
PROP_HEIGHT, PROP_HEIGHT,
PROP_LOADER, PROP_LOADER,
PROP_FORMAT, PROP_FORMAT,
PROP_IS_PRIMITIVE,
PROP_LAST PROP_LAST
}; };
@ -151,6 +152,10 @@ cogl_texture_set_property (GObject *gobject,
texture->premultiplied = TRUE; texture->premultiplied = TRUE;
break; break;
case PROP_IS_PRIMITIVE:
texture->is_primitive = g_value_get_boolean (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break; break;
@ -192,6 +197,10 @@ cogl_texture_class_init (CoglTextureClass *klass)
COGL_PIXEL_FORMAT_ANY, COGL_PIXEL_FORMAT_ANY,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS); G_PARAM_STATIC_STRINGS);
obj_props[PROP_IS_PRIMITIVE] =
g_param_spec_boolean ("is-primitive", NULL, NULL,
FALSE, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, g_object_class_install_properties (gobject_class,
PROP_LAST, PROP_LAST,

View File

@ -984,9 +984,6 @@ cogl_texture_pixmap_x11_class_init (CoglTexturePixmapX11Class *klass)
static void static void
cogl_texture_pixmap_x11_init (CoglTexturePixmapX11 *self) cogl_texture_pixmap_x11_init (CoglTexturePixmapX11 *self)
{ {
CoglTexture *texture = COGL_TEXTURE (self);
texture->is_primitive = FALSE;
} }
uint32_t uint32_t