diff --git a/cogl-pango/cogl-pango-display-list.c b/cogl-pango/cogl-pango-display-list.c index 005b47869..6800c6c07 100644 --- a/cogl-pango/cogl-pango-display-list.c +++ b/cogl-pango/cogl-pango-display-list.c @@ -269,7 +269,8 @@ emit_vertex_buffer_geometry (CoglPangoDisplayListNode *node) n_verts = node->d.texture.rectangles->len * 4; buffer - = cogl_attribute_buffer_new (n_verts * sizeof (CoglVertexP2T2), NULL); + = cogl_attribute_buffer_new (ctx, + n_verts * sizeof (CoglVertexP2T2), NULL); if ((verts = cogl_buffer_map (COGL_BUFFER (buffer), COGL_BUFFER_ACCESS_WRITE, @@ -351,7 +352,7 @@ emit_vertex_buffer_geometry (CoglPangoDisplayListNode *node) quads */ CoglIndices *indices = - cogl_get_rectangle_indices (node->d.texture.rectangles->len); + cogl_get_rectangle_indices (ctx, node->d.texture.rectangles->len); cogl_primitive_set_indices (prim, indices, node->d.texture.rectangles->len * 6); diff --git a/cogl/cogl-attribute-buffer.c b/cogl/cogl-attribute-buffer.c index a627fac6a..95adfe090 100644 --- a/cogl/cogl-attribute-buffer.c +++ b/cogl/cogl-attribute-buffer.c @@ -39,20 +39,21 @@ static void _cogl_attribute_buffer_free (CoglAttributeBuffer *array); COGL_BUFFER_DEFINE (AttributeBuffer, attribute_buffer); CoglAttributeBuffer * -cogl_attribute_buffer_new (gsize bytes, const void *data) +cogl_attribute_buffer_new (CoglContext *context, + gsize bytes, + const void *data) { CoglAttributeBuffer *array = g_slice_new (CoglAttributeBuffer); gboolean use_malloc; - _COGL_GET_CONTEXT (ctx, NULL); - - if (!(ctx->private_feature_flags & COGL_PRIVATE_FEATURE_VBOS)) + if (!(context->private_feature_flags & COGL_PRIVATE_FEATURE_VBOS)) use_malloc = TRUE; else use_malloc = FALSE; /* parent's constructor */ _cogl_buffer_initialize (COGL_BUFFER (array), + context, bytes, use_malloc, COGL_BUFFER_BIND_TARGET_ATTRIBUTE_BUFFER, diff --git a/cogl/cogl-attribute-buffer.h b/cogl/cogl-attribute-buffer.h index 270f76a81..d7860f2dd 100644 --- a/cogl/cogl-attribute-buffer.h +++ b/cogl/cogl-attribute-buffer.h @@ -31,6 +31,8 @@ #ifndef __COGL_ATTRIBUTE_BUFFER_H__ #define __COGL_ATTRIBUTE_BUFFER_H__ +#include + G_BEGIN_DECLS /** @@ -45,6 +47,7 @@ typedef struct _CoglAttributeBuffer CoglAttributeBuffer; /** * cogl_attribute_buffer_new: + * @context: A #CoglContext * @bytes: The number of bytes to allocate for vertex attribute data. * @data: An optional pointer to vertex data to upload immediately. * @@ -59,7 +62,9 @@ typedef struct _CoglAttributeBuffer CoglAttributeBuffer; * Stability: Unstable */ CoglAttributeBuffer * -cogl_attribute_buffer_new (gsize bytes, const void *data); +cogl_attribute_buffer_new (CoglContext *context, + gsize bytes, + const void *data); /** * cogl_is_attribute_buffer: diff --git a/cogl/cogl-buffer-private.h b/cogl/cogl-buffer-private.h index 93c1c065b..490ba6656 100644 --- a/cogl/cogl-buffer-private.h +++ b/cogl/cogl-buffer-private.h @@ -78,6 +78,9 @@ typedef enum { struct _CoglBuffer { CoglObject _parent; + + CoglContext *context; + CoglBufferVtable vtable; CoglBufferBindTarget last_target; @@ -111,6 +114,7 @@ _cogl_buffer_register_buffer_type (const CoglObjectClass *klass); void _cogl_buffer_initialize (CoglBuffer *buffer, + CoglContext *context, unsigned int size, gboolean use_malloc, CoglBufferBindTarget default_target, @@ -133,10 +137,6 @@ _cogl_buffer_get_usage_hint (CoglBuffer *buffer); GLenum _cogl_buffer_access_to_gl_enum (CoglBufferAccess access); -GLenum -_cogl_buffer_hints_to_gl_enum (CoglBufferUsageHint usage_hint, - CoglBufferUpdateHint update_hint); - CoglBuffer * _cogl_buffer_immutable_ref (CoglBuffer *buffer); diff --git a/cogl/cogl-buffer.c b/cogl/cogl-buffer.c index 9b7f6766b..cb9b5c7ae 100644 --- a/cogl/cogl-buffer.c +++ b/cogl/cogl-buffer.c @@ -77,12 +77,12 @@ * abstract class manually. */ +static GSList *_cogl_buffer_types; + void _cogl_buffer_register_buffer_type (const CoglObjectClass *klass) { - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - ctx->buffer_types = g_slist_prepend (ctx->buffer_types, (void *) klass); + _cogl_buffer_types = g_slist_prepend (_cogl_buffer_types, (void *) klass); } gboolean @@ -91,12 +91,10 @@ cogl_is_buffer (const void *object) const CoglHandleObject *obj = object; GSList *l; - _COGL_GET_CONTEXT (ctx, FALSE); - if (object == NULL) return FALSE; - for (l = ctx->buffer_types; l; l = l->next) + for (l = _cogl_buffer_types; l; l = l->next) if (l->data == obj->klass) return TRUE; @@ -121,6 +119,24 @@ convert_bind_target_to_gl_target (CoglBufferBindTarget target) } } +static GLenum +_cogl_buffer_hints_to_gl_enum (CoglBufferUsageHint usage_hint, + CoglBufferUpdateHint update_hint) +{ + /* usage hint is always TEXTURE for now */ + if (update_hint == COGL_BUFFER_UPDATE_HINT_STATIC) + return GL_STATIC_DRAW; + if (update_hint == COGL_BUFFER_UPDATE_HINT_DYNAMIC) + return GL_DYNAMIC_DRAW; + /* OpenGL ES 1.1 and 2 only know about STATIC_DRAW and DYNAMIC_DRAW */ +#ifdef HAVE_COGL_GL + if (update_hint == COGL_BUFFER_UPDATE_HINT_STREAM) + return GL_STREAM_DRAW; +#endif + + return GL_STATIC_DRAW; +} + static void * bo_map (CoglBuffer *buffer, CoglBufferAccess access, @@ -129,8 +145,7 @@ bo_map (CoglBuffer *buffer, guint8 *data; CoglBufferBindTarget target; GLenum gl_target; - - _COGL_GET_CONTEXT (ctx, NULL); + CoglContext *ctx = buffer->context; if ((access & COGL_BUFFER_ACCESS_READ) && !cogl_has_feature (ctx, COGL_FEATURE_ID_MAP_BUFFER_FOR_READ)) @@ -175,7 +190,7 @@ bo_map (CoglBuffer *buffer, static void bo_unmap (CoglBuffer *buffer) { - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + CoglContext *ctx = buffer->context; _cogl_buffer_bind (buffer, buffer->last_target); @@ -194,8 +209,7 @@ bo_set_data (CoglBuffer *buffer, { CoglBufferBindTarget target; GLenum gl_target; - - _COGL_GET_CONTEXT (ctx, FALSE); + CoglContext *ctx = buffer->context; target = buffer->last_target; _cogl_buffer_bind (buffer, target); @@ -254,14 +268,14 @@ malloc_set_data (CoglBuffer *buffer, void _cogl_buffer_initialize (CoglBuffer *buffer, + CoglContext *context, unsigned int size, gboolean use_malloc, CoglBufferBindTarget default_target, CoglBufferUsageHint usage_hint, CoglBufferUpdateHint update_hint) { - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - + buffer->context = cogl_object_ref (context); buffer->flags = COGL_BUFFER_FLAG_NONE; buffer->store_created = FALSE; buffer->size = size; @@ -285,7 +299,7 @@ _cogl_buffer_initialize (CoglBuffer *buffer, buffer->vtable.unmap = bo_unmap; buffer->vtable.set_data = bo_set_data; - GE( ctx, glGenBuffers (1, &buffer->gl_handle) ); + GE( context, glGenBuffers (1, &buffer->gl_handle) ); buffer->flags |= COGL_BUFFER_FLAG_BUFFER_OBJECT; } } @@ -293,15 +307,15 @@ _cogl_buffer_initialize (CoglBuffer *buffer, void _cogl_buffer_fini (CoglBuffer *buffer) { - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - _COGL_RETURN_IF_FAIL (!(buffer->flags & COGL_BUFFER_FLAG_MAPPED)); _COGL_RETURN_IF_FAIL (buffer->immutable_ref == 0); if (buffer->flags & COGL_BUFFER_FLAG_BUFFER_OBJECT) - GE( ctx, glDeleteBuffers (1, &buffer->gl_handle) ); + GE( buffer->context, glDeleteBuffers (1, &buffer->gl_handle) ); else g_free (buffer->data); + + cogl_object_unref (buffer->context); } GLenum @@ -315,30 +329,10 @@ _cogl_buffer_access_to_gl_enum (CoglBufferAccess access) return GL_READ_ONLY; } -GLenum -_cogl_buffer_hints_to_gl_enum (CoglBufferUsageHint usage_hint, - CoglBufferUpdateHint update_hint) -{ - _COGL_GET_CONTEXT (ctx, 0); - - /* usage hint is always TEXTURE for now */ - if (update_hint == COGL_BUFFER_UPDATE_HINT_STATIC) - return GL_STATIC_DRAW; - if (update_hint == COGL_BUFFER_UPDATE_HINT_DYNAMIC) - return GL_DYNAMIC_DRAW; - /* OpenGL ES 1.1 and 2 only know about STATIC_DRAW and DYNAMIC_DRAW */ -#ifdef HAVE_COGL_GL - if (update_hint == COGL_BUFFER_UPDATE_HINT_STREAM) - return GL_STREAM_DRAW; -#endif - - return GL_STATIC_DRAW; -} - void * _cogl_buffer_bind (CoglBuffer *buffer, CoglBufferBindTarget target) { - _COGL_GET_CONTEXT (ctx, NULL); + CoglContext *ctx = buffer->context; _COGL_RETURN_VAL_IF_FAIL (buffer != NULL, NULL); @@ -365,7 +359,7 @@ _cogl_buffer_bind (CoglBuffer *buffer, CoglBufferBindTarget target) void _cogl_buffer_unbind (CoglBuffer *buffer) { - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + CoglContext *ctx = buffer->context; _COGL_RETURN_IF_FAIL (buffer != NULL); @@ -456,10 +450,9 @@ cogl_buffer_unmap (CoglBuffer *buffer) void * _cogl_buffer_map_for_fill_or_fallback (CoglBuffer *buffer) { + CoglContext *ctx = buffer->context; void *ret; - _COGL_GET_CONTEXT (ctx, NULL); - _COGL_RETURN_VAL_IF_FAIL (!ctx->buffer_map_fallback_in_use, NULL); ctx->buffer_map_fallback_in_use = TRUE; @@ -487,7 +480,7 @@ _cogl_buffer_map_for_fill_or_fallback (CoglBuffer *buffer) void _cogl_buffer_unmap_for_fill_or_fallback (CoglBuffer *buffer) { - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + CoglContext *ctx = buffer->context; _COGL_RETURN_IF_FAIL (ctx->buffer_map_fallback_in_use); diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c index a90ce0633..ccefc4926 100644 --- a/cogl/cogl-framebuffer.c +++ b/cogl/cogl-framebuffer.c @@ -2610,6 +2610,8 @@ draw_wireframe (CoglFramebuffer *framebuffer, CoglVertexP3 *lines; CoglAttributeBuffer *attribute_buffer; + _COGL_GET_CONTEXT (ctx, NO_RETVAL); + for (i = 0; i < n_attributes; i++) { if (attributes[i]->name_state->name_id == @@ -2628,7 +2630,7 @@ draw_wireframe (CoglFramebuffer *framebuffer, &n_line_vertices, indices); attribute_buffer = - cogl_attribute_buffer_new (sizeof (CoglVertexP3) * n_line_vertices, + cogl_attribute_buffer_new (ctx, sizeof (CoglVertexP3) * n_line_vertices, lines); wire_attribute[0] = cogl_attribute_new (attribute_buffer, "cogl_position_in", diff --git a/cogl/cogl-index-buffer.c b/cogl/cogl-index-buffer.c index 48c2c423a..7a6b196c6 100644 --- a/cogl/cogl-index-buffer.c +++ b/cogl/cogl-index-buffer.c @@ -42,20 +42,19 @@ COGL_BUFFER_DEFINE (IndexBuffer, index_buffer); * indices buffer should be able to contain multiple ranges of indices * which the wiki design doesn't currently consider. */ CoglIndexBuffer * -cogl_index_buffer_new (gsize bytes) +cogl_index_buffer_new (CoglContext *context, gsize bytes) { CoglIndexBuffer *indices = g_slice_new (CoglIndexBuffer); gboolean use_malloc; - _COGL_GET_CONTEXT (ctx, NULL); - - if (!(ctx->private_feature_flags & COGL_PRIVATE_FEATURE_VBOS)) + if (!(context->private_feature_flags & COGL_PRIVATE_FEATURE_VBOS)) use_malloc = TRUE; else use_malloc = FALSE; /* parent's constructor */ _cogl_buffer_initialize (COGL_BUFFER (indices), + context, bytes, use_malloc, COGL_BUFFER_BIND_TARGET_INDEX_BUFFER, diff --git a/cogl/cogl-index-buffer.h b/cogl/cogl-index-buffer.h index edddfe9fd..e57bcd110 100644 --- a/cogl/cogl-index-buffer.h +++ b/cogl/cogl-index-buffer.h @@ -31,6 +31,8 @@ #ifndef __COGL_INDEX_BUFFER_H__ #define __COGL_INDEX_BUFFER_H__ +#include + G_BEGIN_DECLS /** @@ -45,6 +47,7 @@ typedef struct _CoglIndexBuffer CoglIndexBuffer; /** * cogl_index_buffer_new: + * @context: A #CoglContext * @bytes: The number of bytes to allocate for vertex attribute data. * * Declares a new #CoglIndexBuffer of @size bytes to contain vertex @@ -56,7 +59,8 @@ typedef struct _CoglIndexBuffer CoglIndexBuffer; * Stability: Unstable */ CoglIndexBuffer * -cogl_index_buffer_new (gsize bytes); +cogl_index_buffer_new (CoglContext *context, + gsize bytes); /** * cogl_is_index_buffer: diff --git a/cogl/cogl-indices.c b/cogl/cogl-indices.c index 686ef8ac2..c99985cea 100644 --- a/cogl/cogl-indices.c +++ b/cogl/cogl-indices.c @@ -76,12 +76,13 @@ cogl_indices_new_for_buffer (CoglIndicesType type, } CoglIndices * -cogl_indices_new (CoglIndicesType type, +cogl_indices_new (CoglContext *context, + CoglIndicesType type, const void *indices_data, int n_indices) { size_t buffer_bytes = sizeof_indices_type (type) * n_indices; - CoglIndexBuffer *index_buffer = cogl_index_buffer_new (buffer_bytes); + CoglIndexBuffer *index_buffer = cogl_index_buffer_new (context, buffer_bytes); CoglBuffer *buffer = COGL_BUFFER (index_buffer); CoglIndices *indices; @@ -170,12 +171,10 @@ _cogl_indices_immutable_unref (CoglIndices *indices) } CoglIndices * -cogl_get_rectangle_indices (int n_rectangles) +cogl_get_rectangle_indices (CoglContext *ctx, int n_rectangles) { int n_indices = n_rectangles * 6; - _COGL_GET_CONTEXT (ctx, NULL); - /* Check if the largest index required will fit in a byte array... */ if (n_indices <= 256 / 4 * 6) { @@ -198,7 +197,8 @@ cogl_get_rectangle_indices (int n_rectangles) } ctx->rectangle_byte_indices - = cogl_indices_new (COGL_INDICES_TYPE_UNSIGNED_BYTE, + = cogl_indices_new (ctx, + COGL_INDICES_TYPE_UNSIGNED_BYTE, byte_array, 256 / 4 * 6); @@ -241,7 +241,8 @@ cogl_get_rectangle_indices (int n_rectangles) } ctx->rectangle_short_indices - = cogl_indices_new (COGL_INDICES_TYPE_UNSIGNED_SHORT, + = cogl_indices_new (ctx, + COGL_INDICES_TYPE_UNSIGNED_SHORT, short_array, ctx->rectangle_short_indices_len); diff --git a/cogl/cogl-indices.h b/cogl/cogl-indices.h index be1998c8c..58c2671b6 100644 --- a/cogl/cogl-indices.h +++ b/cogl/cogl-indices.h @@ -97,7 +97,8 @@ G_BEGIN_DECLS typedef struct _CoglIndices CoglIndices; CoglIndices * -cogl_indices_new (CoglIndicesType type, +cogl_indices_new (CoglContext *context, + CoglIndicesType type, const void *indices_data, int n_indices); @@ -120,7 +121,7 @@ cogl_indices_set_offset (CoglIndices *indices, gsize offset); CoglIndices * -cogl_get_rectangle_indices (int n_rectangles); +cogl_get_rectangle_indices (CoglContext *context, int n_rectangles); G_END_DECLS diff --git a/cogl/cogl-journal.c b/cogl/cogl-journal.c index b9e3b179e..5d0cf05ce 100644 --- a/cogl/cogl-journal.c +++ b/cogl/cogl-journal.c @@ -576,6 +576,7 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start, void *data) { CoglJournalFlushState *state = data; + CoglContext *ctx = state->framebuffer->context; gsize stride; int i; CoglAttribute **attribute_entry; @@ -586,8 +587,6 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start, "pipeline + entries", 0 /* no application private data */); - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - COGL_TIMER_START (_cogl_uprof_context, time_flush_vbo_texcoord_pipeline_entries); @@ -630,7 +629,7 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start, COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE); if (ctx->driver != COGL_DRIVER_GL) - state->indices = cogl_get_rectangle_indices (batch_len); + state->indices = cogl_get_rectangle_indices (ctx, batch_len); /* We only create new Attributes when the stride within the * AttributeBuffer changes. (due to a change in the number of pipeline @@ -1133,20 +1132,20 @@ create_attribute_buffer (CoglJournal *journal, really any point in using the pool so we'll just allocate the buffer directly */ if (!(ctx->private_feature_flags & COGL_PRIVATE_FEATURE_VBOS)) - return cogl_attribute_buffer_new (n_bytes, NULL); + return cogl_attribute_buffer_new (ctx, n_bytes, NULL); vbo = journal->vbo_pool[journal->next_vbo_in_pool]; if (vbo == NULL) { - vbo = cogl_attribute_buffer_new (n_bytes, NULL); + vbo = cogl_attribute_buffer_new (ctx, n_bytes, NULL); journal->vbo_pool[journal->next_vbo_in_pool] = vbo; } 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); - vbo = cogl_attribute_buffer_new (n_bytes, NULL); + vbo = cogl_attribute_buffer_new (ctx, n_bytes, NULL); journal->vbo_pool[journal->next_vbo_in_pool] = vbo; } diff --git a/cogl/cogl-pixel-buffer.c b/cogl/cogl-pixel-buffer.c index e49d4a824..84f948f26 100644 --- a/cogl/cogl-pixel-buffer.c +++ b/cogl/cogl-pixel-buffer.c @@ -68,21 +68,20 @@ _cogl_pixel_buffer_free (CoglPixelBuffer *buffer); COGL_BUFFER_DEFINE (PixelBuffer, pixel_buffer) static CoglPixelBuffer * -_cogl_pixel_buffer_new (unsigned int size) +_cogl_pixel_buffer_new (CoglContext *context, unsigned int size) { CoglPixelBuffer *pixel_buffer = g_slice_new0 (CoglPixelBuffer); CoglBuffer *buffer = COGL_BUFFER (pixel_buffer); gboolean use_malloc; - _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE); - - if (!(ctx->private_feature_flags & COGL_PRIVATE_FEATURE_PBOS)) + if (!(context->private_feature_flags & COGL_PRIVATE_FEATURE_PBOS)) use_malloc = TRUE; else use_malloc = FALSE; /* parent's constructor */ _cogl_buffer_initialize (buffer, + context, size, use_malloc, COGL_BUFFER_BIND_TARGET_PIXEL_UNPACK, @@ -94,7 +93,8 @@ _cogl_pixel_buffer_new (unsigned int size) } CoglPixelBuffer * -cogl_pixel_buffer_new_with_size (unsigned int width, +cogl_pixel_buffer_new_with_size (CoglContext *context, + unsigned int width, unsigned int height, CoglPixelFormat format, unsigned int *rowstride) @@ -113,7 +113,7 @@ cogl_pixel_buffer_new_with_size (unsigned int width, if (rowstride) *rowstride = stride; - buffer = _cogl_pixel_buffer_new (height * stride); + buffer = _cogl_pixel_buffer_new (context, height * stride); if (G_UNLIKELY (buffer == COGL_INVALID_HANDLE)) return COGL_INVALID_HANDLE; @@ -129,8 +129,6 @@ cogl_pixel_buffer_new_with_size (unsigned int width, static void _cogl_pixel_buffer_free (CoglPixelBuffer *buffer) { - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - /* parent's destructor */ _cogl_buffer_fini (COGL_BUFFER (buffer)); diff --git a/cogl/cogl-pixel-buffer.h b/cogl/cogl-pixel-buffer.h index cd2f685fb..a529af766 100644 --- a/cogl/cogl-pixel-buffer.h +++ b/cogl/cogl-pixel-buffer.h @@ -34,6 +34,7 @@ #include #include +#include G_BEGIN_DECLS @@ -54,6 +55,7 @@ typedef struct _CoglPixelBuffer CoglPixelBuffer; /** * cogl_pixel_buffer_new_with_size: + * @context: A #CoglContext * @width: width of the pixel array in pixels * @height: height of the pixel array in pixels * @format: the format of the pixels the array will store @@ -75,7 +77,8 @@ typedef struct _CoglPixelBuffer CoglPixelBuffer; * Stability: Unstable */ CoglPixelBuffer * -cogl_pixel_buffer_new_with_size (unsigned int width, +cogl_pixel_buffer_new_with_size (CoglContext *context, + unsigned int width, unsigned int height, CoglPixelFormat format, unsigned int *stride); diff --git a/cogl/cogl-primitive.c b/cogl/cogl-primitive.c index b6a3abdf2..c7f7a4e41 100644 --- a/cogl/cogl-primitive.c +++ b/cogl/cogl-primitive.c @@ -127,12 +127,13 @@ cogl_primitive_new (CoglVerticesMode mode, } CoglPrimitive * -cogl_primitive_new_p2 (CoglVerticesMode mode, +cogl_primitive_new_p2 (CoglContext *ctx, + CoglVerticesMode mode, int n_vertices, const CoglVertexP2 *data) { CoglAttributeBuffer *attribute_buffer = - cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP2), data); + cogl_attribute_buffer_new (ctx, n_vertices * sizeof (CoglVertexP2), data); CoglAttribute *attributes[1]; attributes[0] = cogl_attribute_new (attribute_buffer, @@ -150,12 +151,13 @@ cogl_primitive_new_p2 (CoglVerticesMode mode, } CoglPrimitive * -cogl_primitive_new_p3 (CoglVerticesMode mode, +cogl_primitive_new_p3 (CoglContext *ctx, + CoglVerticesMode mode, int n_vertices, const CoglVertexP3 *data) { CoglAttributeBuffer *attribute_buffer = - cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP3), data); + cogl_attribute_buffer_new (ctx, n_vertices * sizeof (CoglVertexP3), data); CoglAttribute *attributes[1]; attributes[0] = cogl_attribute_new (attribute_buffer, @@ -173,12 +175,13 @@ cogl_primitive_new_p3 (CoglVerticesMode mode, } CoglPrimitive * -cogl_primitive_new_p2c4 (CoglVerticesMode mode, +cogl_primitive_new_p2c4 (CoglContext *ctx, + CoglVerticesMode mode, int n_vertices, const CoglVertexP2C4 *data) { CoglAttributeBuffer *attribute_buffer = - cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP2C4), data); + cogl_attribute_buffer_new (ctx, n_vertices * sizeof (CoglVertexP2C4), data); CoglAttribute *attributes[2]; attributes[0] = cogl_attribute_new (attribute_buffer, @@ -202,12 +205,13 @@ cogl_primitive_new_p2c4 (CoglVerticesMode mode, } CoglPrimitive * -cogl_primitive_new_p3c4 (CoglVerticesMode mode, +cogl_primitive_new_p3c4 (CoglContext *ctx, + CoglVerticesMode mode, int n_vertices, const CoglVertexP3C4 *data) { CoglAttributeBuffer *attribute_buffer = - cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP3C4), data); + cogl_attribute_buffer_new (ctx, n_vertices * sizeof (CoglVertexP3C4), data); CoglAttribute *attributes[2]; attributes[0] = cogl_attribute_new (attribute_buffer, @@ -231,12 +235,13 @@ cogl_primitive_new_p3c4 (CoglVerticesMode mode, } CoglPrimitive * -cogl_primitive_new_p2t2 (CoglVerticesMode mode, +cogl_primitive_new_p2t2 (CoglContext *ctx, + CoglVerticesMode mode, int n_vertices, const CoglVertexP2T2 *data) { CoglAttributeBuffer *attribute_buffer = - cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP2T2), data); + cogl_attribute_buffer_new (ctx, n_vertices * sizeof (CoglVertexP2T2), data); CoglAttribute *attributes[2]; attributes[0] = cogl_attribute_new (attribute_buffer, @@ -260,12 +265,13 @@ cogl_primitive_new_p2t2 (CoglVerticesMode mode, } CoglPrimitive * -cogl_primitive_new_p3t2 (CoglVerticesMode mode, +cogl_primitive_new_p3t2 (CoglContext *ctx, + CoglVerticesMode mode, int n_vertices, const CoglVertexP3T2 *data) { CoglAttributeBuffer *attribute_buffer = - cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP3T2), data); + cogl_attribute_buffer_new (ctx, n_vertices * sizeof (CoglVertexP3T2), data); CoglAttribute *attributes[2]; attributes[0] = cogl_attribute_new (attribute_buffer, @@ -289,12 +295,14 @@ cogl_primitive_new_p3t2 (CoglVerticesMode mode, } CoglPrimitive * -cogl_primitive_new_p2t2c4 (CoglVerticesMode mode, +cogl_primitive_new_p2t2c4 (CoglContext *ctx, + CoglVerticesMode mode, int n_vertices, const CoglVertexP2T2C4 *data) { CoglAttributeBuffer *attribute_buffer = - cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP2T2C4), data); + cogl_attribute_buffer_new (ctx, + n_vertices * sizeof (CoglVertexP2T2C4), data); CoglAttribute *attributes[3]; attributes[0] = cogl_attribute_new (attribute_buffer, @@ -324,12 +332,14 @@ cogl_primitive_new_p2t2c4 (CoglVerticesMode mode, } CoglPrimitive * -cogl_primitive_new_p3t2c4 (CoglVerticesMode mode, +cogl_primitive_new_p3t2c4 (CoglContext *ctx, + CoglVerticesMode mode, int n_vertices, const CoglVertexP3T2C4 *data) { CoglAttributeBuffer *attribute_buffer = - cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP3T2C4), data); + cogl_attribute_buffer_new (ctx, + n_vertices * sizeof (CoglVertexP3T2C4), data); CoglAttribute *attributes[3]; attributes[0] = cogl_attribute_new (attribute_buffer, diff --git a/cogl/cogl-primitive.h b/cogl/cogl-primitive.h index fea8fd609..af114f6f1 100644 --- a/cogl/cogl-primitive.h +++ b/cogl/cogl-primitive.h @@ -244,6 +244,7 @@ cogl_primitive_new_with_attributes (CoglVerticesMode mode, /** * cogl_primitive_new_p2: + * @context: A #CoglContext * @mode: A #CoglVerticesMode defining how to draw the vertices * @n_vertices: The number of vertices to read from @data and also * the number of vertices to read when later drawing. @@ -289,12 +290,14 @@ cogl_primitive_new_with_attributes (CoglVerticesMode mode, * Stability: Unstable */ CoglPrimitive * -cogl_primitive_new_p2 (CoglVerticesMode mode, +cogl_primitive_new_p2 (CoglContext *context, + CoglVerticesMode mode, int n_vertices, const CoglVertexP2 *data); /** * cogl_primitive_new_p3: + * @context: A #CoglContext * @mode: A #CoglVerticesMode defining how to draw the vertices * @n_vertices: The number of vertices to read from @data and also * the number of vertices to read when later drawing. @@ -340,12 +343,14 @@ cogl_primitive_new_p2 (CoglVerticesMode mode, * Stability: Unstable */ CoglPrimitive * -cogl_primitive_new_p3 (CoglVerticesMode mode, +cogl_primitive_new_p3 (CoglContext *context, + CoglVerticesMode mode, int n_vertices, const CoglVertexP3 *data); /** * cogl_primitive_new_p2c4: + * @context: A #CoglContext * @mode: A #CoglVerticesMode defining how to draw the vertices * @n_vertices: The number of vertices to read from @data and also * the number of vertices to read when later drawing. @@ -393,12 +398,14 @@ cogl_primitive_new_p3 (CoglVerticesMode mode, * Stability: Unstable */ CoglPrimitive * -cogl_primitive_new_p2c4 (CoglVerticesMode mode, +cogl_primitive_new_p2c4 (CoglContext *context, + CoglVerticesMode mode, int n_vertices, const CoglVertexP2C4 *data); /** * cogl_primitive_new_p3c4: + * @context: A #CoglContext * @mode: A #CoglVerticesMode defining how to draw the vertices * @n_vertices: The number of vertices to read from @data and also * the number of vertices to read when later drawing. @@ -446,12 +453,14 @@ cogl_primitive_new_p2c4 (CoglVerticesMode mode, * Stability: Unstable */ CoglPrimitive * -cogl_primitive_new_p3c4 (CoglVerticesMode mode, +cogl_primitive_new_p3c4 (CoglContext *context, + CoglVerticesMode mode, int n_vertices, const CoglVertexP3C4 *data); /** * cogl_primitive_new_p2t2: + * @context: A #CoglContext * @mode: A #CoglVerticesMode defining how to draw the vertices * @n_vertices: The number of vertices to read from @data and also * the number of vertices to read when later drawing. @@ -499,12 +508,14 @@ cogl_primitive_new_p3c4 (CoglVerticesMode mode, * Stability: Unstable */ CoglPrimitive * -cogl_primitive_new_p2t2 (CoglVerticesMode mode, +cogl_primitive_new_p2t2 (CoglContext *context, + CoglVerticesMode mode, int n_vertices, const CoglVertexP2T2 *data); /** * cogl_primitive_new_p3t2: + * @context: A #CoglContext * @mode: A #CoglVerticesMode defining how to draw the vertices * @n_vertices: The number of vertices to read from @data and also * the number of vertices to read when later drawing. @@ -552,12 +563,14 @@ cogl_primitive_new_p2t2 (CoglVerticesMode mode, * Stability: Unstable */ CoglPrimitive * -cogl_primitive_new_p3t2 (CoglVerticesMode mode, +cogl_primitive_new_p3t2 (CoglContext *context, + CoglVerticesMode mode, int n_vertices, const CoglVertexP3T2 *data); /** * cogl_primitive_new_p2t2c4: + * @context: A #CoglContext * @mode: A #CoglVerticesMode defining how to draw the vertices * @n_vertices: The number of vertices to read from @data and also * the number of vertices to read when later drawing. @@ -605,12 +618,14 @@ cogl_primitive_new_p3t2 (CoglVerticesMode mode, * Stability: Unstable */ CoglPrimitive * -cogl_primitive_new_p2t2c4 (CoglVerticesMode mode, +cogl_primitive_new_p2t2c4 (CoglContext *context, + CoglVerticesMode mode, int n_vertices, const CoglVertexP2T2C4 *data); /** * cogl_primitive_new_p3t2c4: + * @context: A #CoglContext * @mode: A #CoglVerticesMode defining how to draw the vertices * @n_vertices: The number of vertices to read from @data and also * the number of vertices to read when later drawing. @@ -658,7 +673,8 @@ cogl_primitive_new_p2t2c4 (CoglVerticesMode mode, * Stability: Unstable */ CoglPrimitive * -cogl_primitive_new_p3t2c4 (CoglVerticesMode mode, +cogl_primitive_new_p3t2c4 (CoglContext *context, + CoglVerticesMode mode, int n_vertices, const CoglVertexP3T2C4 *data); int diff --git a/cogl/cogl-primitives.c b/cogl/cogl-primitives.c index d8328b0c9..3bea1b0f0 100644 --- a/cogl/cogl-primitives.c +++ b/cogl/cogl-primitives.c @@ -861,7 +861,10 @@ _cogl_rectangle_immediate (CoglFramebuffer *framebuffer, CoglAttributeBuffer *attribute_buffer; CoglAttribute *attributes[1]; - attribute_buffer = cogl_attribute_buffer_new (sizeof (vertices), vertices); + _COGL_GET_CONTEXT (ctx, NO_RETVAL); + + attribute_buffer = + cogl_attribute_buffer_new (ctx, sizeof (vertices), vertices); attributes[0] = cogl_attribute_new (attribute_buffer, "cogl_position_in", sizeof (float) * 2, /* stride */ @@ -1008,7 +1011,7 @@ cogl_polygon (const CoglTextureVertex *vertices, g_array_set_size (ctx->polygon_vertices, n_vertices * stride); attribute_buffer = - cogl_attribute_buffer_new (n_vertices * stride_bytes, NULL); + cogl_attribute_buffer_new (ctx, n_vertices * stride_bytes, NULL); attributes[0] = cogl_attribute_new (attribute_buffer, "cogl_position_in", diff --git a/cogl/cogl-vertex-buffer.c b/cogl/cogl-vertex-buffer.c index ff795a1a6..31a67ce51 100644 --- a/cogl/cogl-vertex-buffer.c +++ b/cogl/cogl-vertex-buffer.c @@ -1133,8 +1133,10 @@ cogl_vertex_buffer_vbo_resolve (CoglVertexBuffer *buffer, if (!found_target_vbo) { + _COGL_GET_CONTEXT (ctx, NO_RETVAL); + new_cogl_vbo->attribute_buffer = - cogl_attribute_buffer_new (new_cogl_vbo->buffer_bytes, NULL); + cogl_attribute_buffer_new (ctx, new_cogl_vbo->buffer_bytes, NULL); upload_attributes (new_cogl_vbo); *final_vbos = g_list_prepend (*final_vbos, new_cogl_vbo); @@ -1665,8 +1667,11 @@ cogl_vertex_buffer_indices_new (CoglIndicesType indices_type, const void *indices_array, int indices_len) { - CoglIndices *indices = - cogl_indices_new (indices_type, indices_array, indices_len); + CoglIndices *indices; + + _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE); + + indices = cogl_indices_new (ctx, indices_type, indices_array, indices_len); return _cogl_vertex_buffer_indices_new_real (indices); } @@ -1747,7 +1752,7 @@ cogl_vertex_buffer_indices_get_for_quads (unsigned int n_indices) if (ctx->quad_buffer_indices_byte == COGL_INVALID_HANDLE) { /* NB: cogl_get_quad_indices takes n_quads not n_indices... */ - CoglIndices *indices = cogl_get_rectangle_indices (256 / 4); + CoglIndices *indices = cogl_get_rectangle_indices (ctx, 256 / 4); cogl_object_ref (indices); ctx->quad_buffer_indices_byte = _cogl_vertex_buffer_indices_new_real (indices); @@ -1767,7 +1772,8 @@ cogl_vertex_buffer_indices_get_for_quads (unsigned int n_indices) if (ctx->quad_buffer_indices == COGL_INVALID_HANDLE) { /* NB: cogl_get_quad_indices takes n_quads not n_indices... */ - CoglIndices *indices = cogl_get_rectangle_indices (n_indices / 6); + CoglIndices *indices = + cogl_get_rectangle_indices (ctx, n_indices / 6); cogl_object_ref (indices); ctx->quad_buffer_indices = _cogl_vertex_buffer_indices_new_real (indices); diff --git a/cogl/cogl2-path.c b/cogl/cogl2-path.c index cd7e45341..6e86ab81b 100644 --- a/cogl/cogl2-path.c +++ b/cogl/cogl2-path.c @@ -1267,6 +1267,8 @@ _cogl_path_build_fill_attribute_buffer (CoglPath *path) CoglPathData *data = path->data; int i; + _COGL_GET_CONTEXT (ctx, NO_RETVAL); + /* If we've already got a vbo then we don't need to do anything */ if (data->fill_attribute_buffer) return; @@ -1352,7 +1354,8 @@ _cogl_path_build_fill_attribute_buffer (CoglPath *path) gluDeleteTess (tess.glu_tess); data->fill_attribute_buffer = - cogl_attribute_buffer_new (sizeof (CoglPathTesselatorVertex) * + cogl_attribute_buffer_new (ctx, + sizeof (CoglPathTesselatorVertex) * tess.vertices->len, tess.vertices->data); g_array_free (tess.vertices, TRUE); @@ -1372,7 +1375,8 @@ _cogl_path_build_fill_attribute_buffer (CoglPath *path) 2, /* n_components */ COGL_ATTRIBUTE_TYPE_FLOAT); - data->fill_vbo_indices = cogl_indices_new (tess.indices_type, + data->fill_vbo_indices = cogl_indices_new (ctx, + tess.indices_type, tess.indices->data, tess.indices->len); data->fill_vbo_n_indices = tess.indices->len; @@ -1390,12 +1394,14 @@ _cogl_path_build_stroke_attribute_buffer (CoglPath *path) floatVec2 *buffer_p; unsigned int i; + _COGL_GET_CONTEXT (ctx, NO_RETVAL); + /* If we've already got a cached vbo then we don't need to do anything */ if (data->stroke_attribute_buffer) return; data->stroke_attribute_buffer = - cogl_attribute_buffer_new (data->path_nodes->len * sizeof (floatVec2), + cogl_attribute_buffer_new (ctx, data->path_nodes->len * sizeof (floatVec2), NULL); buffer = COGL_BUFFER (data->stroke_attribute_buffer); diff --git a/examples/cogl-crate.c b/examples/cogl-crate.c index cc288327f..22a189868 100644 --- a/examples/cogl-crate.c +++ b/examples/cogl-crate.c @@ -209,8 +209,8 @@ main (int argc, char **argv) * cogl_get_rectangle_indices() is a convenience function for * accessing internal index buffers that can be shared. */ - data.indices = cogl_get_rectangle_indices (6 /* n_rectangles */); - data.prim = cogl_primitive_new_p3t2 (COGL_VERTICES_MODE_TRIANGLES, + data.indices = cogl_get_rectangle_indices (ctx, 6 /* n_rectangles */); + data.prim = cogl_primitive_new_p3t2 (ctx, COGL_VERTICES_MODE_TRIANGLES, G_N_ELEMENTS (vertices), vertices); /* Each face will have 6 indices so we have 6 * 6 indices in total... */ diff --git a/examples/cogl-hello.c b/examples/cogl-hello.c index 5b8b20687..152aa5651 100644 --- a/examples/cogl-hello.c +++ b/examples/cogl-hello.c @@ -29,7 +29,7 @@ main (int argc, char **argv) cogl_onscreen_show (onscreen); fb = COGL_FRAMEBUFFER (onscreen); - triangle = cogl_primitive_new_p2c4 (COGL_VERTICES_MODE_TRIANGLES, + triangle = cogl_primitive_new_p2c4 (ctx, COGL_VERTICES_MODE_TRIANGLES, 3, triangle_vertices); pipeline = cogl_pipeline_new (); diff --git a/examples/cogl-msaa.c b/examples/cogl-msaa.c index 7316e5381..e39f164d2 100644 --- a/examples/cogl-msaa.c +++ b/examples/cogl-msaa.c @@ -77,7 +77,7 @@ main (int argc, char **argv) cogl_framebuffer_set_samples_per_pixel (offscreen_fb, 0); } - triangle = cogl_primitive_new_p2c4 (COGL_VERTICES_MODE_TRIANGLES, + triangle = cogl_primitive_new_p2c4 (ctx, COGL_VERTICES_MODE_TRIANGLES, 3, triangle_vertices); pipeline = cogl_pipeline_new (); diff --git a/examples/cogl-sdl-hello.c b/examples/cogl-sdl-hello.c index db899abb3..d7b8c7625 100644 --- a/examples/cogl-sdl-hello.c +++ b/examples/cogl-sdl-hello.c @@ -148,7 +148,7 @@ main (int argc, char **argv) cogl_onscreen_show (onscreen); - data.triangle = cogl_primitive_new_p2c4 (COGL_VERTICES_MODE_TRIANGLES, + data.triangle = cogl_primitive_new_p2c4 (ctx, COGL_VERTICES_MODE_TRIANGLES, 3, triangle_vertices); data.pipeline = cogl_pipeline_new (); while (!data.quit) diff --git a/examples/cogl-x11-foreign.c b/examples/cogl-x11-foreign.c index 0113130ed..8c063e187 100644 --- a/examples/cogl-x11-foreign.c +++ b/examples/cogl-x11-foreign.c @@ -149,7 +149,7 @@ main (int argc, char **argv) fb = COGL_FRAMEBUFFER (onscreen); - triangle = cogl_primitive_new_p2c4 (COGL_VERTICES_MODE_TRIANGLES, + triangle = cogl_primitive_new_p2c4 (ctx, COGL_VERTICES_MODE_TRIANGLES, 3, triangle_vertices); pipeline = cogl_pipeline_new (); for (;;) diff --git a/examples/cogland.c b/examples/cogland.c index 4f37d837e..67ccff6fb 100644 --- a/examples/cogland.c +++ b/examples/cogland.c @@ -751,7 +751,8 @@ main (int argc, char **argv) if (wl_display_add_socket (compositor.wayland_display, "wayland-0")) g_error ("Failed to create socket"); - compositor.triangle = cogl_primitive_new_p2c4 (COGL_VERTICES_MODE_TRIANGLES, + compositor.triangle = cogl_primitive_new_p2c4 (compositor.cogl_context, + COGL_VERTICES_MODE_TRIANGLES, 3, triangle_vertices); compositor.triangle_pipeline = cogl_pipeline_new (); diff --git a/tests/conform/test-custom-attributes.c b/tests/conform/test-custom-attributes.c index adbb4f053..b4f3fb58c 100644 --- a/tests/conform/test-custom-attributes.c +++ b/tests/conform/test-custom-attributes.c @@ -6,6 +6,7 @@ typedef struct _TestState { + CoglContext *ctx; CoglFramebuffer *fb; CoglPipeline *pipeline; } TestState; @@ -44,7 +45,8 @@ test_float_verts (TestState *state, int offset_x, int offset_y) { 15, 0, /**/ 0, 1, 0, 1 } }; - buffer = cogl_attribute_buffer_new (sizeof (float_verts), float_verts); + buffer = cogl_attribute_buffer_new (state->ctx, + sizeof (float_verts), float_verts); attributes[0] = cogl_attribute_new (buffer, "cogl_position_in", sizeof (FloatVert), @@ -103,7 +105,8 @@ test_byte_verts (TestState *state, int offset_x, int offset_y) { 0, 0, /**/ 0, 0, 1, 1 }, }; - buffer = cogl_attribute_buffer_new (sizeof (norm_verts), norm_verts); + buffer = cogl_attribute_buffer_new (state->ctx, + sizeof (norm_verts), norm_verts); attributes[0] = cogl_attribute_new (buffer, "cogl_position_in", sizeof (ByteVert), @@ -132,7 +135,8 @@ test_byte_verts (TestState *state, int offset_x, int offset_y) cogl_object_unref (attributes[1]); /* Test again with unnormalized attributes */ - unnorm_buffer = cogl_attribute_buffer_new (sizeof (unnorm_verts), + unnorm_buffer = cogl_attribute_buffer_new (state->ctx, + sizeof (unnorm_verts), unnorm_verts); attributes[1] = cogl_attribute_new (unnorm_buffer, "color", @@ -191,7 +195,8 @@ test_short_verts (TestState *state, int offset_x, int offset_y) cogl_pipeline_set_color4ub (pipeline, 255, 0, 0, 255); - buffer = cogl_attribute_buffer_new (sizeof (short_verts), short_verts); + buffer = cogl_attribute_buffer_new (state->ctx, + sizeof (short_verts), short_verts); attributes[0] = cogl_attribute_new (buffer, "pos", sizeof (ShortVert), @@ -274,6 +279,8 @@ test_cogl_custom_attributes (TestUtilsGTestFixture *fixture, TestState state; state.fb = shared_state->fb; + state.ctx = shared_state->ctx; + cogl_ortho (/* left, right */ 0, cogl_framebuffer_get_width (shared_state->fb), /* bottom, top */ diff --git a/tests/conform/test-primitive.c b/tests/conform/test-primitive.c index bed5c1d14..50542492f 100644 --- a/tests/conform/test-primitive.c +++ b/tests/conform/test-primitive.c @@ -17,32 +17,34 @@ typedef struct _TestState #define N_ATTRIBS 8 -typedef CoglPrimitive * (* TestPrimFunc) (guint32 *expected_color); +typedef CoglPrimitive * (* TestPrimFunc) (CoglContext *ctx, guint32 *expected_color); static CoglPrimitive * -test_prim_p2 (guint32 *expected_color) +test_prim_p2 (CoglContext *ctx, guint32 *expected_color) { static const CoglVertexP2 verts[] = { { 0, 0 }, { 0, 10 }, { 10, 0 } }; - return cogl_primitive_new_p2 (COGL_VERTICES_MODE_TRIANGLES, + return cogl_primitive_new_p2 (ctx, + COGL_VERTICES_MODE_TRIANGLES, 3, /* n_vertices */ verts); } static CoglPrimitive * -test_prim_p3 (guint32 *expected_color) +test_prim_p3 (CoglContext *ctx, guint32 *expected_color) { static const CoglVertexP3 verts[] = { { 0, 0, 0 }, { 0, 10, 0 }, { 10, 0, 0 } }; - return cogl_primitive_new_p3 (COGL_VERTICES_MODE_TRIANGLES, + return cogl_primitive_new_p3 (ctx, + COGL_VERTICES_MODE_TRIANGLES, 3, /* n_vertices */ verts); } static CoglPrimitive * -test_prim_p2c4 (guint32 *expected_color) +test_prim_p2c4 (CoglContext *ctx, guint32 *expected_color) { static const CoglVertexP2C4 verts[] = { { 0, 0, 255, 255, 0, 255 }, @@ -51,13 +53,14 @@ test_prim_p2c4 (guint32 *expected_color) *expected_color = 0xffff00ff; - return cogl_primitive_new_p2c4 (COGL_VERTICES_MODE_TRIANGLES, + return cogl_primitive_new_p2c4 (ctx, + COGL_VERTICES_MODE_TRIANGLES, 3, /* n_vertices */ verts); } static CoglPrimitive * -test_prim_p3c4 (guint32 *expected_color) +test_prim_p3c4 (CoglContext *ctx, guint32 *expected_color) { static const CoglVertexP3C4 verts[] = { { 0, 0, 0, 255, 255, 0, 255 }, @@ -66,13 +69,14 @@ test_prim_p3c4 (guint32 *expected_color) *expected_color = 0xffff00ff; - return cogl_primitive_new_p3c4 (COGL_VERTICES_MODE_TRIANGLES, + return cogl_primitive_new_p3c4 (ctx, + COGL_VERTICES_MODE_TRIANGLES, 3, /* n_vertices */ verts); } static CoglPrimitive * -test_prim_p2t2 (guint32 *expected_color) +test_prim_p2t2 (CoglContext *ctx, guint32 *expected_color) { static const CoglVertexP2T2 verts[] = { { 0, 0, 1, 0 }, @@ -81,13 +85,14 @@ test_prim_p2t2 (guint32 *expected_color) *expected_color = TEX_COLOR; - return cogl_primitive_new_p2t2 (COGL_VERTICES_MODE_TRIANGLES, + return cogl_primitive_new_p2t2 (ctx, + COGL_VERTICES_MODE_TRIANGLES, 3, /* n_vertices */ verts); } static CoglPrimitive * -test_prim_p3t2 (guint32 *expected_color) +test_prim_p3t2 (CoglContext *ctx, guint32 *expected_color) { static const CoglVertexP3T2 verts[] = { { 0, 0, 0, 1, 0 }, @@ -96,13 +101,14 @@ test_prim_p3t2 (guint32 *expected_color) *expected_color = TEX_COLOR; - return cogl_primitive_new_p3t2 (COGL_VERTICES_MODE_TRIANGLES, + return cogl_primitive_new_p3t2 (ctx, + COGL_VERTICES_MODE_TRIANGLES, 3, /* n_vertices */ verts); } static CoglPrimitive * -test_prim_p2t2c4 (guint32 *expected_color) +test_prim_p2t2c4 (CoglContext *ctx, guint32 *expected_color) { static const CoglVertexP2T2C4 verts[] = { { 0, 0, 1, 0, 0xff, 0xff, 0xf0, 0xff }, @@ -112,13 +118,14 @@ test_prim_p2t2c4 (guint32 *expected_color) /* The blue component of the texture color should be replaced with 0xf0 */ *expected_color = (TEX_COLOR & 0xffff00ff) | 0x0000f000; - return cogl_primitive_new_p2t2c4 (COGL_VERTICES_MODE_TRIANGLES, + return cogl_primitive_new_p2t2c4 (ctx, + COGL_VERTICES_MODE_TRIANGLES, 3, /* n_vertices */ verts); } static CoglPrimitive * -test_prim_p3t2c4 (guint32 *expected_color) +test_prim_p3t2c4 (CoglContext *ctx, guint32 *expected_color) { static const CoglVertexP3T2C4 verts[] = { { 0, 0, 0, 1, 0, 0xff, 0xff, 0xf0, 0xff }, @@ -128,7 +135,8 @@ test_prim_p3t2c4 (guint32 *expected_color) /* The blue component of the texture color should be replaced with 0xf0 */ *expected_color = (TEX_COLOR & 0xffff00ff) | 0x0000f000; - return cogl_primitive_new_p3t2c4 (COGL_VERTICES_MODE_TRIANGLES, + return cogl_primitive_new_p3t2c4 (ctx, + COGL_VERTICES_MODE_TRIANGLES, 3, /* n_vertices */ verts); } @@ -184,7 +192,7 @@ test_paint (TestState *state) CoglPrimitive *prim; guint32 expected_color = PRIM_COLOR; - prim = test_prim_funcs[i] (&expected_color); + prim = test_prim_funcs[i] (state->context, &expected_color); cogl_push_matrix (); cogl_translate (i * 10, 0, 0); @@ -227,7 +235,8 @@ static void test_copy (TestState *state) { static const guint16 indices_data[2] = { 1, 2 }; - CoglAttributeBuffer *buffer = cogl_attribute_buffer_new (100, NULL); + CoglAttributeBuffer *buffer = + cogl_attribute_buffer_new (state->context, 100, NULL); CoglAttribute *attributes[N_ATTRIBS]; CoglAttribute *attributes_a[N_ATTRIBS], *attributes_b[N_ATTRIBS]; CoglAttribute **p; @@ -252,7 +261,8 @@ test_copy (TestState *state) attributes, N_ATTRIBS); - indices = cogl_indices_new (COGL_INDICES_TYPE_UNSIGNED_SHORT, + indices = cogl_indices_new (state->context, + COGL_INDICES_TYPE_UNSIGNED_SHORT, indices_data, 2 /* n_indices */);