From 80316eb1d6b4171ab44a377b53f1c1e9a2f5c886 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sun, 20 Oct 2024 10:58:47 +0200 Subject: [PATCH] cogl/texture: Add a is-primitive property Avoids accessing texture's private struct from sub-types. Part-of: --- cogl/cogl/cogl-atlas-texture.c | 3 --- cogl/cogl/cogl-sub-texture.c | 3 --- cogl/cogl/cogl-texture-2d-sliced.c | 3 --- cogl/cogl/cogl-texture-2d.c | 4 +--- cogl/cogl/cogl-texture.c | 9 +++++++++ cogl/cogl/winsys/cogl-texture-pixmap-x11.c | 3 --- 6 files changed, 10 insertions(+), 15 deletions(-) diff --git a/cogl/cogl/cogl-atlas-texture.c b/cogl/cogl/cogl-atlas-texture.c index 41b30616c..873b08022 100644 --- a/cogl/cogl/cogl-atlas-texture.c +++ b/cogl/cogl/cogl-atlas-texture.c @@ -832,9 +832,6 @@ cogl_atlas_texture_class_init (CoglAtlasTextureClass *klass) static void cogl_atlas_texture_init (CoglAtlasTexture *self) { - CoglTexture *texture = COGL_TEXTURE (self); - - texture->is_primitive = FALSE; } static CoglTexture * diff --git a/cogl/cogl/cogl-sub-texture.c b/cogl/cogl/cogl-sub-texture.c index 7a22122a7..692c578ee 100644 --- a/cogl/cogl/cogl-sub-texture.c +++ b/cogl/cogl/cogl-sub-texture.c @@ -383,9 +383,6 @@ cogl_sub_texture_class_init (CoglSubTextureClass *klass) static void cogl_sub_texture_init (CoglSubTexture *self) { - CoglTexture *texture = COGL_TEXTURE (self); - - texture->is_primitive = FALSE; } CoglTexture * diff --git a/cogl/cogl/cogl-texture-2d-sliced.c b/cogl/cogl/cogl-texture-2d-sliced.c index 6a8df1eb4..7c3981e6a 100644 --- a/cogl/cogl/cogl-texture-2d-sliced.c +++ b/cogl/cogl/cogl-texture-2d-sliced.c @@ -1205,9 +1205,6 @@ cogl_texture_2d_sliced_class_init (CoglTexture2DSlicedClass *klass) static void cogl_texture_2d_sliced_init (CoglTexture2DSliced *self) { - CoglTexture *texture = COGL_TEXTURE (self); - - texture->is_primitive = FALSE; } static CoglTexture * diff --git a/cogl/cogl/cogl-texture-2d.c b/cogl/cogl/cogl-texture-2d.c index d08e53a2d..94cbb16ef 100644 --- a/cogl/cogl/cogl-texture-2d.c +++ b/cogl/cogl/cogl-texture-2d.c @@ -85,6 +85,7 @@ _cogl_texture_2d_create_base (CoglContext *ctx, "height", height, "loader", loader, "format", internal_format, + "is-primitive", TRUE, NULL); tex_2d->mipmaps_dirty = TRUE; tex_2d->auto_mipmap = TRUE; @@ -346,9 +347,6 @@ cogl_texture_2d_class_init (CoglTexture2DClass *klass) static void cogl_texture_2d_init (CoglTexture2D *self) { - CoglTexture *texture = COGL_TEXTURE (self); - - texture->is_primitive = TRUE; } CoglTexture * diff --git a/cogl/cogl/cogl-texture.c b/cogl/cogl/cogl-texture.c index a20b06217..6d0902614 100644 --- a/cogl/cogl/cogl-texture.c +++ b/cogl/cogl/cogl-texture.c @@ -70,6 +70,7 @@ enum PROP_HEIGHT, PROP_LOADER, PROP_FORMAT, + PROP_IS_PRIMITIVE, PROP_LAST }; @@ -151,6 +152,10 @@ cogl_texture_set_property (GObject *gobject, texture->premultiplied = TRUE; break; + case PROP_IS_PRIMITIVE: + texture->is_primitive = g_value_get_boolean (value); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); break; @@ -192,6 +197,10 @@ cogl_texture_class_init (CoglTextureClass *klass) COGL_PIXEL_FORMAT_ANY, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | 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, PROP_LAST, diff --git a/cogl/cogl/winsys/cogl-texture-pixmap-x11.c b/cogl/cogl/winsys/cogl-texture-pixmap-x11.c index 0314598d3..f904b0593 100644 --- a/cogl/cogl/winsys/cogl-texture-pixmap-x11.c +++ b/cogl/cogl/winsys/cogl-texture-pixmap-x11.c @@ -984,9 +984,6 @@ cogl_texture_pixmap_x11_class_init (CoglTexturePixmapX11Class *klass) static void cogl_texture_pixmap_x11_init (CoglTexturePixmapX11 *self) { - CoglTexture *texture = COGL_TEXTURE (self); - - texture->is_primitive = FALSE; } uint32_t