1
0
Fork 0

cogl: Generate a GType for PixelFormat

So that CoglTexture uses the proper pspec type for it format property

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3357>
This commit is contained in:
Bilal Elmoussaoui 2024-01-02 14:18:04 +01:00 committed by Marge Bot
parent e7ba16689d
commit 63a558950b
5 changed files with 91 additions and 4 deletions

View file

@ -0,0 +1,40 @@
/*** BEGIN file-header ***/
#include "config.h"
#include "cogl/cogl-enum-types.h"
/*** END file-header ***/
/*** BEGIN file-production ***/
/* enumerations from "@filename@" */
#include "@filename@"
/*** END file-production ***/
/*** BEGIN value-header ***/
GType
@enum_name@_get_type (void)
{
static size_t g_enum_type_id = 0;
if (g_once_init_enter (&g_enum_type_id))
{
static const G@Type@Value values[] = {
/*** END value-header ***/
/*** BEGIN value-production ***/
{ @VALUENAME@, "@VALUENAME@", "@valuenick@" },
/*** END value-production ***/
/*** BEGIN value-tail ***/
{ 0, NULL, NULL }
};
GType id;
id = g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
g_once_init_leave (&g_enum_type_id, id);
}
return g_enum_type_id;
}
/*** END value-tail ***/

View file

@ -0,0 +1,27 @@
/*** BEGIN file-header ***/
#pragma once
#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
#error "Only <cogl/cogl.h> can be included directly."
#endif
#include "cogl/cogl-types.h"
G_BEGIN_DECLS
/*** END file-header ***/
/*** BEGIN file-production ***/
/* enumerations from "@basename@" */
/*** END file-production ***/
/*** BEGIN value-header ***/
COGL_EXPORT GType @enum_name@_get_type (void) G_GNUC_CONST;
#define COGL_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
/*** END value-header ***/
/*** BEGIN file-tail ***/
G_END_DECLS
/*** END file-tail ***/

View file

@ -40,6 +40,7 @@
#include "cogl/cogl-bitmap.h" #include "cogl/cogl-bitmap.h"
#include "cogl/cogl-bitmap-private.h" #include "cogl/cogl-bitmap-private.h"
#include "cogl/cogl-buffer-private.h" #include "cogl/cogl-buffer-private.h"
#include "cogl/cogl-enum-types.h"
#include "cogl/cogl-pixel-buffer-private.h" #include "cogl/cogl-pixel-buffer-private.h"
#include "cogl/cogl-private.h" #include "cogl/cogl-private.h"
#include "cogl/cogl-texture-private.h" #include "cogl/cogl-texture-private.h"
@ -135,7 +136,7 @@ cogl_texture_set_property (GObject *gobject,
break; break;
case PROP_FORMAT: case PROP_FORMAT:
_cogl_texture_set_internal_format (texture, g_value_get_uint (value)); _cogl_texture_set_internal_format (texture, g_value_get_enum (value));
/* Although we want to initialize texture::components according /* Although we want to initialize texture::components according
* to the source format, we always want the internal layout to * to the source format, we always want the internal layout to
* be considered premultiplied by default. * be considered premultiplied by default.
@ -188,8 +189,8 @@ cogl_texture_class_init (CoglTextureClass *klass)
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_FORMAT] = obj_props[PROP_FORMAT] =
g_param_spec_uint ("format", NULL, NULL, g_param_spec_enum ("format", NULL, NULL,
COGL_PIXEL_FORMAT_ANY, G_MAXINT, COGL_TYPE_PIXEL_FORMAT,
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);

View file

@ -85,6 +85,7 @@
#include "cogl/cogl-atlas-texture.h" #include "cogl/cogl-atlas-texture.h"
#include "cogl/cogl-meta-texture.h" #include "cogl/cogl-meta-texture.h"
#include "cogl/cogl-primitive-texture.h" #include "cogl/cogl-primitive-texture.h"
#include "cogl/cogl-enum-types.h"
#include "cogl/cogl-index-buffer.h" #include "cogl/cogl-index-buffer.h"
#include "cogl/cogl-attribute-buffer.h" #include "cogl/cogl-attribute-buffer.h"
#include "cogl/cogl-indices.h" #include "cogl/cogl-indices.h"

View file

@ -18,7 +18,6 @@ cogl_headers = [
'cogl-pipeline-layer-state.h', 'cogl-pipeline-layer-state.h',
'cogl-pipeline-state.h', 'cogl-pipeline-state.h',
'cogl-pipeline.h', 'cogl-pipeline.h',
'cogl-pixel-format.h',
'cogl-snippet.h', 'cogl-snippet.h',
'cogl-texture-2d-sliced.h', 'cogl-texture-2d-sliced.h',
'cogl-texture-2d.h', 'cogl-texture-2d.h',
@ -356,7 +355,26 @@ if have_egl_xlib
] ]
endif endif
cogl_enum_headers = [
'cogl-pixel-format.h',
]
cogl_headers += [
cogl_enum_headers,
]
cogl_enums = gnome.mkenums('cogl-enums',
sources: cogl_enum_headers,
c_template: 'cogl-enum-types.c.in',
h_template: 'cogl-enum-types.h.in',
install_dir: cogl_cogl_includedir,
install_header: true,
)
cogl_sources += [cogl_enums[0]]
cogl_introspected_headers = [ cogl_introspected_headers = [
cogl_enums[1],
cogl_headers, cogl_headers,
cogl_deprecated_headers, cogl_deprecated_headers,
] ]