diff --git a/cogl-pango/cogl-pango-pipeline-cache.c b/cogl-pango/cogl-pango-pipeline-cache.c index 3b9ad9008..5a2e2ecdc 100644 --- a/cogl-pango/cogl-pango-pipeline-cache.c +++ b/cogl-pango/cogl-pango-pipeline-cache.c @@ -33,6 +33,8 @@ #include #include "cogl-pango-pipeline-cache.h" +#include "cogl/cogl-context-private.h" + typedef struct _CoglPangoPipelineCacheEntry CoglPangoPipelineCacheEntry; struct _CoglPangoPipelineCache @@ -105,7 +107,9 @@ get_base_texture_rgba_pipeline (CoglPangoPipelineCache *cache) { CoglPipeline *pipeline; - pipeline = cache->base_texture_rgba_pipeline = cogl_pipeline_new (); + _COGL_GET_CONTEXT (ctx, NULL); + + pipeline = cache->base_texture_rgba_pipeline = cogl_pipeline_new (ctx); cogl_pipeline_set_layer_wrap_mode (pipeline, 0, COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE); @@ -201,8 +205,10 @@ _cogl_pango_pipeline_cache_get (CoglPangoPipelineCache *cache, } else { + _COGL_GET_CONTEXT (ctx, NULL); + entry->texture = NULL; - entry->pipeline = cogl_pipeline_new (); + entry->pipeline = cogl_pipeline_new (ctx); } /* Add a weak reference to the pipeline so we can remove it from the diff --git a/cogl/cogl-blit.c b/cogl/cogl-blit.c index d856aca20..56c0c141b 100644 --- a/cogl/cogl-blit.c +++ b/cogl/cogl-blit.c @@ -81,7 +81,7 @@ _cogl_blit_texture_render_begin (CoglBlitData *data) program */ if (ctx->blit_texture_pipeline == NULL) { - ctx->blit_texture_pipeline = cogl_pipeline_new (); + ctx->blit_texture_pipeline = cogl_pipeline_new (ctx); cogl_pipeline_set_layer_filters (ctx->blit_texture_pipeline, 0, COGL_PIPELINE_FILTER_NEAREST, diff --git a/cogl/cogl-context.c b/cogl/cogl-context.c index 5ee75aa2d..fb27160b7 100644 --- a/cogl/cogl-context.c +++ b/cogl/cogl-context.c @@ -269,9 +269,9 @@ cogl_context_new (CoglDisplay *display, context->legacy_fog_state.enabled = FALSE; - context->opaque_color_pipeline = cogl_pipeline_new (); - context->blended_color_pipeline = cogl_pipeline_new (); - context->texture_pipeline = cogl_pipeline_new (); + context->opaque_color_pipeline = cogl_pipeline_new (context); + context->blended_color_pipeline = cogl_pipeline_new (context); + context->texture_pipeline = cogl_pipeline_new (context); context->codegen_header_buffer = g_string_new (""); context->codegen_source_buffer = g_string_new (""); context->source_stack = NULL; @@ -350,7 +350,7 @@ cogl_context_new (CoglDisplay *display, } context->current_path = cogl2_path_new (); - context->stencil_pipeline = cogl_pipeline_new (); + context->stencil_pipeline = cogl_pipeline_new (context); context->in_begin_gl_block = FALSE; diff --git a/cogl/cogl-journal.c b/cogl/cogl-journal.c index df9deedd1..bec9e6dcd 100644 --- a/cogl/cogl-journal.c +++ b/cogl/cogl-journal.c @@ -358,7 +358,7 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start, _COGL_GET_CONTEXT (ctxt, NO_RETVAL); if (outline == NULL) - outline = cogl_pipeline_new (); + outline = cogl_pipeline_new (ctxt); /* The least significant three bits represent the three components so that the order of colours goes red, green, diff --git a/cogl/cogl-material-compat.c b/cogl/cogl-material-compat.c index 8caede983..2e7192829 100644 --- a/cogl/cogl-material-compat.c +++ b/cogl/cogl-material-compat.c @@ -36,7 +36,8 @@ CoglMaterial * cogl_material_new (void) { - return COGL_MATERIAL (cogl_pipeline_new ()); + _COGL_GET_CONTEXT(ctx, NULL); + return COGL_MATERIAL (cogl_pipeline_new (ctx)); } CoglMaterial * diff --git a/cogl/cogl-pipeline.c b/cogl/cogl-pipeline.c index 2d459f4e1..7545855aa 100644 --- a/cogl/cogl-pipeline.c +++ b/cogl/cogl-pipeline.c @@ -422,13 +422,11 @@ _cogl_pipeline_weak_copy (CoglPipeline *pipeline, } CoglPipeline * -cogl_pipeline_new (void) +cogl_pipeline_new (CoglContext *context) { CoglPipeline *new; - _COGL_GET_CONTEXT (ctx, NULL); - - new = cogl_pipeline_copy (ctx->default_pipeline); + new = cogl_pipeline_copy (context->default_pipeline); _cogl_pipeline_set_static_breadcrumb (new, "new"); return new; } diff --git a/cogl/cogl-pipeline.h b/cogl/cogl-pipeline.h index a50a5a293..d990e2448 100644 --- a/cogl/cogl-pipeline.h +++ b/cogl/cogl-pipeline.h @@ -28,7 +28,13 @@ #ifndef __COGL_PIPELINE_H__ #define __COGL_PIPELINE_H__ +/* We forward declare the CoglPipeline type here to avoid some circular + * dependency issues with the following headers. + */ +typedef struct _CoglPipeline CoglPipeline; + #include +#include #include G_BEGIN_DECLS @@ -48,12 +54,12 @@ G_BEGIN_DECLS * performs fragment processing including depth testing and texture * mapping. Finally it blends the result with the framebuffer. */ -typedef struct _CoglPipeline CoglPipeline; #define COGL_PIPELINE(OBJECT) ((CoglPipeline *)OBJECT) /** * cogl_pipeline_new: + * @context: a #CoglContext * * Allocates and initializes a default simple pipeline that will color * a primitive white. @@ -64,7 +70,7 @@ typedef struct _CoglPipeline CoglPipeline; * Stability: Unstable */ CoglPipeline * -cogl_pipeline_new (void); +cogl_pipeline_new (CoglContext *context); /** * cogl_pipeline_copy: diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c index b68fa8171..9cb3a6af7 100644 --- a/cogl/cogl-texture.c +++ b/cogl/cogl-texture.c @@ -914,7 +914,7 @@ _cogl_texture_draw_and_read (CoglTexture *texture, if (ctx->texture_download_pipeline == NULL) { - ctx->texture_download_pipeline = cogl_pipeline_new (); + ctx->texture_download_pipeline = cogl_pipeline_new (ctx); cogl_pipeline_set_blend (ctx->texture_download_pipeline, "RGBA = ADD (SRC_COLOR, 0)", NULL); diff --git a/examples/cogl-crate.c b/examples/cogl-crate.c index 22a189868..cddd990dd 100644 --- a/examples/cogl-crate.c +++ b/examples/cogl-crate.c @@ -231,7 +231,7 @@ main (int argc, char **argv) * processing, fragment processing and blending geometry. When * drawing the geometry for the crate this pipeline says to sample a * single texture during fragment processing... */ - data.crate_pipeline = cogl_pipeline_new (); + data.crate_pipeline = cogl_pipeline_new (ctx); cogl_pipeline_set_layer_texture (data.crate_pipeline, 0, data.texture); /* Since the box is made of multiple triangles that will overlap diff --git a/examples/cogl-hello.c b/examples/cogl-hello.c index 152aa5651..2896f2439 100644 --- a/examples/cogl-hello.c +++ b/examples/cogl-hello.c @@ -32,7 +32,7 @@ main (int argc, char **argv) triangle = cogl_primitive_new_p2c4 (ctx, COGL_VERTICES_MODE_TRIANGLES, 3, triangle_vertices); - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (ctx); for (;;) { CoglPollFD *poll_fds; diff --git a/examples/cogl-msaa.c b/examples/cogl-msaa.c index e39f164d2..320dbc2d1 100644 --- a/examples/cogl-msaa.c +++ b/examples/cogl-msaa.c @@ -79,7 +79,7 @@ main (int argc, char **argv) triangle = cogl_primitive_new_p2c4 (ctx, COGL_VERTICES_MODE_TRIANGLES, 3, triangle_vertices); - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (ctx); for (;;) { CoglPollFD *poll_fds; diff --git a/examples/cogl-sdl-hello.c b/examples/cogl-sdl-hello.c index d7b8c7625..057235c20 100644 --- a/examples/cogl-sdl-hello.c +++ b/examples/cogl-sdl-hello.c @@ -150,7 +150,7 @@ main (int argc, char **argv) data.triangle = cogl_primitive_new_p2c4 (ctx, COGL_VERTICES_MODE_TRIANGLES, 3, triangle_vertices); - data.pipeline = cogl_pipeline_new (); + data.pipeline = cogl_pipeline_new (ctx); while (!data.quit) { CoglPollFD *poll_fds; diff --git a/examples/cogl-x11-foreign.c b/examples/cogl-x11-foreign.c index 8c063e187..202b8d250 100644 --- a/examples/cogl-x11-foreign.c +++ b/examples/cogl-x11-foreign.c @@ -151,7 +151,7 @@ main (int argc, char **argv) triangle = cogl_primitive_new_p2c4 (ctx, COGL_VERTICES_MODE_TRIANGLES, 3, triangle_vertices); - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (ctx); for (;;) { CoglPollFD *poll_fds; diff --git a/examples/cogland.c b/examples/cogland.c index 67ccff6fb..36c2cb345 100644 --- a/examples/cogland.c +++ b/examples/cogland.c @@ -754,7 +754,7 @@ main (int argc, char **argv) compositor.triangle = cogl_primitive_new_p2c4 (compositor.cogl_context, COGL_VERTICES_MODE_TRIANGLES, 3, triangle_vertices); - compositor.triangle_pipeline = cogl_pipeline_new (); + compositor.triangle_pipeline = cogl_pipeline_new (compositor.cogl_context); g_timeout_add (16, paint_cb, &compositor); diff --git a/tests/conform/test-backface-culling.c b/tests/conform/test-backface-culling.c index dacc305d7..b8c2b475f 100644 --- a/tests/conform/test-backface-culling.c +++ b/tests/conform/test-backface-culling.c @@ -17,6 +17,7 @@ typedef struct _TestState { + CoglContext *ctx; CoglFramebuffer *fb; CoglHandle texture; CoglFramebuffer *offscreen; @@ -46,7 +47,7 @@ static void paint_test_backface_culling (TestState *state) { int draw_num; - CoglPipeline *base_pipeline = cogl_pipeline_new (); + CoglPipeline *base_pipeline = cogl_pipeline_new (state->ctx); CoglColor clear_color; cogl_ortho (0, state->width, /* left, right */ @@ -285,6 +286,7 @@ test_cogl_backface_culling (TestUtilsGTestFixture *fixture, TestState state; CoglHandle tex; + state.ctx = shared_state->ctx; state.fb = shared_state->fb; state.width = cogl_framebuffer_get_width (shared_state->fb); state.height = cogl_framebuffer_get_height (shared_state->fb); diff --git a/tests/conform/test-blend-strings.c b/tests/conform/test-blend-strings.c index d41072737..74d502204 100644 --- a/tests/conform/test-blend-strings.c +++ b/tests/conform/test-blend-strings.c @@ -21,7 +21,7 @@ typedef struct _TestState { - int dummy; + CoglContext *ctx; } TestState; @@ -60,7 +60,7 @@ test_blend (TestState *state, int x_off; /* First write out the destination color without any blending... */ - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (state->ctx); cogl_pipeline_set_color4ub (pipeline, Dr, Dg, Db, Da); cogl_pipeline_set_blend (pipeline, "RGBA = ADD (SRC_COLOR, 0)", NULL); cogl_set_source (pipeline); @@ -74,7 +74,7 @@ test_blend (TestState *state, * Now blend a rectangle over our well defined destination: */ - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (state->ctx); cogl_pipeline_set_color4ub (pipeline, Sr, Sg, Sb, Sa); status = cogl_pipeline_set_blend (pipeline, blend_string, &error); @@ -414,6 +414,8 @@ test_cogl_blend_strings (TestUtilsGTestFixture *fixture, TestUtilsSharedState *shared_state = data; TestState state; + state.ctx = shared_state->ctx; + cogl_ortho (0, cogl_framebuffer_get_width (shared_state->fb), /* left, right */ cogl_framebuffer_get_height (shared_state->fb), 0, /* bottom, top */ -1, 100 /* z near, far */); diff --git a/tests/conform/test-custom-attributes.c b/tests/conform/test-custom-attributes.c index b4f3fb58c..39b01c658 100644 --- a/tests/conform/test-custom-attributes.c +++ b/tests/conform/test-custom-attributes.c @@ -182,7 +182,7 @@ test_short_verts (TestState *state, int offset_x, int offset_y) { -5, -1 } }; - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (state->ctx); snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_VERTEX_TRANSFORM, "attribute vec2 pos;", NULL); @@ -288,7 +288,7 @@ test_cogl_custom_attributes (TestUtilsGTestFixture *fixture, /* z near, far */ -1, 100); - state.pipeline = cogl_pipeline_new (); + state.pipeline = cogl_pipeline_new (state.ctx); snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_VERTEX, "attribute vec4 color;", "cogl_color_out = color;"); diff --git a/tests/conform/test-depth-test.c b/tests/conform/test-depth-test.c index d42571fef..dfa6191a3 100644 --- a/tests/conform/test-depth-test.c +++ b/tests/conform/test-depth-test.c @@ -18,7 +18,7 @@ typedef struct _TestState { - int dummy; + CoglContext *ctx; } TestState; typedef struct @@ -53,7 +53,7 @@ draw_rectangle (TestState *state, rect_state->range_near, rect_state->range_far); - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (state->ctx); if (!cogl_pipeline_set_depth_state (pipeline, &depth_state, NULL)) { cogl_object_unref (pipeline); @@ -235,6 +235,8 @@ test_cogl_depth_test (TestUtilsGTestFixture *fixture, TestUtilsSharedState *shared_state = data; TestState state; + state.ctx = shared_state->ctx; + cogl_ortho (0, cogl_framebuffer_get_width (shared_state->fb), /* left, right */ cogl_framebuffer_get_height (shared_state->fb), 0, /* bottom, top */ -1, 100 /* z near, far */); diff --git a/tests/conform/test-just-vertex-shader.c b/tests/conform/test-just-vertex-shader.c index 91e05fd41..f564a3952 100644 --- a/tests/conform/test-just-vertex-shader.c +++ b/tests/conform/test-just-vertex-shader.c @@ -6,7 +6,7 @@ typedef struct _TestState { - int dummy; + CoglContext *ctx; } TestState; static CoglHandle @@ -97,7 +97,7 @@ paint_legacy (TestState *state) static void paint (TestState *state) { - CoglPipeline *pipeline = cogl_pipeline_new (); + CoglPipeline *pipeline = cogl_pipeline_new (state->ctx); CoglHandle tex; CoglColor color; GError *error = NULL; @@ -181,6 +181,8 @@ test_cogl_just_vertex_shader (TestUtilsGTestFixture *fixture, TestUtilsSharedState *shared_state = data; TestState state; + state.ctx = shared_state->ctx; + cogl_ortho (0, cogl_framebuffer_get_width (shared_state->fb), /* left, right */ cogl_framebuffer_get_height (shared_state->fb), 0, /* bottom, top */ -1, 100 /* z near, far */); diff --git a/tests/conform/test-pipeline-uniforms.c b/tests/conform/test-pipeline-uniforms.c index 8908bf729..2e915c264 100644 --- a/tests/conform/test-pipeline-uniforms.c +++ b/tests/conform/test-pipeline-uniforms.c @@ -8,6 +8,8 @@ typedef struct _TestState { + CoglContext *ctx; + CoglPipeline *pipeline_red; CoglPipeline *pipeline_green; CoglPipeline *pipeline_blue; @@ -84,13 +86,13 @@ long_source[] = "}\n"; static CoglPipeline * -create_pipeline_for_shader (const char *shader_source) +create_pipeline_for_shader (TestState *state, const char *shader_source) { CoglPipeline *pipeline; CoglHandle shader; CoglHandle program; - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (state->ctx); shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT); cogl_shader_source (shader, shader_source); @@ -111,7 +113,7 @@ init_state (TestState *state) { int uniform_location; - state->pipeline_red = create_pipeline_for_shader (color_source); + state->pipeline_red = create_pipeline_for_shader (state, color_source); uniform_location = cogl_pipeline_get_uniform_location (state->pipeline_red, "red"); @@ -133,9 +135,9 @@ init_state (TestState *state) cogl_pipeline_get_uniform_location (state->pipeline_blue, "blue"); cogl_pipeline_set_uniform_1f (state->pipeline_blue, uniform_location, 1.0f); - state->matrix_pipeline = create_pipeline_for_shader (matrix_source); - state->vector_pipeline = create_pipeline_for_shader (vector_source); - state->int_pipeline = create_pipeline_for_shader (int_source); + state->matrix_pipeline = create_pipeline_for_shader (state, matrix_source); + state->vector_pipeline = create_pipeline_for_shader (state, vector_source); + state->int_pipeline = create_pipeline_for_shader (state, int_source); state->long_pipeline = NULL; } @@ -145,7 +147,7 @@ init_long_pipeline_state (TestState *state) { int i; - state->long_pipeline = create_pipeline_for_shader (long_source); + state->long_pipeline = create_pipeline_for_shader (state, long_source); /* This tries to lookup a large number of uniform names to make sure that the bitmask of overriden uniforms flows over the size of a @@ -395,6 +397,8 @@ test_cogl_pipeline_uniforms (TestUtilsGTestFixture *fixture, { TestState state; + state.ctx = shared_state->ctx; + init_state (&state); cogl_ortho (/* left, right */ diff --git a/tests/conform/test-pipeline-user-matrix.c b/tests/conform/test-pipeline-user-matrix.c index daf9aef74..c4b9bec4c 100644 --- a/tests/conform/test-pipeline-user-matrix.c +++ b/tests/conform/test-pipeline-user-matrix.c @@ -6,6 +6,7 @@ typedef struct _TestState { + CoglContext *ctx; int width; int height; } TestState; @@ -81,7 +82,7 @@ paint (TestState *state) 6, data1); - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (state->ctx); /* Set the two textures as layers */ cogl_pipeline_set_layer_texture (pipeline, 0, tex0); @@ -129,6 +130,8 @@ test_cogl_pipeline_user_matrix (TestUtilsGTestFixture *fixture, TestUtilsSharedState *shared_state = data; TestState state; + state.ctx = shared_state->ctx; + state.width = cogl_framebuffer_get_width (shared_state->fb); state.height = cogl_framebuffer_get_height (shared_state->fb); diff --git a/tests/conform/test-primitive.c b/tests/conform/test-primitive.c index 50542492f..bbfec5ec7 100644 --- a/tests/conform/test-primitive.c +++ b/tests/conform/test-primitive.c @@ -6,7 +6,7 @@ typedef struct _TestState { - CoglContext *context; + CoglContext *ctx; int fb_width; int fb_height; CoglFramebuffer *fb; @@ -178,7 +178,7 @@ test_paint (TestState *state) COGL_PIXEL_FORMAT_ANY, 6, /* rowstride */ tex_data); - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (state->ctx); cogl_pipeline_set_color4ub (pipeline, (PRIM_COLOR >> 24) & 0xff, (PRIM_COLOR >> 16) & 0xff, @@ -192,7 +192,7 @@ test_paint (TestState *state) CoglPrimitive *prim; guint32 expected_color = PRIM_COLOR; - prim = test_prim_funcs[i] (state->context, &expected_color); + prim = test_prim_funcs[i] (state->ctx, &expected_color); cogl_push_matrix (); cogl_translate (i * 10, 0, 0); @@ -236,7 +236,7 @@ test_copy (TestState *state) { static const guint16 indices_data[2] = { 1, 2 }; CoglAttributeBuffer *buffer = - cogl_attribute_buffer_new (state->context, 100, NULL); + cogl_attribute_buffer_new (state->ctx, 100, NULL); CoglAttribute *attributes[N_ATTRIBS]; CoglAttribute *attributes_a[N_ATTRIBS], *attributes_b[N_ATTRIBS]; CoglAttribute **p; @@ -261,7 +261,7 @@ test_copy (TestState *state) attributes, N_ATTRIBS); - indices = cogl_indices_new (state->context, + indices = cogl_indices_new (state->ctx, COGL_INDICES_TYPE_UNSIGNED_SHORT, indices_data, 2 /* n_indices */); @@ -320,7 +320,7 @@ test_cogl_primitive (TestUtilsGTestFixture *fixture, TestUtilsSharedState *shared_state = data; TestState state; - state.context = shared_state->ctx; + state.ctx = shared_state->ctx; state.fb_width = cogl_framebuffer_get_width (shared_state->fb); state.fb_height = cogl_framebuffer_get_height (shared_state->fb); state.fb = shared_state->fb; diff --git a/tests/conform/test-snippets.c b/tests/conform/test-snippets.c index 655b34047..56ad224ba 100644 --- a/tests/conform/test-snippets.c +++ b/tests/conform/test-snippets.c @@ -6,14 +6,14 @@ typedef struct _TestState { + CoglContext *ctx; CoglFramebuffer *fb; - CoglContext *context; } TestState; typedef void (* SnippetTestFunc) (TestState *state); static CoglPipeline * -create_texture_pipeline (void) +create_texture_pipeline (TestState *state) { CoglPipeline *pipeline; CoglHandle tex; @@ -30,7 +30,7 @@ create_texture_pipeline (void) 8, /* rowstride */ tex_data); - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (state->ctx); cogl_pipeline_set_layer_texture (pipeline, 0, tex); @@ -50,7 +50,7 @@ simple_fragment_snippet (TestState *state) CoglSnippet *snippet; /* Simple fragment snippet */ - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (state->ctx); cogl_pipeline_set_color4ub (pipeline, 255, 0, 0, 255); @@ -76,7 +76,7 @@ simple_vertex_snippet (TestState *state) CoglSnippet *snippet; /* Simple vertex snippet */ - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (state->ctx); cogl_pipeline_set_color4ub (pipeline, 255, 0, 0, 255); @@ -104,7 +104,7 @@ shared_uniform (TestState *state) /* Snippets sharing a uniform across the vertex and fragment hooks */ - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (state->ctx); location = cogl_pipeline_get_uniform_location (pipeline, "a_value"); cogl_pipeline_set_uniform_1f (pipeline, location, 0.25f); @@ -140,7 +140,7 @@ lots_snippets (TestState *state) int i; /* Lots of snippets on one pipeline */ - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (state->ctx); cogl_pipeline_set_color4ub (pipeline, 0, 0, 0, 255); @@ -185,7 +185,7 @@ shared_variable_pre_post (TestState *state) /* Test that the pre string can declare variables used by the post string */ - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (state->ctx); cogl_pipeline_set_color4ub (pipeline, 255, 255, 255, 255); @@ -223,14 +223,14 @@ test_pipeline_caching (TestState *state) " unrelated pipelines */", "cogl_color_out = vec4 (0.0, 1.0, 0.0, 1.0);\n"); - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (state->ctx); cogl_pipeline_add_snippet (pipeline, snippet); cogl_push_source (pipeline); cogl_rectangle (50, 0, 60, 10); cogl_pop_source (); cogl_object_unref (pipeline); - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (state->ctx); cogl_pipeline_add_snippet (pipeline, snippet); cogl_push_source (pipeline); cogl_rectangle (60, 0, 70, 10); @@ -260,7 +260,7 @@ test_replace_string (TestState *state) cogl_snippet_set_post (snippet, "cogl_color_out += vec4 (0.5, 0.0, 0.0, 1.0);"); - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (state->ctx); cogl_pipeline_add_snippet (pipeline, snippet); cogl_push_source (pipeline); cogl_rectangle (70, 0, 80, 10); @@ -286,7 +286,7 @@ test_texture_lookup_hook (TestState *state) get the green texel */ cogl_snippet_set_pre (snippet, "cogl_tex_coord.x = 1.0 - cogl_tex_coord.x;"); - pipeline = create_texture_pipeline (); + pipeline = create_texture_pipeline (state); cogl_pipeline_add_layer_snippet (pipeline, 0, snippet); cogl_push_source (pipeline); cogl_rectangle_with_texture_coords (80, 0, 90, 10, @@ -315,7 +315,7 @@ test_multiple_samples (TestState *state) "texture2D (cogl_sampler, vec2 (0.25, 0.25)) + " "texture2D (cogl_sampler, vec2 (0.75, 0.25));"); - pipeline = create_texture_pipeline (); + pipeline = create_texture_pipeline (state); cogl_pipeline_add_layer_snippet (pipeline, 0, snippet); cogl_push_source (pipeline); cogl_rectangle (0, 0, 10, 10); @@ -337,7 +337,7 @@ test_replace_lookup_hook (TestState *state) snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_TEXTURE_LOOKUP, NULL, NULL); cogl_snippet_set_replace (snippet, "cogl_texel = vec4 (0.0, 0.0, 1.0, 0.0);"); - pipeline = create_texture_pipeline (); + pipeline = create_texture_pipeline (state); cogl_pipeline_add_layer_snippet (pipeline, 0, snippet); cogl_push_source (pipeline); cogl_rectangle_with_texture_coords (90, 0, 100, 10, @@ -357,7 +357,7 @@ test_replace_snippet (TestState *state) CoglSnippet *snippet; /* Test replacing a previous snippet */ - pipeline = create_texture_pipeline (); + pipeline = create_texture_pipeline (state); snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT, NULL, @@ -388,7 +388,7 @@ test_replace_fragment_layer (TestState *state) CoglSnippet *snippet; /* Test replacing the fragment layer code */ - pipeline = create_texture_pipeline (); + pipeline = create_texture_pipeline (state); snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_LAYER_FRAGMENT, NULL, NULL); cogl_snippet_set_replace (snippet, "cogl_layer = vec4 (0.0, 0.0, 1.0, 1.0);"); @@ -420,7 +420,7 @@ test_modify_fragment_layer (TestState *state) CoglSnippet *snippet; /* Test modifying the fragment layer code */ - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (state->ctx); cogl_pipeline_set_uniform_1f (pipeline, cogl_pipeline_get_uniform_location (pipeline, @@ -450,7 +450,7 @@ test_modify_vertex_layer (TestState *state) CoglMatrix matrix; /* Test modifying the vertex layer code */ - pipeline = create_texture_pipeline (); + pipeline = create_texture_pipeline (state); cogl_matrix_init_identity (&matrix); cogl_matrix_translate (&matrix, 0.0f, 1.0f, 0.0f); @@ -479,7 +479,7 @@ test_replace_vertex_layer (TestState *state) CoglMatrix matrix; /* Test replacing the vertex layer code */ - pipeline = create_texture_pipeline (); + pipeline = create_texture_pipeline (state); cogl_matrix_init_identity (&matrix); cogl_matrix_translate (&matrix, 0.0f, 1.0f, 0.0f); @@ -514,7 +514,7 @@ test_vertex_transform_hook (TestState *state) cogl_matrix_init_identity (&identity_matrix); - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (state->ctx); cogl_pipeline_set_color4ub (pipeline, 255, 0, 255, 255); @@ -564,7 +564,7 @@ test_snippet_order (TestState *state) sections in the same order as they were added. Therefore the r component should be taken from the the second snippet and the g component from the first */ - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (state->ctx); cogl_pipeline_set_color4ub (pipeline, 0, 0, 0, 255); @@ -609,10 +609,10 @@ test_naming_texture_units (TestState *state) "texture2D (cogl_sampler100, vec2 (0.0, 0.0)) + " "texture2D (cogl_sampler200, vec2 (0.0, 0.0));"); - tex1 = test_utils_create_color_texture (state->context, 0xff0000ff); - tex2 = test_utils_create_color_texture (state->context, 0x00ff00ff); + tex1 = test_utils_create_color_texture (state->ctx, 0xff0000ff); + tex2 = test_utils_create_color_texture (state->ctx, 0x00ff00ff); - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (state->ctx); cogl_pipeline_set_layer_texture (pipeline, 100, tex1); cogl_pipeline_set_layer_texture (pipeline, 200, tex2); @@ -722,8 +722,8 @@ test_cogl_snippets (TestUtilsGTestFixture *fixture, { TestState state; + state.ctx = shared_state->ctx; state.fb = shared_state->fb; - state.context = shared_state->ctx; cogl_ortho (/* left, right */ 0, cogl_framebuffer_get_width (shared_state->fb), diff --git a/tests/conform/test-sparse-pipeline.c b/tests/conform/test-sparse-pipeline.c index ec8c987ea..2df3fec15 100644 --- a/tests/conform/test-sparse-pipeline.c +++ b/tests/conform/test-sparse-pipeline.c @@ -5,7 +5,7 @@ typedef struct _TestState { - CoglContext *context; + CoglContext *ctx; int fb_width; int fb_height; CoglFramebuffer *fb; @@ -24,10 +24,10 @@ test_sparse_layer_combine (TestState *state) creating a pipeline with very large layer numbers. This should end up being mapped to much smaller unit numbers */ - tex1 = test_utils_create_color_texture (state->context, 0xff0000ff); - tex2 = test_utils_create_color_texture (state->context, 0x00ff00ff); + tex1 = test_utils_create_color_texture (state->ctx, 0xff0000ff); + tex2 = test_utils_create_color_texture (state->ctx, 0x00ff00ff); - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (state->ctx); cogl_pipeline_set_layer_texture (pipeline, 50, tex1); cogl_pipeline_set_layer_texture (pipeline, 100, tex2); @@ -53,7 +53,7 @@ test_cogl_sparse_pipeline (TestUtilsGTestFixture *fixture, TestUtilsSharedState *shared_state = data; TestState state; - state.context = shared_state->ctx; + state.ctx = shared_state->ctx; state.fb_width = cogl_framebuffer_get_width (shared_state->fb); state.fb_height = cogl_framebuffer_get_height (shared_state->fb); state.fb = shared_state->fb; diff --git a/tests/conform/test-texture-3d.c b/tests/conform/test-texture-3d.c index fcd511cb3..f9084a204 100644 --- a/tests/conform/test-texture-3d.c +++ b/tests/conform/test-texture-3d.c @@ -13,7 +13,7 @@ typedef struct _TestState { - CoglContext *context; + CoglContext *ctx; int fb_width; int fb_height; CoglFramebuffer *fb; @@ -75,8 +75,8 @@ create_texture_3d (CoglContext *context) static void draw_frame (TestState *state) { - CoglTexture *tex = COGL_TEXTURE (create_texture_3d (state->context)); - CoglPipeline *pipeline = cogl_pipeline_new (); + CoglTexture *tex = COGL_TEXTURE (create_texture_3d (state->ctx)); + CoglPipeline *pipeline = cogl_pipeline_new (state->ctx); typedef struct { float x, y, s, t, r; } Vert; CoglPrimitive *primitive; CoglAttributeBuffer *attribute_buffer; @@ -135,7 +135,7 @@ draw_frame (TestState *state) v++; } - attribute_buffer = cogl_attribute_buffer_new (state->context, + attribute_buffer = cogl_attribute_buffer_new (state->ctx, 4 * TEX_DEPTH * sizeof (Vert), verts); attributes[0] = cogl_attribute_new (attribute_buffer, @@ -156,7 +156,7 @@ draw_frame (TestState *state) 2 /* n_attributes */); cogl_primitive_set_indices (primitive, - cogl_get_rectangle_indices (state->context, + cogl_get_rectangle_indices (state->ctx, TEX_DEPTH), 6 * TEX_DEPTH); @@ -211,13 +211,13 @@ test_multi_texture (TestState *state) sampled with TEXTURE_? just to pick up a specific bug that was happening with the ARBfp fragend */ - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (state->ctx); tex_data[0] = 0xff; tex_data[1] = 0x00; tex_data[2] = 0x00; tex_data[3] = 0xff; - tex_2d = cogl_texture_2d_new_from_data (state->context, + tex_2d = cogl_texture_2d_new_from_data (state->ctx, 1, 1, /* width/height */ COGL_PIXEL_FORMAT_RGBA_8888_PRE, COGL_PIXEL_FORMAT_RGBA_8888_PRE, @@ -230,7 +230,7 @@ test_multi_texture (TestState *state) tex_data[1] = 0xff; tex_data[2] = 0x00; tex_data[3] = 0xff; - tex_3d = cogl_texture_3d_new_from_data (state->context, + tex_3d = cogl_texture_3d_new_from_data (state->ctx, 1, 1, 1, /* width/height/depth */ COGL_PIXEL_FORMAT_RGBA_8888_PRE, COGL_PIXEL_FORMAT_RGBA_8888_PRE, @@ -270,7 +270,7 @@ test_cogl_texture_3d (TestUtilsGTestFixture *fixture, { TestState state; - state.context = shared_state->ctx; + state.ctx = shared_state->ctx; state.fb_width = cogl_framebuffer_get_width (shared_state->fb); state.fb_height = cogl_framebuffer_get_height (shared_state->fb); state.fb = shared_state->fb; diff --git a/tests/conform/test-wrap-modes.c b/tests/conform/test-wrap-modes.c index 8ebc01133..bb05c3d1f 100644 --- a/tests/conform/test-wrap-modes.c +++ b/tests/conform/test-wrap-modes.c @@ -46,7 +46,7 @@ create_pipeline (TestState *state, { CoglPipeline *pipeline; - pipeline = cogl_pipeline_new (); + pipeline = cogl_pipeline_new (state->ctx); cogl_pipeline_set_layer_texture (pipeline, 0, state->texture); cogl_pipeline_set_layer_filters (pipeline, 0, COGL_PIPELINE_FILTER_NEAREST,