mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 01:50:42 -05:00
cogl: Port Indices away from CoglObject
Also renames Indices.get_type to Indices.get_indices_type to avoid a conflict with the generated Object.get_type function Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
This commit is contained in:
parent
4ea3593ebf
commit
df8ae83040
@ -488,7 +488,7 @@ clutter_deform_effect_init_arrays (ClutterDeformEffect *self)
|
|||||||
n_indices);
|
n_indices);
|
||||||
}
|
}
|
||||||
|
|
||||||
cogl_object_unref (indices);
|
g_object_unref (indices);
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
g_object_unref (attributes[i]);
|
g_object_unref (attributes[i]);
|
||||||
|
@ -95,9 +95,9 @@ cogl_context_dispose (GObject *object)
|
|||||||
g_array_free (context->journal_clip_bounds, TRUE);
|
g_array_free (context->journal_clip_bounds, TRUE);
|
||||||
|
|
||||||
if (context->rectangle_byte_indices)
|
if (context->rectangle_byte_indices)
|
||||||
cogl_object_unref (context->rectangle_byte_indices);
|
g_object_unref (context->rectangle_byte_indices);
|
||||||
if (context->rectangle_short_indices)
|
if (context->rectangle_short_indices)
|
||||||
cogl_object_unref (context->rectangle_short_indices);
|
g_object_unref (context->rectangle_short_indices);
|
||||||
|
|
||||||
if (context->default_pipeline)
|
if (context->default_pipeline)
|
||||||
cogl_object_unref (context->default_pipeline);
|
cogl_object_unref (context->default_pipeline);
|
||||||
|
@ -2195,7 +2195,7 @@ get_wire_line_indices (CoglContext *ctx,
|
|||||||
indices = _cogl_buffer_map (COGL_BUFFER (index_buffer),
|
indices = _cogl_buffer_map (COGL_BUFFER (index_buffer),
|
||||||
COGL_BUFFER_ACCESS_READ, 0,
|
COGL_BUFFER_ACCESS_READ, 0,
|
||||||
NULL);
|
NULL);
|
||||||
indices_type = cogl_indices_get_type (user_indices);
|
indices_type = cogl_indices_get_indices_type (user_indices);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2375,7 +2375,7 @@ draw_wireframe (CoglContext *ctx,
|
|||||||
flags);
|
flags);
|
||||||
COGL_DEBUG_SET_FLAG (COGL_DEBUG_WIREFRAME);
|
COGL_DEBUG_SET_FLAG (COGL_DEBUG_WIREFRAME);
|
||||||
|
|
||||||
cogl_object_unref (wire_indices);
|
g_object_unref (wire_indices);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -33,13 +33,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cogl/cogl-object-private.h"
|
|
||||||
#include "cogl/cogl-index-buffer-private.h"
|
#include "cogl/cogl-index-buffer-private.h"
|
||||||
#include "cogl/cogl-types.h"
|
#include "cogl/cogl-types.h"
|
||||||
|
|
||||||
struct _CoglIndices
|
struct _CoglIndices
|
||||||
{
|
{
|
||||||
CoglObject _parent;
|
GObject parent_instance;
|
||||||
|
|
||||||
CoglIndexBuffer *buffer;
|
CoglIndexBuffer *buffer;
|
||||||
size_t offset;
|
size_t offset;
|
||||||
|
@ -35,19 +35,37 @@
|
|||||||
#include "cogl-config.h"
|
#include "cogl-config.h"
|
||||||
|
|
||||||
#include "cogl/cogl-util.h"
|
#include "cogl/cogl-util.h"
|
||||||
#include "cogl/cogl-object-private.h"
|
|
||||||
#include "cogl/cogl-context-private.h"
|
#include "cogl/cogl-context-private.h"
|
||||||
#include "cogl/cogl-indices.h"
|
#include "cogl/cogl-indices.h"
|
||||||
#include "cogl/cogl-indices-private.h"
|
#include "cogl/cogl-indices-private.h"
|
||||||
#include "cogl/cogl-index-buffer.h"
|
#include "cogl/cogl-index-buffer.h"
|
||||||
#include "cogl/cogl-gtype-private.h"
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
static void _cogl_indices_free (CoglIndices *indices);
|
G_DEFINE_TYPE (CoglIndices, cogl_indices, G_TYPE_OBJECT);
|
||||||
|
|
||||||
COGL_OBJECT_DEFINE (Indices, indices);
|
static void
|
||||||
COGL_GTYPE_DEFINE_CLASS (Indices, indices);
|
cogl_indices_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
CoglIndices *indices = COGL_INDICES (object);
|
||||||
|
|
||||||
|
cogl_object_unref (indices->buffer);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (cogl_indices_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cogl_indices_init (CoglIndices *indices)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cogl_indices_class_init (CoglIndicesClass *class)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||||
|
|
||||||
|
object_class->dispose = cogl_indices_dispose;
|
||||||
|
}
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
sizeof_indices_type (CoglIndicesType type)
|
sizeof_indices_type (CoglIndicesType type)
|
||||||
@ -69,7 +87,7 @@ cogl_indices_new_for_buffer (CoglIndicesType type,
|
|||||||
CoglIndexBuffer *buffer,
|
CoglIndexBuffer *buffer,
|
||||||
size_t offset)
|
size_t offset)
|
||||||
{
|
{
|
||||||
CoglIndices *indices = g_new0 (CoglIndices, 1);
|
CoglIndices *indices = g_object_new (COGL_TYPE_INDICES, NULL);
|
||||||
|
|
||||||
indices->buffer = cogl_object_ref (buffer);
|
indices->buffer = cogl_object_ref (buffer);
|
||||||
indices->offset = offset;
|
indices->offset = offset;
|
||||||
@ -78,7 +96,7 @@ cogl_indices_new_for_buffer (CoglIndicesType type,
|
|||||||
|
|
||||||
indices->immutable_ref = 0;
|
indices->immutable_ref = 0;
|
||||||
|
|
||||||
return _cogl_indices_object_new (indices);
|
return indices;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoglIndices *
|
CoglIndices *
|
||||||
@ -118,9 +136,9 @@ cogl_indices_get_buffer (CoglIndices *indices)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CoglIndicesType
|
CoglIndicesType
|
||||||
cogl_indices_get_type (CoglIndices *indices)
|
cogl_indices_get_indices_type (CoglIndices *indices)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (cogl_is_indices (indices),
|
g_return_val_if_fail (COGL_IS_INDICES (indices),
|
||||||
COGL_INDICES_TYPE_UNSIGNED_BYTE);
|
COGL_INDICES_TYPE_UNSIGNED_BYTE);
|
||||||
return indices->type;
|
return indices->type;
|
||||||
}
|
}
|
||||||
@ -128,7 +146,7 @@ cogl_indices_get_type (CoglIndices *indices)
|
|||||||
size_t
|
size_t
|
||||||
cogl_indices_get_offset (CoglIndices *indices)
|
cogl_indices_get_offset (CoglIndices *indices)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (cogl_is_indices (indices), 0);
|
g_return_val_if_fail (COGL_IS_INDICES (indices), 0);
|
||||||
|
|
||||||
return indices->offset;
|
return indices->offset;
|
||||||
}
|
}
|
||||||
@ -149,7 +167,7 @@ void
|
|||||||
cogl_indices_set_offset (CoglIndices *indices,
|
cogl_indices_set_offset (CoglIndices *indices,
|
||||||
size_t offset)
|
size_t offset)
|
||||||
{
|
{
|
||||||
g_return_if_fail (cogl_is_indices (indices));
|
g_return_if_fail (COGL_IS_INDICES (indices));
|
||||||
|
|
||||||
if (G_UNLIKELY (indices->immutable_ref))
|
if (G_UNLIKELY (indices->immutable_ref))
|
||||||
warn_about_midscene_changes ();
|
warn_about_midscene_changes ();
|
||||||
@ -157,17 +175,10 @@ cogl_indices_set_offset (CoglIndices *indices,
|
|||||||
indices->offset = offset;
|
indices->offset = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
_cogl_indices_free (CoglIndices *indices)
|
|
||||||
{
|
|
||||||
cogl_object_unref (indices->buffer);
|
|
||||||
g_free (indices);
|
|
||||||
}
|
|
||||||
|
|
||||||
CoglIndices *
|
CoglIndices *
|
||||||
_cogl_indices_immutable_ref (CoglIndices *indices)
|
_cogl_indices_immutable_ref (CoglIndices *indices)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (cogl_is_indices (indices), NULL);
|
g_return_val_if_fail (COGL_IS_INDICES (indices), NULL);
|
||||||
|
|
||||||
indices->immutable_ref++;
|
indices->immutable_ref++;
|
||||||
_cogl_buffer_immutable_ref (COGL_BUFFER (indices->buffer));
|
_cogl_buffer_immutable_ref (COGL_BUFFER (indices->buffer));
|
||||||
@ -177,7 +188,7 @@ _cogl_indices_immutable_ref (CoglIndices *indices)
|
|||||||
void
|
void
|
||||||
_cogl_indices_immutable_unref (CoglIndices *indices)
|
_cogl_indices_immutable_unref (CoglIndices *indices)
|
||||||
{
|
{
|
||||||
g_return_if_fail (cogl_is_indices (indices));
|
g_return_if_fail (COGL_IS_INDICES (indices));
|
||||||
g_return_if_fail (indices->immutable_ref > 0);
|
g_return_if_fail (indices->immutable_ref > 0);
|
||||||
|
|
||||||
indices->immutable_ref--;
|
indices->immutable_ref--;
|
||||||
@ -230,7 +241,7 @@ cogl_get_rectangle_indices (CoglContext *ctx, int n_rectangles)
|
|||||||
int i, vert_num = 0;
|
int i, vert_num = 0;
|
||||||
|
|
||||||
if (ctx->rectangle_short_indices != NULL)
|
if (ctx->rectangle_short_indices != NULL)
|
||||||
cogl_object_unref (ctx->rectangle_short_indices);
|
g_object_unref (ctx->rectangle_short_indices);
|
||||||
/* Pick a power of two >= MAX (512, n_indices) */
|
/* Pick a power of two >= MAX (512, n_indices) */
|
||||||
if (ctx->rectangle_short_indices_len == 0)
|
if (ctx->rectangle_short_indices_len == 0)
|
||||||
ctx->rectangle_short_indices_len = 512;
|
ctx->rectangle_short_indices_len = 512;
|
||||||
|
@ -49,8 +49,9 @@ typedef struct _CoglIndices CoglIndices;
|
|||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SECTION:cogl-indices
|
* CoglIndices:
|
||||||
* @short_description: Describe vertex indices stored in a #CoglIndexBuffer.
|
*
|
||||||
|
* Describe vertex indices stored in a #CoglIndexBuffer.
|
||||||
*
|
*
|
||||||
* Indices allow you to avoid duplicating vertices in your vertex data
|
* Indices allow you to avoid duplicating vertices in your vertex data
|
||||||
* by virtualizing your data and instead providing a sequence of index
|
* by virtualizing your data and instead providing a sequence of index
|
||||||
@ -106,13 +107,11 @@ G_BEGIN_DECLS
|
|||||||
* for drawing quads as above.
|
* for drawing quads as above.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
#define COGL_TYPE_INDICES (cogl_indices_get_type ())
|
||||||
* cogl_indices_get_gtype:
|
|
||||||
*
|
|
||||||
* Returns: a #GType that can be used with the GLib type system.
|
|
||||||
*/
|
|
||||||
COGL_EXPORT
|
COGL_EXPORT
|
||||||
GType cogl_indices_get_gtype (void);
|
G_DECLARE_FINAL_TYPE (CoglIndices, cogl_indices,
|
||||||
|
COGL, INDICES, GObject)
|
||||||
|
|
||||||
COGL_EXPORT CoglIndices *
|
COGL_EXPORT CoglIndices *
|
||||||
cogl_indices_new (CoglContext *context,
|
cogl_indices_new (CoglContext *context,
|
||||||
@ -129,7 +128,7 @@ COGL_EXPORT CoglIndexBuffer *
|
|||||||
cogl_indices_get_buffer (CoglIndices *indices);
|
cogl_indices_get_buffer (CoglIndices *indices);
|
||||||
|
|
||||||
COGL_EXPORT CoglIndicesType
|
COGL_EXPORT CoglIndicesType
|
||||||
cogl_indices_get_type (CoglIndices *indices);
|
cogl_indices_get_indices_type (CoglIndices *indices);
|
||||||
|
|
||||||
COGL_EXPORT size_t
|
COGL_EXPORT size_t
|
||||||
cogl_indices_get_offset (CoglIndices *indices);
|
cogl_indices_get_offset (CoglIndices *indices);
|
||||||
@ -141,16 +140,4 @@ cogl_indices_set_offset (CoglIndices *indices,
|
|||||||
COGL_EXPORT CoglIndices *
|
COGL_EXPORT CoglIndices *
|
||||||
cogl_get_rectangle_indices (CoglContext *context, int n_rectangles);
|
cogl_get_rectangle_indices (CoglContext *context, int n_rectangles);
|
||||||
|
|
||||||
/**
|
|
||||||
* cogl_is_indices:
|
|
||||||
* @object: A #CoglObject pointer
|
|
||||||
*
|
|
||||||
* Gets whether the given object references a #CoglIndices.
|
|
||||||
*
|
|
||||||
* Return value: %TRUE if the object references a #CoglIndices
|
|
||||||
* and %FALSE otherwise.
|
|
||||||
*/
|
|
||||||
COGL_EXPORT gboolean
|
|
||||||
cogl_is_indices (void *object);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
@ -387,7 +387,7 @@ _cogl_primitive_free (CoglPrimitive *primitive)
|
|||||||
g_free (primitive->attributes);
|
g_free (primitive->attributes);
|
||||||
|
|
||||||
if (primitive->indices)
|
if (primitive->indices)
|
||||||
cogl_object_unref (primitive->indices);
|
g_object_unref (primitive->indices);
|
||||||
|
|
||||||
g_free (primitive);
|
g_free (primitive);
|
||||||
}
|
}
|
||||||
@ -532,9 +532,9 @@ cogl_primitive_set_indices (CoglPrimitive *primitive,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (indices)
|
if (indices)
|
||||||
cogl_object_ref (indices);
|
g_object_ref (indices);
|
||||||
if (primitive->indices)
|
if (primitive->indices)
|
||||||
cogl_object_unref (primitive->indices);
|
g_object_unref (primitive->indices);
|
||||||
primitive->indices = indices;
|
primitive->indices = indices;
|
||||||
primitive->n_vertices = n_indices;
|
primitive->n_vertices = n_indices;
|
||||||
}
|
}
|
||||||
|
@ -383,9 +383,9 @@ cogl_gl_framebuffer_draw_indexed_attributes (CoglFramebufferDriver *driver,
|
|||||||
base = _cogl_buffer_gl_bind (buffer,
|
base = _cogl_buffer_gl_bind (buffer,
|
||||||
COGL_BUFFER_BIND_TARGET_INDEX_BUFFER, NULL);
|
COGL_BUFFER_BIND_TARGET_INDEX_BUFFER, NULL);
|
||||||
buffer_offset = cogl_indices_get_offset (indices);
|
buffer_offset = cogl_indices_get_offset (indices);
|
||||||
index_size = sizeof_index_type (cogl_indices_get_type (indices));
|
index_size = sizeof_index_type (cogl_indices_get_indices_type (indices));
|
||||||
|
|
||||||
switch (cogl_indices_get_type (indices))
|
switch (cogl_indices_get_indices_type (indices))
|
||||||
{
|
{
|
||||||
case COGL_INDICES_TYPE_UNSIGNED_BYTE:
|
case COGL_INDICES_TYPE_UNSIGNED_BYTE:
|
||||||
indices_gl_type = GL_UNSIGNED_BYTE;
|
indices_gl_type = GL_UNSIGNED_BYTE;
|
||||||
|
@ -303,7 +303,7 @@ test_copy (TestState *state)
|
|||||||
|
|
||||||
cogl_object_unref (prim_a);
|
cogl_object_unref (prim_a);
|
||||||
cogl_object_unref (prim_b);
|
cogl_object_unref (prim_b);
|
||||||
cogl_object_unref (indices);
|
g_object_unref (indices);
|
||||||
|
|
||||||
for (i = 0; i < N_ATTRIBS; i++)
|
for (i = 0; i < N_ATTRIBS; i++)
|
||||||
g_object_unref (attributes[i]);
|
g_object_unref (attributes[i]);
|
||||||
|
Loading…
Reference in New Issue
Block a user