mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 11:32:04 +00:00
Adds a context arg to cogl_pipeline_new()
As we move towards Cogl 2.0 we are aiming to remove the need for a default global CoglContext and so everything should be explicitly related to a context somehow. CoglPipelines are top level objects and so this patch adds a context argument to cogl_pipeline_new(). Reviewed-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
parent
13c36fff0d
commit
785e6375eb
@ -33,6 +33,8 @@
|
||||
#include <cogl/cogl.h>
|
||||
#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
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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 *
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 <cogl/cogl-types.h>
|
||||
#include <cogl/cogl-context.h>
|
||||
#include <cogl/cogl-snippet.h>
|
||||
|
||||
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:
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 */);
|
||||
|
@ -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;");
|
||||
|
@ -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 */);
|
||||
|
@ -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 */);
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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),
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user