mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 01:50:42 -05:00
cogl: Port Buffer* away from CoglObject
Make CoglBuffer an abstract class and inherit the various Cogl*Buffer types from it. As none of the subclasses is overriding the vtable functions, they were not turned into vfuncs but plain function pointers in CoglBuffer. We still use _cogl_buffer_initialize until we port the various params into actual construct-only properties, similar to the previous commit for CoglTexture. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
This commit is contained in:
parent
1d47e809e4
commit
739c59fefc
@ -337,7 +337,7 @@ clutter_deform_effect_free_arrays (ClutterDeformEffect *self)
|
||||
{
|
||||
ClutterDeformEffectPrivate *priv = self->priv;
|
||||
|
||||
cogl_clear_object (&priv->buffer);
|
||||
g_clear_object (&priv->buffer);
|
||||
cogl_clear_object (&priv->primitive);
|
||||
cogl_clear_object (&priv->lines_primitive);
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ emit_vertex_buffer_geometry (CoglFramebuffer *fb,
|
||||
|
||||
node->d.texture.primitive = prim;
|
||||
|
||||
cogl_object_unref (buffer);
|
||||
g_object_unref (buffer);
|
||||
g_object_unref (attributes[0]);
|
||||
g_object_unref (attributes[1]);
|
||||
}
|
||||
|
@ -37,5 +37,10 @@
|
||||
|
||||
struct _CoglAttributeBuffer
|
||||
{
|
||||
CoglBuffer _parent;
|
||||
CoglBuffer parent_instance;
|
||||
};
|
||||
|
||||
struct _CoglAttributeBufferClass
|
||||
{
|
||||
CoglBufferClass parent_class;
|
||||
};
|
||||
|
@ -33,22 +33,27 @@
|
||||
|
||||
#include "cogl-config.h"
|
||||
|
||||
#include "cogl/cogl-object-private.h"
|
||||
#include "cogl/cogl-attribute-buffer.h"
|
||||
#include "cogl/cogl-attribute-buffer-private.h"
|
||||
#include "cogl/cogl-context-private.h"
|
||||
#include "cogl/cogl-gtype-private.h"
|
||||
|
||||
static void _cogl_attribute_buffer_free (CoglAttributeBuffer *array);
|
||||
G_DEFINE_FINAL_TYPE (CoglAttributeBuffer, cogl_attribute_buffer, COGL_TYPE_BUFFER)
|
||||
|
||||
COGL_BUFFER_DEFINE (AttributeBuffer, attribute_buffer);
|
||||
COGL_GTYPE_DEFINE_CLASS (AttributeBuffer, attribute_buffer);
|
||||
static void
|
||||
cogl_attribute_buffer_class_init (CoglAttributeBufferClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
cogl_attribute_buffer_init (CoglAttributeBuffer *buffer)
|
||||
{
|
||||
}
|
||||
|
||||
CoglAttributeBuffer *
|
||||
cogl_attribute_buffer_new_with_size (CoglContext *context,
|
||||
size_t bytes)
|
||||
{
|
||||
CoglAttributeBuffer *buffer = g_new0 (CoglAttributeBuffer, 1);
|
||||
CoglAttributeBuffer *buffer = g_object_new (COGL_TYPE_ATTRIBUTE_BUFFER, NULL);
|
||||
|
||||
/* parent's constructor */
|
||||
_cogl_buffer_initialize (COGL_BUFFER (buffer),
|
||||
@ -58,7 +63,7 @@ cogl_attribute_buffer_new_with_size (CoglContext *context,
|
||||
COGL_BUFFER_USAGE_HINT_ATTRIBUTE_BUFFER,
|
||||
COGL_BUFFER_UPDATE_HINT_STATIC);
|
||||
|
||||
return _cogl_attribute_buffer_object_new (buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
CoglAttributeBuffer *
|
||||
@ -90,13 +95,3 @@ cogl_attribute_buffer_new (CoglContext *context,
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_attribute_buffer_free (CoglAttributeBuffer *array)
|
||||
{
|
||||
/* parent's destructor */
|
||||
_cogl_buffer_fini (COGL_BUFFER (array));
|
||||
|
||||
g_free (array);
|
||||
}
|
||||
|
||||
|
@ -49,22 +49,25 @@ typedef struct _CoglAttributeBuffer CoglAttributeBuffer;
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* SECTION:cogl-attribute-buffer
|
||||
* @short_description: Functions for creating and manipulating attribute
|
||||
* buffers
|
||||
* CoglAttributeBuffer:
|
||||
*
|
||||
* FIXME
|
||||
* Functions for creating and manipulating attribute buffers
|
||||
*/
|
||||
#define COGL_TYPE_ATTRIBUTE_BUFFER (cogl_attribute_buffer_get_type ())
|
||||
#define COGL_ATTRIBUTE_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COGL_TYPE_ATTRIBUTE_BUFFER, CoglAttributeBuffer))
|
||||
#define COGL_ATTRIBUTE_BUFFER_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COGL_TYPE_ATTRIBUTE_BUFFER, CoglAttributeBuffer const))
|
||||
#define COGL_ATTRIBUTE_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), COGL_TYPE_ATTRIBUTE_BUFFER, CoglAttributeBufferClass))
|
||||
#define COGL_IS_ATTRIBUTE_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), COGL_TYPE_ATTRIBUTE_BUFFER))
|
||||
#define COGL_IS_ATTRIBUTE_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), COGL_TYPE_ATTRIBUTE_BUFFER))
|
||||
#define COGL_ATTRIBUTE_BUFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), COGL_TYPE_ATTRIBUTE_BUFFER, CoglAttributeBufferClass))
|
||||
|
||||
#define COGL_ATTRIBUTE_BUFFER(buffer) ((CoglAttributeBuffer *)(buffer))
|
||||
typedef struct _CoglAttributeBufferClass CoglAttributeBufferClass;
|
||||
typedef struct _CoglAttributeBuffer CoglAttributeBuffer;
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglAttributeBuffer, g_object_unref)
|
||||
|
||||
/**
|
||||
* cogl_attribute_buffer_get_gtype:
|
||||
*
|
||||
* Returns: a #GType that can be used with the GLib type system.
|
||||
*/
|
||||
COGL_EXPORT
|
||||
GType cogl_attribute_buffer_get_gtype (void);
|
||||
GType cogl_attribute_buffer_get_type (void) G_GNUC_CONST;
|
||||
|
||||
/**
|
||||
* cogl_attribute_buffer_new_with_size:
|
||||
@ -122,17 +125,4 @@ cogl_attribute_buffer_new (CoglContext *context,
|
||||
size_t bytes,
|
||||
const void *data);
|
||||
|
||||
/**
|
||||
* cogl_is_attribute_buffer:
|
||||
* @object: A #CoglObject
|
||||
*
|
||||
* Gets whether the given object references a #CoglAttributeBuffer.
|
||||
*
|
||||
* Returns: %TRUE if @object references a #CoglAttributeBuffer,
|
||||
* %FALSE otherwise
|
||||
*/
|
||||
COGL_EXPORT gboolean
|
||||
cogl_is_attribute_buffer (void *object);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -57,7 +57,7 @@ cogl_attribute_dispose (GObject *object)
|
||||
CoglAttribute *attribute = COGL_ATTRIBUTE (object);
|
||||
|
||||
if (attribute->is_buffered)
|
||||
cogl_object_unref (attribute->d.buffered.attribute_buffer);
|
||||
g_object_unref (attribute->d.buffered.attribute_buffer);
|
||||
else
|
||||
_cogl_boxed_value_destroy (&attribute->d.constant.boxed);
|
||||
|
||||
@ -229,7 +229,7 @@ cogl_attribute_new (CoglAttributeBuffer *attribute_buffer,
|
||||
attribute->name_state = name_state;
|
||||
}
|
||||
|
||||
attribute->d.buffered.attribute_buffer = cogl_object_ref (attribute_buffer);
|
||||
attribute->d.buffered.attribute_buffer = g_object_ref (attribute_buffer);
|
||||
attribute->d.buffered.stride = stride;
|
||||
attribute->d.buffered.offset = offset;
|
||||
attribute->d.buffered.n_components = n_components;
|
||||
@ -505,9 +505,9 @@ cogl_attribute_set_buffer (CoglAttribute *attribute,
|
||||
if (G_UNLIKELY (attribute->immutable_ref))
|
||||
warn_about_midscene_changes ();
|
||||
|
||||
cogl_object_ref (attribute_buffer);
|
||||
g_object_ref (attribute_buffer);
|
||||
|
||||
cogl_object_unref (attribute->d.buffered.attribute_buffer);
|
||||
g_object_unref (attribute->d.buffered.attribute_buffer);
|
||||
attribute->d.buffered.attribute_buffer = attribute_buffer;
|
||||
}
|
||||
|
||||
|
@ -56,8 +56,7 @@ cogl_bitmap_dispose (GObject *object)
|
||||
g_object_unref (bmp->shared_bmp);
|
||||
|
||||
if (bmp->buffer)
|
||||
cogl_object_unref (bmp->buffer);
|
||||
|
||||
g_object_unref (bmp->buffer);
|
||||
|
||||
G_OBJECT_CLASS (cogl_bitmap_parent_class)->dispose (object);
|
||||
}
|
||||
@ -283,7 +282,7 @@ cogl_bitmap_new_from_buffer (CoglBuffer *buffer,
|
||||
{
|
||||
CoglBitmap *bmp;
|
||||
|
||||
g_return_val_if_fail (cogl_is_buffer (buffer), NULL);
|
||||
g_return_val_if_fail (COGL_IS_BUFFER (buffer), NULL);
|
||||
|
||||
bmp = cogl_bitmap_new_for_data (buffer->context,
|
||||
width, height,
|
||||
@ -291,7 +290,7 @@ cogl_bitmap_new_from_buffer (CoglBuffer *buffer,
|
||||
rowstride,
|
||||
NULL /* data */);
|
||||
|
||||
bmp->buffer = cogl_object_ref (buffer);
|
||||
bmp->buffer = g_object_ref (buffer);
|
||||
bmp->data = GINT_TO_POINTER (offset);
|
||||
|
||||
return bmp;
|
||||
@ -328,7 +327,7 @@ cogl_bitmap_new_with_size (CoglContext *context,
|
||||
rowstride,
|
||||
0 /* offset */);
|
||||
|
||||
cogl_object_unref (pixel_buffer);
|
||||
g_object_unref (pixel_buffer);
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
@ -36,33 +36,12 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "cogl/cogl-object-private.h"
|
||||
#include "cogl/cogl-buffer.h"
|
||||
#include "cogl/cogl-context.h"
|
||||
#include "cogl/cogl-gl-header.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _CoglBufferVtable CoglBufferVtable;
|
||||
|
||||
struct _CoglBufferVtable
|
||||
{
|
||||
void * (* map_range) (CoglBuffer *buffer,
|
||||
size_t offset,
|
||||
size_t size,
|
||||
CoglBufferAccess access,
|
||||
CoglBufferMapHint hints,
|
||||
GError **error);
|
||||
|
||||
void (* unmap) (CoglBuffer *buffer);
|
||||
|
||||
gboolean (* set_data) (CoglBuffer *buffer,
|
||||
unsigned int offset,
|
||||
const void *data,
|
||||
unsigned int size,
|
||||
GError **error);
|
||||
};
|
||||
|
||||
typedef enum _CoglBufferFlags
|
||||
{
|
||||
COGL_BUFFER_FLAG_NONE = 0,
|
||||
@ -90,12 +69,10 @@ typedef enum
|
||||
|
||||
struct _CoglBuffer
|
||||
{
|
||||
CoglObject _parent;
|
||||
GObject parent_instance;
|
||||
|
||||
CoglContext *context;
|
||||
|
||||
CoglBufferVtable vtable;
|
||||
|
||||
CoglBufferBindTarget last_target;
|
||||
|
||||
CoglBufferFlags flags;
|
||||
@ -111,18 +88,27 @@ struct _CoglBuffer
|
||||
|
||||
int immutable_ref;
|
||||
|
||||
unsigned int store_created:1;
|
||||
unsigned int store_created : 1;
|
||||
|
||||
void * (* map_range) (CoglBuffer *buffer,
|
||||
size_t offset,
|
||||
size_t size,
|
||||
CoglBufferAccess access,
|
||||
CoglBufferMapHint hints,
|
||||
GError **error);
|
||||
|
||||
void (* unmap) (CoglBuffer *buffer);
|
||||
|
||||
gboolean (* set_data) (CoglBuffer *buffer,
|
||||
unsigned int offset,
|
||||
const void *data,
|
||||
unsigned int size,
|
||||
GError **error);
|
||||
};
|
||||
struct _CoglBufferClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
/* This is used to register a type to the list of handle types that
|
||||
will be considered a texture in cogl_is_texture() */
|
||||
void
|
||||
_cogl_buffer_register_buffer_type (const CoglObjectClass *klass);
|
||||
|
||||
#define COGL_BUFFER_DEFINE(TypeName, type_name) \
|
||||
COGL_OBJECT_DEFINE_WITH_CODE \
|
||||
(TypeName, type_name, \
|
||||
_cogl_buffer_register_buffer_type (&_cogl_##type_name##_class))
|
||||
|
||||
void
|
||||
_cogl_buffer_initialize (CoglBuffer *buffer,
|
||||
@ -132,9 +118,6 @@ _cogl_buffer_initialize (CoglBuffer *buffer,
|
||||
CoglBufferUsageHint usage_hint,
|
||||
CoglBufferUpdateHint update_hint);
|
||||
|
||||
void
|
||||
_cogl_buffer_fini (CoglBuffer *buffer);
|
||||
|
||||
CoglBufferUsageHint
|
||||
_cogl_buffer_get_usage_hint (CoglBuffer *buffer);
|
||||
|
||||
|
@ -45,37 +45,42 @@
|
||||
|
||||
#include "cogl/cogl-util.h"
|
||||
#include "cogl/cogl-context-private.h"
|
||||
#include "cogl/cogl-object-private.h"
|
||||
#include "cogl/cogl-pixel-buffer-private.h"
|
||||
|
||||
/* XXX:
|
||||
* The CoglObject macros don't support any form of inheritance, so for
|
||||
* now we implement the CoglObject support for the CoglBuffer
|
||||
* abstract class manually.
|
||||
*/
|
||||
|
||||
static GSList *_cogl_buffer_types;
|
||||
G_DEFINE_ABSTRACT_TYPE (CoglBuffer, cogl_buffer, G_TYPE_OBJECT)
|
||||
|
||||
void
|
||||
_cogl_buffer_register_buffer_type (const CoglObjectClass *klass)
|
||||
static void
|
||||
cogl_buffer_dispose (GObject *object)
|
||||
{
|
||||
_cogl_buffer_types = g_slist_prepend (_cogl_buffer_types, (void *) klass);
|
||||
CoglBuffer *buffer = COGL_BUFFER (object);
|
||||
|
||||
g_return_if_fail (!(buffer->flags & COGL_BUFFER_FLAG_MAPPED));
|
||||
g_return_if_fail (buffer->immutable_ref == 0);
|
||||
|
||||
if (buffer->flags & COGL_BUFFER_FLAG_BUFFER_OBJECT)
|
||||
buffer->context->driver_vtable->buffer_destroy (buffer);
|
||||
else
|
||||
g_free (buffer->data);
|
||||
|
||||
G_OBJECT_CLASS (cogl_buffer_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
gboolean
|
||||
cogl_is_buffer (void *object)
|
||||
static void
|
||||
cogl_buffer_class_init (CoglBufferClass *klass)
|
||||
{
|
||||
const CoglObject *obj = object;
|
||||
GSList *l;
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
if (object == NULL)
|
||||
return FALSE;
|
||||
gobject_class->dispose = cogl_buffer_dispose;
|
||||
}
|
||||
|
||||
for (l = _cogl_buffer_types; l; l = l->next)
|
||||
if (l->data == obj->klass)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
static void
|
||||
cogl_buffer_init (CoglBuffer *buffer)
|
||||
{
|
||||
buffer->flags = COGL_BUFFER_FLAG_NONE;
|
||||
buffer->store_created = FALSE;
|
||||
buffer->data = NULL;
|
||||
buffer->immutable_ref = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -122,14 +127,10 @@ _cogl_buffer_initialize (CoglBuffer *buffer,
|
||||
gboolean use_malloc = FALSE;
|
||||
|
||||
buffer->context = ctx;
|
||||
buffer->flags = COGL_BUFFER_FLAG_NONE;
|
||||
buffer->store_created = FALSE;
|
||||
buffer->size = size;
|
||||
buffer->last_target = default_target;
|
||||
buffer->usage_hint = usage_hint;
|
||||
buffer->update_hint = update_hint;
|
||||
buffer->data = NULL;
|
||||
buffer->immutable_ref = 0;
|
||||
|
||||
if (default_target == COGL_BUFFER_BIND_TARGET_PIXEL_PACK ||
|
||||
default_target == COGL_BUFFER_BIND_TARGET_PIXEL_UNPACK)
|
||||
@ -140,17 +141,17 @@ _cogl_buffer_initialize (CoglBuffer *buffer,
|
||||
|
||||
if (use_malloc)
|
||||
{
|
||||
buffer->vtable.map_range = malloc_map_range;
|
||||
buffer->vtable.unmap = malloc_unmap;
|
||||
buffer->vtable.set_data = malloc_set_data;
|
||||
buffer->map_range = malloc_map_range;
|
||||
buffer->unmap = malloc_unmap;
|
||||
buffer->set_data = malloc_set_data;
|
||||
|
||||
buffer->data = g_malloc (size);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer->vtable.map_range = ctx->driver_vtable->buffer_map_range;
|
||||
buffer->vtable.unmap = ctx->driver_vtable->buffer_unmap;
|
||||
buffer->vtable.set_data = ctx->driver_vtable->buffer_set_data;
|
||||
buffer->map_range = ctx->driver_vtable->buffer_map_range;
|
||||
buffer->unmap = ctx->driver_vtable->buffer_unmap;
|
||||
buffer->set_data = ctx->driver_vtable->buffer_set_data;
|
||||
|
||||
ctx->driver_vtable->buffer_create (buffer);
|
||||
|
||||
@ -158,33 +159,19 @@ _cogl_buffer_initialize (CoglBuffer *buffer,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_buffer_fini (CoglBuffer *buffer)
|
||||
{
|
||||
g_return_if_fail (!(buffer->flags & COGL_BUFFER_FLAG_MAPPED));
|
||||
g_return_if_fail (buffer->immutable_ref == 0);
|
||||
|
||||
if (buffer->flags & COGL_BUFFER_FLAG_BUFFER_OBJECT)
|
||||
buffer->context->driver_vtable->buffer_destroy (buffer);
|
||||
else
|
||||
g_free (buffer->data);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
cogl_buffer_get_size (CoglBuffer *buffer)
|
||||
{
|
||||
if (!cogl_is_buffer (buffer))
|
||||
return 0;
|
||||
g_return_val_if_fail (COGL_IS_BUFFER (buffer), 0);
|
||||
|
||||
return COGL_BUFFER (buffer)->size;
|
||||
return buffer->size;
|
||||
}
|
||||
|
||||
void
|
||||
cogl_buffer_set_update_hint (CoglBuffer *buffer,
|
||||
CoglBufferUpdateHint hint)
|
||||
{
|
||||
if (!cogl_is_buffer (buffer))
|
||||
return;
|
||||
g_return_if_fail (COGL_IS_BUFFER (buffer));
|
||||
|
||||
if (G_UNLIKELY (hint > COGL_BUFFER_UPDATE_HINT_STREAM))
|
||||
hint = COGL_BUFFER_UPDATE_HINT_STATIC;
|
||||
@ -195,7 +182,7 @@ cogl_buffer_set_update_hint (CoglBuffer *buffer,
|
||||
CoglBufferUpdateHint
|
||||
cogl_buffer_get_update_hint (CoglBuffer *buffer)
|
||||
{
|
||||
if (!cogl_is_buffer (buffer))
|
||||
if (!COGL_IS_BUFFER (buffer))
|
||||
return FALSE;
|
||||
|
||||
return buffer->update_hint;
|
||||
@ -219,7 +206,7 @@ _cogl_buffer_map (CoglBuffer *buffer,
|
||||
CoglBufferMapHint hints,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (cogl_is_buffer (buffer), NULL);
|
||||
g_return_val_if_fail (COGL_IS_BUFFER (buffer), NULL);
|
||||
|
||||
return cogl_buffer_map_range (buffer, 0, buffer->size, access, hints, error);
|
||||
}
|
||||
@ -245,18 +232,18 @@ cogl_buffer_map_range (CoglBuffer *buffer,
|
||||
CoglBufferMapHint hints,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (cogl_is_buffer (buffer), NULL);
|
||||
g_return_val_if_fail (COGL_IS_BUFFER (buffer), NULL);
|
||||
g_return_val_if_fail (!(buffer->flags & COGL_BUFFER_FLAG_MAPPED), NULL);
|
||||
|
||||
if (G_UNLIKELY (buffer->immutable_ref))
|
||||
warn_about_midscene_changes ();
|
||||
|
||||
buffer->data = buffer->vtable.map_range (buffer,
|
||||
offset,
|
||||
size,
|
||||
access,
|
||||
hints,
|
||||
error);
|
||||
buffer->data = buffer->map_range (buffer,
|
||||
offset,
|
||||
size,
|
||||
access,
|
||||
hints,
|
||||
error);
|
||||
|
||||
return buffer->data;
|
||||
}
|
||||
@ -264,13 +251,12 @@ cogl_buffer_map_range (CoglBuffer *buffer,
|
||||
void
|
||||
cogl_buffer_unmap (CoglBuffer *buffer)
|
||||
{
|
||||
if (!cogl_is_buffer (buffer))
|
||||
return;
|
||||
g_return_if_fail (COGL_IS_BUFFER (buffer));
|
||||
|
||||
if (!(buffer->flags & COGL_BUFFER_FLAG_MAPPED))
|
||||
return;
|
||||
|
||||
buffer->vtable.unmap (buffer);
|
||||
buffer->unmap (buffer);
|
||||
}
|
||||
|
||||
void *
|
||||
@ -359,13 +345,13 @@ _cogl_buffer_set_data (CoglBuffer *buffer,
|
||||
size_t size,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (cogl_is_buffer (buffer), FALSE);
|
||||
g_return_val_if_fail (COGL_IS_BUFFER (buffer), FALSE);
|
||||
g_return_val_if_fail ((offset + size) <= buffer->size, FALSE);
|
||||
|
||||
if (G_UNLIKELY (buffer->immutable_ref))
|
||||
warn_about_midscene_changes ();
|
||||
|
||||
return buffer->vtable.set_data (buffer, offset, data, size, error);
|
||||
return buffer->set_data (buffer, offset, data, size, error);
|
||||
}
|
||||
|
||||
gboolean
|
||||
@ -384,7 +370,7 @@ cogl_buffer_set_data (CoglBuffer *buffer,
|
||||
CoglBuffer *
|
||||
_cogl_buffer_immutable_ref (CoglBuffer *buffer)
|
||||
{
|
||||
g_return_val_if_fail (cogl_is_buffer (buffer), NULL);
|
||||
g_return_val_if_fail (COGL_IS_BUFFER (buffer), NULL);
|
||||
|
||||
buffer->immutable_ref++;
|
||||
return buffer;
|
||||
@ -393,7 +379,7 @@ _cogl_buffer_immutable_ref (CoglBuffer *buffer)
|
||||
void
|
||||
_cogl_buffer_immutable_unref (CoglBuffer *buffer)
|
||||
{
|
||||
g_return_if_fail (cogl_is_buffer (buffer));
|
||||
g_return_if_fail (COGL_IS_BUFFER (buffer));
|
||||
g_return_if_fail (buffer->immutable_ref > 0);
|
||||
|
||||
buffer->immutable_ref--;
|
||||
|
@ -43,8 +43,9 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* SECTION:cogl-buffer
|
||||
* @short_description: Common buffer functions, including data upload APIs
|
||||
* CoglBuffer:
|
||||
*
|
||||
* Common buffer functions, including data upload APIs
|
||||
*
|
||||
* The CoglBuffer API provides a common interface to manipulate
|
||||
* buffers that have been allocated either via cogl_pixel_buffer_new()
|
||||
@ -62,17 +63,21 @@ G_BEGIN_DECLS
|
||||
* of loading an image file and unpacking it into the mapped buffer
|
||||
* without blocking other Cogl operations.
|
||||
*/
|
||||
#define COGL_TYPE_BUFFER (cogl_buffer_get_type ())
|
||||
#define COGL_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COGL_TYPE_BUFFER, CoglBuffer))
|
||||
#define COGL_BUFFER_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COGL_TYPE_BUFFER, CoglBuffer const))
|
||||
#define COGL_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), COGL_TYPE_BUFFER, CoglBufferClass))
|
||||
#define COGL_IS_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), COGL_TYPE_BUFFER))
|
||||
#define COGL_IS_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), COGL_TYPE_BUFFER))
|
||||
#define COGL_BUFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), COGL_TYPE_BUFFER, CoglBufferClass))
|
||||
|
||||
#if defined(__COGL_H_INSIDE__) && !defined(COGL_ENABLE_MUTTER_API) && \
|
||||
!defined(COGL_GIR_SCANNING)
|
||||
/* For the public C api we typedef interface types as void to avoid needing
|
||||
* lots of casting in code and instead we will rely on runtime type checking
|
||||
* for these objects. */
|
||||
typedef void CoglBuffer;
|
||||
#else
|
||||
typedef struct _CoglBufferClass CoglBufferClass;
|
||||
typedef struct _CoglBuffer CoglBuffer;
|
||||
#define COGL_BUFFER(buffer) ((CoglBuffer *)(buffer))
|
||||
#endif
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglBuffer, g_object_unref)
|
||||
|
||||
COGL_EXPORT
|
||||
GType cogl_buffer_get_type (void) G_GNUC_CONST;
|
||||
|
||||
#define COGL_BUFFER_ERROR (_cogl_buffer_error_domain ())
|
||||
|
||||
@ -92,17 +97,6 @@ typedef enum /*< prefix=COGL_BUFFER_ERROR >*/
|
||||
uint32_t
|
||||
_cogl_buffer_error_domain (void);
|
||||
|
||||
/**
|
||||
* cogl_is_buffer:
|
||||
* @object: a buffer object
|
||||
*
|
||||
* Checks whether @buffer is a buffer object.
|
||||
*
|
||||
* Return value: %TRUE if the handle is a CoglBuffer, and %FALSE otherwise
|
||||
*/
|
||||
COGL_EXPORT gboolean
|
||||
cogl_is_buffer (void *object);
|
||||
|
||||
/**
|
||||
* cogl_buffer_get_size:
|
||||
* @buffer: a buffer object
|
||||
|
@ -37,5 +37,10 @@
|
||||
|
||||
struct _CoglIndexBuffer
|
||||
{
|
||||
CoglBuffer _parent;
|
||||
CoglBuffer parent_instance;
|
||||
};
|
||||
|
||||
struct _CoglIndexBufferClass
|
||||
{
|
||||
CoglBufferClass parent_class;
|
||||
};
|
||||
|
@ -33,16 +33,21 @@
|
||||
|
||||
#include "cogl-config.h"
|
||||
|
||||
#include "cogl/cogl-object-private.h"
|
||||
#include "cogl/cogl-indices.h"
|
||||
#include "cogl/cogl-indices-private.h"
|
||||
#include "cogl/cogl-context-private.h"
|
||||
#include "cogl/cogl-gtype-private.h"
|
||||
|
||||
static void _cogl_index_buffer_free (CoglIndexBuffer *indices);
|
||||
G_DEFINE_FINAL_TYPE (CoglIndexBuffer, cogl_index_buffer, COGL_TYPE_BUFFER)
|
||||
|
||||
COGL_BUFFER_DEFINE (IndexBuffer, index_buffer);
|
||||
COGL_GTYPE_DEFINE_CLASS (IndexBuffer, index_buffer);
|
||||
static void
|
||||
cogl_index_buffer_class_init (CoglIndexBufferClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
cogl_index_buffer_init (CoglIndexBuffer *buffer)
|
||||
{
|
||||
}
|
||||
|
||||
/* XXX: Unlike the wiki design this just takes a size. A single
|
||||
* indices buffer should be able to contain multiple ranges of indices
|
||||
@ -50,7 +55,7 @@ COGL_GTYPE_DEFINE_CLASS (IndexBuffer, index_buffer);
|
||||
CoglIndexBuffer *
|
||||
cogl_index_buffer_new (CoglContext *context, size_t bytes)
|
||||
{
|
||||
CoglIndexBuffer *indices = g_new0 (CoglIndexBuffer, 1);
|
||||
CoglIndexBuffer *indices = g_object_new (COGL_TYPE_INDEX_BUFFER, NULL);
|
||||
|
||||
/* parent's constructor */
|
||||
_cogl_buffer_initialize (COGL_BUFFER (indices),
|
||||
@ -60,51 +65,5 @@ cogl_index_buffer_new (CoglContext *context, size_t bytes)
|
||||
COGL_BUFFER_USAGE_HINT_INDEX_BUFFER,
|
||||
COGL_BUFFER_UPDATE_HINT_STATIC);
|
||||
|
||||
return _cogl_index_buffer_object_new (indices);
|
||||
return indices;
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_index_buffer_free (CoglIndexBuffer *indices)
|
||||
{
|
||||
/* parent's destructor */
|
||||
_cogl_buffer_fini (COGL_BUFFER (indices));
|
||||
|
||||
g_free (indices);
|
||||
}
|
||||
|
||||
/* XXX: do we want a convenience function like this as an alternative
|
||||
* to using cogl_buffer_set_data? The advantage of this is that we can
|
||||
* track meta data such as the indices type and max_index_value for a
|
||||
* range as part of the indices buffer. If we just leave people to use
|
||||
* cogl_buffer_set_data then we either need a way to specify the type
|
||||
* and max index value at draw time or we'll want a separate way to
|
||||
* declare the type and max value for a range after uploading the
|
||||
* data.
|
||||
*
|
||||
* XXX: I think in the end it'll be that CoglIndices are to
|
||||
* CoglIndexBuffers as CoglAttributes are to CoglAttributeBuffers. I.e
|
||||
* a CoglIndexBuffer is a lite subclass of CoglBuffer that simply
|
||||
* implies that the buffer will later be bound as indices but doesn't
|
||||
* track more detailed meta data. CoglIndices build on a
|
||||
* CoglIndexBuffer and define the type and max_index_value for some
|
||||
* sub-range of a CoglIndexBuffer.
|
||||
*/
|
||||
#if 0
|
||||
void
|
||||
cogl_index_buffer_set_data (CoglIndexBuffer *indices,
|
||||
CoglIndicesType type,
|
||||
int max_index_value,
|
||||
size_t write_offset,
|
||||
void *user_indices,
|
||||
int n_indices)
|
||||
{
|
||||
GList *l;
|
||||
|
||||
for (l = indices->ranges; l; l = l->next)
|
||||
{
|
||||
|
||||
}
|
||||
cogl_buffer_set
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -44,23 +44,25 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* SECTION:cogl-index-buffer
|
||||
* @short_description: Functions for creating and manipulating vertex
|
||||
* indices.
|
||||
* CoglIndexBuffer:
|
||||
*
|
||||
* FIXME
|
||||
*Functions for creating and manipulating vertex indices.
|
||||
*/
|
||||
#define COGL_TYPE_INDEX_BUFFER (cogl_index_buffer_get_type ())
|
||||
#define COGL_INDEX_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COGL_TYPE_INDEX_BUFFER, CoglIndexBuffer))
|
||||
#define COGL_INDEX_BUFFER_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COGL_TYPE_INDEX_BUFFER, CoglIndexBuffer const))
|
||||
#define COGL_INDEX_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), COGL_TYPE_INDEX_BUFFER, CoglIndexBufferClass))
|
||||
#define COGL_IS_INDEX_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), COGL_TYPE_INDEX_BUFFER))
|
||||
#define COGL_IS_INDEX_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), COGL_TYPE_INDEX_BUFFER))
|
||||
#define COGL_INDEX_BUFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), COGL_TYPE_INDEX_BUFFER, CoglIndexBufferClass))
|
||||
|
||||
#define COGL_INDEX_BUFFER(buffer) ((CoglIndexBuffer*) buffer)
|
||||
typedef struct _CoglIndexBufferClass CoglIndexBufferClass;
|
||||
typedef struct _CoglIndexBuffer CoglIndexBuffer;
|
||||
|
||||
typedef struct _CoglIndexBuffer CoglIndexBuffer;
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglIndexBuffer, g_object_unref)
|
||||
|
||||
/**
|
||||
* cogl_index_buffer_get_gtype:
|
||||
*
|
||||
* Returns: a #GType that can be used with the GLib type system.
|
||||
*/
|
||||
COGL_EXPORT GType cogl_index_buffer_get_gtype (void);
|
||||
COGL_EXPORT
|
||||
GType cogl_index_buffer_get_type (void) G_GNUC_CONST;
|
||||
|
||||
/**
|
||||
* cogl_index_buffer_new:
|
||||
@ -78,16 +80,4 @@ COGL_EXPORT CoglIndexBuffer *
|
||||
cogl_index_buffer_new (CoglContext *context,
|
||||
size_t bytes);
|
||||
|
||||
/**
|
||||
* cogl_is_index_buffer:
|
||||
* @object: A #CoglObject
|
||||
*
|
||||
* Gets whether the given object references a #CoglIndexBuffer.
|
||||
*
|
||||
* Returns: %TRUE if the @object references a #CoglIndexBuffer,
|
||||
* %FALSE otherwise
|
||||
*/
|
||||
COGL_EXPORT gboolean
|
||||
cogl_is_index_buffer (void *object);
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -49,7 +49,7 @@ cogl_indices_dispose (GObject *object)
|
||||
{
|
||||
CoglIndices *indices = COGL_INDICES (object);
|
||||
|
||||
cogl_object_unref (indices->buffer);
|
||||
g_object_unref (indices->buffer);
|
||||
|
||||
G_OBJECT_CLASS (cogl_indices_parent_class)->dispose (object);
|
||||
}
|
||||
@ -89,7 +89,7 @@ cogl_indices_new_for_buffer (CoglIndicesType type,
|
||||
{
|
||||
CoglIndices *indices = g_object_new (COGL_TYPE_INDICES, NULL);
|
||||
|
||||
indices->buffer = cogl_object_ref (buffer);
|
||||
indices->buffer = g_object_ref (buffer);
|
||||
indices->offset = offset;
|
||||
|
||||
indices->type = type;
|
||||
@ -119,12 +119,12 @@ cogl_indices_new (CoglContext *context,
|
||||
if (ignore_error)
|
||||
{
|
||||
g_error_free (ignore_error);
|
||||
cogl_object_unref (index_buffer);
|
||||
g_object_unref (index_buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
indices = cogl_indices_new_for_buffer (type, index_buffer, 0);
|
||||
cogl_object_unref (index_buffer);
|
||||
g_object_unref (index_buffer);
|
||||
|
||||
return indices;
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ cogl_journal_dispose (GObject *object)
|
||||
|
||||
for (i = 0; i < COGL_JOURNAL_VBO_POOL_SIZE; i++)
|
||||
if (journal->vbo_pool[i])
|
||||
cogl_object_unref (journal->vbo_pool[i]);
|
||||
g_object_unref (journal->vbo_pool[i]);
|
||||
|
||||
G_OBJECT_CLASS (cogl_journal_parent_class)->dispose (object);
|
||||
}
|
||||
@ -1145,7 +1145,7 @@ create_attribute_buffer (CoglJournal *journal,
|
||||
else if (cogl_buffer_get_size (COGL_BUFFER (vbo)) < n_bytes)
|
||||
{
|
||||
/* If the buffer is too small then we'll just recreate it */
|
||||
cogl_object_unref (vbo);
|
||||
g_object_unref (vbo);
|
||||
vbo = cogl_attribute_buffer_new_with_size (ctx, n_bytes);
|
||||
journal->vbo_pool[journal->next_vbo_in_pool] = vbo;
|
||||
}
|
||||
@ -1153,7 +1153,7 @@ create_attribute_buffer (CoglJournal *journal,
|
||||
journal->next_vbo_in_pool = ((journal->next_vbo_in_pool + 1) %
|
||||
COGL_JOURNAL_VBO_POOL_SIZE);
|
||||
|
||||
return cogl_object_ref (vbo);
|
||||
return g_object_ref (vbo);
|
||||
}
|
||||
|
||||
static CoglAttributeBuffer *
|
||||
@ -1478,7 +1478,7 @@ _cogl_journal_flush (CoglJournal *journal)
|
||||
g_object_unref (g_array_index (state.attributes, CoglAttribute *, i));
|
||||
g_array_set_size (state.attributes, 0);
|
||||
|
||||
cogl_object_unref (state.attribute_buffer);
|
||||
g_object_unref (state.attribute_buffer);
|
||||
|
||||
COGL_TIMER_START (_cogl_uprof_context, discard_timer);
|
||||
_cogl_journal_discard (journal);
|
||||
|
@ -43,7 +43,12 @@ G_BEGIN_DECLS
|
||||
|
||||
struct _CoglPixelBuffer
|
||||
{
|
||||
CoglBuffer _parent;
|
||||
CoglBuffer parent_instance;
|
||||
};
|
||||
|
||||
struct _CoglPixelBufferClass
|
||||
{
|
||||
CoglBufferClass parent_class;
|
||||
};
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -46,16 +46,20 @@
|
||||
#include "cogl/cogl-private.h"
|
||||
#include "cogl/cogl-util.h"
|
||||
#include "cogl/cogl-context-private.h"
|
||||
#include "cogl/cogl-object.h"
|
||||
#include "cogl/cogl-pixel-buffer-private.h"
|
||||
#include "cogl/cogl-pixel-buffer.h"
|
||||
#include "cogl/cogl-gtype-private.h"
|
||||
|
||||
G_DEFINE_FINAL_TYPE (CoglPixelBuffer, cogl_pixel_buffer, COGL_TYPE_BUFFER)
|
||||
|
||||
static void
|
||||
_cogl_pixel_buffer_free (CoglPixelBuffer *buffer);
|
||||
cogl_pixel_buffer_class_init (CoglPixelBufferClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
COGL_BUFFER_DEFINE (PixelBuffer, pixel_buffer)
|
||||
COGL_GTYPE_DEFINE_CLASS (PixelBuffer, pixel_buffer)
|
||||
static void
|
||||
cogl_pixel_buffer_init (CoglPixelBuffer *buffer)
|
||||
{
|
||||
}
|
||||
|
||||
static CoglPixelBuffer *
|
||||
_cogl_pixel_buffer_new (CoglContext *context,
|
||||
@ -63,18 +67,16 @@ _cogl_pixel_buffer_new (CoglContext *context,
|
||||
const void *data,
|
||||
GError **error)
|
||||
{
|
||||
CoglPixelBuffer *pixel_buffer = g_new0 (CoglPixelBuffer, 1);
|
||||
CoglBuffer *buffer = COGL_BUFFER (pixel_buffer);
|
||||
CoglPixelBuffer *pixel_buffer = g_object_new (COGL_TYPE_PIXEL_BUFFER, NULL);
|
||||
|
||||
/* parent's constructor */
|
||||
_cogl_buffer_initialize (buffer,
|
||||
_cogl_buffer_initialize (COGL_BUFFER (pixel_buffer),
|
||||
context,
|
||||
size,
|
||||
COGL_BUFFER_BIND_TARGET_PIXEL_UNPACK,
|
||||
COGL_BUFFER_USAGE_HINT_TEXTURE,
|
||||
COGL_BUFFER_UPDATE_HINT_STATIC);
|
||||
|
||||
_cogl_pixel_buffer_object_new (pixel_buffer);
|
||||
|
||||
if (data)
|
||||
{
|
||||
@ -84,7 +86,7 @@ _cogl_pixel_buffer_new (CoglContext *context,
|
||||
size,
|
||||
error))
|
||||
{
|
||||
cogl_object_unref (pixel_buffer);
|
||||
g_object_unref (pixel_buffer);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@ -104,13 +106,3 @@ cogl_pixel_buffer_new (CoglContext *context,
|
||||
g_clear_error (&ignore_error);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_pixel_buffer_free (CoglPixelBuffer *buffer)
|
||||
{
|
||||
/* parent's destructor */
|
||||
_cogl_buffer_fini (COGL_BUFFER (buffer));
|
||||
|
||||
g_free (buffer);
|
||||
}
|
||||
|
||||
|
@ -49,19 +49,24 @@ typedef struct _CoglPixelBuffer CoglPixelBuffer;
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define COGL_PIXEL_BUFFER(buffer) ((CoglPixelBuffer *)(buffer))
|
||||
|
||||
/**
|
||||
* CoglPixelBuffer: (skip)
|
||||
* CoglPixelBuffer:
|
||||
*/
|
||||
#define COGL_TYPE_PIXEL_BUFFER (cogl_pixel_buffer_get_type ())
|
||||
#define COGL_PIXEL_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COGL_TYPE_PIXEL_BUFFER, CoglPixelBuffer))
|
||||
#define COGL_PIXEL_BUFFER_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COGL_TYPE_PIXEL_BUFFER, CoglPixelBuffer const))
|
||||
#define COGL_PIXEL_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), COGL_TYPE_PIXEL_BUFFER, CoglPixelBufferClass))
|
||||
#define COGL_IS_PIXEL_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), COGL_TYPE_PIXEL_BUFFER))
|
||||
#define COGL_IS_PIXEL_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), COGL_TYPE_PIXEL_BUFFER))
|
||||
#define COGL_PIXEL_BUFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), COGL_TYPE_PIXEL_BUFFER, CoglPixelBufferClass))
|
||||
|
||||
typedef struct _CoglPixelBufferClass CoglPixelBufferClass;
|
||||
typedef struct _CoglPixelBuffer CoglPixelBuffer;
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglPixelBuffer, g_object_unref)
|
||||
|
||||
/**
|
||||
* cogl_pixel_buffer_get_gtype:
|
||||
*
|
||||
* Returns: a #GType that can be used with the GLib type system.
|
||||
*/
|
||||
COGL_EXPORT
|
||||
GType cogl_pixel_buffer_get_gtype (void);
|
||||
GType cogl_pixel_buffer_get_type (void) G_GNUC_CONST;
|
||||
|
||||
/**
|
||||
* cogl_pixel_buffer_new:
|
||||
@ -84,16 +89,4 @@ cogl_pixel_buffer_new (CoglContext *context,
|
||||
size_t size,
|
||||
const void *data);
|
||||
|
||||
/**
|
||||
* cogl_is_pixel_buffer:
|
||||
* @object: a #CoglObject to test
|
||||
*
|
||||
* Checks whether @object is a pixel buffer.
|
||||
*
|
||||
* Return value: %TRUE if the @object is a pixel buffer, and %FALSE
|
||||
* otherwise
|
||||
*/
|
||||
COGL_EXPORT gboolean
|
||||
cogl_is_pixel_buffer (void *object);
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -150,7 +150,7 @@ cogl_primitive_new_p2 (CoglContext *ctx,
|
||||
2,
|
||||
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||
|
||||
cogl_object_unref (attribute_buffer);
|
||||
g_object_unref (attribute_buffer);
|
||||
|
||||
return _cogl_primitive_new_with_attributes_unref (mode, n_vertices,
|
||||
attributes,
|
||||
@ -174,7 +174,7 @@ cogl_primitive_new_p3 (CoglContext *ctx,
|
||||
3,
|
||||
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||
|
||||
cogl_object_unref (attribute_buffer);
|
||||
g_object_unref (attribute_buffer);
|
||||
|
||||
return _cogl_primitive_new_with_attributes_unref (mode, n_vertices,
|
||||
attributes,
|
||||
@ -204,7 +204,7 @@ cogl_primitive_new_p2c4 (CoglContext *ctx,
|
||||
4,
|
||||
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
|
||||
|
||||
cogl_object_unref (attribute_buffer);
|
||||
g_object_unref (attribute_buffer);
|
||||
|
||||
return _cogl_primitive_new_with_attributes_unref (mode, n_vertices,
|
||||
attributes,
|
||||
@ -234,7 +234,7 @@ cogl_primitive_new_p3c4 (CoglContext *ctx,
|
||||
4,
|
||||
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
|
||||
|
||||
cogl_object_unref (attribute_buffer);
|
||||
g_object_unref (attribute_buffer);
|
||||
|
||||
return _cogl_primitive_new_with_attributes_unref (mode, n_vertices,
|
||||
attributes,
|
||||
@ -264,7 +264,7 @@ cogl_primitive_new_p2t2 (CoglContext *ctx,
|
||||
2,
|
||||
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||
|
||||
cogl_object_unref (attribute_buffer);
|
||||
g_object_unref (attribute_buffer);
|
||||
|
||||
return _cogl_primitive_new_with_attributes_unref (mode, n_vertices,
|
||||
attributes,
|
||||
@ -294,7 +294,7 @@ cogl_primitive_new_p3t2 (CoglContext *ctx,
|
||||
2,
|
||||
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||
|
||||
cogl_object_unref (attribute_buffer);
|
||||
g_object_unref (attribute_buffer);
|
||||
|
||||
return _cogl_primitive_new_with_attributes_unref (mode, n_vertices,
|
||||
attributes,
|
||||
@ -331,7 +331,7 @@ cogl_primitive_new_p2t2c4 (CoglContext *ctx,
|
||||
4,
|
||||
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
|
||||
|
||||
cogl_object_unref (attribute_buffer);
|
||||
g_object_unref (attribute_buffer);
|
||||
|
||||
return _cogl_primitive_new_with_attributes_unref (mode, n_vertices,
|
||||
attributes,
|
||||
@ -368,7 +368,7 @@ cogl_primitive_new_p3t2c4 (CoglContext *ctx,
|
||||
4,
|
||||
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
|
||||
|
||||
cogl_object_unref (attribute_buffer);
|
||||
g_object_unref (attribute_buffer);
|
||||
|
||||
return _cogl_primitive_new_with_attributes_unref (mode, n_vertices,
|
||||
attributes,
|
||||
|
@ -740,7 +740,7 @@ cogl_2d_primitives_immediate (CoglFramebuffer *framebuffer,
|
||||
|
||||
|
||||
g_object_unref (attributes[0]);
|
||||
cogl_object_unref (attribute_buffer);
|
||||
g_object_unref (attribute_buffer);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -76,11 +76,6 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* It would be good to move these casts up into 1.x only api if we can
|
||||
* update Clutter, Mutter and GnomeShell to avoid redundant casts when
|
||||
* they enable the experimental api... */
|
||||
#include <cogl/deprecated/cogl-type-casts.h>
|
||||
|
||||
#include <cogl/deprecated/cogl-shader.h>
|
||||
|
||||
#ifdef COGL_ENABLE_MUTTER_API
|
||||
|
@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* A Low Level GPU Graphics and Utilities API
|
||||
*
|
||||
* Copyright (C) 2013 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy,
|
||||
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
|
||||
#error "Only <cogl/cogl.h> can be included directly."
|
||||
#endif
|
||||
|
||||
/* The various interface types in Cogl used to be more strongly typed
|
||||
* which required lots type casting by developers. We provided
|
||||
* macros for performing these casts following a widely used Gnome
|
||||
* coding style. Since we now consistently typedef these interfaces
|
||||
* as void for the public C api and use runtime type checking to
|
||||
* catch programming errors the casts have become redundant and
|
||||
* so these macros are only kept for compatibility...
|
||||
*/
|
||||
|
||||
#if !defined(COGL_ENABLE_MUTTER_API) && !defined(COGL_GIR_SCANNING)
|
||||
#define COGL_BUFFER(X) (X)
|
||||
#endif
|
@ -61,7 +61,6 @@ cogl_deprecated_headers = [
|
||||
'deprecated/cogl-program.h',
|
||||
'deprecated/cogl-shader.h',
|
||||
'deprecated/cogl-clutter.h',
|
||||
'deprecated/cogl-type-casts.h',
|
||||
]
|
||||
|
||||
cogl_headers = [
|
||||
|
@ -74,7 +74,7 @@ test_float_verts (TestState *state, int offset_x, int offset_y)
|
||||
|
||||
g_object_unref (attributes[1]);
|
||||
g_object_unref (attributes[0]);
|
||||
cogl_object_unref (buffer);
|
||||
g_object_unref (buffer);
|
||||
|
||||
test_utils_check_pixel (test_fb, offset_x + 5, offset_y + 5, 0xff0000ff);
|
||||
test_utils_check_pixel (test_fb, offset_x + 15, offset_y + 5, 0x00ff00ff);
|
||||
@ -157,8 +157,8 @@ test_byte_verts (TestState *state, int offset_x, int offset_y)
|
||||
|
||||
g_object_unref (attributes[0]);
|
||||
g_object_unref (attributes[1]);
|
||||
cogl_object_unref (buffer);
|
||||
cogl_object_unref (unnorm_buffer);
|
||||
g_object_unref (buffer);
|
||||
g_object_unref (unnorm_buffer);
|
||||
|
||||
test_utils_check_pixel (test_fb, offset_x + 5, offset_y + 5, 0xff0000ff);
|
||||
test_utils_check_pixel (test_fb, offset_x + 15, offset_y + 5, 0x00ff00ff);
|
||||
@ -256,7 +256,7 @@ test_short_verts (TestState *state, int offset_x, int offset_y)
|
||||
|
||||
cogl_object_unref (pipeline2);
|
||||
cogl_object_unref (pipeline);
|
||||
cogl_object_unref (buffer);
|
||||
g_object_unref (buffer);
|
||||
|
||||
test_utils_check_pixel (test_fb, offset_x + 5, offset_y + 5, 0xff0000ff);
|
||||
test_utils_check_pixel (test_fb, offset_x + 15, offset_y + 5, 0x00ff00ff);
|
||||
|
@ -67,7 +67,7 @@ test_map_buffer_range (void)
|
||||
|
||||
/* Replace the texture coordinates of the third vertex with the
|
||||
* coordinates for a green texel */
|
||||
data = cogl_buffer_map_range (buffer,
|
||||
data = cogl_buffer_map_range (COGL_BUFFER (buffer),
|
||||
sizeof (vertex_data[0]) * 2,
|
||||
sizeof (vertex_data[0]),
|
||||
COGL_BUFFER_ACCESS_WRITE,
|
||||
@ -80,7 +80,7 @@ test_map_buffer_range (void)
|
||||
data->s = 1.0f;
|
||||
data->t = 0.0f;
|
||||
|
||||
cogl_buffer_unmap (buffer);
|
||||
cogl_buffer_unmap (COGL_BUFFER (buffer));
|
||||
|
||||
pos_attribute =
|
||||
cogl_attribute_new (buffer,
|
||||
@ -117,7 +117,7 @@ test_map_buffer_range (void)
|
||||
test_utils_check_pixel (test_fb, 1, fb_height - 2, 0xff0000ff);
|
||||
test_utils_check_pixel (test_fb, fb_width - 2, fb_height - 2, 0xff0000ff);
|
||||
|
||||
cogl_object_unref (buffer);
|
||||
g_object_unref (buffer);
|
||||
g_object_unref (pos_attribute);
|
||||
g_object_unref (tex_coord_attribute);
|
||||
|
||||
|
@ -33,7 +33,7 @@ static CoglBitmap *
|
||||
create_bitmap (void)
|
||||
{
|
||||
CoglBitmap *bitmap;
|
||||
CoglBuffer *buffer;
|
||||
CoglPixelBuffer *buffer;
|
||||
|
||||
bitmap = cogl_bitmap_new_with_size (test_ctx,
|
||||
BITMAP_SIZE,
|
||||
@ -41,11 +41,11 @@ create_bitmap (void)
|
||||
COGL_PIXEL_FORMAT_RGBA_8888);
|
||||
buffer = cogl_bitmap_get_buffer (bitmap);
|
||||
|
||||
g_assert (cogl_is_pixel_buffer (buffer));
|
||||
g_assert (cogl_is_buffer (buffer));
|
||||
g_assert (COGL_IS_PIXEL_BUFFER (buffer));
|
||||
g_assert (COGL_IS_BUFFER (buffer));
|
||||
|
||||
cogl_buffer_set_update_hint (buffer, COGL_BUFFER_UPDATE_HINT_DYNAMIC);
|
||||
g_assert_cmpint (cogl_buffer_get_update_hint (buffer),
|
||||
cogl_buffer_set_update_hint (COGL_BUFFER (buffer), COGL_BUFFER_UPDATE_HINT_DYNAMIC);
|
||||
g_assert_cmpint (cogl_buffer_get_update_hint (COGL_BUFFER (buffer)),
|
||||
==,
|
||||
COGL_BUFFER_UPDATE_HINT_DYNAMIC);
|
||||
|
||||
@ -56,20 +56,20 @@ static CoglBitmap *
|
||||
create_and_fill_bitmap (void)
|
||||
{
|
||||
CoglBitmap *bitmap = create_bitmap ();
|
||||
CoglBuffer *buffer = cogl_bitmap_get_buffer (bitmap);
|
||||
CoglPixelBuffer *buffer = cogl_bitmap_get_buffer (bitmap);
|
||||
uint8_t *map;
|
||||
unsigned int stride;
|
||||
|
||||
stride = cogl_bitmap_get_rowstride (bitmap);
|
||||
|
||||
map = cogl_buffer_map (buffer,
|
||||
map = cogl_buffer_map (COGL_BUFFER (buffer),
|
||||
COGL_BUFFER_ACCESS_WRITE,
|
||||
COGL_BUFFER_MAP_HINT_DISCARD);
|
||||
g_assert (map);
|
||||
|
||||
generate_bitmap_data (map, stride);
|
||||
|
||||
cogl_buffer_unmap (buffer);
|
||||
cogl_buffer_unmap (COGL_BUFFER (buffer));
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
@ -166,7 +166,7 @@ static void
|
||||
test_pixel_buffer_set_data (void)
|
||||
{
|
||||
CoglBitmap *bitmap = create_bitmap ();
|
||||
CoglBuffer *buffer = cogl_bitmap_get_buffer (bitmap);
|
||||
CoglPixelBuffer *buffer = cogl_bitmap_get_buffer (bitmap);
|
||||
CoglPipeline *pipeline;
|
||||
CoglTexture *texture;
|
||||
uint8_t *data;
|
||||
@ -178,7 +178,7 @@ test_pixel_buffer_set_data (void)
|
||||
|
||||
generate_bitmap_data (data, stride);
|
||||
|
||||
cogl_buffer_set_data (buffer,
|
||||
cogl_buffer_set_data (COGL_BUFFER (buffer),
|
||||
0, /* offset */
|
||||
data,
|
||||
stride * (BITMAP_SIZE - 1) +
|
||||
|
@ -308,7 +308,7 @@ test_copy (TestState *state)
|
||||
for (i = 0; i < N_ATTRIBS; i++)
|
||||
g_object_unref (attributes[i]);
|
||||
|
||||
cogl_object_unref (buffer);
|
||||
g_object_unref (buffer);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user