diff --git a/clutter/cogl/cogl/Makefile.am b/clutter/cogl/cogl/Makefile.am index 4616245b7..de85ae35a 100644 --- a/clutter/cogl/cogl/Makefile.am +++ b/clutter/cogl/cogl/Makefile.am @@ -60,7 +60,8 @@ cogl_public_h = \ $(srcdir)/cogl-buffer.h \ $(srcdir)/cogl-color.h \ $(srcdir)/cogl-fixed.h \ - $(srcdir)/cogl-material.h \ + $(srcdir)/cogl-material-compat.h \ + $(srcdir)/cogl-pipeline.h \ $(srcdir)/cogl-vector.h \ $(srcdir)/cogl-matrix.h \ $(srcdir)/cogl-offscreen.h \ @@ -225,16 +226,17 @@ cogl_sources_c = \ $(srcdir)/cogl-matrix-private.h \ $(srcdir)/cogl-matrix-stack.c \ $(srcdir)/cogl-matrix-stack.h \ - $(srcdir)/cogl-material.c \ - $(srcdir)/cogl-material-private.h \ - $(srcdir)/cogl-material-opengl.c \ - $(srcdir)/cogl-material-opengl-private.h \ - $(srcdir)/cogl-material-glsl.c \ - $(srcdir)/cogl-material-glsl-private.h \ - $(srcdir)/cogl-material-arbfp.c \ - $(srcdir)/cogl-material-arbfp-private.h \ - $(srcdir)/cogl-material-fixed.c \ - $(srcdir)/cogl-material-fixed-private.h \ + $(srcdir)/cogl-pipeline.c \ + $(srcdir)/cogl-pipeline-private.h \ + $(srcdir)/cogl-pipeline-opengl.c \ + $(srcdir)/cogl-pipeline-opengl-private.h \ + $(srcdir)/cogl-pipeline-glsl.c \ + $(srcdir)/cogl-pipeline-glsl-private.h \ + $(srcdir)/cogl-pipeline-arbfp.c \ + $(srcdir)/cogl-pipeline-arbfp-private.h \ + $(srcdir)/cogl-pipeline-fixed.c \ + $(srcdir)/cogl-pipeline-fixed-private.h \ + $(srcdir)/cogl-material-compat.c \ $(srcdir)/cogl-program.c \ $(srcdir)/cogl-program-private.h \ $(srcdir)/cogl-blend-string.c \ diff --git a/clutter/cogl/cogl/cogl-atlas-texture.c b/clutter/cogl/cogl/cogl-atlas-texture.c index e5a80ccc8..2ad7445bd 100644 --- a/clutter/cogl/cogl/cogl-atlas-texture.c +++ b/clutter/cogl/cogl/cogl-atlas-texture.c @@ -41,7 +41,7 @@ #include "cogl-texture-driver.h" #include "cogl-rectangle-map.h" #include "cogl-journal-private.h" -#include "cogl-material-opengl-private.h" +#include "cogl-pipeline-opengl-private.h" #include "cogl-atlas.h" #include @@ -87,17 +87,17 @@ _cogl_atlas_texture_reorganize_foreach_cb (const CoglRectangleMapEntry *entry, void *rectangle_data, void *user_data) { - /* Notify cogl-material.c that the texture's underlying GL texture + /* Notify cogl-pipeline.c that the texture's underlying GL texture * storage is changing so it knows it may need to bind a new texture * if the CoglTexture is reused with the same texture unit. */ - _cogl_material_texture_storage_change_notify (rectangle_data); + _cogl_pipeline_texture_storage_change_notify (rectangle_data); } static void _cogl_atlas_texture_reorganize_cb (void *data) { CoglAtlas *atlas; - /* We don't know if any materials may currently be referenced in + /* We don't know if any pipelines may currently be referenced in * the journal that depend on the current underlying GL texture * storage so we flush the journal before migrating. * @@ -274,7 +274,7 @@ _cogl_atlas_texture_migrate_out_of_atlas (CoglAtlasTexture *atlas_tex) { COGL_NOTE (ATLAS, "Migrating texture out of the atlas"); - /* We don't know if any materials may currently be referenced in + /* We don't know if any pipelines may currently be referenced in * the journal that depend on the current underlying GL texture * storage so we flush the journal before migrating. * @@ -283,10 +283,10 @@ _cogl_atlas_texture_migrate_out_of_atlas (CoglAtlasTexture *atlas_tex) */ _cogl_journal_flush (); - /* Notify cogl-material.c that the texture's underlying GL texture + /* Notify cogl-pipeline.c that the texture's underlying GL texture * storage is changing so it knows it may need to bind a new texture * if the CoglTexture is reused with the same texture unit. */ - _cogl_material_texture_storage_change_notify (atlas_tex); + _cogl_pipeline_texture_storage_change_notify (atlas_tex); cogl_handle_unref (atlas_tex->sub_texture); diff --git a/clutter/cogl/cogl/cogl-atlas.c b/clutter/cogl/cogl/cogl-atlas.c index 1d6a8159a..9882d658d 100644 --- a/clutter/cogl/cogl/cogl-atlas.c +++ b/clutter/cogl/cogl/cogl-atlas.c @@ -35,7 +35,7 @@ #include "cogl-texture-private.h" #include "cogl-texture-2d-private.h" #include "cogl-texture-driver.h" -#include "cogl-material-opengl-private.h" +#include "cogl-pipeline-opengl-private.h" #include "cogl-debug.h" #include diff --git a/clutter/cogl/cogl/cogl-buffer-private.h b/clutter/cogl/cogl/cogl-buffer-private.h index 97659bc15..3f4686c71 100644 --- a/clutter/cogl/cogl/cogl-buffer-private.h +++ b/clutter/cogl/cogl/cogl-buffer-private.h @@ -31,7 +31,7 @@ #include #include "cogl.h" -#include "cogl-object.h" +#include "cogl-object-private.h" #include "cogl-buffer.h" G_BEGIN_DECLS diff --git a/clutter/cogl/cogl/cogl-clip-stack.c b/clutter/cogl/cogl/cogl-clip-stack.c index 9f33274bb..0c36b34fd 100644 --- a/clutter/cogl/cogl/cogl-clip-stack.c +++ b/clutter/cogl/cogl/cogl-clip-stack.c @@ -308,8 +308,8 @@ add_stencil_clip_rectangle (float x_1, _cogl_framebuffer_flush_state (framebuffer, 0); - /* temporarily swap in our special stenciling material */ - cogl_push_source (ctx->stencil_material); + /* temporarily swap in our special stenciling pipeline */ + cogl_push_source (ctx->stencil_pipeline); if (first) { @@ -367,7 +367,7 @@ add_stencil_clip_rectangle (float x_1, GE( glStencilFunc (GL_EQUAL, 0x1, 0x1) ); GE( glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP) ); - /* restore the original source material */ + /* restore the original source pipeline */ cogl_pop_source (); } diff --git a/clutter/cogl/cogl/cogl-context.c b/clutter/cogl/cogl/cogl-context.c index 1d34e2541..7395b76a4 100644 --- a/clutter/cogl/cogl/cogl-context.c +++ b/clutter/cogl/cogl/cogl-context.c @@ -32,8 +32,8 @@ #include "cogl-context.h" #include "cogl-journal-private.h" #include "cogl-texture-private.h" -#include "cogl-material-private.h" -#include "cogl-material-opengl-private.h" +#include "cogl-pipeline-private.h" +#include "cogl-pipeline-opengl-private.h" #include "cogl-framebuffer-private.h" #include "cogl-path-private.h" @@ -103,8 +103,8 @@ cogl_create_context (void) _cogl_create_context_winsys (_context); - _cogl_material_init_default_material (); - _cogl_material_init_default_layers (); + _cogl_pipeline_init_default_pipeline (); + _cogl_pipeline_init_default_layers (); _context->enable_flags = 0; @@ -122,15 +122,15 @@ cogl_create_context (void) _context->texture_units = g_array_new (FALSE, FALSE, sizeof (CoglTextureUnit)); - /* See cogl-material.c for more details about why we leave texture unit 1 + /* See cogl-pipeline.c for more details about why we leave texture unit 1 * active by default... */ _context->active_texture_unit = 1; GE (glActiveTexture (GL_TEXTURE1)); _context->legacy_fog_state.enabled = FALSE; - _context->simple_material = cogl_material_new (); - _context->texture_material = cogl_material_new (); + _context->simple_pipeline = cogl_pipeline_new (); + _context->texture_pipeline = cogl_pipeline_new (); _context->arbfp_source_buffer = g_string_new (""); _context->source_stack = NULL; @@ -146,13 +146,13 @@ cogl_create_context (void) _context->polygon_vertices = g_array_new (FALSE, FALSE, sizeof (float)); - _context->current_material = NULL; - _context->current_material_changes_since_flush = 0; - _context->current_material_skip_gl_color = FALSE; + _context->current_pipeline = NULL; + _context->current_pipeline_changes_since_flush = 0; + _context->current_pipeline_skip_gl_color = FALSE; - _context->material0_nodes = + _context->pipeline0_nodes = g_array_sized_new (FALSE, FALSE, sizeof (CoglHandle), 20); - _context->material1_nodes = + _context->pipeline1_nodes = g_array_sized_new (FALSE, FALSE, sizeof (CoglHandle), 20); _cogl_bitmask_init (&_context->texcoord_arrays_enabled); @@ -165,7 +165,7 @@ cogl_create_context (void) _context->current_program = COGL_INVALID_HANDLE; - _context->current_use_program_type = COGL_MATERIAL_PROGRAM_TYPE_FIXED; + _context->current_use_program_type = COGL_PIPELINE_PROGRAM_TYPE_FIXED; _context->current_gl_program = 0; _context->gl_blend_enable_cache = FALSE; @@ -195,7 +195,7 @@ cogl_create_context (void) _context->dirty_gl_viewport = TRUE; _context->current_path = _cogl_path_new (); - _context->stencil_material = cogl_material_new (); + _context->stencil_pipeline = cogl_pipeline_new (); _context->in_begin_gl_block = FALSE; @@ -207,7 +207,7 @@ cogl_create_context (void) _context->rectangle_short_indices = NULL; _context->rectangle_short_indices_len = 0; - _context->texture_download_material = COGL_INVALID_HANDLE; + _context->texture_download_pipeline = COGL_INVALID_HANDLE; /* The default for GL_ALPHA_TEST is to always pass which is equivalent to * the test being disabled therefore we assume that for all drivers there @@ -235,8 +235,8 @@ cogl_create_context (void) 0, /* auto calc row stride */ default_texture_data); - cogl_push_source (_context->simple_material); - _cogl_material_flush_gl_state (_context->simple_material, FALSE); + cogl_push_source (_context->simple_pipeline); + _cogl_pipeline_flush_gl_state (_context->simple_pipeline, FALSE); _cogl_enable (enable_flags); _cogl_flush_face_winding (); @@ -246,7 +246,7 @@ cogl_create_context (void) unless GL_COORD_REPLACE is enabled for an individual layer. Therefore it seems like it should be ok to just leave it enabled all the time instead of having to have a set property on - each material to track whether any layers have point sprite + each pipeline to track whether any layers have point sprite coords enabled */ if (cogl_features_available (COGL_FEATURE_POINT_SPRITE)) GE (glEnable (GL_POINT_SPRITE)); @@ -275,10 +275,10 @@ _cogl_destroy_context (void) if (_context->default_gl_texture_rect_tex) cogl_handle_unref (_context->default_gl_texture_rect_tex); - if (_context->simple_material) - cogl_handle_unref (_context->simple_material); - if (_context->texture_material) - cogl_handle_unref (_context->texture_material); + if (_context->simple_pipeline) + cogl_handle_unref (_context->simple_pipeline); + if (_context->texture_pipeline) + cogl_handle_unref (_context->texture_pipeline); if (_context->journal) g_array_free (_context->journal, TRUE); @@ -300,8 +300,8 @@ _cogl_destroy_context (void) if (_context->rectangle_short_indices) cogl_object_unref (_context->rectangle_short_indices); - if (_context->default_material) - cogl_handle_unref (_context->default_material); + if (_context->default_pipeline) + cogl_handle_unref (_context->default_pipeline); if (_context->dummy_layer_dependant) cogl_handle_unref (_context->dummy_layer_dependant); diff --git a/clutter/cogl/cogl/cogl-context.h b/clutter/cogl/cogl/cogl-context.h index 779a2527c..96157cb28 100644 --- a/clutter/cogl/cogl/cogl-context.h +++ b/clutter/cogl/cogl/cogl-context.h @@ -38,7 +38,7 @@ #include "cogl-primitives.h" #include "cogl-clip-stack.h" #include "cogl-matrix-stack.h" -#include "cogl-material-private.h" +#include "cogl-pipeline-private.h" #include "cogl-buffer-private.h" #include "cogl-bitmask.h" #include "cogl-atlas.h" @@ -57,7 +57,7 @@ typedef struct CoglFeatureFlagsPrivate feature_flags_private; gboolean features_cached; - CoglHandle default_material; + CoglHandle default_pipeline; CoglHandle default_layer_0; CoglHandle default_layer_n; CoglHandle dummy_layer_dependant; @@ -80,11 +80,11 @@ typedef struct GArray *texture_units; int active_texture_unit; - CoglMaterialFogState legacy_fog_state; + CoglPipelineFogState legacy_fog_state; /* Materials */ - CoglMaterial *simple_material; /* used for set_source_color */ - CoglMaterial *texture_material; /* used for set_source_texture */ + CoglPipeline *simple_pipeline; /* used for set_source_color */ + CoglPipeline *texture_pipeline; /* used for set_source_texture */ GString *arbfp_source_buffer; GList *source_stack; @@ -105,13 +105,13 @@ typedef struct GArray *polygon_vertices; /* Some simple caching, to minimize state changes... */ - CoglMaterial *current_material; - unsigned long current_material_changes_since_flush; - gboolean current_material_skip_gl_color; - unsigned long current_material_age; + CoglPipeline *current_pipeline; + unsigned long current_pipeline_changes_since_flush; + gboolean current_pipeline_skip_gl_color; + unsigned long current_pipeline_age; - GArray *material0_nodes; - GArray *material1_nodes; + GArray *pipeline0_nodes; + GArray *pipeline1_nodes; /* Bitmask of texture coordinates arrays that are enabled */ CoglBitmask texcoord_arrays_enabled; @@ -143,7 +143,7 @@ typedef struct /* Primitives */ CoglHandle current_path; - CoglMaterial *stencil_material; + CoglPipeline *stencil_pipeline; /* Pre-generated VBOs containing indices to generate GL_TRIANGLES out of a vertex array of quads */ @@ -157,7 +157,7 @@ typedef struct gboolean in_begin_gl_block; - CoglMaterial *texture_download_material; + CoglPipeline *texture_download_pipeline; CoglAtlas *atlas; @@ -176,7 +176,7 @@ typedef struct /* Fragment processing programs */ CoglHandle current_program; - CoglMaterialProgramType current_use_program_type; + CoglPipelineProgramType current_use_program_type; GLuint current_gl_program; /* List of types that will be considered a subclass of CoglTexture in diff --git a/clutter/cogl/cogl/cogl-framebuffer.c b/clutter/cogl/cogl/cogl-framebuffer.c index 07b5b0199..0a5388a74 100644 --- a/clutter/cogl/cogl/cogl-framebuffer.c +++ b/clutter/cogl/cogl/cogl-framebuffer.c @@ -470,7 +470,7 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle) * To avoid an error with drivers that do consider this a problem we * explicitly set non mipmapped filters here. These will later be reset when * the texture is actually used for rendering according to the filters set on - * the corresponding CoglMaterial. + * the corresponding CoglPipeline. */ _cogl_texture_set_filters (texhandle, GL_NEAREST, GL_NEAREST); diff --git a/clutter/cogl/cogl/cogl-journal-private.h b/clutter/cogl/cogl/cogl-journal-private.h index da4f08f16..a38fa801f 100644 --- a/clutter/cogl/cogl/cogl-journal-private.h +++ b/clutter/cogl/cogl/cogl-journal-private.h @@ -31,21 +31,21 @@ * later flush the journal we aim to batch data, and gl draw calls. */ typedef struct _CoglJournalEntry { - CoglHandle material; + CoglPipeline *pipeline; int n_layers; CoglMatrix model_view; /* XXX: These entries are pretty big now considering the padding in - * CoglMaterialFlushOptions and CoglMatrix, so we might need to optimize this + * CoglPipelineFlushOptions and CoglMatrix, so we might need to optimize this * later. */ } CoglJournalEntry; void _cogl_journal_log_quad (const float *position, - CoglHandle material, + CoglPipeline *pipeline, int n_layers, guint32 fallback_layers, GLuint layer0_override_texture, - const CoglMaterialWrapModeOverrides * + const CoglPipelineWrapModeOverrides * wrap_mode_overrides, const float *tex_coords, unsigned int tex_coords_len); diff --git a/clutter/cogl/cogl/cogl-journal.c b/clutter/cogl/cogl/cogl-journal.c index e9e813746..a68a30a9f 100644 --- a/clutter/cogl/cogl/cogl-journal.c +++ b/clutter/cogl/cogl/cogl-journal.c @@ -31,8 +31,8 @@ #include "cogl-context.h" #include "cogl-journal-private.h" #include "cogl-texture-private.h" -#include "cogl-material-private.h" -#include "cogl-material-opengl-private.h" +#include "cogl-pipeline-private.h" +#include "cogl-pipeline-opengl-private.h" #include "cogl-vertex-buffer-private.h" #include "cogl-framebuffer-private.h" #include "cogl-profile.h" @@ -49,7 +49,7 @@ * 4 RGBA GLubytes, * 2 GLfloats per tex coord * n_layers * - * Where n_layers corresponds to the number of material layers enabled + * Where n_layers corresponds to the number of pipeline layers enabled * * To avoid frequent changes in the stride of our vertex data we always pad * n_layers to be >= 2 @@ -85,7 +85,7 @@ typedef struct _CoglJournalFlushState #endif CoglMatrixStack *modelview_stack; - CoglMaterial *source; + CoglPipeline *source; } CoglJournalFlushState; typedef void (*CoglJournalBatchCallback) (CoglJournalEntry *start, @@ -184,7 +184,7 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start, CoglJournalFlushState *state = data; CoglVertexAttribute **attributes; COGL_STATIC_TIMER (time_flush_modelview_and_entries, - "flush: material+entries", /* parent */ + "flush: pipeline+entries", /* parent */ "flush: modelview+entries", "The time spent flushing modelview + entries", 0 /* no application private data */); @@ -239,15 +239,15 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start, */ if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_RECTANGLES)) { - static CoglHandle outline = COGL_INVALID_HANDLE; + static CoglPipeline *outline = NULL; guint8 color_intensity; int i; CoglVertexAttribute *loop_attributes[2]; _COGL_GET_CONTEXT (ctxt, NO_RETVAL); - if (outline == COGL_INVALID_HANDLE) - outline = cogl_material_new (); + if (outline == NULL) + outline = cogl_pipeline_new (); /* The least significant three bits represent the three components so that the order of colours goes red, green, @@ -257,7 +257,7 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start, of 24 colours. If there are more than 24 batches on the stage then it will wrap around */ color_intensity = 0xff - 0x33 * (ctxt->journal_rectangles_color >> 3); - cogl_material_set_color4ub (outline, + cogl_pipeline_set_color4ub (outline, (ctxt->journal_rectangles_color & 1) ? color_intensity : 0, (ctxt->journal_rectangles_color & 2) ? @@ -313,27 +313,27 @@ compare_entry_modelviews (CoglJournalEntry *entry0, } /* At this point we have a run of quads that we know have compatible - * materials, but they may not all have the same modelview matrix */ + * pipelines, but they may not all have the same modelview matrix */ static void -_cogl_journal_flush_material_and_entries (CoglJournalEntry *batch_start, +_cogl_journal_flush_pipeline_and_entries (CoglJournalEntry *batch_start, int batch_len, void *data) { CoglJournalFlushState *state = data; - COGL_STATIC_TIMER (time_flush_material_entries, - "flush: texcoords+material+entries", /* parent */ - "flush: material+entries", - "The time spent flushing material + entries", + COGL_STATIC_TIMER (time_flush_pipeline_entries, + "flush: texcoords+pipeline+entries", /* parent */ + "flush: pipeline+entries", + "The time spent flushing pipeline + entries", 0 /* no application private data */); _COGL_GET_CONTEXT (ctx, NO_RETVAL); - COGL_TIMER_START (_cogl_uprof_context, time_flush_material_entries); + COGL_TIMER_START (_cogl_uprof_context, time_flush_pipeline_entries); if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_BATCHING)) - g_print ("BATCHING: material batch len = %d\n", batch_len); + g_print ("BATCHING: pipeline batch len = %d\n", batch_len); - state->source = batch_start->material; + state->source = batch_start->pipeline; /* If we haven't transformed the quads in software then we need to also break * up batches according to changes in the modelview matrix... */ @@ -348,20 +348,20 @@ _cogl_journal_flush_material_and_entries (CoglJournalEntry *batch_start, else _cogl_journal_flush_modelview_and_entries (batch_start, batch_len, data); - COGL_TIMER_STOP (_cogl_uprof_context, time_flush_material_entries); + COGL_TIMER_STOP (_cogl_uprof_context, time_flush_pipeline_entries); } static gboolean -compare_entry_materials (CoglJournalEntry *entry0, CoglJournalEntry *entry1) +compare_entry_pipelines (CoglJournalEntry *entry0, CoglJournalEntry *entry1) { - /* batch rectangles using compatible materials */ + /* batch rectangles using compatible pipelines */ - /* XXX: _cogl_material_equal may give false negatives since it avoids + /* XXX: _cogl_pipeline_equal may give false negatives since it avoids * deep comparisons as an optimization. It aims to compare enough so * that we that we are able to batch the 90% common cases, but may not * look at less common differences. */ - if (_cogl_material_equal (entry0->material, - entry1->material, + if (_cogl_pipeline_equal (entry0->pipeline, + entry1->pipeline, TRUE)) return TRUE; else @@ -379,16 +379,16 @@ _cogl_journal_flush_texcoord_vbo_offsets_and_entries ( { CoglJournalFlushState *state = data; int i; - COGL_STATIC_TIMER (time_flush_texcoord_material_entries, - "flush: vbo+texcoords+material+entries", /* parent */ - "flush: texcoords+material+entries", - "The time spent flushing texcoord offsets + material " + COGL_STATIC_TIMER (time_flush_texcoord_pipeline_entries, + "flush: vbo+texcoords+pipeline+entries", /* parent */ + "flush: texcoords+pipeline+entries", + "The time spent flushing texcoord offsets + pipeline " "+ entries", 0 /* no application private data */); _COGL_GET_CONTEXT (ctx, NO_RETVAL); - COGL_TIMER_START (_cogl_uprof_context, time_flush_texcoord_material_entries); + COGL_TIMER_START (_cogl_uprof_context, time_flush_texcoord_pipeline_entries); /* NB: attributes 0 and 1 are position and color */ @@ -444,10 +444,10 @@ _cogl_journal_flush_texcoord_vbo_offsets_and_entries ( batch_and_call (batch_start, batch_len, - compare_entry_materials, - _cogl_journal_flush_material_and_entries, + compare_entry_pipelines, + _cogl_journal_flush_pipeline_and_entries, data); - COGL_TIMER_STOP (_cogl_uprof_context, time_flush_texcoord_material_entries); + COGL_TIMER_STOP (_cogl_uprof_context, time_flush_texcoord_pipeline_entries); } static gboolean @@ -470,17 +470,17 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start, gsize stride; int i; CoglVertexAttribute **attribute_entry; - COGL_STATIC_TIMER (time_flush_vbo_texcoord_material_entries, + COGL_STATIC_TIMER (time_flush_vbo_texcoord_pipeline_entries, "Journal Flush", /* parent */ - "flush: vbo+texcoords+material+entries", + "flush: vbo+texcoords+pipeline+entries", "The time spent flushing vbo + texcoord offsets + " - "material + entries", + "pipeline + entries", 0 /* no application private data */); _COGL_GET_CONTEXT (ctx, NO_RETVAL); COGL_TIMER_START (_cogl_uprof_context, - time_flush_vbo_texcoord_material_entries); + time_flush_vbo_texcoord_pipeline_entries); if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_BATCHING)) g_print ("BATCHING: vbo offset batch len = %d\n", batch_len); @@ -529,7 +529,7 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start, #endif /* We only create new VertexAttributes when the stride within the - * VertexArray changes. (due to a change in the number of material layers) + * VertexArray changes. (due to a change in the number of pipeline layers) * While the stride remains constant we walk forward through the above * VertexArray using a vertex offset passed to cogl_draw_vertex_attributes */ @@ -561,14 +561,14 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start, g_print ("new vbo offset = %lu\n", (unsigned long)state->array_offset); COGL_TIMER_STOP (_cogl_uprof_context, - time_flush_vbo_texcoord_material_entries); + time_flush_vbo_texcoord_pipeline_entries); } static gboolean compare_entry_strides (CoglJournalEntry *entry0, CoglJournalEntry *entry1) { /* Currently the only thing that affects the stride for our vertex arrays - * is the number of material layers. We need to update our VBO offsets + * is the number of pipeline layers. We need to update our VBO offsets * whenever the stride changes. */ /* TODO: We should be padding the n_layers == 1 case as if it were * n_layers == 2 so we can reduce the need to split batches. */ @@ -605,7 +605,7 @@ upload_vertices (GArray *vertices, CoglJournalFlushState *state) } /* XXX NB: When _cogl_journal_flush() returns all state relating - * to materials, all glEnable flags and current matrix state + * to pipelines, all glEnable flags and current matrix state * is undefined. */ void @@ -659,14 +659,14 @@ _cogl_journal_flush (void) * Each time the stride of our vertex data changes we need to call * gl{Vertex,Color}Pointer to inform GL of new VBO offsets. * Currently the only thing that affects the stride of our vertex data - * is the number of material layers. - * 2) We split the entries explicitly by the number of material layers: + * is the number of pipeline layers. + * 2) We split the entries explicitly by the number of pipeline layers: * We pad our vertex data when the number of layers is < 2 so that we * can minimize changes in stride. Each time the number of layers * changes we need to call glTexCoordPointer to inform GL of new VBO * offsets. - * 3) We then split according to compatible Cogl materials: - * This is where we flush material state + * 3) We then split according to compatible Cogl pipelines: + * This is where we flush pipeline state * 4) Finally we split according to modelview matrix changes: * This is when we finally tell GL to draw something. * Note: Splitting by modelview changes is skipped when are doing the @@ -684,7 +684,7 @@ _cogl_journal_flush (void) { CoglJournalEntry *entry = &g_array_index (ctx->journal, CoglJournalEntry, i); - _cogl_material_journal_unref (entry->material); + _cogl_pipeline_journal_unref (entry->pipeline); } g_array_set_size (ctx->journal, 0); @@ -707,11 +707,11 @@ _cogl_journal_init (void) void _cogl_journal_log_quad (const float *position, - CoglHandle material, + CoglPipeline *pipeline, int n_layers, guint32 fallback_layers, GLuint layer0_override_texture, - const CoglMaterialWrapModeOverrides * + const CoglPipelineWrapModeOverrides * wrap_mode_overrides, const float *tex_coords, unsigned int tex_coords_len) @@ -726,8 +726,8 @@ _cogl_journal_log_quad (const float *position, int next_entry; guint32 disable_layers; CoglJournalEntry *entry; - CoglHandle source; - CoglMaterialFlushOptions flush_options; + CoglPipeline *source; + CoglPipelineFlushOptions flush_options; COGL_STATIC_TIMER (log_timer, "Mainloop", /* parent */ "Journal Log", @@ -764,7 +764,7 @@ _cogl_journal_log_quad (const float *position, /* FIXME: This is a hacky optimization, since it will break if we * change the definition of CoglColor: */ - _cogl_material_get_colorubv (material, c); + _cogl_pipeline_get_colorubv (pipeline, c); src_c = c; for (i = 0; i < 3; i++) { @@ -846,49 +846,49 @@ _cogl_journal_log_quad (const float *position, entry->n_layers = n_layers; - source = material; + source = pipeline; if (G_UNLIKELY (ctx->legacy_state_set)) { - source = cogl_material_copy (material); - _cogl_material_apply_legacy_state (source); + source = cogl_pipeline_copy (pipeline); + _cogl_pipeline_apply_legacy_state (source); } flush_options.flags = 0; - if (G_UNLIKELY (cogl_material_get_n_layers (material) != n_layers)) + if (G_UNLIKELY (cogl_pipeline_get_n_layers (pipeline) != n_layers)) { disable_layers = (1 << n_layers) - 1; disable_layers = ~disable_layers; flush_options.disable_layers = disable_layers; - flush_options.flags |= COGL_MATERIAL_FLUSH_DISABLE_MASK; + flush_options.flags |= COGL_PIPELINE_FLUSH_DISABLE_MASK; } if (G_UNLIKELY (fallback_layers)) { flush_options.fallback_layers = fallback_layers; - flush_options.flags |= COGL_MATERIAL_FLUSH_FALLBACK_MASK; + flush_options.flags |= COGL_PIPELINE_FLUSH_FALLBACK_MASK; } if (G_UNLIKELY (layer0_override_texture)) { - flush_options.flags |= COGL_MATERIAL_FLUSH_LAYER0_OVERRIDE; + flush_options.flags |= COGL_PIPELINE_FLUSH_LAYER0_OVERRIDE; flush_options.layer0_override_texture = layer0_override_texture; } if (wrap_mode_overrides) { - flush_options.flags |= COGL_MATERIAL_FLUSH_WRAP_MODE_OVERRIDES; + flush_options.flags |= COGL_PIPELINE_FLUSH_WRAP_MODE_OVERRIDES; flush_options.wrap_mode_overrides = *wrap_mode_overrides; } if (G_UNLIKELY (flush_options.flags)) { - /* If we haven't already created a derived material... */ - if (source == material) - source = cogl_material_copy (material); - _cogl_material_apply_overrides (source, &flush_options); + /* If we haven't already created a derived pipeline... */ + if (source == pipeline) + source = cogl_pipeline_copy (pipeline); + _cogl_pipeline_apply_overrides (source, &flush_options); } - entry->material = _cogl_material_journal_ref (source); + entry->pipeline = _cogl_pipeline_journal_ref (source); - if (G_UNLIKELY (source != material)) + if (G_UNLIKELY (source != pipeline)) cogl_handle_unref (source); if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM)) diff --git a/clutter/cogl/cogl/cogl-material-compat.c b/clutter/cogl/cogl/cogl-material-compat.c new file mode 100644 index 000000000..94d07fce1 --- /dev/null +++ b/clutter/cogl/cogl/cogl-material-compat.c @@ -0,0 +1,495 @@ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2010 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Authors: + * Robert Bragg + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include + +CoglMaterial * +cogl_material_new (void) +{ + return COGL_MATERIAL (cogl_pipeline_new ()); +} + +CoglMaterial * +cogl_material_copy (CoglMaterial *source) +{ + return COGL_MATERIAL (cogl_pipeline_copy (COGL_PIPELINE (source))); +} + +CoglHandle +cogl_material_ref (CoglHandle handle) +{ + return cogl_object_ref (handle); +} + +void +cogl_material_unref (CoglHandle handle) +{ + cogl_object_unref (handle); +} + +gboolean +cogl_is_material (CoglHandle handle) +{ + return cogl_is_pipeline (handle); +} + +void +cogl_material_set_color (CoglMaterial *material, + const CoglColor *color) +{ + cogl_pipeline_set_color (COGL_PIPELINE (material), color); +} + +void +cogl_material_set_color4ub (CoglMaterial *material, + guint8 red, + guint8 green, + guint8 blue, + guint8 alpha) +{ + cogl_pipeline_set_color4ub (COGL_PIPELINE (material), + red, green, blue, alpha); +} + +void +cogl_material_set_color4f (CoglMaterial *material, + float red, + float green, + float blue, + float alpha) +{ + cogl_pipeline_set_color4f (COGL_PIPELINE (material), + red, green, blue, alpha); +} + +void +cogl_material_get_color (CoglMaterial *material, + CoglColor *color) +{ + cogl_pipeline_get_color (COGL_PIPELINE (material), color); +} + +void +cogl_material_set_ambient (CoglMaterial *material, + const CoglColor *ambient) +{ + cogl_pipeline_set_ambient (COGL_PIPELINE (material), ambient); +} + +void +cogl_material_get_ambient (CoglMaterial *material, + CoglColor *ambient) +{ + cogl_pipeline_get_ambient (COGL_PIPELINE (material), ambient); +} + +void +cogl_material_set_diffuse (CoglMaterial *material, + const CoglColor *diffuse) +{ + cogl_pipeline_set_diffuse (COGL_PIPELINE (material), diffuse); +} + +void +cogl_material_get_diffuse (CoglMaterial *material, + CoglColor *diffuse) +{ + cogl_pipeline_get_diffuse (COGL_PIPELINE (material), diffuse); +} + +void +cogl_material_set_ambient_and_diffuse (CoglMaterial *material, + const CoglColor *color) +{ + cogl_pipeline_set_ambient_and_diffuse (COGL_PIPELINE (material), color); + +} + +void +cogl_material_set_specular (CoglMaterial *material, + const CoglColor *specular) +{ + cogl_pipeline_set_specular (COGL_PIPELINE (material), specular); +} + +void +cogl_material_get_specular (CoglMaterial *material, + CoglColor *specular) +{ + cogl_pipeline_get_specular (COGL_PIPELINE (material), specular); +} + +void +cogl_material_set_shininess (CoglMaterial *material, + float shininess) +{ + cogl_pipeline_set_shininess (COGL_PIPELINE (material), shininess); +} + +float +cogl_material_get_shininess (CoglMaterial *material) +{ + return cogl_pipeline_get_shininess (COGL_PIPELINE (material)); +} + +void +cogl_material_set_emission (CoglMaterial *material, + const CoglColor *emission) +{ + cogl_pipeline_set_emission (COGL_PIPELINE (material), emission); + +} + +void +cogl_material_get_emission (CoglMaterial *material, + CoglColor *emission) +{ + cogl_pipeline_get_emission (COGL_PIPELINE (material), emission); + +} + +void +cogl_material_set_alpha_test_function (CoglMaterial *material, + CoglMaterialAlphaFunc alpha_func, + float alpha_reference) +{ + cogl_pipeline_set_alpha_test_function (COGL_PIPELINE (material), + alpha_func, + alpha_reference); +} + +gboolean +cogl_material_set_blend (CoglMaterial *material, + const char *blend_string, + GError **error) +{ + return cogl_pipeline_set_blend (COGL_PIPELINE (material), + blend_string, + error); +} + +void +cogl_material_set_blend_constant (CoglMaterial *material, + const CoglColor *constant_color) +{ + cogl_pipeline_set_blend_constant (COGL_PIPELINE (material), constant_color); +} + +void +cogl_material_set_point_size (CoglMaterial *material, + float point_size) +{ + cogl_pipeline_set_point_size (COGL_PIPELINE (material), point_size); +} + +float +cogl_material_get_point_size (CoglMaterial *material) +{ + return cogl_pipeline_get_point_size (COGL_PIPELINE (material)); +} + +CoglHandle +cogl_material_get_user_program (CoglMaterial *material) +{ + return cogl_pipeline_get_user_program (COGL_PIPELINE (material)); +} + +void +cogl_material_set_user_program (CoglMaterial *material, + CoglHandle program) +{ + cogl_pipeline_set_user_program (COGL_PIPELINE (material), program); +} + +void +cogl_material_set_layer (CoglMaterial *material, + int layer_index, + CoglHandle texture) +{ + cogl_pipeline_set_layer_texture (COGL_PIPELINE (material), + layer_index, texture); +} + +void +cogl_material_remove_layer (CoglMaterial *material, + int layer_index) +{ + cogl_pipeline_remove_layer (COGL_PIPELINE (material), layer_index); +} + +gboolean +cogl_material_set_layer_combine (CoglMaterial *material, + int layer_index, + const char *blend_string, + GError **error) +{ + return cogl_pipeline_set_layer_combine (COGL_PIPELINE (material), + layer_index, + blend_string, + error); +} + +void +cogl_material_set_layer_combine_constant (CoglMaterial *material, + int layer_index, + const CoglColor *constant) +{ + cogl_pipeline_set_layer_combine_constant (COGL_PIPELINE (material), + layer_index, + constant); +} + +void +cogl_material_set_layer_matrix (CoglMaterial *material, + int layer_index, + const CoglMatrix *matrix) +{ + cogl_pipeline_set_layer_matrix (COGL_PIPELINE (material), + layer_index, matrix); +} + +G_CONST_RETURN GList * +cogl_material_get_layers (CoglMaterial *material) +{ + return _cogl_pipeline_get_layers (COGL_PIPELINE (material)); +} + +int +cogl_material_get_n_layers (CoglMaterial *material) +{ + return cogl_pipeline_get_n_layers (COGL_PIPELINE (material)); +} + +CoglMaterialLayerType +cogl_material_layer_get_type (CoglMaterialLayer *layer) +{ + return COGL_MATERIAL_LAYER_TYPE_TEXTURE; +} + +CoglHandle +cogl_material_layer_get_texture (CoglMaterialLayer *layer) +{ + return _cogl_pipeline_layer_get_texture (COGL_PIPELINE_LAYER (layer)); +} + +CoglMaterialFilter +cogl_material_layer_get_min_filter (CoglMaterialLayer *layer) +{ + return _cogl_pipeline_layer_get_min_filter (COGL_PIPELINE_LAYER (layer)); +} + +CoglMaterialFilter +cogl_material_layer_get_mag_filter (CoglMaterialLayer *layer) +{ + return _cogl_pipeline_layer_get_mag_filter (COGL_PIPELINE_LAYER (layer)); +} + +void +cogl_material_set_layer_filters (CoglMaterial *material, + int layer_index, + CoglMaterialFilter min_filter, + CoglMaterialFilter mag_filter) +{ + cogl_pipeline_set_layer_filters (COGL_PIPELINE (material), + layer_index, + min_filter, + mag_filter); +} + +gboolean +cogl_material_set_layer_point_sprite_coords_enabled (CoglMaterial *material, + int layer_index, + gboolean enable, + GError **error) +{ + CoglPipeline *pipeline = COGL_PIPELINE (material); + return cogl_pipeline_set_layer_point_sprite_coords_enabled (pipeline, + layer_index, + enable, + error); +} + +gboolean +cogl_material_get_layer_point_sprite_coords_enabled (CoglMaterial *material, + int layer_index) +{ + CoglPipeline *pipeline = COGL_PIPELINE (material); + return cogl_pipeline_get_layer_point_sprite_coords_enabled (pipeline, + layer_index); +} + +CoglMaterialWrapMode +cogl_material_get_layer_wrap_mode_s (CoglMaterial *material, + int layer_index) +{ + return cogl_pipeline_get_layer_wrap_mode_s (COGL_PIPELINE (material), + layer_index); +} + +void +cogl_material_set_layer_wrap_mode_s (CoglMaterial *material, + int layer_index, + CoglMaterialWrapMode mode) +{ + cogl_pipeline_set_layer_wrap_mode_s (COGL_PIPELINE (material), layer_index, + mode); +} + +CoglMaterialWrapMode +cogl_material_get_layer_wrap_mode_t (CoglMaterial *material, + int layer_index) +{ + return cogl_pipeline_get_layer_wrap_mode_t (COGL_PIPELINE (material), + layer_index); +} + +void +cogl_material_set_layer_wrap_mode_t (CoglMaterial *material, + int layer_index, + CoglMaterialWrapMode mode) +{ + cogl_pipeline_set_layer_wrap_mode_t (COGL_PIPELINE (material), layer_index, + mode); +} + +CoglMaterialWrapMode +cogl_material_get_layer_wrap_mode_p (CoglMaterial *material, + int layer_index) +{ + return cogl_pipeline_get_layer_wrap_mode_p (COGL_PIPELINE (material), + layer_index); +} + +void +cogl_material_set_layer_wrap_mode_p (CoglMaterial *material, + int layer_index, + CoglMaterialWrapMode mode) +{ + cogl_pipeline_set_layer_wrap_mode_p (COGL_PIPELINE (material), layer_index, + mode); +} + +void +cogl_material_set_layer_wrap_mode (CoglMaterial *material, + int layer_index, + CoglMaterialWrapMode mode) +{ + cogl_pipeline_set_layer_wrap_mode (COGL_PIPELINE (material), layer_index, + mode); +} + +CoglMaterialWrapMode +cogl_material_layer_get_wrap_mode_s (CoglMaterialLayer *layer) +{ + return _cogl_pipeline_layer_get_wrap_mode_s (COGL_PIPELINE_LAYER (layer)); +} + +CoglMaterialWrapMode +cogl_material_layer_get_wrap_mode_t (CoglMaterialLayer *layer) +{ + return _cogl_pipeline_layer_get_wrap_mode_t (COGL_PIPELINE_LAYER (layer)); +} + +CoglMaterialWrapMode +cogl_material_layer_get_wrap_mode_p (CoglMaterialLayer *layer) +{ + return _cogl_pipeline_layer_get_wrap_mode_p (COGL_PIPELINE_LAYER (layer)); +} + +void +cogl_material_set_depth_test_enabled (CoglMaterial *material, + gboolean enable) +{ + cogl_pipeline_set_depth_test_enabled (COGL_PIPELINE (material), enable); +} + +gboolean +cogl_material_get_depth_test_enabled (CoglMaterial *material) +{ + return cogl_pipeline_get_depth_test_enabled (COGL_PIPELINE (material)); +} + +void +cogl_material_set_depth_writing_enabled (CoglMaterial *material, + gboolean enable) +{ + cogl_pipeline_set_depth_writing_enabled (COGL_PIPELINE (material), enable); +} + +gboolean +cogl_material_get_depth_writing_enabled (CoglMaterial *material) +{ + return cogl_pipeline_get_depth_writing_enabled (COGL_PIPELINE (material)); +} + +void +cogl_material_set_depth_test_function (CoglMaterial *material, + CoglDepthTestFunction function) +{ + cogl_pipeline_set_depth_test_function (COGL_PIPELINE (material), function); +} + +CoglDepthTestFunction +cogl_material_get_depth_test_function (CoglMaterial *material) +{ + return cogl_pipeline_get_depth_test_function (COGL_PIPELINE (material)); +} + +gboolean +cogl_material_set_depth_range (CoglMaterial *material, + float near_val, + float far_val, + GError **error) +{ + return cogl_pipeline_set_depth_range (COGL_PIPELINE (material), + near_val, far_val, error); +} + +void +cogl_material_get_depth_range (CoglMaterial *material, + float *near_val, + float *far_val) +{ + cogl_pipeline_get_depth_range (COGL_PIPELINE (material), near_val, far_val); +} + +void +cogl_material_foreach_layer (CoglMaterial *material, + CoglMaterialLayerCallback callback, + void *user_data) +{ + cogl_pipeline_foreach_layer (COGL_PIPELINE (material), + (CoglPipelineLayerCallback)callback, user_data); +} + diff --git a/clutter/cogl/cogl/cogl-material.h b/clutter/cogl/cogl/cogl-material-compat.h similarity index 93% rename from clutter/cogl/cogl/cogl-material.h rename to clutter/cogl/cogl/cogl-material-compat.h index 35cf7b99b..b6e25ff84 100644 --- a/clutter/cogl/cogl/cogl-material.h +++ b/clutter/cogl/cogl/cogl-material-compat.h @@ -76,13 +76,14 @@ typedef struct _CoglMaterialLayer CoglMaterialLayer; * average or simply using the nearest texel. */ typedef enum { - COGL_MATERIAL_FILTER_NEAREST = GL_NEAREST, - COGL_MATERIAL_FILTER_LINEAR = GL_LINEAR, - COGL_MATERIAL_FILTER_NEAREST_MIPMAP_NEAREST = GL_NEAREST_MIPMAP_NEAREST, - COGL_MATERIAL_FILTER_LINEAR_MIPMAP_NEAREST = GL_LINEAR_MIPMAP_NEAREST, - COGL_MATERIAL_FILTER_NEAREST_MIPMAP_LINEAR = GL_NEAREST_MIPMAP_LINEAR, - COGL_MATERIAL_FILTER_LINEAR_MIPMAP_LINEAR = GL_LINEAR_MIPMAP_LINEAR + COGL_MATERIAL_FILTER_NEAREST = 0x2600, + COGL_MATERIAL_FILTER_LINEAR = 0x2601, + COGL_MATERIAL_FILTER_NEAREST_MIPMAP_NEAREST = 0x2700, + COGL_MATERIAL_FILTER_LINEAR_MIPMAP_NEAREST = 0x2701, + COGL_MATERIAL_FILTER_NEAREST_MIPMAP_LINEAR = 0x2702, + COGL_MATERIAL_FILTER_LINEAR_MIPMAP_LINEAR = 0x2703 } CoglMaterialFilter; +/* NB: these values come from the equivalents in gl.h */ /** * CoglMaterialWrapMode: @@ -119,10 +120,11 @@ typedef enum { * enum so no conversion is actually needed. */ typedef enum { - COGL_MATERIAL_WRAP_MODE_REPEAT = GL_REPEAT, - COGL_MATERIAL_WRAP_MODE_CLAMP_TO_EDGE = GL_CLAMP_TO_EDGE, - COGL_MATERIAL_WRAP_MODE_AUTOMATIC = GL_ALWAYS + COGL_MATERIAL_WRAP_MODE_REPEAT = 0x2901, + COGL_MATERIAL_WRAP_MODE_CLAMP_TO_EDGE = 0x812F, + COGL_MATERIAL_WRAP_MODE_AUTOMATIC = 0x0207 } CoglMaterialWrapMode; +/* NB: these values come from the equivalents in gl.h */ /** * cogl_material_new: @@ -468,14 +470,14 @@ cogl_material_get_emission (CoglMaterial *material, * determines how the comparison is done. */ typedef enum { - COGL_MATERIAL_ALPHA_FUNC_NEVER = GL_NEVER, - COGL_MATERIAL_ALPHA_FUNC_LESS = GL_LESS, - COGL_MATERIAL_ALPHA_FUNC_EQUAL = GL_EQUAL, - COGL_MATERIAL_ALPHA_FUNC_LEQUAL = GL_LEQUAL, - COGL_MATERIAL_ALPHA_FUNC_GREATER = GL_GREATER, - COGL_MATERIAL_ALPHA_FUNC_NOTEQUAL = GL_NOTEQUAL, - COGL_MATERIAL_ALPHA_FUNC_GEQUAL = GL_GEQUAL, - COGL_MATERIAL_ALPHA_FUNC_ALWAYS = GL_ALWAYS + COGL_MATERIAL_ALPHA_FUNC_NEVER = 0x0200, + COGL_MATERIAL_ALPHA_FUNC_LESS = 0x0201, + COGL_MATERIAL_ALPHA_FUNC_EQUAL = 0x0202, + COGL_MATERIAL_ALPHA_FUNC_LEQUAL = 0x0203, + COGL_MATERIAL_ALPHA_FUNC_GREATER = 0x0204, + COGL_MATERIAL_ALPHA_FUNC_NOTEQUAL = 0x0205, + COGL_MATERIAL_ALPHA_FUNC_GEQUAL = 0x0206, + COGL_MATERIAL_ALPHA_FUNC_ALWAYS = 0x0207 } CoglMaterialAlphaFunc; /** @@ -619,8 +621,8 @@ cogl_material_set_blend_constant (CoglMaterial *material, * Since: 1.4 */ void -cogl_material_set_point_size (CoglHandle material, - float point_size); +cogl_material_set_point_size (CoglMaterial *material, + float point_size); /** * cogl_material_get_point_size: @@ -634,7 +636,7 @@ cogl_material_set_point_size (CoglHandle material, * Since: 1.4 */ float -cogl_material_get_point_size (CoglHandle material); +cogl_material_get_point_size (CoglMaterial *material); /** * cogl_material_get_user_program: @@ -1189,52 +1191,6 @@ cogl_material_layer_get_wrap_mode_t (CoglMaterialLayer *layer); CoglMaterialWrapMode cogl_material_layer_get_wrap_mode_p (CoglMaterialLayer *layer); -/* XXX: should this be CoglMaterialDepthTestFunction? - * It makes it very verbose but would be consistent with - * CoglMaterialWrapMode */ - -/** - * CoglDepthTestFunction: - * @COGL_DEPTH_TEST_FUNCTION_NEVER: Never passes. - * @COGL_DEPTH_TEST_FUNCTION_LESS: Passes if the fragment's depth - * value is less than the value currently in the depth buffer. - * @COGL_DEPTH_TEST_FUNCTION_EQUAL: Passes if the fragment's depth - * value is equal to the value currently in the depth buffer. - * @COGL_DEPTH_TEST_FUNCTION_LEQUAL: Passes if the fragment's depth - * value is less or equal to the value currently in the depth buffer. - * @COGL_DEPTH_TEST_FUNCTION_GREATER: Passes if the fragment's depth - * value is greater than the value currently in the depth buffer. - * @COGL_DEPTH_TEST_FUNCTION_NOTEQUAL: Passes if the fragment's depth - * value is not equal to the value currently in the depth buffer. - * @COGL_DEPTH_TEST_FUNCTION_GEQUAL: Passes if the fragment's depth - * value greater than or equal to the value currently in the depth buffer. - * @COGL_DEPTH_TEST_FUNCTION_ALWAYS: Always passes. - * - * When using depth testing one of these functions is used to compare - * the depth of an incoming fragment against the depth value currently - * stored in the depth buffer. The function is changed using - * cogl_material_set_depth_test_function(). - * - * The test is only done when depth testing is explicitly enabled. (See - * cogl_material_set_depth_test_enabled()) - */ -typedef enum -{ - COGL_DEPTH_TEST_FUNCTION_NEVER = GL_NEVER, - COGL_DEPTH_TEST_FUNCTION_LESS = GL_LESS, - COGL_DEPTH_TEST_FUNCTION_EQUAL = GL_EQUAL, - COGL_DEPTH_TEST_FUNCTION_LEQUAL = GL_LEQUAL, - COGL_DEPTH_TEST_FUNCTION_GREATER = GL_GREATER, - COGL_DEPTH_TEST_FUNCTION_NOTEQUAL = GL_NOTEQUAL, - COGL_DEPTH_TEST_FUNCTION_GEQUAL = GL_GEQUAL, - COGL_DEPTH_TEST_FUNCTION_ALWAYS = GL_ALWAYS -} CoglDepthTestFunction; -/* XXX: to avoid having to split this into a separate include that can - * in #included internally without needing the - * COGL_ENABLE_EXPERIMENTAL_API define this isn't guarded. It's still - * considered experimental but it's guarded instead by the fact that - * there's no corresponding API. */ - #ifdef COGL_ENABLE_EXPERIMENTAL_API /** diff --git a/clutter/cogl/cogl/cogl-material-private.h b/clutter/cogl/cogl/cogl-material-private.h deleted file mode 100644 index 88dbfc0e8..000000000 --- a/clutter/cogl/cogl/cogl-material-private.h +++ /dev/null @@ -1,957 +0,0 @@ -/* - * Cogl - * - * An object oriented GL/GLES Abstraction/Utility Layer - * - * Copyright (C) 2008,2009,2010 Intel Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - * - * - * - * Authors: - * Robert Bragg - */ - -#ifndef __COGL_MATERIAL_PRIVATE_H -#define __COGL_MATERIAL_PRIVATE_H - -#include "cogl.h" - -#include "cogl-material.h" -#include "cogl-matrix.h" -#include "cogl-handle.h" -#include "cogl-profile.h" - -#include - -#if defined (HAVE_COGL_GL) - -/* NB: material->backend is currently a 3bit unsigned int bitfield */ -#define COGL_MATERIAL_BACKEND_GLSL 0 -#define COGL_MATERIAL_BACKEND_GLSL_MASK (1L<<0) -#define COGL_MATERIAL_BACKEND_ARBFP 1 -#define COGL_MATERIAL_BACKEND_ARBFP_MASK (1L<<1) -#define COGL_MATERIAL_BACKEND_FIXED 2 -#define COGL_MATERIAL_BACKEND_FIXED_MASK (1L<<2) - -#define COGL_MATERIAL_N_BACKENDS 3 - -#elif defined (HAVE_COGL_GLES2) - -#define COGL_MATERIAL_BACKEND_GLSL 0 -#define COGL_MATERIAL_BACKEND_GLSL_MASK (1L<<0) -#define COGL_MATERIAL_BACKEND_FIXED 1 -#define COGL_MATERIAL_BACKEND_FIXED_MASK (1L<<1) - -#define COGL_MATERIAL_N_BACKENDS 2 - -#else /* HAVE_COGL_GLES */ - -#define COGL_MATERIAL_BACKEND_FIXED 0 -#define COGL_MATERIAL_BACKEND_FIXED_MASK (1L<<0) - -#define COGL_MATERIAL_N_BACKENDS 1 - -#endif - -#define COGL_MATERIAL_BACKEND_DEFAULT 0 -#define COGL_MATERIAL_BACKEND_UNDEFINED 3 - -typedef enum -{ - COGL_MATERIAL_LAYER_STATE_UNIT = 1L<<0, - COGL_MATERIAL_LAYER_STATE_TEXTURE = 1L<<1, - COGL_MATERIAL_LAYER_STATE_FILTERS = 1L<<2, - COGL_MATERIAL_LAYER_STATE_WRAP_MODES = 1L<<3, - - COGL_MATERIAL_LAYER_STATE_COMBINE = 1L<<4, - COGL_MATERIAL_LAYER_STATE_COMBINE_CONSTANT = 1L<<5, - COGL_MATERIAL_LAYER_STATE_USER_MATRIX = 1L<<6, - - COGL_MATERIAL_LAYER_STATE_POINT_SPRITE_COORDS = 1L<<7, - - /* COGL_MATERIAL_LAYER_STATE_TEXTURE_INTERN = 1L<<8, */ - - COGL_MATERIAL_LAYER_STATE_ALL_SPARSE = - COGL_MATERIAL_LAYER_STATE_UNIT | - COGL_MATERIAL_LAYER_STATE_TEXTURE | - COGL_MATERIAL_LAYER_STATE_FILTERS | - COGL_MATERIAL_LAYER_STATE_WRAP_MODES | - COGL_MATERIAL_LAYER_STATE_COMBINE | - COGL_MATERIAL_LAYER_STATE_COMBINE_CONSTANT | - COGL_MATERIAL_LAYER_STATE_USER_MATRIX | - COGL_MATERIAL_LAYER_STATE_POINT_SPRITE_COORDS, - - COGL_MATERIAL_LAYER_STATE_NEEDS_BIG_STATE = - COGL_MATERIAL_LAYER_STATE_COMBINE | - COGL_MATERIAL_LAYER_STATE_COMBINE_CONSTANT | - COGL_MATERIAL_LAYER_STATE_USER_MATRIX | - COGL_MATERIAL_LAYER_STATE_POINT_SPRITE_COORDS, - -} CoglMaterialLayerState; - -typedef struct -{ - /* The texture combine state determines how the color of individual - * texture fragments are calculated. */ - GLint texture_combine_rgb_func; - GLint texture_combine_rgb_src[3]; - GLint texture_combine_rgb_op[3]; - - GLint texture_combine_alpha_func; - GLint texture_combine_alpha_src[3]; - GLint texture_combine_alpha_op[3]; - - float texture_combine_constant[4]; - - /* The texture matrix dscribes how to transform texture coordinates */ - CoglMatrix matrix; - - gboolean point_sprite_coords; - -} CoglMaterialLayerBigState; - -/* Materials and layers represent their state in a tree structure where - * some of the state relating to a given material or layer may actually - * be owned by one if is ancestors in the tree. We have a common data - * type to track the tree heirachy so we can share code... */ -typedef struct _CoglMaterialNode CoglMaterialNode; -struct _CoglMaterialNode -{ - /* the parent in terms of class hierarchy, so anything inheriting - * from CoglMaterialNode also inherits from CoglObject. */ - CoglObject _parent; - - /* The parent material/layer */ - CoglMaterialNode *parent; - - /* TRUE if the node took a strong reference on its parent. Weak - * materials for instance don't take a reference on their parent. */ - gboolean has_parent_reference; - - /* As an optimization for creating leaf node materials/layers (the - * most common) we don't require any list node allocations to link - * to a single descendant. */ - CoglMaterialNode *first_child; - - /* Determines if node->first_child and node->children are - * initialized pointers. */ - gboolean has_children; - - /* Materials and layers are sparse structures defined as a diff - * against their parent and may have multiple children which depend - * on them to define the values of properties which they don't - * change. */ - GList *children; -}; - -#define COGL_MATERIAL_NODE(X) ((CoglMaterialNode *)(X)) - -typedef void (*CoglMaterialNodeUnparentVFunc) (CoglMaterialNode *node); - -typedef gboolean (*CoglMaterialNodeChildCallback) (CoglMaterialNode *child, - void *user_data); - -void -_cogl_material_node_foreach_child (CoglMaterialNode *node, - CoglMaterialNodeChildCallback callback, - void *user_data); - -struct _CoglMaterialLayer -{ - /* XXX: Please think twice about adding members that *have* be - * initialized during a _cogl_material_layer_copy. We are aiming - * to have copies be as cheap as possible and copies may be - * done by the primitives APIs which means they may happen - * in performance critical code paths. - * - * XXX: If you are extending the state we track please consider if - * the state is expected to vary frequently across many materials or - * if the state can be shared among many derived materials instead. - * This will determine if the state should be added directly to this - * structure which will increase the memory overhead for *all* - * layers or if instead it can go under ->big_state. - */ - - /* Layers represent their state in a tree structure where some of - * the state relating to a given material or layer may actually be - * owned by one if is ancestors in the tree. We have a common data - * type to track the tree heirachy so we can share code... */ - CoglMaterialNode _parent; - - /* Some layers have a material owner, which is to say that the layer - * is referenced in that materials->layer_differences list. A layer - * doesn't always have an owner and may simply be an ancestor for - * other layers that keeps track of some shared state. */ - CoglMaterial *owner; - - /* The lowest index is blended first then others on top */ - int index; - - /* Different material backends (GLSL/ARBfp/Fixed Function) may - * want to associate private data with a layer... - * - * NB: we have per backend pointers because a layer may be - * associated with multiple materials with different backends. - */ - void *backend_priv[COGL_MATERIAL_N_BACKENDS]; - - /* A mask of which state groups are different in this layer - * in comparison to its parent. */ - unsigned long differences; - - /* Common differences - * - * As a basic way to reduce memory usage we divide the layer - * state into two groups; the minimal state modified in 90% of - * all layers and the rest, so that the second group can - * be allocated dynamically when required. - */ - - /* Each layer is directly associated with a single texture unit */ - int unit_index; - - /* The texture for this layer, or COGL_INVALID_HANDLE for an empty - * layer */ - CoglHandle texture; - gboolean texture_overridden; - /* If ->texture_overridden == TRUE then the texture is instead - * defined by these... */ - GLuint slice_gl_texture; - GLenum slice_gl_target; - - CoglMaterialFilter mag_filter; - CoglMaterialFilter min_filter; - - CoglMaterialWrapMode wrap_mode_s; - CoglMaterialWrapMode wrap_mode_t; - CoglMaterialWrapMode wrap_mode_p; - - /* Infrequent differences aren't currently tracked in - * a separate, dynamically allocated structure as they are - * for materials... */ - CoglMaterialLayerBigState *big_state; - - /* bitfields */ - - /* Determines if layer->big_state is valid */ - unsigned int has_big_state:1; - -}; - -/* Used in material->differences masks and for notifying material - * state changes... */ -typedef enum _CoglMaterialState -{ - COGL_MATERIAL_STATE_COLOR = 1L<<0, - COGL_MATERIAL_STATE_BLEND_ENABLE = 1L<<1, - COGL_MATERIAL_STATE_LAYERS = 1L<<2, - - COGL_MATERIAL_STATE_LIGHTING = 1L<<3, - COGL_MATERIAL_STATE_ALPHA_FUNC = 1L<<4, - COGL_MATERIAL_STATE_BLEND = 1L<<5, - COGL_MATERIAL_STATE_USER_SHADER = 1L<<6, - COGL_MATERIAL_STATE_DEPTH = 1L<<7, - COGL_MATERIAL_STATE_FOG = 1L<<8, - COGL_MATERIAL_STATE_POINT_SIZE = 1L<<9, - - COGL_MATERIAL_STATE_REAL_BLEND_ENABLE = 1L<<10, - - COGL_MATERIAL_STATE_ALL_SPARSE = - COGL_MATERIAL_STATE_COLOR | - COGL_MATERIAL_STATE_BLEND_ENABLE | - COGL_MATERIAL_STATE_LAYERS | - COGL_MATERIAL_STATE_LIGHTING | - COGL_MATERIAL_STATE_ALPHA_FUNC | - COGL_MATERIAL_STATE_BLEND | - COGL_MATERIAL_STATE_USER_SHADER | - COGL_MATERIAL_STATE_DEPTH | - COGL_MATERIAL_STATE_FOG | - COGL_MATERIAL_STATE_POINT_SIZE, - - COGL_MATERIAL_STATE_AFFECTS_BLENDING = - COGL_MATERIAL_STATE_COLOR | - COGL_MATERIAL_STATE_BLEND_ENABLE | - COGL_MATERIAL_STATE_LAYERS | - COGL_MATERIAL_STATE_LIGHTING | - COGL_MATERIAL_STATE_BLEND | - COGL_MATERIAL_STATE_USER_SHADER, - - COGL_MATERIAL_STATE_NEEDS_BIG_STATE = - COGL_MATERIAL_STATE_LIGHTING | - COGL_MATERIAL_STATE_ALPHA_FUNC | - COGL_MATERIAL_STATE_BLEND | - COGL_MATERIAL_STATE_USER_SHADER | - COGL_MATERIAL_STATE_DEPTH | - COGL_MATERIAL_STATE_FOG | - COGL_MATERIAL_STATE_POINT_SIZE - -} CoglMaterialState; - -typedef enum -{ - COGL_MATERIAL_LIGHTING_STATE_PROPERTY_AMBIENT = 1, - COGL_MATERIAL_LIGHTING_STATE_PROPERTY_DIFFUSE, - COGL_MATERIAL_LIGHTING_STATE_PROPERTY_SPECULAR, - COGL_MATERIAL_LIGHTING_STATE_PROPERTY_EMISSION, - COGL_MATERIAL_LIGHTING_STATE_PROPERTY_SHININESS -} CoglMaterialLightingStateProperty; - -typedef struct -{ - /* Standard OpenGL lighting model attributes */ - float ambient[4]; - float diffuse[4]; - float specular[4]; - float emission[4]; - float shininess; -} CoglMaterialLightingState; - -typedef struct -{ - /* Determines what fragments are discarded based on their alpha */ - CoglMaterialAlphaFunc alpha_func; - GLfloat alpha_func_reference; -} CoglMaterialAlphaFuncState; - -typedef enum _CoglMaterialBlendEnable -{ - /* XXX: we want to detect users mistakenly using TRUE or FALSE - * so start the enum at 2. */ - COGL_MATERIAL_BLEND_ENABLE_ENABLED = 2, - COGL_MATERIAL_BLEND_ENABLE_DISABLED, - COGL_MATERIAL_BLEND_ENABLE_AUTOMATIC -} CoglMaterialBlendEnable; - -typedef struct -{ - /* Determines how this material is blended with other primitives */ -#ifndef HAVE_COGL_GLES - GLenum blend_equation_rgb; - GLenum blend_equation_alpha; - GLint blend_src_factor_alpha; - GLint blend_dst_factor_alpha; - CoglColor blend_constant; -#endif - GLint blend_src_factor_rgb; - GLint blend_dst_factor_rgb; -} CoglMaterialBlendState; - -typedef struct -{ - gboolean depth_test_enabled; - CoglDepthTestFunction depth_test_function; - gboolean depth_writing_enabled; - float depth_range_near; - float depth_range_far; -} CoglMaterialDepthState; - -typedef struct -{ - gboolean enabled; - CoglColor color; - CoglFogMode mode; - float density; - float z_near; - float z_far; -} CoglMaterialFogState; - -typedef struct -{ - CoglMaterialLightingState lighting_state; - CoglMaterialAlphaFuncState alpha_state; - CoglMaterialBlendState blend_state; - CoglHandle user_program; - CoglMaterialDepthState depth_state; - CoglMaterialFogState fog_state; - float point_size; -} CoglMaterialBigState; - -typedef enum -{ - COGL_MATERIAL_FLAG_DIRTY_LAYERS_CACHE = 1L<<0, - COGL_MATERIAL_FLAG_DIRTY_GET_LAYERS_LIST = 1L<<1 -} CoglMaterialFlag; - -typedef struct -{ - CoglMaterial *owner; - CoglMaterialLayer *layer; -} CoglMaterialLayerCacheEntry; - -/* - * CoglMaterialDestroyCallback - * @material: The #CoglMaterial that has been destroyed - * @user_data: The private data associated with the callback - * - * Notifies when a weak material has been destroyed because one - * of its ancestors has been freed or modified. - */ -typedef void (*CoglMaterialDestroyCallback)(CoglMaterial *material, - void *user_data); - -struct _CoglMaterial -{ - /* XXX: Please think twice about adding members that *have* be - * initialized during a cogl_material_copy. We are aiming to have - * copies be as cheap as possible and copies may be done by the - * primitives APIs which means they may happen in performance - * critical code paths. - * - * XXX: If you are extending the state we track please consider if - * the state is expected to vary frequently across many materials or - * if the state can be shared among many derived materials instead. - * This will determine if the state should be added directly to this - * structure which will increase the memory overhead for *all* - * materials or if instead it can go under ->big_state. - */ - - /* Layers represent their state in a tree structure where some of - * the state relating to a given material or layer may actually be - * owned by one if is ancestors in the tree. We have a common data - * type to track the tree heirachy so we can share code... */ - CoglMaterialNode _parent; - - /* We need to track if a material is referenced in the journal - * because we can't allow modification to these materials without - * flushing the journal first */ - unsigned long journal_ref_count; - - /* When weak materials are destroyed the user is notified via this - * callback */ - CoglMaterialDestroyCallback destroy_callback; - - /* When notifying that a weak material has been destroyed this - * private data is passed to the above callback */ - void *destroy_data; - - /* A mask of which sparse state groups are different in this - * material in comparison to its parent. */ - unsigned long differences; - - /* The fragment processing backends can associate private data with a - * material. */ - void *backend_privs[COGL_MATERIAL_N_BACKENDS]; - - /* Whenever a material is modified we increment the age. There's no - * guarantee that it won't wrap but it can nevertheless be a - * convenient mechanism to determine when a material has been - * changed to you can invalidate some some associated cache that - * depends on the old state. */ - unsigned long age; - - /* This is the primary color of the material. - * - * This is a sparse property, ref COGL_MATERIAL_STATE_COLOR */ - CoglColor color; - - /* A material may be made up with multiple layers used to combine - * textures together. - * - * This is sparse state, ref COGL_MATERIAL_STATE_LAYERS */ - GList *layer_differences; - unsigned int n_layers; - - /* As a basic way to reduce memory usage we divide the material - * state into two groups; the minimal state modified in 90% of - * all materials and the rest, so that the second group can - * be allocated dynamically when required... */ - CoglMaterialBigState *big_state; - - /* For debugging purposes it's possible to associate a static const - * string with a material which can be an aid when trying to trace - * where the material originates from */ - const char *static_breadcrumb; - - /* Cached state... */ - - /* A cached, complete list of the layers this material depends - * on sorted by layer->unit_index. */ - CoglMaterialLayer **layers_cache; - /* To avoid a separate ->layers_cache allocation for common - * materials with only a few layers... */ - CoglMaterialLayer *short_layers_cache[3]; - - /* The deprecated cogl_material_get_layers() API returns a - * const GList of layers, which we track here... */ - GList *deprecated_get_layers_list; - - /* XXX: consider adding an authorities cache to speed up sparse - * property value lookups: - * CoglMaterial *authorities_cache[COGL_MATERIAL_N_SPARSE_PROPERTIES]; - * and corresponding authorities_cache_dirty:1 bitfield - */ - - /* bitfields */ - - /* A material can have private data associated with it for multiple - * fragment processing backends. Although only one backend is - * associated with a material the backends may want to cache private - * state with the ancestors of other materials and those ancestors - * could currently be associated with different backends. - * - * Each set bit indicates if the correspondong ->backend_privs[] - * entry is valid. - */ - unsigned int backend_priv_set_mask:COGL_MATERIAL_N_BACKENDS; - - /* Weak materials don't count as dependants on their parents which - * means that the parent material can be modified without - * considering how the modifications may affect the weak material. - */ - unsigned int is_weak:1; - - /* Determines if material->big_state is valid */ - unsigned int has_big_state:1; - - /* By default blending is enabled automatically depending on the - * unlit color, the lighting colors or the texture format. The user - * can override this to explicitly enable or disable blending. - * - * This is a sparse property */ - unsigned int blend_enable:3; - - /* There are many factors that can determine if we need to enable - * blending, this holds our final decision */ - unsigned int real_blend_enable:1; - - unsigned int layers_cache_dirty:1; - unsigned int deprecated_get_layers_list_dirty:1; - - /* For debugging purposes it's possible to associate a static const - * string with a material which can be an aid when trying to trace - * where the material originates from */ - unsigned int has_static_breadcrumb:1; - - /* There are multiple fragment processing backends for CoglMaterial, - * glsl, arbfp and fixed. This identifies the backend being used for - * the material and any private state the backend has associated - * with the material. */ - unsigned int backend:3; -}; - -typedef struct _CoglMaterialBackend -{ - int (*get_max_texture_units) (void); - - gboolean (*start) (CoglMaterial *material, - int n_layers, - unsigned long materials_difference); - gboolean (*add_layer) (CoglMaterial *material, - CoglMaterialLayer *layer, - unsigned long layers_difference); - gboolean (*passthrough) (CoglMaterial *material); - gboolean (*end) (CoglMaterial *material, - unsigned long materials_difference); - - void (*material_pre_change_notify) (CoglMaterial *material, - CoglMaterialState change, - const CoglColor *new_color); - void (*material_set_parent_notify) (CoglMaterial *material); - void (*layer_pre_change_notify) (CoglMaterial *owner, - CoglMaterialLayer *layer, - CoglMaterialLayerState change); - - void (*free_priv) (CoglMaterial *material); - void (*free_layer_priv) (CoglMaterialLayer *layer); -} CoglMaterialBackend; - -typedef enum -{ - COGL_MATERIAL_PROGRAM_TYPE_GLSL = 1, - COGL_MATERIAL_PROGRAM_TYPE_ARBFP, - COGL_MATERIAL_PROGRAM_TYPE_FIXED -} CoglMaterialProgramType; - -extern const CoglMaterialBackend * -_cogl_material_backends[COGL_MATERIAL_N_BACKENDS]; - -void -_cogl_material_init_default_material (void); - -void -_cogl_material_init_default_layers (void); - -/* - * SECTION:cogl-material-internals - * @short_description: Functions for creating custom primitives that make use - * of Cogl materials for filling. - * - * Normally you shouldn't need to use this API directly, but if you need to - * developing a custom/specialised primitive - probably using raw OpenGL - then - * this API aims to expose enough of the material internals to support being - * able to fill your geometry according to a given Cogl material. - */ - -gboolean -_cogl_material_get_real_blend_enabled (CoglMaterial *material); - -gboolean -_cogl_material_layer_has_user_matrix (CoglMaterialLayer *layer); - -/* - * Calls the pre_paint method on the layer texture if there is - * one. This will determine whether mipmaps are needed based on the - * filter settings. - */ -void -_cogl_material_layer_pre_paint (CoglMaterialLayer *layerr); - -/* - * Calls the pre_paint method on the layer texture if there is - * one. This will determine whether mipmaps are needed based on the - * filter settings. - */ -void -_cogl_material_pre_paint_for_layer (CoglMaterial *material, - int layer_id); - -/* - * CoglMaterialFlushFlag: - * @COGL_MATERIAL_FLUSH_FALLBACK_MASK: The fallback_layers member is set to - * a guint32 mask of the layers that can't be supported with the user - * supplied texture and need to be replaced with fallback textures. (1 = - * fallback, and the least significant bit = layer 0) - * @COGL_MATERIAL_FLUSH_DISABLE_MASK: The disable_layers member is set to - * a guint32 mask of the layers that you want to completly disable - * texturing for (1 = fallback, and the least significant bit = layer 0) - * @COGL_MATERIAL_FLUSH_LAYER0_OVERRIDE: The layer0_override_texture member is - * set to a GLuint OpenGL texture name to override the texture used for - * layer 0 of the material. This is intended for dealing with sliced - * textures where you will need to point to each of the texture slices in - * turn when drawing your geometry. Passing a value of 0 is the same as - * not passing the option at all. - * @COGL_MATERIAL_FLUSH_SKIP_GL_COLOR: When flushing the GL state for the - * material don't call glColor. - * @COGL_MATERIAL_FLUSH_WRAP_MODE_OVERRIDES: Specifies that a bitmask - * of overrides for the wrap modes for some or all layers is - * given. - */ -typedef enum _CoglMaterialFlushFlag -{ - COGL_MATERIAL_FLUSH_FALLBACK_MASK = 1L<<0, - COGL_MATERIAL_FLUSH_DISABLE_MASK = 1L<<1, - COGL_MATERIAL_FLUSH_LAYER0_OVERRIDE = 1L<<2, - COGL_MATERIAL_FLUSH_SKIP_GL_COLOR = 1L<<3, - COGL_MATERIAL_FLUSH_WRAP_MODE_OVERRIDES = 1L<<4 -} CoglMaterialFlushFlag; - -/* This isn't defined in the GLES headers */ -#ifndef GL_CLAMP_TO_BORDER -#define GL_CLAMP_TO_BORDER 0x812d -#endif - -/* GL_ALWAYS is just used here as a value that is known not to clash - * with any valid GL wrap modes. - * - * XXX: keep the values in sync with the CoglMaterialWrapMode enum - * so no conversion is actually needed. - */ -typedef enum _CoglMaterialWrapModeInternal -{ - COGL_MATERIAL_WRAP_MODE_INTERNAL_REPEAT = GL_REPEAT, - COGL_MATERIAL_WRAP_MODE_INTERNAL_CLAMP_TO_EDGE = GL_CLAMP_TO_EDGE, - COGL_MATERIAL_WRAP_MODE_INTERNAL_CLAMP_TO_BORDER = GL_CLAMP_TO_BORDER, - COGL_MATERIAL_WRAP_MODE_INTERNAL_AUTOMATIC = GL_ALWAYS -} CoglMaterialWrapModeInternal; - -typedef enum _CoglMaterialWrapModeOverride -{ - COGL_MATERIAL_WRAP_MODE_OVERRIDE_NONE = 0, - COGL_MATERIAL_WRAP_MODE_OVERRIDE_REPEAT = - COGL_MATERIAL_WRAP_MODE_INTERNAL_REPEAT, - COGL_MATERIAL_WRAP_MODE_OVERRIDE_CLAMP_TO_EDGE = - COGL_MATERIAL_WRAP_MODE_INTERNAL_CLAMP_TO_EDGE, - COGL_MATERIAL_WRAP_MODE_OVERRIDE_CLAMP_TO_BORDER = - COGL_MATERIAL_WRAP_MODE_INTERNAL_CLAMP_TO_BORDER, -} CoglMaterialWrapModeOverride; - -/* There can't be more than 32 layers because we need to fit a bitmask - of the layers into a guint32 */ -#define COGL_MATERIAL_MAX_LAYERS 32 - -typedef struct _CoglMaterialWrapModeOverrides -{ - struct - { - CoglMaterialWrapModeOverride s; - CoglMaterialWrapModeOverride t; - CoglMaterialWrapModeOverride p; - } values[COGL_MATERIAL_MAX_LAYERS]; -} CoglMaterialWrapModeOverrides; - -/* - * CoglMaterialFlushOptions: - * - */ -typedef struct _CoglMaterialFlushOptions -{ - CoglMaterialFlushFlag flags; - - guint32 fallback_layers; - guint32 disable_layers; - GLuint layer0_override_texture; - CoglMaterialWrapModeOverrides wrap_mode_overrides; -} CoglMaterialFlushOptions; - - -int -_cogl_get_max_texture_image_units (void); - - -void -_cogl_use_program (GLuint gl_program, CoglMaterialProgramType type); - -unsigned int -_cogl_get_n_args_for_combine_func (GLint func); - -/* - * _cogl_material_weak_copy: - * @material: A #CoglMaterial object - * @callback: A callback to notify when your weak material is destroyed - * @user_data: Private data to pass to your given callback. - * - * Returns a weak copy of the given source @material. Unlike a normal - * copy no internal reference is taken on the source @material and you - * can expect that later modifications of the source material (or in - * fact any other material) can result in the weak material being - * destroyed. - * - * To understand this better its good to know a bit about the internal - * design of #CoglMaterial... - * - * Internally #CoglMaterials are represented as a graph of - * property diff's, where each node is a diff of properties that gets - * applied on top of its parent. Copying a material creates an empty - * diff and a child->parent relationship between the empty diff and - * the source @material, parent. - * - * Because of this internal graph design a single #CoglMaterial may - * indirectly depend on a chain of ancestors to fully define all of - * its properties. Because a node depends on its ancestors it normally - * owns a reference to its parent to stop it from being freed. Also if - * you try to modify a material with children we internally use a - * copy-on-write mechanism to ensure that you don't indirectly change - * the properties those children. - * - * Weak materials avoid the use of copy-on-write to preserve the - * integrity of weak dependants and instead weak dependants are - * simply destroyed allowing the parent to be modified directly. Also - * because weak materials don't own a reference to their parent they - * won't stop the source @material from being freed when the user - * releases their reference on it. - * - * Because weak materials don't own a reference on their parent they - * are the recommended mechanism for creating derived materials that you - * want to cache as a private property of the original material - * because they won't result in a circular dependency. - * - * An example use case: - * - * Consider for example you are implementing a custom primitive that is - * not compatible with certain source materials. To handle this you - * implement a validation stage that given an arbitrary material as - * input will create a derived material that is suitable for drawing - * your primitive. - * - * Because you don't want to have to repeat this validation every time - * the same incompatible material is given as input you want to cache - * the result as a private property of the original material. If the - * derived material were created using cogl_material_copy that would - * create a circular dependency so the original material can never be - * freed. - * - * If you instead create a weak copy you won't stop the original material - * from being freed if it's no longer needed, and you will instead simply - * be notified that your weak material has been destroyed. - * - * This is the recommended coding pattern for validating an input - * material and caching a derived result: - * |[ - * static CoglUserDataKey _cogl_my_cache_key; - * - * typedef struct { - * CoglMaterial *validated_source; - * } MyValidatedMaterialCache; - * - * static void - * destroy_cache_cb (CoglObject *object, void *user_data) - * { - * g_slice_free (MyValidatedMaterialCache, user_data); - * } - * - * static void - * invalidate_cache_cb (CoglMaterial *destroyed, void *user_data) - * { - * MyValidatedMaterialCache *cache = user_data; - * cogl_object_unref (cache->validated_source); - * cache->validated_source = NULL; - * } - * - * static CoglMaterial * - * get_validated_material (CoglMaterial *source) - * { - * MyValidatedMaterialCache *cache = - * cogl_object_get_user_data (COGL_OBJECT (source), - * &_cogl_my_cache_key); - * if (G_UNLIKELY (cache == NULL)) - * { - * cache = g_slice_new (MyValidatedMaterialCache); - * cogl_object_set_user_data (COGL_OBJECT (source), - * &_cogl_my_cache_key, - * cache, destroy_cache_cb); - * cache->validated_source = source; - * } - * - * if (G_UNLIKELY (cache->validated_source == NULL)) - * { - * cache->validated_source = source; - * - * / * Start validating source... * / - * - * / * If you find you need to change something... * / - * if (cache->validated_source == source) - * cache->validated_source = - * cogl_material_weak_copy (source, - * invalidate_cache_cb, - * cache); - * - * / * Modify cache->validated_source * / - * } - * - * return cache->validated_source; - * } - * ]| - */ -CoglMaterial * -_cogl_material_weak_copy (CoglMaterial *material, - CoglMaterialDestroyCallback callback, - void *user_data); - -void -_cogl_material_set_backend (CoglMaterial *material, int backend); - -CoglMaterial * -_cogl_material_get_parent (CoglMaterial *material); - -void -_cogl_material_get_colorubv (CoglMaterial *material, - guint8 *color); - -unsigned long -_cogl_material_compare_differences (CoglMaterial *material0, - CoglMaterial *material1); - -gboolean -_cogl_material_equal (CoglMaterial *material0, - CoglMaterial *material1, - gboolean skip_gl_color); - -CoglMaterial * -_cogl_material_journal_ref (CoglMaterial *material); - -void -_cogl_material_journal_unref (CoglMaterial *material); - -void -_cogl_material_layer_get_wrap_modes (CoglMaterialLayer *layer, - CoglMaterialWrapModeInternal *wrap_mode_s, - CoglMaterialWrapModeInternal *wrap_mode_t, - CoglMaterialWrapModeInternal *wrap_mode_r); - -void -_cogl_material_layer_get_filters (CoglMaterialLayer *layer, - CoglMaterialFilter *min_filter, - CoglMaterialFilter *mag_filter); - -void -_cogl_material_get_layer_filters (CoglMaterial *material, - int layer_index, - CoglMaterialFilter *min_filter, - CoglMaterialFilter *mag_filter); - -CoglMaterialFilter -_cogl_material_get_layer_min_filter (CoglMaterial *material, - int layer_index); - -CoglMaterialFilter -_cogl_material_get_layer_mag_filter (CoglMaterial *material, - int layer_index); - -void -_cogl_material_texture_storage_change_notify (CoglHandle texture); - -void -_cogl_material_apply_legacy_state (CoglMaterial *material); - -void -_cogl_material_apply_overrides (CoglMaterial *material, - CoglMaterialFlushOptions *options); - -CoglMaterialBlendEnable -_cogl_material_get_blend_enabled (CoglMaterial *material); - -void -_cogl_material_set_blend_enabled (CoglMaterial *material, - CoglMaterialBlendEnable enable); - -void -_cogl_material_set_static_breadcrumb (CoglMaterial *material, - const char *breadcrumb); - -unsigned long -_cogl_material_get_age (CoglMaterial *material); - -CoglMaterial * -_cogl_material_get_authority (CoglMaterial *material, - unsigned long difference); - -unsigned long -_cogl_material_layer_compare_differences (CoglMaterialLayer *layer0, - CoglMaterialLayer *layer1); - -CoglMaterialLayer * -_cogl_material_layer_get_authority (CoglMaterialLayer *layer, - unsigned long difference); - -CoglHandle -_cogl_material_layer_get_texture (CoglMaterialLayer *layer); - -CoglHandle -_cogl_material_get_layer_texture (CoglMaterial *material, - int layer_index); - -typedef gboolean (*CoglMaterialInternalLayerCallback) (CoglMaterialLayer *layer, - void *user_data); - -void -_cogl_material_foreach_layer_internal (CoglMaterial *material, - CoglMaterialInternalLayerCallback callback, - void *user_data); - -int -_cogl_material_layer_get_unit_index (CoglMaterialLayer *layer); - -void -_cogl_material_get_layer_combine_constant (CoglMaterial *material, - int layer_index, - float *constant); - -void -_cogl_material_prune_to_n_layers (CoglMaterial *material, int n); - -#endif /* __COGL_MATERIAL_PRIVATE_H */ - diff --git a/clutter/cogl/cogl/cogl-path.c b/clutter/cogl/cogl/cogl-path.c index 2ac194975..34f6b7946 100644 --- a/clutter/cogl/cogl/cogl-path.c +++ b/clutter/cogl/cogl/cogl-path.c @@ -30,8 +30,8 @@ #include "cogl-internal.h" #include "cogl-context.h" #include "cogl-journal-private.h" -#include "cogl-material-private.h" -#include "cogl-material-opengl-private.h" +#include "cogl-pipeline-private.h" +#include "cogl-pipeline-opengl-private.h" #include "cogl-framebuffer-private.h" #include "cogl-path-private.h" #include "cogl-texture-private.h" @@ -181,8 +181,8 @@ _cogl_path_stroke_nodes (void) unsigned int path_start = 0; unsigned long enable_flags = COGL_ENABLE_VERTEX_ARRAY; CoglPathData *data; - CoglMaterial *copy = NULL; - CoglMaterial *source; + CoglPipeline *copy = NULL; + CoglPipeline *source; _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -191,7 +191,7 @@ _cogl_path_stroke_nodes (void) _cogl_journal_flush (); /* NB: _cogl_framebuffer_flush_state may disrupt various state (such - * as the material state) when flushing the clip stack, so should + * as the pipeline state) when flushing the clip stack, so should * always be done first when preparing to draw. */ _cogl_framebuffer_flush_state (_cogl_get_framebuffer (), 0); @@ -199,26 +199,26 @@ _cogl_path_stroke_nodes (void) if (G_UNLIKELY (ctx->legacy_state_set)) { - CoglMaterial *users_source = cogl_get_source (); - copy = cogl_material_copy (users_source); - _cogl_material_apply_legacy_state (copy); + CoglPipeline *users_source = cogl_get_source (); + copy = cogl_pipeline_copy (users_source); + _cogl_pipeline_apply_legacy_state (copy); source = copy; } else source = cogl_get_source (); - if (cogl_material_get_n_layers (source) != 0) + if (cogl_pipeline_get_n_layers (source) != 0) { - /* If we haven't already created a derivative material... */ + /* If we haven't already created a derivative pipeline... */ if (!copy) - copy = cogl_material_copy (source); - _cogl_material_prune_to_n_layers (copy, 0); + copy = cogl_pipeline_copy (source); + _cogl_pipeline_prune_to_n_layers (copy, 0); source = copy; } cogl_push_source (source); - _cogl_material_flush_gl_state (source, FALSE); + _cogl_pipeline_flush_gl_state (source, FALSE); /* Disable all client texture coordinate arrays */ _cogl_bitmask_clear_all (&ctx->temp_bitmask); @@ -304,14 +304,14 @@ _cogl_path_fill_nodes (CoglPath *path) _COGL_GET_CONTEXT (ctx, NO_RETVAL); - /* If any of the layers of the current material contain sliced + /* If any of the layers of the current pipeline contain sliced textures or textures with waste then it won't work to draw the path directly. Instead we can use draw the texture as a quad clipped to the stencil buffer. */ - for (l = cogl_material_get_layers (cogl_get_source ()); l; l = l->next) + for (l = _cogl_pipeline_get_layers (cogl_get_source ()); l; l = l->next) { CoglHandle layer = l->data; - CoglHandle texture = cogl_material_layer_get_texture (layer); + CoglHandle texture = _cogl_pipeline_layer_get_texture (layer); if (texture != COGL_INVALID_HANDLE && (cogl_texture_is_sliced (texture) || @@ -365,14 +365,14 @@ _cogl_add_path_to_stencil_buffer (CoglPath *path, _cogl_journal_flush (); /* NB: _cogl_framebuffer_flush_state may disrupt various state (such - * as the material state) when flushing the clip stack, so should + * as the pipeline state) when flushing the clip stack, so should * always be done first when preparing to draw. */ _cogl_framebuffer_flush_state (framebuffer, 0); - /* Just setup a simple material that doesn't use texturing... */ - cogl_push_source (ctx->stencil_material); + /* Just setup a simple pipeline that doesn't use texturing... */ + cogl_push_source (ctx->stencil_pipeline); - _cogl_material_flush_gl_state (ctx->stencil_material, FALSE); + _cogl_pipeline_flush_gl_state (ctx->stencil_pipeline, FALSE); _cogl_enable (enable_flags); @@ -461,7 +461,7 @@ _cogl_add_path_to_stencil_buffer (CoglPath *path, GE (glStencilFunc (GL_EQUAL, 0x1, 0x1)); GE (glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP)); - /* restore the original material */ + /* restore the original pipeline */ cogl_pop_source (); } diff --git a/clutter/cogl/cogl/cogl-material-arbfp-private.h b/clutter/cogl/cogl/cogl-pipeline-arbfp-private.h similarity index 79% rename from clutter/cogl/cogl/cogl-material-arbfp-private.h rename to clutter/cogl/cogl/cogl-pipeline-arbfp-private.h index a0a882d68..cbd2b39d0 100644 --- a/clutter/cogl/cogl/cogl-material-arbfp-private.h +++ b/clutter/cogl/cogl/cogl-pipeline-arbfp-private.h @@ -25,12 +25,12 @@ * Robert Bragg */ -#ifndef __COGL_MATERIAL_ARBFP_PRIVATE_H -#define __COGL_MATERIAL_ARBFP_PRIVATE_H +#ifndef __COGL_PIPELINE_ARBFP_PRIVATE_H +#define __COGL_PIPELINE_ARBFP_PRIVATE_H -#include "cogl-material-private.h" +#include "cogl-pipeline-private.h" -extern const CoglMaterialBackend _cogl_material_arbfp_backend; +extern const CoglPipelineBackend _cogl_pipeline_arbfp_backend; -#endif /* __COGL_MATERIAL_ARBFP_PRIVATE_H */ +#endif /* __COGL_PIPELINE_ARBFP_PRIVATE_H */ diff --git a/clutter/cogl/cogl/cogl-material-arbfp.c b/clutter/cogl/cogl/cogl-pipeline-arbfp.c similarity index 77% rename from clutter/cogl/cogl/cogl-material-arbfp.c rename to clutter/cogl/cogl/cogl-pipeline-arbfp.c index a3f90c111..dea031c98 100644 --- a/clutter/cogl/cogl/cogl-material-arbfp.c +++ b/clutter/cogl/cogl/cogl-pipeline-arbfp.c @@ -30,9 +30,9 @@ #endif #include "cogl-debug.h" -#include "cogl-material-private.h" +#include "cogl-pipeline-private.h" -#ifdef COGL_MATERIAL_BACKEND_ARBFP +#ifdef COGL_PIPELINE_BACKEND_ARBFP #include "cogl.h" #include "cogl-internal.h" @@ -51,7 +51,7 @@ #include /* - * GL/GLES compatability defines for material thingies: + * GL/GLES compatability defines for pipeline thingies: */ #ifdef HAVE_COGL_GLES2 @@ -94,17 +94,17 @@ typedef struct _ArbfpProgramState is used to detect when we need to flush all of the uniforms */ unsigned int user_program_age; - /* We need to track the last material that an ARBfp program was used + /* We need to track the last pipeline that an ARBfp program was used * with so know if we need to update any program.local parameters. */ - CoglMaterial *last_used_for_material; + CoglPipeline *last_used_for_pipeline; } ArbfpProgramState; -typedef struct _CoglMaterialBackendARBfpPrivate +typedef struct _CoglPipelineBackendARBfpPrivate { ArbfpProgramState *arbfp_program_state; -} CoglMaterialBackendARBfpPrivate; +} CoglPipelineBackendARBfpPrivate; -const CoglMaterialBackend _cogl_material_arbfp_backend; +const CoglPipelineBackend _cogl_pipeline_arbfp_backend; static ArbfpProgramState * @@ -146,7 +146,7 @@ arbfp_program_state_unref (ArbfpProgramState *state) } static int -_cogl_material_backend_arbfp_get_max_texture_units (void) +_cogl_pipeline_backend_arbfp_get_max_texture_units (void) { return _cogl_get_max_texture_image_units (); } @@ -154,11 +154,11 @@ _cogl_material_backend_arbfp_get_max_texture_units (void) typedef struct { int i; - CoglMaterialLayer **layers; + CoglPipelineLayer **layers; } AddLayersToArrayState; static gboolean -add_layer_to_array_cb (CoglMaterialLayer *layer, +add_layer_to_array_cb (CoglPipelineLayer *layer, void *user_data) { AddLayersToArrayState *state = user_data; @@ -167,36 +167,36 @@ add_layer_to_array_cb (CoglMaterialLayer *layer, } static gboolean -layers_arbfp_would_differ (CoglMaterialLayer **material0_layers, - CoglMaterialLayer **material1_layers, +layers_arbfp_would_differ (CoglPipelineLayer **pipeline0_layers, + CoglPipelineLayer **pipeline1_layers, int n_layers) { int i; /* The layer state that affects arbfp codegen... */ unsigned long arbfp_codegen_modifiers = - COGL_MATERIAL_LAYER_STATE_COMBINE | - COGL_MATERIAL_LAYER_STATE_UNIT; + COGL_PIPELINE_LAYER_STATE_COMBINE | + COGL_PIPELINE_LAYER_STATE_UNIT; for (i = 0; i < n_layers; i++) { - CoglMaterialLayer *layer0 = material0_layers[i]; - CoglMaterialLayer *layer1 = material1_layers[i]; + CoglPipelineLayer *layer0 = pipeline0_layers[i]; + CoglPipelineLayer *layer1 = pipeline1_layers[i]; unsigned long layer_differences; if (layer0 == layer1) continue; layer_differences = - _cogl_material_layer_compare_differences (layer0, layer1); + _cogl_pipeline_layer_compare_differences (layer0, layer1); if (layer_differences & arbfp_codegen_modifiers) { /* When it comes to texture differences the only thing that * affects the arbfp is the target enum... */ - if (layer_differences == COGL_MATERIAL_LAYER_STATE_TEXTURE) + if (layer_differences == COGL_PIPELINE_LAYER_STATE_TEXTURE) { - CoglHandle tex0 = _cogl_material_layer_get_texture (layer0); - CoglHandle tex1 = _cogl_material_layer_get_texture (layer1); + CoglHandle tex0 = _cogl_pipeline_layer_get_texture (layer0); + CoglHandle tex1 = _cogl_pipeline_layer_get_texture (layer1); GLenum gl_target0; GLenum gl_target1; @@ -213,37 +213,37 @@ layers_arbfp_would_differ (CoglMaterialLayer **material0_layers, } /* This tries to find the oldest ancestor whos state would generate - * the same arbfp program as the current material. This is a simple + * the same arbfp program as the current pipeline. This is a simple * mechanism for reducing the number of arbfp programs we have to * generate. */ -static CoglMaterial * -find_arbfp_authority (CoglMaterial *material, CoglHandle user_program) +static CoglPipeline * +find_arbfp_authority (CoglPipeline *pipeline, CoglHandle user_program) { - CoglMaterial *authority0; - CoglMaterial *authority1; + CoglPipeline *authority0; + CoglPipeline *authority1; int n_layers; - CoglMaterialLayer **authority0_layers; - CoglMaterialLayer **authority1_layers; + CoglPipelineLayer **authority0_layers; + CoglPipelineLayer **authority1_layers; /* XXX: we'll need to update this when we add fog support to the * arbfp codegen */ if (user_program != COGL_INVALID_HANDLE) - return material; + return pipeline; - /* Find the first material that modifies state that affects the + /* Find the first pipeline that modifies state that affects the * arbfp codegen... */ - authority0 = _cogl_material_get_authority (material, - COGL_MATERIAL_STATE_LAYERS); + authority0 = _cogl_pipeline_get_authority (pipeline, + COGL_PIPELINE_STATE_LAYERS); /* Find the next ancestor after that, that also modifies state * affecting arbfp codegen... */ - if (_cogl_material_get_parent (authority0)) + if (_cogl_pipeline_get_parent (authority0)) { authority1 = - _cogl_material_get_authority (_cogl_material_get_parent (authority0), - COGL_MATERIAL_STATE_LAYERS); + _cogl_pipeline_get_authority (_cogl_pipeline_get_parent (authority0), + COGL_PIPELINE_STATE_LAYERS); } else return authority0; @@ -258,18 +258,18 @@ find_arbfp_authority (CoglMaterial *material, CoglHandle user_program) return authority0; authority0_layers = - g_alloca (sizeof (CoglMaterialLayer *) * n_layers); + g_alloca (sizeof (CoglPipelineLayer *) * n_layers); state.i = 0; state.layers = authority0_layers; - _cogl_material_foreach_layer_internal (authority0, + _cogl_pipeline_foreach_layer_internal (authority0, add_layer_to_array_cb, &state); authority1_layers = - g_alloca (sizeof (CoglMaterialLayer *) * n_layers); + g_alloca (sizeof (CoglPipelineLayer *) * n_layers); state.i = 0; state.layers = authority1_layers; - _cogl_material_foreach_layer_internal (authority1, + _cogl_pipeline_foreach_layer_internal (authority1, add_layer_to_array_cb, &state); @@ -280,13 +280,13 @@ find_arbfp_authority (CoglMaterial *material, CoglHandle user_program) /* Find the next ancestor after that, that also modifies state * affecting arbfp codegen... */ - if (!_cogl_material_get_parent (authority1)) + if (!_cogl_pipeline_get_parent (authority1)) break; authority0 = authority1; authority1 = - _cogl_material_get_authority (_cogl_material_get_parent (authority1), - COGL_MATERIAL_STATE_LAYERS); + _cogl_pipeline_get_authority (_cogl_pipeline_get_parent (authority1), + COGL_PIPELINE_STATE_LAYERS); if (authority1 == authority0) break; } @@ -294,44 +294,44 @@ find_arbfp_authority (CoglMaterial *material, CoglHandle user_program) return authority1; } -static CoglMaterialBackendARBfpPrivate * -get_arbfp_priv (CoglMaterial *material) +static CoglPipelineBackendARBfpPrivate * +get_arbfp_priv (CoglPipeline *pipeline) { - if (!(material->backend_priv_set_mask & COGL_MATERIAL_BACKEND_ARBFP_MASK)) + if (!(pipeline->backend_priv_set_mask & COGL_PIPELINE_BACKEND_ARBFP_MASK)) return NULL; - return material->backend_privs[COGL_MATERIAL_BACKEND_ARBFP]; + return pipeline->backend_privs[COGL_PIPELINE_BACKEND_ARBFP]; } static void -set_arbfp_priv (CoglMaterial *material, CoglMaterialBackendARBfpPrivate *priv) +set_arbfp_priv (CoglPipeline *pipeline, CoglPipelineBackendARBfpPrivate *priv) { if (priv) { - material->backend_privs[COGL_MATERIAL_BACKEND_ARBFP] = priv; - material->backend_priv_set_mask |= COGL_MATERIAL_BACKEND_ARBFP_MASK; + pipeline->backend_privs[COGL_PIPELINE_BACKEND_ARBFP] = priv; + pipeline->backend_priv_set_mask |= COGL_PIPELINE_BACKEND_ARBFP_MASK; } else - material->backend_priv_set_mask &= ~COGL_MATERIAL_BACKEND_ARBFP_MASK; + pipeline->backend_priv_set_mask &= ~COGL_PIPELINE_BACKEND_ARBFP_MASK; } static ArbfpProgramState * -get_arbfp_program_state (CoglMaterial *material) +get_arbfp_program_state (CoglPipeline *pipeline) { - CoglMaterialBackendARBfpPrivate *priv = get_arbfp_priv (material); + CoglPipelineBackendARBfpPrivate *priv = get_arbfp_priv (pipeline); if (!priv) return NULL; return priv->arbfp_program_state; } static gboolean -_cogl_material_backend_arbfp_start (CoglMaterial *material, +_cogl_pipeline_backend_arbfp_start (CoglPipeline *pipeline, int n_layers, - unsigned long materials_difference) + unsigned long pipelines_difference) { - CoglMaterialBackendARBfpPrivate *priv; - CoglMaterial *authority; - CoglMaterialBackendARBfpPrivate *authority_priv; + CoglPipelineBackendARBfpPrivate *priv; + CoglPipeline *authority; + CoglPipelineBackendARBfpPrivate *authority_priv; CoglHandle user_program; _COGL_GET_CONTEXT (ctx, FALSE); @@ -346,18 +346,18 @@ _cogl_material_backend_arbfp_start (CoglMaterial *material, if (ctx->legacy_fog_state.enabled) return FALSE; - user_program = cogl_material_get_user_program (material); + user_program = cogl_pipeline_get_user_program (pipeline); if (user_program != COGL_INVALID_HANDLE && _cogl_program_get_language (user_program) != COGL_SHADER_LANGUAGE_ARBFP) return FALSE; /* Now lookup our ARBfp backend private state (allocating if * necessary) */ - priv = get_arbfp_priv (material); + priv = get_arbfp_priv (pipeline); if (!priv) { - priv = g_slice_new0 (CoglMaterialBackendARBfpPrivate); - set_arbfp_priv (material, priv); + priv = g_slice_new0 (CoglPipelineBackendARBfpPrivate); + set_arbfp_priv (pipeline, priv); } /* If we have a valid arbfp_program_state pointer then we are all @@ -367,17 +367,17 @@ _cogl_material_backend_arbfp_start (CoglMaterial *material, /* If we don't have an associated arbfp program yet then find the * arbfp-authority (the oldest ancestor whose state will result in - * the same program being generated as for this material). + * the same program being generated as for this pipeline). * * We always make sure to associate new programs with the - * arbfp-authority to maximize the chance that other materials can + * arbfp-authority to maximize the chance that other pipelines can * share it. */ - authority = find_arbfp_authority (material, user_program); + authority = find_arbfp_authority (pipeline, user_program); authority_priv = get_arbfp_priv (authority); if (!authority_priv) { - authority_priv = g_slice_new0 (CoglMaterialBackendARBfpPrivate); + authority_priv = g_slice_new0 (CoglPipelineBackendARBfpPrivate); set_arbfp_priv (authority, authority_priv); } @@ -416,10 +416,10 @@ _cogl_material_backend_arbfp_start (CoglMaterial *material, } } - /* Finally, if the material isn't actually its own arbfp-authority + /* Finally, if the pipeline isn't actually its own arbfp-authority * then steal a reference to the program state associated with the * arbfp-authority... */ - if (authority != material) + if (authority != pipeline) priv->arbfp_program_state = arbfp_program_state_ref (authority_priv->arbfp_program_state); @@ -431,9 +431,9 @@ _cogl_material_backend_arbfp_start (CoglMaterial *material, * with the same arguments... */ static gboolean -need_texture_combine_separate (CoglMaterialLayer *combine_authority) +need_texture_combine_separate (CoglPipelineLayer *combine_authority) { - CoglMaterialLayerBigState *big_state = combine_authority->big_state; + CoglPipelineLayerBigState *big_state = combine_authority->big_state; int n_args; int i; @@ -539,18 +539,18 @@ setup_texture_source (ArbfpProgramState *arbfp_program_state, } } -typedef enum _CoglMaterialBackendARBfpArgType +typedef enum _CoglPipelineBackendARBfpArgType { - COGL_MATERIAL_BACKEND_ARBFP_ARG_TYPE_SIMPLE, - COGL_MATERIAL_BACKEND_ARBFP_ARG_TYPE_CONSTANT, - COGL_MATERIAL_BACKEND_ARBFP_ARG_TYPE_TEXTURE -} CoglMaterialBackendARBfpArgType; + COGL_PIPELINE_BACKEND_ARBFP_ARG_TYPE_SIMPLE, + COGL_PIPELINE_BACKEND_ARBFP_ARG_TYPE_CONSTANT, + COGL_PIPELINE_BACKEND_ARBFP_ARG_TYPE_TEXTURE +} CoglPipelineBackendARBfpArgType; -typedef struct _CoglMaterialBackendARBfpArg +typedef struct _CoglPipelineBackendARBfpArg { const char *name; - CoglMaterialBackendARBfpArgType type; + CoglPipelineBackendARBfpArgType type; /* for type = TEXTURE */ int texture_unit; @@ -561,22 +561,22 @@ typedef struct _CoglMaterialBackendARBfpArg const char *swizzle; -} CoglMaterialBackendARBfpArg; +} CoglPipelineBackendARBfpArg; static void -append_arg (GString *source, const CoglMaterialBackendARBfpArg *arg) +append_arg (GString *source, const CoglPipelineBackendARBfpArg *arg) { switch (arg->type) { - case COGL_MATERIAL_BACKEND_ARBFP_ARG_TYPE_TEXTURE: + case COGL_PIPELINE_BACKEND_ARBFP_ARG_TYPE_TEXTURE: g_string_append_printf (source, "texel%d%s", arg->texture_unit, arg->swizzle); break; - case COGL_MATERIAL_BACKEND_ARBFP_ARG_TYPE_CONSTANT: + case COGL_PIPELINE_BACKEND_ARBFP_ARG_TYPE_CONSTANT: g_string_append_printf (source, "program.local[%d]%s", arg->constant_id, arg->swizzle); break; - case COGL_MATERIAL_BACKEND_ARBFP_ARG_TYPE_SIMPLE: + case COGL_PIPELINE_BACKEND_ARBFP_ARG_TYPE_SIMPLE: g_string_append_printf (source, "%s%s", arg->name, arg->swizzle); break; @@ -585,17 +585,17 @@ append_arg (GString *source, const CoglMaterialBackendARBfpArg *arg) /* Note: we are trying to avoid duplicating strings during codegen * which is why we have the slightly awkward - * CoglMaterialBackendARBfpArg mechanism. */ + * CoglPipelineBackendARBfpArg mechanism. */ static void -setup_arg (CoglMaterial *material, - CoglMaterialLayer *layer, +setup_arg (CoglPipeline *pipeline, + CoglPipelineLayer *layer, CoglBlendStringChannelMask mask, int arg_index, GLint src, GLint op, - CoglMaterialBackendARBfpArg *arg) + CoglPipelineBackendARBfpArg *arg) { - ArbfpProgramState *arbfp_program_state = get_arbfp_program_state (material); + ArbfpProgramState *arbfp_program_state = get_arbfp_program_state (pipeline); static const char *tmp_name[3] = { "tmp0", "tmp1", "tmp2" }; GLenum gl_target; CoglHandle texture; @@ -603,42 +603,42 @@ setup_arg (CoglMaterial *material, switch (src) { case GL_TEXTURE: - arg->type = COGL_MATERIAL_BACKEND_ARBFP_ARG_TYPE_TEXTURE; + arg->type = COGL_PIPELINE_BACKEND_ARBFP_ARG_TYPE_TEXTURE; arg->name = "texel%d"; - arg->texture_unit = _cogl_material_layer_get_unit_index (layer); - texture = _cogl_material_layer_get_texture (layer); + arg->texture_unit = _cogl_pipeline_layer_get_unit_index (layer); + texture = _cogl_pipeline_layer_get_texture (layer); cogl_texture_get_gl_texture (texture, NULL, &gl_target); setup_texture_source (arbfp_program_state, arg->texture_unit, gl_target); break; case GL_CONSTANT: { - int unit_index = _cogl_material_layer_get_unit_index (layer); + int unit_index = _cogl_pipeline_layer_get_unit_index (layer); UnitState *unit_state = &arbfp_program_state->unit_state[unit_index]; unit_state->constant_id = arbfp_program_state->next_constant_id++; unit_state->dirty_combine_constant = TRUE; - arg->type = COGL_MATERIAL_BACKEND_ARBFP_ARG_TYPE_CONSTANT; + arg->type = COGL_PIPELINE_BACKEND_ARBFP_ARG_TYPE_CONSTANT; arg->name = "program.local[%d]"; arg->constant_id = unit_state->constant_id; break; } case GL_PRIMARY_COLOR: - arg->type = COGL_MATERIAL_BACKEND_ARBFP_ARG_TYPE_SIMPLE; + arg->type = COGL_PIPELINE_BACKEND_ARBFP_ARG_TYPE_SIMPLE; arg->name = "fragment.color.primary"; break; case GL_PREVIOUS: - arg->type = COGL_MATERIAL_BACKEND_ARBFP_ARG_TYPE_SIMPLE; - if (_cogl_material_layer_get_unit_index (layer) == 0) + arg->type = COGL_PIPELINE_BACKEND_ARBFP_ARG_TYPE_SIMPLE; + if (_cogl_pipeline_layer_get_unit_index (layer) == 0) arg->name = "fragment.color.primary"; else arg->name = "output"; break; default: /* GL_TEXTURE0..N */ - arg->type = COGL_MATERIAL_BACKEND_ARBFP_ARG_TYPE_TEXTURE; + arg->type = COGL_PIPELINE_BACKEND_ARBFP_ARG_TYPE_TEXTURE; arg->name = "texture[%d]"; arg->texture_unit = src - GL_TEXTURE0; - texture = _cogl_material_layer_get_texture (layer); + texture = _cogl_pipeline_layer_get_texture (layer); cogl_texture_get_gl_texture (texture, NULL, &gl_target); setup_texture_source (arbfp_program_state, arg->texture_unit, gl_target); } @@ -655,7 +655,7 @@ setup_arg (CoglMaterial *material, arg_index); append_arg (arbfp_program_state->source, arg); g_string_append_printf (arbfp_program_state->source, ";\n"); - arg->type = COGL_MATERIAL_BACKEND_ARBFP_ARG_TYPE_SIMPLE; + arg->type = COGL_PIPELINE_BACKEND_ARBFP_ARG_TYPE_SIMPLE; arg->name = tmp_name[arg_index]; arg->swizzle = ""; break; @@ -676,7 +676,7 @@ setup_arg (CoglMaterial *material, g_string_append_printf (arbfp_program_state->source, ".a;\n"); else g_string_append_printf (arbfp_program_state->source, ";\n"); - arg->type = COGL_MATERIAL_BACKEND_ARBFP_ARG_TYPE_SIMPLE; + arg->type = COGL_PIPELINE_BACKEND_ARBFP_ARG_TYPE_SIMPLE; arg->name = tmp_name[arg_index]; break; default: @@ -686,8 +686,8 @@ setup_arg (CoglMaterial *material, } static gboolean -backend_arbfp_args_equal (CoglMaterialBackendARBfpArg *arg0, - CoglMaterialBackendARBfpArg *arg1) +backend_arbfp_args_equal (CoglPipelineBackendARBfpArg *arg0, + CoglPipelineBackendARBfpArg *arg1) { if (arg0->type != arg1->type) return FALSE; @@ -696,13 +696,13 @@ backend_arbfp_args_equal (CoglMaterialBackendARBfpArg *arg0, strcmp (arg0->name, arg1->name) != 0) return FALSE; - if (arg0->type == COGL_MATERIAL_BACKEND_ARBFP_ARG_TYPE_TEXTURE && + if (arg0->type == COGL_PIPELINE_BACKEND_ARBFP_ARG_TYPE_TEXTURE && arg0->texture_unit != arg1->texture_unit) return FALSE; /* Note we don't have to check the target; a texture unit can only * have one target enabled at a time. */ - if (arg0->type == COGL_MATERIAL_BACKEND_ARBFP_ARG_TYPE_CONSTANT && + if (arg0->type == COGL_PIPELINE_BACKEND_ARBFP_ARG_TYPE_CONSTANT && arg0->constant_id != arg0->constant_id) return FALSE; @@ -714,13 +714,13 @@ backend_arbfp_args_equal (CoglMaterialBackendARBfpArg *arg0, } static void -append_function (CoglMaterial *material, +append_function (CoglPipeline *pipeline, CoglBlendStringChannelMask mask, GLint function, - CoglMaterialBackendARBfpArg *args, + CoglPipelineBackendARBfpArg *args, int n_args) { - ArbfpProgramState *arbfp_program_state = get_arbfp_program_state (material); + ArbfpProgramState *arbfp_program_state = get_arbfp_program_state (pipeline); const char *mask_name; switch (mask) @@ -852,8 +852,8 @@ append_function (CoglMaterial *material, } static void -append_masked_combine (CoglMaterial *arbfp_authority, - CoglMaterialLayer *layer, +append_masked_combine (CoglPipeline *arbfp_authority, + CoglPipelineLayer *layer, CoglBlendStringChannelMask mask, GLint function, GLint *src, @@ -861,7 +861,7 @@ append_masked_combine (CoglMaterial *arbfp_authority, { int i; int n_args; - CoglMaterialBackendARBfpArg args[3]; + CoglPipelineBackendARBfpArg args[3]; n_args = _cogl_get_n_args_for_combine_func (function); @@ -884,15 +884,15 @@ append_masked_combine (CoglMaterial *arbfp_authority, } static gboolean -_cogl_material_backend_arbfp_add_layer (CoglMaterial *material, - CoglMaterialLayer *layer, +_cogl_pipeline_backend_arbfp_add_layer (CoglPipeline *pipeline, + CoglPipelineLayer *layer, unsigned long layers_difference) { - ArbfpProgramState *arbfp_program_state = get_arbfp_program_state (material); - CoglMaterialLayer *combine_authority = - _cogl_material_layer_get_authority (layer, - COGL_MATERIAL_LAYER_STATE_COMBINE); - CoglMaterialLayerBigState *big_state = combine_authority->big_state; + ArbfpProgramState *arbfp_program_state = get_arbfp_program_state (pipeline); + CoglPipelineLayer *combine_authority = + _cogl_pipeline_layer_get_authority (layer, + COGL_PIPELINE_LAYER_STATE_COMBINE); + CoglPipelineLayerBigState *big_state = combine_authority->big_state; /* Notes... * @@ -928,7 +928,7 @@ _cogl_material_backend_arbfp_add_layer (CoglMaterial *material, if (!need_texture_combine_separate (combine_authority)) { - append_masked_combine (material, + append_masked_combine (pipeline, layer, COGL_BLEND_STRING_CHANNEL_MASK_RGBA, big_state->texture_combine_rgb_func, @@ -940,7 +940,7 @@ _cogl_material_backend_arbfp_add_layer (CoglMaterial *material, /* GL_DOT3_RGBA Is a bit weird as a GL_COMBINE_RGB function * since if you use it, it overrides your ALPHA function... */ - append_masked_combine (material, + append_masked_combine (pipeline, layer, COGL_BLEND_STRING_CHANNEL_MASK_RGBA, big_state->texture_combine_rgb_func, @@ -949,13 +949,13 @@ _cogl_material_backend_arbfp_add_layer (CoglMaterial *material, } else { - append_masked_combine (material, + append_masked_combine (pipeline, layer, COGL_BLEND_STRING_CHANNEL_MASK_RGB, big_state->texture_combine_rgb_func, big_state->texture_combine_rgb_src, big_state->texture_combine_rgb_op); - append_masked_combine (material, + append_masked_combine (pipeline, layer, COGL_BLEND_STRING_CHANNEL_MASK_ALPHA, big_state->texture_combine_alpha_func, @@ -967,9 +967,9 @@ _cogl_material_backend_arbfp_add_layer (CoglMaterial *material, } gboolean -_cogl_material_backend_arbfp_passthrough (CoglMaterial *material) +_cogl_pipeline_backend_arbfp_passthrough (CoglPipeline *pipeline) { - ArbfpProgramState *arbfp_program_state = get_arbfp_program_state (material); + ArbfpProgramState *arbfp_program_state = get_arbfp_program_state (pipeline); if (!arbfp_program_state->source) return TRUE; @@ -987,7 +987,7 @@ typedef struct _UpdateConstantsState } UpdateConstantsState; static gboolean -update_constants_cb (CoglMaterial *material, +update_constants_cb (CoglPipeline *pipeline, int layer_index, void *user_data) { @@ -1000,7 +1000,7 @@ update_constants_cb (CoglMaterial *material, if (state->update_all || unit_state->dirty_combine_constant) { float constant[4]; - _cogl_material_get_layer_combine_constant (material, + _cogl_pipeline_get_layer_combine_constant (pipeline, layer_index, constant); GE (glProgramLocalParameter4fv (GL_FRAGMENT_PROGRAM_ARB, @@ -1012,10 +1012,10 @@ update_constants_cb (CoglMaterial *material, } static gboolean -_cogl_material_backend_arbfp_end (CoglMaterial *material, - unsigned long materials_difference) +_cogl_pipeline_backend_arbfp_end (CoglPipeline *pipeline, + unsigned long pipelines_difference) { - ArbfpProgramState *arbfp_program_state = get_arbfp_program_state (material); + ArbfpProgramState *arbfp_program_state = get_arbfp_program_state (pipeline); GLuint gl_program; _COGL_GET_CONTEXT (ctx, FALSE); @@ -1036,7 +1036,7 @@ _cogl_material_backend_arbfp_end (CoglMaterial *material, g_string_append (arbfp_program_state->source, "END\n"); if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_SHOW_SOURCE)) - g_message ("material program:\n%s", arbfp_program_state->source->str); + g_message ("pipeline program:\n%s", arbfp_program_state->source->str); GE (glGenPrograms (1, &arbfp_program_state->gl_program)); @@ -1072,18 +1072,18 @@ _cogl_material_backend_arbfp_end (CoglMaterial *material, gl_program = arbfp_program_state->gl_program; GE (glBindProgram (GL_FRAGMENT_PROGRAM_ARB, gl_program)); - _cogl_use_program (0, COGL_MATERIAL_PROGRAM_TYPE_ARBFP); + _cogl_use_program (0, COGL_PIPELINE_PROGRAM_TYPE_ARBFP); if (arbfp_program_state->user_program == COGL_INVALID_HANDLE) { UpdateConstantsState state; state.unit = 0; state.arbfp_program_state = arbfp_program_state; - /* If this arbfp program was last used with a different material + /* If this arbfp program was last used with a different pipeline * then we need to ensure we update all program.local params */ state.update_all = - material != arbfp_program_state->last_used_for_material; - cogl_material_foreach_layer (material, + pipeline != arbfp_program_state->last_used_for_pipeline; + cogl_pipeline_foreach_layer (pipeline, update_constants_cb, &state); } @@ -1101,22 +1101,22 @@ _cogl_material_backend_arbfp_end (CoglMaterial *material, arbfp_program_state->user_program_age = program->age; } - /* We need to track what material used this arbfp program last since + /* We need to track what pipeline used this arbfp program last since * we will need to update program.local params when switching - * between different materials. */ - arbfp_program_state->last_used_for_material = material; + * between different pipelines. */ + arbfp_program_state->last_used_for_pipeline = pipeline; return TRUE; } static void -dirty_arbfp_program_state (CoglMaterial *material) +dirty_arbfp_program_state (CoglPipeline *pipeline) { - CoglMaterialBackendARBfpPrivate *priv; + CoglPipelineBackendARBfpPrivate *priv; _COGL_GET_CONTEXT (ctx, NO_RETVAL); - priv = get_arbfp_priv (material); + priv = get_arbfp_priv (pipeline); if (!priv) return; @@ -1128,40 +1128,40 @@ dirty_arbfp_program_state (CoglMaterial *material) } static void -_cogl_material_backend_arbfp_material_pre_change_notify ( - CoglMaterial *material, - CoglMaterialState change, +_cogl_pipeline_backend_arbfp_pipeline_pre_change_notify ( + CoglPipeline *pipeline, + CoglPipelineState change, const CoglColor *new_color) { static const unsigned long fragment_op_changes = - COGL_MATERIAL_STATE_LAYERS | - COGL_MATERIAL_STATE_USER_SHADER; - /* TODO: COGL_MATERIAL_STATE_FOG */ + COGL_PIPELINE_STATE_LAYERS | + COGL_PIPELINE_STATE_USER_SHADER; + /* TODO: COGL_PIPELINE_STATE_FOG */ if (!(change & fragment_op_changes)) return; - dirty_arbfp_program_state (material); + dirty_arbfp_program_state (pipeline); } /* NB: layers are considered immutable once they have any dependants - * so although multiple materials can end up depending on a single + * so although multiple pipelines can end up depending on a single * static layer, we can guarantee that if a layer is being *changed* - * then it can only have one material depending on it. + * then it can only have one pipeline depending on it. * * XXX: Don't forget this is *pre* change, we can't read the new value * yet! */ static void -_cogl_material_backend_arbfp_layer_pre_change_notify ( - CoglMaterial *owner, - CoglMaterialLayer *layer, - CoglMaterialLayerState change) +_cogl_pipeline_backend_arbfp_layer_pre_change_notify ( + CoglPipeline *owner, + CoglPipelineLayer *layer, + CoglPipelineLayerState change) { - CoglMaterialBackendARBfpPrivate *priv; + CoglPipelineBackendARBfpPrivate *priv; static const unsigned long not_fragment_op_changes = - COGL_MATERIAL_LAYER_STATE_COMBINE_CONSTANT | - COGL_MATERIAL_LAYER_STATE_TEXTURE; + COGL_PIPELINE_LAYER_STATE_COMBINE_CONSTANT | + COGL_PIPELINE_LAYER_STATE_TEXTURE; priv = get_arbfp_priv (owner); if (!priv) @@ -1173,11 +1173,11 @@ _cogl_material_backend_arbfp_layer_pre_change_notify ( return; } - if (change & COGL_MATERIAL_LAYER_STATE_COMBINE_CONSTANT) + if (change & COGL_PIPELINE_LAYER_STATE_COMBINE_CONSTANT) { ArbfpProgramState *arbfp_program_state = get_arbfp_program_state (owner); - int unit_index = _cogl_material_layer_get_unit_index (layer); + int unit_index = _cogl_pipeline_layer_get_unit_index (layer); arbfp_program_state->unit_state[unit_index].dirty_combine_constant = TRUE; } @@ -1188,31 +1188,31 @@ _cogl_material_backend_arbfp_layer_pre_change_notify ( } static void -_cogl_material_backend_arbfp_free_priv (CoglMaterial *material) +_cogl_pipeline_backend_arbfp_free_priv (CoglPipeline *pipeline) { - CoglMaterialBackendARBfpPrivate *priv = get_arbfp_priv (material); + CoglPipelineBackendARBfpPrivate *priv = get_arbfp_priv (pipeline); if (priv) { if (priv->arbfp_program_state) arbfp_program_state_unref (priv->arbfp_program_state); - g_slice_free (CoglMaterialBackendARBfpPrivate, priv); - set_arbfp_priv (material, NULL); + g_slice_free (CoglPipelineBackendARBfpPrivate, priv); + set_arbfp_priv (pipeline, NULL); } } -const CoglMaterialBackend _cogl_material_arbfp_backend = +const CoglPipelineBackend _cogl_pipeline_arbfp_backend = { - _cogl_material_backend_arbfp_get_max_texture_units, - _cogl_material_backend_arbfp_start, - _cogl_material_backend_arbfp_add_layer, - _cogl_material_backend_arbfp_passthrough, - _cogl_material_backend_arbfp_end, - _cogl_material_backend_arbfp_material_pre_change_notify, + _cogl_pipeline_backend_arbfp_get_max_texture_units, + _cogl_pipeline_backend_arbfp_start, + _cogl_pipeline_backend_arbfp_add_layer, + _cogl_pipeline_backend_arbfp_passthrough, + _cogl_pipeline_backend_arbfp_end, + _cogl_pipeline_backend_arbfp_pipeline_pre_change_notify, NULL, - _cogl_material_backend_arbfp_layer_pre_change_notify, - _cogl_material_backend_arbfp_free_priv, + _cogl_pipeline_backend_arbfp_layer_pre_change_notify, + _cogl_pipeline_backend_arbfp_free_priv, NULL }; -#endif /* COGL_MATERIAL_BACKEND_ARBFP */ +#endif /* COGL_PIPELINE_BACKEND_ARBFP */ diff --git a/clutter/cogl/cogl/cogl-material-fixed-private.h b/clutter/cogl/cogl/cogl-pipeline-fixed-private.h similarity index 79% rename from clutter/cogl/cogl/cogl-material-fixed-private.h rename to clutter/cogl/cogl/cogl-pipeline-fixed-private.h index 25704caf3..d24dcdcea 100644 --- a/clutter/cogl/cogl/cogl-material-fixed-private.h +++ b/clutter/cogl/cogl/cogl-pipeline-fixed-private.h @@ -25,12 +25,12 @@ * Robert Bragg */ -#ifndef __COGL_MATERIAL_FIXED_PRIVATE_H -#define __COGL_MATERIAL_FIXED_PRIVATE_H +#ifndef __COGL_PIPELINE_FIXED_PRIVATE_H +#define __COGL_PIPELINE_FIXED_PRIVATE_H -#include "cogl-material-private.h" +#include "cogl-pipeline-private.h" -extern const CoglMaterialBackend _cogl_material_fixed_backend; +extern const CoglPipelineBackend _cogl_pipeline_fixed_backend; -#endif /* __COGL_MATERIAL_FIXED_PRIVATE_H */ +#endif /* __COGL_PIPELINE_FIXED_PRIVATE_H */ diff --git a/clutter/cogl/cogl/cogl-material-fixed.c b/clutter/cogl/cogl/cogl-pipeline-fixed.c similarity index 78% rename from clutter/cogl/cogl/cogl-material-fixed.c rename to clutter/cogl/cogl/cogl-pipeline-fixed.c index b5d898324..092e5cccd 100644 --- a/clutter/cogl/cogl/cogl-material-fixed.c +++ b/clutter/cogl/cogl/cogl-pipeline-fixed.c @@ -29,10 +29,10 @@ #include "config.h" #endif -#include "cogl-material-private.h" -#include "cogl-material-opengl-private.h" +#include "cogl-pipeline-private.h" +#include "cogl-pipeline-opengl-private.h" -#ifdef COGL_MATERIAL_BACKEND_FIXED +#ifdef COGL_PIPELINE_BACKEND_FIXED #include "cogl.h" #include "cogl-internal.h" @@ -51,10 +51,10 @@ #include "../gles/cogl-gles2-wrapper.h" #endif -const CoglMaterialBackend _cogl_material_fixed_backend; +const CoglPipelineBackend _cogl_pipeline_fixed_backend; static int -_cogl_material_backend_fixed_get_max_texture_units (void) +_cogl_pipeline_backend_fixed_get_max_texture_units (void) { _COGL_GET_CONTEXT (ctx, 0); @@ -71,21 +71,21 @@ _cogl_material_backend_fixed_get_max_texture_units (void) } static gboolean -_cogl_material_backend_fixed_start (CoglMaterial *material, +_cogl_pipeline_backend_fixed_start (CoglPipeline *pipeline, int n_layers, - unsigned long materials_difference) + unsigned long pipelines_difference) { - _cogl_use_program (0, COGL_MATERIAL_PROGRAM_TYPE_FIXED); + _cogl_use_program (0, COGL_PIPELINE_PROGRAM_TYPE_FIXED); return TRUE; } static gboolean -_cogl_material_backend_fixed_add_layer (CoglMaterial *material, - CoglMaterialLayer *layer, +_cogl_pipeline_backend_fixed_add_layer (CoglPipeline *pipeline, + CoglPipelineLayer *layer, unsigned long layers_difference) { CoglTextureUnit *unit = - _cogl_get_texture_unit (_cogl_material_layer_get_unit_index (layer)); + _cogl_get_texture_unit (_cogl_pipeline_layer_get_unit_index (layer)); int unit_index = unit->index; int n_rgb_func_args; int n_alpha_func_args; @@ -100,12 +100,12 @@ _cogl_material_backend_fixed_add_layer (CoglMaterial *material, */ _cogl_set_active_texture_unit (unit_index); - if (layers_difference & COGL_MATERIAL_LAYER_STATE_COMBINE) + if (layers_difference & COGL_PIPELINE_LAYER_STATE_COMBINE) { - CoglMaterialLayer *authority = - _cogl_material_layer_get_authority (layer, - COGL_MATERIAL_LAYER_STATE_COMBINE); - CoglMaterialLayerBigState *big_state = authority->big_state; + CoglPipelineLayer *authority = + _cogl_pipeline_layer_get_authority (layer, + COGL_PIPELINE_LAYER_STATE_COMBINE); + CoglPipelineLayerBigState *big_state = authority->big_state; GE (glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE)); @@ -168,12 +168,12 @@ _cogl_material_backend_fixed_add_layer (CoglMaterial *material, } } - if (layers_difference & COGL_MATERIAL_LAYER_STATE_COMBINE) + if (layers_difference & COGL_PIPELINE_LAYER_STATE_COMBINE) { - CoglMaterialLayer *authority = - _cogl_material_layer_get_authority (layer, - COGL_MATERIAL_LAYER_STATE_COMBINE); - CoglMaterialLayerBigState *big_state = authority->big_state; + CoglPipelineLayer *authority = + _cogl_pipeline_layer_get_authority (layer, + COGL_PIPELINE_LAYER_STATE_COMBINE); + CoglPipelineLayerBigState *big_state = authority->big_state; GE (glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, big_state->texture_combine_constant)); @@ -183,14 +183,14 @@ _cogl_material_backend_fixed_add_layer (CoglMaterial *material, } static gboolean -_cogl_material_backend_fixed_end (CoglMaterial *material, - unsigned long materials_difference) +_cogl_pipeline_backend_fixed_end (CoglPipeline *pipeline, + unsigned long pipelines_difference) { - if (materials_difference & COGL_MATERIAL_STATE_FOG) + if (pipelines_difference & COGL_PIPELINE_STATE_FOG) { - CoglMaterial *authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_FOG); - CoglMaterialFogState *fog_state = &authority->big_state->fog_state; + CoglPipeline *authority = + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_FOG); + CoglPipelineFogState *fog_state = &authority->big_state->fog_state; if (fog_state->enabled) { @@ -244,18 +244,18 @@ _cogl_material_backend_fixed_end (CoglMaterial *material, return TRUE; } -const CoglMaterialBackend _cogl_material_fixed_backend = +const CoglPipelineBackend _cogl_pipeline_fixed_backend = { - _cogl_material_backend_fixed_get_max_texture_units, - _cogl_material_backend_fixed_start, - _cogl_material_backend_fixed_add_layer, + _cogl_pipeline_backend_fixed_get_max_texture_units, + _cogl_pipeline_backend_fixed_start, + _cogl_pipeline_backend_fixed_add_layer, NULL, /* passthrough */ - _cogl_material_backend_fixed_end, - NULL, /* material_change_notify */ - NULL, /* material_set_parent_notify */ + _cogl_pipeline_backend_fixed_end, + NULL, /* pipeline_change_notify */ + NULL, /* pipeline_set_parent_notify */ NULL, /* layer_change_notify */ NULL /* free_priv */ }; -#endif /* COGL_MATERIAL_BACKEND_FIXED */ +#endif /* COGL_PIPELINE_BACKEND_FIXED */ diff --git a/clutter/cogl/cogl/cogl-material-glsl-private.h b/clutter/cogl/cogl/cogl-pipeline-glsl-private.h similarity index 79% rename from clutter/cogl/cogl/cogl-material-glsl-private.h rename to clutter/cogl/cogl/cogl-pipeline-glsl-private.h index 742e39932..17542844b 100644 --- a/clutter/cogl/cogl/cogl-material-glsl-private.h +++ b/clutter/cogl/cogl/cogl-pipeline-glsl-private.h @@ -25,12 +25,12 @@ * Robert Bragg */ -#ifndef __COGL_MATERIAL_GLSL_PRIVATE_H -#define __COGL_MATERIAL_GLSL_PRIVATE_H +#ifndef __COGL_PIPELINE_GLSL_PRIVATE_H +#define __COGL_PIPELINE_GLSL_PRIVATE_H -#include "cogl-material-private.h" +#include "cogl-pipeline-private.h" -extern const CoglMaterialBackend _cogl_material_glsl_backend; +extern const CoglPipelineBackend _cogl_pipeline_glsl_backend; -#endif /* __COGL_MATERIAL_GLSL_PRIVATE_H */ +#endif /* __COGL_PIPELINE_GLSL_PRIVATE_H */ diff --git a/clutter/cogl/cogl/cogl-material-glsl.c b/clutter/cogl/cogl/cogl-pipeline-glsl.c similarity index 73% rename from clutter/cogl/cogl/cogl-material-glsl.c rename to clutter/cogl/cogl/cogl-pipeline-glsl.c index 6da5a6219..3e322e2f3 100644 --- a/clutter/cogl/cogl/cogl-material-glsl.c +++ b/clutter/cogl/cogl/cogl-pipeline-glsl.c @@ -29,10 +29,10 @@ #include "config.h" #endif -#include "cogl-material-private.h" +#include "cogl-pipeline-private.h" #include "cogl-shader-private.h" -#ifdef COGL_MATERIAL_BACKEND_GLSL +#ifdef COGL_PIPELINE_BACKEND_GLSL #include "cogl.h" #include "cogl-internal.h" @@ -56,7 +56,7 @@ #include /* - * GL/GLES compatability defines for material thingies: + * GL/GLES compatability defines for pipeline thingies: */ #ifdef HAVE_COGL_GLES2 @@ -87,15 +87,15 @@ typedef struct _GlslProgramState #endif } GlslProgramState; -typedef struct _CoglMaterialBackendGlslPrivate +typedef struct _CoglPipelineBackendGlslPrivate { GlslProgramState *glsl_program_state; -} CoglMaterialBackendGlslPrivate; +} CoglPipelineBackendGlslPrivate; -const CoglMaterialBackend _cogl_material_glsl_backend; +const CoglPipelineBackend _cogl_pipeline_glsl_backend; static int -_cogl_material_backend_glsl_get_max_texture_units (void) +_cogl_pipeline_backend_glsl_get_max_texture_units (void) { return _cogl_get_max_texture_image_units (); } @@ -152,56 +152,56 @@ glsl_program_state_unref (GlslProgramState *state) } /* This tries to find the oldest ancestor whos state would generate - * the same glsl program as the current material. This is a simple + * the same glsl program as the current pipeline. This is a simple * mechanism for reducing the number of glsl programs we have to * generate. */ -static CoglMaterial * -find_glsl_authority (CoglMaterial *material, CoglHandle user_program) +static CoglPipeline * +find_glsl_authority (CoglPipeline *pipeline, CoglHandle user_program) { - /* Find the first material that modifies the user shader */ - return _cogl_material_get_authority (material, - COGL_MATERIAL_STATE_USER_SHADER); + /* Find the first pipeline that modifies the user shader */ + return _cogl_pipeline_get_authority (pipeline, + COGL_PIPELINE_STATE_USER_SHADER); } -static CoglMaterialBackendGlslPrivate * -get_glsl_priv (CoglMaterial *material) +static CoglPipelineBackendGlslPrivate * +get_glsl_priv (CoglPipeline *pipeline) { - if (!(material->backend_priv_set_mask & COGL_MATERIAL_BACKEND_GLSL_MASK)) + if (!(pipeline->backend_priv_set_mask & COGL_PIPELINE_BACKEND_GLSL_MASK)) return NULL; - return material->backend_privs[COGL_MATERIAL_BACKEND_GLSL]; + return pipeline->backend_privs[COGL_PIPELINE_BACKEND_GLSL]; } static void -set_glsl_priv (CoglMaterial *material, CoglMaterialBackendGlslPrivate *priv) +set_glsl_priv (CoglPipeline *pipeline, CoglPipelineBackendGlslPrivate *priv) { if (priv) { - material->backend_privs[COGL_MATERIAL_BACKEND_GLSL] = priv; - material->backend_priv_set_mask |= COGL_MATERIAL_BACKEND_GLSL_MASK; + pipeline->backend_privs[COGL_PIPELINE_BACKEND_GLSL] = priv; + pipeline->backend_priv_set_mask |= COGL_PIPELINE_BACKEND_GLSL_MASK; } else - material->backend_priv_set_mask &= ~COGL_MATERIAL_BACKEND_GLSL_MASK; + pipeline->backend_priv_set_mask &= ~COGL_PIPELINE_BACKEND_GLSL_MASK; } static GlslProgramState * -get_glsl_program_state (CoglMaterial *material) +get_glsl_program_state (CoglPipeline *pipeline) { - CoglMaterialBackendGlslPrivate *priv = get_glsl_priv (material); + CoglPipelineBackendGlslPrivate *priv = get_glsl_priv (pipeline); if (!priv) return NULL; return priv->glsl_program_state; } static void -dirty_glsl_program_state (CoglMaterial *material) +dirty_glsl_program_state (CoglPipeline *pipeline) { - CoglMaterialBackendGlslPrivate *priv; + CoglPipelineBackendGlslPrivate *priv; _COGL_GET_CONTEXT (ctx, NO_RETVAL); - priv = get_glsl_priv (material); + priv = get_glsl_priv (pipeline); if (!priv) return; @@ -250,13 +250,13 @@ link_program (GLint gl_program) } static gboolean -_cogl_material_backend_glsl_start (CoglMaterial *material, +_cogl_pipeline_backend_glsl_start (CoglPipeline *pipeline, int n_layers, - unsigned long materials_difference) + unsigned long pipelines_difference) { - CoglMaterialBackendGlslPrivate *priv; - CoglMaterial *authority; - CoglMaterialBackendGlslPrivate *authority_priv; + CoglPipelineBackendGlslPrivate *priv; + CoglPipeline *authority; + CoglPipelineBackendGlslPrivate *authority_priv; CoglProgram *user_program; GLuint gl_program; GSList *l; @@ -266,18 +266,18 @@ _cogl_material_backend_glsl_start (CoglMaterial *material, if (!cogl_features_available (COGL_FEATURE_SHADERS_GLSL)) return FALSE; - user_program = cogl_material_get_user_program (material); + user_program = cogl_pipeline_get_user_program (pipeline); if (user_program == COGL_INVALID_HANDLE || _cogl_program_get_language (user_program) != COGL_SHADER_LANGUAGE_GLSL) return FALSE; /* XXX: change me when we support code generation here */ /* Now lookup our glsl backend private state (allocating if * necessary) */ - priv = get_glsl_priv (material); + priv = get_glsl_priv (pipeline); if (!priv) { - priv = g_slice_new0 (CoglMaterialBackendGlslPrivate); - set_glsl_priv (material, priv); + priv = g_slice_new0 (CoglPipelineBackendGlslPrivate); + set_glsl_priv (pipeline, priv); } /* If we already have a valid GLSL program then we don't need to @@ -299,17 +299,17 @@ _cogl_material_backend_glsl_start (CoglMaterial *material, { /* If we don't have an associated glsl program yet then find the * glsl-authority (the oldest ancestor whose state will result in - * the same program being generated as for this material). + * the same program being generated as for this pipeline). * * We always make sure to associate new programs with the - * glsl-authority to maximize the chance that other materials can + * glsl-authority to maximize the chance that other pipelines can * share it. */ - authority = find_glsl_authority (material, user_program); + authority = find_glsl_authority (pipeline, user_program); authority_priv = get_glsl_priv (authority); if (!authority_priv) { - authority_priv = g_slice_new0 (CoglMaterialBackendGlslPrivate); + authority_priv = g_slice_new0 (CoglPipelineBackendGlslPrivate); set_glsl_priv (authority, authority_priv); } @@ -322,10 +322,10 @@ _cogl_material_backend_glsl_start (CoglMaterial *material, glsl_program_state_new (n_layers); authority_priv->glsl_program_state = glsl_program_state; - /* If the material isn't actually its own glsl-authority + /* If the pipeline isn't actually its own glsl-authority * then take a reference to the program state associated * with the glsl-authority... */ - if (authority != material) + if (authority != pipeline) priv->glsl_program_state = glsl_program_state_ref (authority_priv->glsl_program_state); } @@ -359,24 +359,24 @@ _cogl_material_backend_glsl_start (CoglMaterial *material, } gboolean -_cogl_material_backend_glsl_add_layer (CoglMaterial *material, - CoglMaterialLayer *layer, +_cogl_pipeline_backend_glsl_add_layer (CoglPipeline *pipeline, + CoglPipelineLayer *layer, unsigned long layers_difference) { return TRUE; } gboolean -_cogl_material_backend_glsl_passthrough (CoglMaterial *material) +_cogl_pipeline_backend_glsl_passthrough (CoglPipeline *pipeline) { return TRUE; } gboolean -_cogl_material_backend_glsl_end (CoglMaterial *material, - unsigned long materials_difference) +_cogl_pipeline_backend_glsl_end (CoglPipeline *pipeline, + unsigned long pipelines_difference) { - GlslProgramState *glsl_program_state = get_glsl_program_state (material); + GlslProgramState *glsl_program_state = get_glsl_program_state (pipeline); GLuint gl_program; gboolean gl_program_changed; @@ -396,10 +396,10 @@ _cogl_material_backend_glsl_end (CoglMaterial *material, gl_program_changed = TRUE; } #else - _cogl_use_program (gl_program, COGL_MATERIAL_PROGRAM_TYPE_GLSL); + _cogl_use_program (gl_program, COGL_PIPELINE_PROGRAM_TYPE_GLSL); #endif - _cogl_program_flush_uniforms (cogl_material_get_user_program (material), + _cogl_program_flush_uniforms (cogl_pipeline_get_user_program (pipeline), gl_program, gl_program_changed); glsl_program_state->gl_program_changed = FALSE; @@ -408,45 +408,45 @@ _cogl_material_backend_glsl_end (CoglMaterial *material, } static void -_cogl_material_backend_glsl_pre_change_notify (CoglMaterial *material, - CoglMaterialState change, +_cogl_pipeline_backend_glsl_pre_change_notify (CoglPipeline *pipeline, + CoglPipelineState change, const CoglColor *new_color) { static const unsigned long glsl_op_changes = - COGL_MATERIAL_STATE_USER_SHADER; + COGL_PIPELINE_STATE_USER_SHADER; if (!(change & glsl_op_changes)) return; - dirty_glsl_program_state (material); + dirty_glsl_program_state (pipeline); } static void -_cogl_material_backend_glsl_free_priv (CoglMaterial *material) +_cogl_pipeline_backend_glsl_free_priv (CoglPipeline *pipeline) { - CoglMaterialBackendGlslPrivate *priv = get_glsl_priv (material); + CoglPipelineBackendGlslPrivate *priv = get_glsl_priv (pipeline); if (priv) { if (priv->glsl_program_state) glsl_program_state_unref (priv->glsl_program_state); - g_slice_free (CoglMaterialBackendGlslPrivate, priv); - set_glsl_priv (material, NULL); + g_slice_free (CoglPipelineBackendGlslPrivate, priv); + set_glsl_priv (pipeline, NULL); } } -const CoglMaterialBackend _cogl_material_glsl_backend = +const CoglPipelineBackend _cogl_pipeline_glsl_backend = { - _cogl_material_backend_glsl_get_max_texture_units, - _cogl_material_backend_glsl_start, - _cogl_material_backend_glsl_add_layer, - _cogl_material_backend_glsl_passthrough, - _cogl_material_backend_glsl_end, - _cogl_material_backend_glsl_pre_change_notify, - NULL, /* material_set_parent_notify */ + _cogl_pipeline_backend_glsl_get_max_texture_units, + _cogl_pipeline_backend_glsl_start, + _cogl_pipeline_backend_glsl_add_layer, + _cogl_pipeline_backend_glsl_passthrough, + _cogl_pipeline_backend_glsl_end, + _cogl_pipeline_backend_glsl_pre_change_notify, + NULL, /* pipeline_set_parent_notify */ NULL, /* layer_pre_change_notify */ - _cogl_material_backend_glsl_free_priv, + _cogl_pipeline_backend_glsl_free_priv, NULL /* free_layer_priv */ }; -#endif /* COGL_MATERIAL_BACKEND_GLSL */ +#endif /* COGL_PIPELINE_BACKEND_GLSL */ diff --git a/clutter/cogl/cogl/cogl-material-opengl-private.h b/clutter/cogl/cogl/cogl-pipeline-opengl-private.h similarity index 87% rename from clutter/cogl/cogl/cogl-material-opengl-private.h rename to clutter/cogl/cogl/cogl-pipeline-opengl-private.h index d12a555db..21bf0c5e9 100644 --- a/clutter/cogl/cogl/cogl-material-opengl-private.h +++ b/clutter/cogl/cogl/cogl-pipeline-opengl-private.h @@ -25,15 +25,16 @@ * Robert Bragg */ -#ifndef __COGL_MATERIAL_OPENGL_PRIVATE_H -#define __COGL_MATERIAL_OPENGL_PRIVATE_H +#ifndef __COGL_PIPELINE_OPENGL_PRIVATE_H +#define __COGL_PIPELINE_OPENGL_PRIVATE_H #include "cogl.h" +#include "cogl-pipeline-private.h" #include "cogl-matrix-stack.h" /* - * cogl-material.c owns the GPU's texture unit state so we have some + * cogl-pipeline.c owns the GPU's texture unit state so we have some * private structures for describing the current state of a texture * unit that we track in a per context array (ctx->texture_units) that * grows according to the largest texture unit used so far... @@ -41,7 +42,7 @@ * Roughly speaking the members in this structure are of two kinds: * either they are a low level reflection of the state we send to * OpenGL or they are for high level meta data assoicated with the - * texture unit when flushing CoglMaterialLayers that is typically + * texture unit when flushing CoglPipelineLayers that is typically * used to optimize subsequent re-flushing of the same layer. * * The low level members are at the top, and the high level members @@ -79,7 +80,7 @@ typedef struct _CoglTextureUnit * to track when the unit->gl_texture state is out of sync with the GL * texture object really bound too (GL_TEXTURE0+unit->index). * - * XXX: as a further optimization cogl-material.c uses a convention + * XXX: as a further optimization cogl-pipeline.c uses a convention * of always using texture unit 1 for these transient bindings so we * can assume this is only ever TRUE for unit 1. */ @@ -93,14 +94,14 @@ typedef struct _CoglTextureUnit * Higher level layer state associated with the unit... */ - /* The CoglMaterialLayer whos state was flushed to update this + /* The CoglPipelineLayer whos state was flushed to update this * texture unit last. * * This will be set to NULL if the layer is modified or freed which * means when we come to flush a layer; if this pointer is still * valid and == to the layer being flushed we don't need to update * any texture unit state. */ - CoglMaterialLayer *layer; + CoglPipelineLayer *layer; /* To help minimize the state changes required we track the * difference flags associated with the layer whos state was last @@ -114,12 +115,12 @@ typedef struct _CoglTextureUnit unsigned long layer_changes_since_flush; /* Whenever a CoglTexture's internal GL texture storage changes - * cogl-material.c is notified with a call to - * _cogl_material_texture_storage_change_notify which inturn sets + * cogl-pipeline.c is notified with a call to + * _cogl_pipeline_texture_storage_change_notify which inturn sets * this to TRUE for each texture unit that it is currently bound - * too. When we later come to flush some material state then we will + * too. When we later come to flush some pipeline state then we will * always check this to potentially force an update of the texture - * state even if the material hasn't changed. */ + * state even if the pipeline hasn't changed. */ gboolean texture_storage_changed; } CoglTextureUnit; @@ -148,8 +149,8 @@ void _cogl_gl_use_program_wrapper (CoglHandle program); void -_cogl_material_flush_gl_state (CoglMaterial *material, +_cogl_pipeline_flush_gl_state (CoglPipeline *pipeline, gboolean skip_gl_state); -#endif /* __COGL_MATERIAL_OPENGL_PRIVATE_H */ +#endif /* __COGL_PIPELINE_OPENGL_PRIVATE_H */ diff --git a/clutter/cogl/cogl/cogl-material-opengl.c b/clutter/cogl/cogl/cogl-pipeline-opengl.c similarity index 79% rename from clutter/cogl/cogl/cogl-material-opengl.c rename to clutter/cogl/cogl/cogl-pipeline-opengl.c index 7b7f85baa..7c2d1d77b 100644 --- a/clutter/cogl/cogl/cogl-material-opengl.c +++ b/clutter/cogl/cogl/cogl-pipeline-opengl.c @@ -32,26 +32,26 @@ #include "cogl.h" #include "cogl-debug.h" -#include "cogl-material-opengl-private.h" -#include "cogl-material-private.h" +#include "cogl-pipeline-opengl-private.h" +#include "cogl-pipeline-private.h" #include "cogl-context.h" #include "cogl-texture-private.h" -#ifdef COGL_MATERIAL_BACKEND_GLSL -#include "cogl-material-glsl-private.h" +#ifdef COGL_PIPELINE_BACKEND_GLSL +#include "cogl-pipeline-glsl-private.h" #endif -#ifdef COGL_MATERIAL_BACKEND_ARBFP -#include "cogl-material-arbfp-private.h" +#ifdef COGL_PIPELINE_BACKEND_ARBFP +#include "cogl-pipeline-arbfp-private.h" #endif -#ifdef COGL_MATERIAL_BACKEND_FIXED -#include "cogl-material-fixed-private.h" +#ifdef COGL_PIPELINE_BACKEND_FIXED +#include "cogl-pipeline-fixed-private.h" #endif #include #include /* - * GL/GLES compatability defines for material thingies: + * GL/GLES compatability defines for pipeline thingies: */ #ifdef HAVE_COGL_GLES2 @@ -258,7 +258,7 @@ _cogl_delete_gl_texture (GLuint gl_texture) * if it is reused again with the same texture unit. */ void -_cogl_material_texture_storage_change_notify (CoglHandle texture) +_cogl_pipeline_texture_storage_change_notify (CoglHandle texture) { int i; @@ -270,7 +270,7 @@ _cogl_material_texture_storage_change_notify (CoglHandle texture) &g_array_index (ctx->texture_units, CoglTextureUnit, i); if (unit->layer && - _cogl_material_layer_get_texture (unit->layer) == texture) + _cogl_pipeline_layer_get_texture (unit->layer) == texture) unit->texture_storage_changed = TRUE; /* NB: the texture may be bound to multiple texture units so @@ -279,7 +279,7 @@ _cogl_material_texture_storage_change_notify (CoglHandle texture) } void -_cogl_use_program (GLuint gl_program, CoglMaterialProgramType type) +_cogl_use_program (GLuint gl_program, CoglPipelineProgramType type) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -289,18 +289,18 @@ _cogl_use_program (GLuint gl_program, CoglMaterialProgramType type) /* ... disable the old type */ switch (ctx->current_use_program_type) { - case COGL_MATERIAL_PROGRAM_TYPE_GLSL: + case COGL_PIPELINE_PROGRAM_TYPE_GLSL: GE( glUseProgram (0) ); ctx->current_gl_program = 0; break; - case COGL_MATERIAL_PROGRAM_TYPE_ARBFP: + case COGL_PIPELINE_PROGRAM_TYPE_ARBFP: #ifdef HAVE_COGL_GL GE( glDisable (GL_FRAGMENT_PROGRAM_ARB) ); #endif break; - case COGL_MATERIAL_PROGRAM_TYPE_FIXED: + case COGL_PIPELINE_PROGRAM_TYPE_FIXED: /* don't need to to anything */ break; } @@ -308,22 +308,22 @@ _cogl_use_program (GLuint gl_program, CoglMaterialProgramType type) /* ... and enable the new type */ switch (type) { - case COGL_MATERIAL_PROGRAM_TYPE_ARBFP: + case COGL_PIPELINE_PROGRAM_TYPE_ARBFP: #ifdef HAVE_COGL_GL GE( glEnable (GL_FRAGMENT_PROGRAM_ARB) ); #endif break; - case COGL_MATERIAL_PROGRAM_TYPE_GLSL: - case COGL_MATERIAL_PROGRAM_TYPE_FIXED: + case COGL_PIPELINE_PROGRAM_TYPE_GLSL: + case COGL_PIPELINE_PROGRAM_TYPE_FIXED: /* don't need to to anything */ break; } } - if (type == COGL_MATERIAL_PROGRAM_TYPE_GLSL) + if (type == COGL_PIPELINE_PROGRAM_TYPE_GLSL) { -#ifdef COGL_MATERIAL_BACKEND_GLSL +#ifdef COGL_PIPELINE_BACKEND_GLSL if (ctx->current_gl_program != gl_program) { @@ -345,18 +345,18 @@ _cogl_use_program (GLuint gl_program, CoglMaterialProgramType type) g_warning ("Unexpected use of GLSL backend!"); -#endif /* COGL_MATERIAL_BACKEND_GLSL */ +#endif /* COGL_PIPELINE_BACKEND_GLSL */ } -#ifndef COGL_MATERIAL_BACKEND_ARBFP - else if (type == COGL_MATERIAL_PROGRAM_TYPE_ARBFP) +#ifndef COGL_PIPELINE_BACKEND_ARBFP + else if (type == COGL_PIPELINE_PROGRAM_TYPE_ARBFP) g_warning ("Unexpected use of ARBFP backend!"); -#endif /* COGL_MATERIAL_BACKEND_ARBFP */ +#endif /* COGL_PIPELINE_BACKEND_ARBFP */ ctx->current_use_program_type = type; } -#if defined (COGL_MATERIAL_BACKEND_GLSL) || \ - defined (COGL_MATERIAL_BACKEND_ARBFP) +#if defined (COGL_PIPELINE_BACKEND_GLSL) || \ + defined (COGL_PIPELINE_BACKEND_ARBFP) int _cogl_get_max_texture_image_units (void) { @@ -376,7 +376,7 @@ _cogl_get_max_texture_image_units (void) #endif static void -_cogl_material_layer_get_texture_info (CoglMaterialLayer *layer, +_cogl_pipeline_layer_get_texture_info (CoglPipelineLayer *layer, CoglHandle *texture, GLuint *gl_texture, GLuint *gl_target) @@ -409,7 +409,7 @@ blend_factor_uses_constant (GLenum blend_factor) #endif static void -flush_depth_state (CoglMaterialDepthState *depth_state) +flush_depth_state (CoglPipelineDepthState *depth_state) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -444,22 +444,22 @@ flush_depth_state (CoglMaterialDepthState *depth_state) } static void -_cogl_material_flush_color_blend_alpha_depth_state ( - CoglMaterial *material, - unsigned long materials_difference, +_cogl_pipeline_flush_color_blend_alpha_depth_state ( + CoglPipeline *pipeline, + unsigned long pipelines_difference, gboolean skip_gl_color) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); if (!skip_gl_color) { - if ((materials_difference & COGL_MATERIAL_STATE_COLOR) || + if ((pipelines_difference & COGL_PIPELINE_STATE_COLOR) || /* Assume if we were previously told to skip the color, then * the current color needs updating... */ - ctx->current_material_skip_gl_color) + ctx->current_pipeline_skip_gl_color) { - CoglMaterial *authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_COLOR); + CoglPipeline *authority = + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_COLOR); GE (glColor4ub (cogl_color_get_red_byte (&authority->color), cogl_color_get_green_byte (&authority->color), cogl_color_get_blue_byte (&authority->color), @@ -467,11 +467,11 @@ _cogl_material_flush_color_blend_alpha_depth_state ( } } - if (materials_difference & COGL_MATERIAL_STATE_LIGHTING) + if (pipelines_difference & COGL_PIPELINE_STATE_LIGHTING) { - CoglMaterial *authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_LIGHTING); - CoglMaterialLightingState *lighting_state = + CoglPipeline *authority = + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LIGHTING); + CoglPipelineLightingState *lighting_state = &authority->big_state->lighting_state; GE (glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT, lighting_state->ambient)); @@ -482,11 +482,11 @@ _cogl_material_flush_color_blend_alpha_depth_state ( &lighting_state->shininess)); } - if (materials_difference & COGL_MATERIAL_STATE_BLEND) + if (pipelines_difference & COGL_PIPELINE_STATE_BLEND) { - CoglMaterial *authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_BLEND); - CoglMaterialBlendState *blend_state = + CoglPipeline *authority = + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_BLEND); + CoglPipelineBlendState *blend_state = &authority->big_state->blend_state; #if defined (HAVE_COGL_GLES2) @@ -541,11 +541,11 @@ _cogl_material_flush_color_blend_alpha_depth_state ( blend_state->blend_dst_factor_rgb)); } - if (materials_difference & COGL_MATERIAL_STATE_ALPHA_FUNC) + if (pipelines_difference & COGL_PIPELINE_STATE_ALPHA_FUNC) { - CoglMaterial *authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_ALPHA_FUNC); - CoglMaterialAlphaFuncState *alpha_state = + CoglPipeline *authority = + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_ALPHA_FUNC); + CoglPipelineAlphaFuncState *alpha_state = &authority->big_state->alpha_state; /* NB: Currently the Cogl defines are compatible with the GL ones: */ @@ -553,11 +553,11 @@ _cogl_material_flush_color_blend_alpha_depth_state ( alpha_state->alpha_func_reference)); } - if (materials_difference & COGL_MATERIAL_STATE_DEPTH) + if (pipelines_difference & COGL_PIPELINE_STATE_DEPTH) { - CoglMaterial *authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_DEPTH); - CoglMaterialDepthState *depth_state = &authority->big_state->depth_state; + CoglPipeline *authority = + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_DEPTH); + CoglPipelineDepthState *depth_state = &authority->big_state->depth_state; if (depth_state->depth_test_enabled) { @@ -575,10 +575,10 @@ _cogl_material_flush_color_blend_alpha_depth_state ( } } - if (materials_difference & COGL_MATERIAL_STATE_POINT_SIZE) + if (pipelines_difference & COGL_PIPELINE_STATE_POINT_SIZE) { - CoglMaterial *authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_POINT_SIZE); + CoglPipeline *authority = + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_POINT_SIZE); if (ctx->point_size_cache != authority->big_state->point_size) { @@ -587,15 +587,15 @@ _cogl_material_flush_color_blend_alpha_depth_state ( } } - if (material->real_blend_enable != ctx->gl_blend_enable_cache) + if (pipeline->real_blend_enable != ctx->gl_blend_enable_cache) { - if (material->real_blend_enable) + if (pipeline->real_blend_enable) GE (glEnable (GL_BLEND)); else GE (glDisable (GL_BLEND)); /* XXX: we shouldn't update any other blend state if blending * is disabled! */ - ctx->gl_blend_enable_cache = material->real_blend_enable; + ctx->gl_blend_enable_cache = pipeline->real_blend_enable; } } @@ -627,12 +627,12 @@ typedef struct { int i; unsigned long *layer_differences; -} CoglMaterialFlushLayerState; +} CoglPipelineFlushLayerState; static gboolean -flush_layers_common_gl_state_cb (CoglMaterialLayer *layer, void *user_data) +flush_layers_common_gl_state_cb (CoglPipelineLayer *layer, void *user_data) { - CoglMaterialFlushLayerState *flush_state = user_data; + CoglPipelineFlushLayerState *flush_state = user_data; int unit_index = flush_state->i; CoglTextureUnit *unit = _cogl_get_texture_unit (unit_index); unsigned long layers_difference = @@ -654,16 +654,16 @@ flush_layers_common_gl_state_cb (CoglMaterialLayer *layer, void *user_data) return FALSE; } - if (layers_difference & COGL_MATERIAL_LAYER_STATE_TEXTURE) + if (layers_difference & COGL_PIPELINE_LAYER_STATE_TEXTURE) { - CoglMaterialLayer *authority = - _cogl_material_layer_get_authority (layer, - COGL_MATERIAL_LAYER_STATE_TEXTURE); + CoglPipelineLayer *authority = + _cogl_pipeline_layer_get_authority (layer, + COGL_PIPELINE_LAYER_STATE_TEXTURE); CoglHandle texture = NULL; GLuint gl_texture; GLenum gl_target; - _cogl_material_layer_get_texture_info (authority, + _cogl_pipeline_layer_get_texture_info (authority, &texture, &gl_texture, &gl_target); @@ -679,7 +679,7 @@ flush_layers_common_gl_state_cb (CoglMaterialLayer *layer, void *user_data) * * Because texture unit 1 is a bit special we actually defer any * necessary glBindTexture for it until the end of - * _cogl_material_flush_gl_state(). + * _cogl_pipeline_flush_gl_state(). * * NB: we get notified whenever glDeleteTextures is used (see * _cogl_delete_gl_texture()) where we invalidate @@ -740,11 +740,11 @@ flush_layers_common_gl_state_cb (CoglMaterialLayer *layer, void *user_data) } } - if (layers_difference & COGL_MATERIAL_LAYER_STATE_USER_MATRIX) + if (layers_difference & COGL_PIPELINE_LAYER_STATE_USER_MATRIX) { - CoglMaterialLayerState state = COGL_MATERIAL_LAYER_STATE_USER_MATRIX; - CoglMaterialLayer *authority = - _cogl_material_layer_get_authority (layer, state); + CoglPipelineLayerState state = COGL_PIPELINE_LAYER_STATE_USER_MATRIX; + CoglPipelineLayer *authority = + _cogl_pipeline_layer_get_authority (layer, state); _cogl_matrix_stack_set (unit->matrix_stack, &authority->big_state->matrix); @@ -752,12 +752,12 @@ flush_layers_common_gl_state_cb (CoglMaterialLayer *layer, void *user_data) _cogl_matrix_stack_flush_to_gl (unit->matrix_stack, COGL_MATRIX_TEXTURE); } - if (layers_difference & COGL_MATERIAL_LAYER_STATE_POINT_SPRITE_COORDS) + if (layers_difference & COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS) { - CoglMaterialState change = COGL_MATERIAL_LAYER_STATE_POINT_SPRITE_COORDS; - CoglMaterialLayer *authority = - _cogl_material_layer_get_authority (layer, change); - CoglMaterialLayerBigState *big_state = authority->big_state; + CoglPipelineState change = COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS; + CoglPipelineLayer *authority = + _cogl_pipeline_layer_get_authority (layer, change); + CoglPipelineLayerBigState *big_state = authority->big_state; _cogl_set_active_texture_unit (unit_index); @@ -778,22 +778,22 @@ flush_layers_common_gl_state_cb (CoglMaterialLayer *layer, void *user_data) } static void -_cogl_material_flush_common_gl_state (CoglMaterial *material, - unsigned long materials_difference, +_cogl_pipeline_flush_common_gl_state (CoglPipeline *pipeline, + unsigned long pipelines_difference, unsigned long *layer_differences, gboolean skip_gl_color) { - CoglMaterialFlushLayerState state; + CoglPipelineFlushLayerState state; _COGL_GET_CONTEXT (ctx, NO_RETVAL); - _cogl_material_flush_color_blend_alpha_depth_state (material, - materials_difference, + _cogl_pipeline_flush_color_blend_alpha_depth_state (pipeline, + pipelines_difference, skip_gl_color); state.i = 0; state.layer_differences = layer_differences; - _cogl_material_foreach_layer_internal (material, + _cogl_pipeline_foreach_layer_internal (pipeline, flush_layers_common_gl_state_cb, &state); @@ -808,16 +808,16 @@ _cogl_material_flush_common_gl_state (CoglMaterial *material, * since the actual texture being used may have been overridden. */ static void -_cogl_material_layer_forward_wrap_modes (CoglMaterialLayer *layer, +_cogl_pipeline_layer_forward_wrap_modes (CoglPipelineLayer *layer, CoglHandle texture) { - CoglMaterialWrapModeInternal wrap_mode_s, wrap_mode_t, wrap_mode_p; + CoglPipelineWrapModeInternal wrap_mode_s, wrap_mode_t, wrap_mode_p; GLenum gl_wrap_mode_s, gl_wrap_mode_t, gl_wrap_mode_p; if (texture == COGL_INVALID_HANDLE) return; - _cogl_material_layer_get_wrap_modes (layer, + _cogl_pipeline_layer_get_wrap_modes (layer, &wrap_mode_s, &wrap_mode_t, &wrap_mode_p); @@ -833,17 +833,17 @@ _cogl_material_layer_forward_wrap_modes (CoglMaterialLayer *layer, will break if the application tries to use different modes in different layers using the same texture. */ - if (wrap_mode_s == COGL_MATERIAL_WRAP_MODE_INTERNAL_AUTOMATIC) + if (wrap_mode_s == COGL_PIPELINE_WRAP_MODE_INTERNAL_AUTOMATIC) gl_wrap_mode_s = GL_CLAMP_TO_EDGE; else gl_wrap_mode_s = wrap_mode_s; - if (wrap_mode_t == COGL_MATERIAL_WRAP_MODE_INTERNAL_AUTOMATIC) + if (wrap_mode_t == COGL_PIPELINE_WRAP_MODE_INTERNAL_AUTOMATIC) gl_wrap_mode_t = GL_CLAMP_TO_EDGE; else gl_wrap_mode_t = wrap_mode_t; - if (wrap_mode_p == COGL_MATERIAL_WRAP_MODE_INTERNAL_AUTOMATIC) + if (wrap_mode_p == COGL_PIPELINE_WRAP_MODE_INTERNAL_AUTOMATIC) gl_wrap_mode_p = GL_CLAMP_TO_EDGE; else gl_wrap_mode_p = wrap_mode_p; @@ -857,7 +857,7 @@ _cogl_material_layer_forward_wrap_modes (CoglMaterialLayer *layer, /* OpenGL associates the min/mag filters and repeat modes with the * texture object not the texture unit so we always have to re-assert * the filter and repeat modes whenever we use a texture since it may - * be referenced by multiple materials with different modes. + * be referenced by multiple pipelines with different modes. * * XXX: GL_ARB_sampler_objects fixes this in OpenGL so we should * eventually look at using this extension when available. @@ -879,14 +879,14 @@ foreach_texture_unit_update_filter_and_wrap_modes (void) if (unit->layer) { - CoglHandle texture = _cogl_material_layer_get_texture (unit->layer); - CoglMaterialFilter min; - CoglMaterialFilter mag; + CoglHandle texture = _cogl_pipeline_layer_get_texture (unit->layer); + CoglPipelineFilter min; + CoglPipelineFilter mag; - _cogl_material_layer_get_filters (unit->layer, &min, &mag); + _cogl_pipeline_layer_get_filters (unit->layer, &min, &mag); _cogl_texture_set_filters (texture, min, mag); - _cogl_material_layer_forward_wrap_modes (unit->layer, texture); + _cogl_pipeline_layer_forward_wrap_modes (unit->layer, texture); } } } @@ -895,12 +895,12 @@ typedef struct { int i; unsigned long *layer_differences; -} CoglMaterialCompareLayersState; +} CoglPipelineCompareLayersState; static gboolean -compare_layer_differences_cb (CoglMaterialLayer *layer, void *user_data) +compare_layer_differences_cb (CoglPipelineLayer *layer, void *user_data) { - CoglMaterialCompareLayersState *state = user_data; + CoglPipelineCompareLayersState *state = user_data; CoglTextureUnit *unit = _cogl_get_texture_unit (state->i); if (unit->layer == layer) @@ -909,21 +909,21 @@ compare_layer_differences_cb (CoglMaterialLayer *layer, void *user_data) { state->layer_differences[state->i] = unit->layer_changes_since_flush; state->layer_differences[state->i] |= - _cogl_material_layer_compare_differences (layer, unit->layer); + _cogl_pipeline_layer_compare_differences (layer, unit->layer); } else - state->layer_differences[state->i] = COGL_MATERIAL_LAYER_STATE_ALL_SPARSE; + state->layer_differences[state->i] = COGL_PIPELINE_LAYER_STATE_ALL_SPARSE; /* XXX: There is always a possibility that a CoglTexture's * underlying GL texture storage has been changed since it was last * bound to a texture unit which is why we have a callback into - * _cogl_material_texture_storage_change_notify whenever a textures + * _cogl_pipeline_texture_storage_change_notify whenever a textures * underlying GL texture storage changes which will set the * unit->texture_intern_changed flag. If we see that's been set here * then we force an update of the texture state... */ if (unit->texture_storage_changed) - state->layer_differences[state->i] |= COGL_MATERIAL_LAYER_STATE_TEXTURE; + state->layer_differences[state->i] |= COGL_PIPELINE_LAYER_STATE_TEXTURE; state->i++; @@ -932,22 +932,22 @@ compare_layer_differences_cb (CoglMaterialLayer *layer, void *user_data) typedef struct { - const CoglMaterialBackend *backend; - CoglMaterial *material; + const CoglPipelineBackend *backend; + CoglPipeline *pipeline; unsigned long *layer_differences; gboolean error_adding_layer; gboolean added_layer; -} CoglMaterialBackendAddLayerState; +} CoglPipelineBackendAddLayerState; static gboolean -backend_add_layer_cb (CoglMaterialLayer *layer, +backend_add_layer_cb (CoglPipelineLayer *layer, void *user_data) { - CoglMaterialBackendAddLayerState *state = user_data; - const CoglMaterialBackend *backend = state->backend; - CoglMaterial *material = state->material; - int unit_index = _cogl_material_layer_get_unit_index (layer); + CoglPipelineBackendAddLayerState *state = user_data; + const CoglPipelineBackend *backend = state->backend; + CoglPipeline *pipeline = state->pipeline; + int unit_index = _cogl_pipeline_layer_get_unit_index (layer); CoglTextureUnit *unit = _cogl_get_texture_unit (unit_index); _COGL_GET_CONTEXT (ctx, FALSE); @@ -971,7 +971,7 @@ backend_add_layer_cb (CoglMaterialLayer *layer, /* Either generate per layer code snippets or setup the * fixed function glTexEnv for each layer... */ - if (G_LIKELY (backend->add_layer (material, + if (G_LIKELY (backend->add_layer (pipeline, layer, state->layer_differences[unit_index]))) state->added_layer = TRUE; @@ -985,10 +985,10 @@ backend_add_layer_cb (CoglMaterialLayer *layer, } /* - * _cogl_material_flush_gl_state: + * _cogl_pipeline_flush_gl_state: * * Details of override options: - * ->fallback_mask: is a bitmask of the material layers that need to be + * ->fallback_mask: is a bitmask of the pipeline layers that need to be * replaced with the default, fallback textures. The fallback textures are * fully transparent textures so they hopefully wont contribute to the * texture combining. @@ -999,7 +999,7 @@ backend_add_layer_cb (CoglMaterialLayer *layer, * have a fighting chance of looking close to their originally intended * result. * - * ->disable_mask: is a bitmask of the material layers that will simply have + * ->disable_mask: is a bitmask of the pipeline layers that will simply have * texturing disabled. It's only really intended for disabling all layers * > X; i.e. we'd expect to see a contiguous run of 0 starting from the LSB * and at some point the remaining bits flip to 1. It might work to disable @@ -1016,7 +1016,7 @@ backend_add_layer_cb (CoglMaterialLayer *layer, * 0. * * The intention of this is for any primitives that supports sliced textures. - * The code will can iterate each of the slices and re-flush the material + * The code will can iterate each of the slices and re-flush the pipeline * forcing the GL texture of each slice in turn. * * ->wrap_mode_overrides: overrides the wrap modes set on each @@ -1035,16 +1035,16 @@ backend_add_layer_cb (CoglMaterialLayer *layer, * isn't ideal, and can't be used with CoglVertexBuffers. */ void -_cogl_material_flush_gl_state (CoglMaterial *material, +_cogl_pipeline_flush_gl_state (CoglPipeline *pipeline, gboolean skip_gl_color) { - unsigned long materials_difference; + unsigned long pipelines_difference; int n_layers; unsigned long *layer_differences; int i; CoglTextureUnit *unit1; - COGL_STATIC_TIMER (material_flush_timer, + COGL_STATIC_TIMER (pipeline_flush_timer, "Mainloop", /* parent */ "Material Flush", "The time spent flushing material state", @@ -1052,37 +1052,37 @@ _cogl_material_flush_gl_state (CoglMaterial *material, _COGL_GET_CONTEXT (ctx, NO_RETVAL); - COGL_TIMER_START (_cogl_uprof_context, material_flush_timer); + COGL_TIMER_START (_cogl_uprof_context, pipeline_flush_timer); - if (ctx->current_material == material) + if (ctx->current_pipeline == pipeline) { /* Bail out asap if we've been asked to re-flush the already current - * material and we can see the material hasn't changed */ - if (ctx->current_material_age == material->age) + * pipeline and we can see the pipeline hasn't changed */ + if (ctx->current_pipeline_age == pipeline->age) goto done; - materials_difference = ctx->current_material_changes_since_flush; + pipelines_difference = ctx->current_pipeline_changes_since_flush; } - else if (ctx->current_material) + else if (ctx->current_pipeline) { - materials_difference = ctx->current_material_changes_since_flush; - materials_difference |= - _cogl_material_compare_differences (ctx->current_material, - material); + pipelines_difference = ctx->current_pipeline_changes_since_flush; + pipelines_difference |= + _cogl_pipeline_compare_differences (ctx->current_pipeline, + pipeline); } else - materials_difference = COGL_MATERIAL_STATE_ALL_SPARSE; + pipelines_difference = COGL_PIPELINE_STATE_ALL_SPARSE; /* Get a layer_differences mask for each layer to be flushed */ - n_layers = cogl_material_get_n_layers (material); + n_layers = cogl_pipeline_get_n_layers (pipeline); if (n_layers) { - CoglMaterialCompareLayersState state; + CoglPipelineCompareLayersState state; layer_differences = g_alloca (sizeof (unsigned long *) * n_layers); memset (layer_differences, 0, sizeof (layer_differences)); state.i = 0; state.layer_differences = layer_differences; - _cogl_material_foreach_layer_internal (material, + _cogl_pipeline_foreach_layer_internal (pipeline, compare_layer_differences_cb, &state); } @@ -1090,7 +1090,7 @@ _cogl_material_flush_gl_state (CoglMaterial *material, layer_differences = NULL; /* First flush everything that's the same regardless of which - * material backend is being used... + * pipeline backend is being used... * * 1) top level state: * glColor (or skip if a vertex attribute is being used for color) @@ -1103,51 +1103,51 @@ _cogl_material_flush_gl_state (CoglMaterial *material, * enable/disable target * flush user matrix * - * Note: After _cogl_material_flush_common_gl_state you can expect + * Note: After _cogl_pipeline_flush_common_gl_state you can expect * all state of the layers corresponding texture unit to be * updated. */ - _cogl_material_flush_common_gl_state (material, - materials_difference, + _cogl_pipeline_flush_common_gl_state (pipeline, + pipelines_difference, layer_differences, skip_gl_color); /* Now flush the fragment processing state according to the current * fragment processing backend. * - * Note: Some of the backends may not support the current material + * Note: Some of the backends may not support the current pipeline * configuration and in that case it will report an error and we * will fallback to a different backend. * - * NB: if material->backend != COGL_MATERIAL_BACKEND_UNDEFINED then - * we have previously managed to successfully flush this material + * NB: if pipeline->backend != COGL_PIPELINE_BACKEND_UNDEFINED then + * we have previously managed to successfully flush this pipeline * with the given backend so we will simply use that to avoid * fallback code paths. */ - if (material->backend == COGL_MATERIAL_BACKEND_UNDEFINED) - _cogl_material_set_backend (material, COGL_MATERIAL_BACKEND_DEFAULT); + if (pipeline->backend == COGL_PIPELINE_BACKEND_UNDEFINED) + _cogl_pipeline_set_backend (pipeline, COGL_PIPELINE_BACKEND_DEFAULT); - for (i = material->backend; - i < G_N_ELEMENTS (_cogl_material_backends); - i++, _cogl_material_set_backend (material, i)) + for (i = pipeline->backend; + i < G_N_ELEMENTS (_cogl_pipeline_backends); + i++, _cogl_pipeline_set_backend (pipeline, i)) { - const CoglMaterialBackend *backend = _cogl_material_backends[i]; - CoglMaterialBackendAddLayerState state; + const CoglPipelineBackend *backend = _cogl_pipeline_backends[i]; + CoglPipelineBackendAddLayerState state; /* E.g. For backends generating code they can setup their * scratch buffers here... */ - if (G_UNLIKELY (!backend->start (material, + if (G_UNLIKELY (!backend->start (pipeline, n_layers, - materials_difference))) + pipelines_difference))) continue; state.backend = backend; - state.material = material; + state.pipeline = pipeline; state.layer_differences = layer_differences; state.error_adding_layer = FALSE; state.added_layer = FALSE; - _cogl_material_foreach_layer_internal (material, + _cogl_pipeline_foreach_layer_internal (pipeline, backend_add_layer_cb, &state); @@ -1156,34 +1156,34 @@ _cogl_material_flush_gl_state (CoglMaterial *material, if (!state.added_layer && backend->passthrough && - G_UNLIKELY (!backend->passthrough (material))) + G_UNLIKELY (!backend->passthrough (pipeline))) continue; /* For backends generating code they may compile and link their * programs here, update any uniforms and tell OpenGL to use * that program. */ - if (G_UNLIKELY (!backend->end (material, materials_difference))) + if (G_UNLIKELY (!backend->end (pipeline, pipelines_difference))) continue; break; } /* FIXME: This reference is actually resulting in lots of - * copy-on-write reparenting because one-shot materials end up + * copy-on-write reparenting because one-shot pipelines end up * living for longer than necessary and so any later modification of * the parent will cause a copy-on-write. * * XXX: The issue should largely go away when we switch to using - * weak materials for overrides. + * weak pipelines for overrides. */ - cogl_object_ref (material); - if (ctx->current_material != NULL) - cogl_object_unref (ctx->current_material); - ctx->current_material = material; - ctx->current_material_changes_since_flush = 0; - ctx->current_material_skip_gl_color = skip_gl_color; - ctx->current_material_age = material->age; + cogl_object_ref (pipeline); + if (ctx->current_pipeline != NULL) + cogl_object_unref (ctx->current_pipeline); + ctx->current_pipeline = pipeline; + ctx->current_pipeline_changes_since_flush = 0; + ctx->current_pipeline_skip_gl_color = skip_gl_color; + ctx->current_pipeline_age = pipeline->age; done: @@ -1191,12 +1191,12 @@ done: * modes with the texture objects not the texture units... */ foreach_texture_unit_update_filter_and_wrap_modes (); - /* If this material has more than one layer then we always need + /* If this pipeline has more than one layer then we always need * to make sure we rebind the texture for unit 1. * * NB: various components of Cogl may temporarily bind arbitrary * textures to texture unit 1 so they can query and modify texture - * object parameters. cogl-material.c (See + * object parameters. cogl-pipeline.c (See * _cogl_bind_gl_texture_transient) */ unit1 = _cogl_get_texture_unit (1); @@ -1207,6 +1207,6 @@ done: unit1->dirty_gl_texture = FALSE; } - COGL_TIMER_STOP (_cogl_uprof_context, material_flush_timer); + COGL_TIMER_STOP (_cogl_uprof_context, pipeline_flush_timer); } diff --git a/clutter/cogl/cogl/cogl-pipeline-private.h b/clutter/cogl/cogl/cogl-pipeline-private.h new file mode 100644 index 000000000..955c3d767 --- /dev/null +++ b/clutter/cogl/cogl/cogl-pipeline-private.h @@ -0,0 +1,993 @@ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2008,2009,2010 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + * + * + * Authors: + * Robert Bragg + */ + +#ifndef __COGL_PIPELINE_PRIVATE_H +#define __COGL_PIPELINE_PRIVATE_H + +#include "cogl.h" + +#include "cogl-pipeline.h" +#include "cogl-matrix.h" +#include "cogl-object-private.h" +#include "cogl-profile.h" + +#include + +typedef struct _CoglPipelineLayer CoglPipelineLayer; +#define COGL_PIPELINE_LAYER(OBJECT) ((CoglPipelineLayer *)OBJECT) + +#if defined (HAVE_COGL_GL) + +/* NB: pipeline->backend is currently a 3bit unsigned int bitfield */ +#define COGL_PIPELINE_BACKEND_GLSL 0 +#define COGL_PIPELINE_BACKEND_GLSL_MASK (1L<<0) +#define COGL_PIPELINE_BACKEND_ARBFP 1 +#define COGL_PIPELINE_BACKEND_ARBFP_MASK (1L<<1) +#define COGL_PIPELINE_BACKEND_FIXED 2 +#define COGL_PIPELINE_BACKEND_FIXED_MASK (1L<<2) + +#define COGL_PIPELINE_N_BACKENDS 3 + +#elif defined (HAVE_COGL_GLES2) + +#define COGL_PIPELINE_BACKEND_GLSL 0 +#define COGL_PIPELINE_BACKEND_GLSL_MASK (1L<<0) +#define COGL_PIPELINE_BACKEND_FIXED 1 +#define COGL_PIPELINE_BACKEND_FIXED_MASK (1L<<1) + +#define COGL_PIPELINE_N_BACKENDS 2 + +#else /* HAVE_COGL_GLES */ + +#define COGL_PIPELINE_BACKEND_FIXED 0 +#define COGL_PIPELINE_BACKEND_FIXED_MASK (1L<<0) + +#define COGL_PIPELINE_N_BACKENDS 1 + +#endif + +#define COGL_PIPELINE_BACKEND_DEFAULT 0 +#define COGL_PIPELINE_BACKEND_UNDEFINED 3 + +typedef enum +{ + COGL_PIPELINE_LAYER_STATE_UNIT = 1L<<0, + COGL_PIPELINE_LAYER_STATE_TEXTURE = 1L<<1, + COGL_PIPELINE_LAYER_STATE_FILTERS = 1L<<2, + COGL_PIPELINE_LAYER_STATE_WRAP_MODES = 1L<<3, + + COGL_PIPELINE_LAYER_STATE_COMBINE = 1L<<4, + COGL_PIPELINE_LAYER_STATE_COMBINE_CONSTANT = 1L<<5, + COGL_PIPELINE_LAYER_STATE_USER_MATRIX = 1L<<6, + + COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS = 1L<<7, + + /* COGL_PIPELINE_LAYER_STATE_TEXTURE_INTERN = 1L<<8, */ + + COGL_PIPELINE_LAYER_STATE_ALL_SPARSE = + COGL_PIPELINE_LAYER_STATE_UNIT | + COGL_PIPELINE_LAYER_STATE_TEXTURE | + COGL_PIPELINE_LAYER_STATE_FILTERS | + COGL_PIPELINE_LAYER_STATE_WRAP_MODES | + COGL_PIPELINE_LAYER_STATE_COMBINE | + COGL_PIPELINE_LAYER_STATE_COMBINE_CONSTANT | + COGL_PIPELINE_LAYER_STATE_USER_MATRIX | + COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS, + + COGL_PIPELINE_LAYER_STATE_NEEDS_BIG_STATE = + COGL_PIPELINE_LAYER_STATE_COMBINE | + COGL_PIPELINE_LAYER_STATE_COMBINE_CONSTANT | + COGL_PIPELINE_LAYER_STATE_USER_MATRIX | + COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS, + +} CoglPipelineLayerState; + +typedef struct +{ + /* The texture combine state determines how the color of individual + * texture fragments are calculated. */ + GLint texture_combine_rgb_func; + GLint texture_combine_rgb_src[3]; + GLint texture_combine_rgb_op[3]; + + GLint texture_combine_alpha_func; + GLint texture_combine_alpha_src[3]; + GLint texture_combine_alpha_op[3]; + + float texture_combine_constant[4]; + + /* The texture matrix dscribes how to transform texture coordinates */ + CoglMatrix matrix; + + gboolean point_sprite_coords; + +} CoglPipelineLayerBigState; + +/* Materials and layers represent their state in a tree structure where + * some of the state relating to a given pipeline or layer may actually + * be owned by one if is ancestors in the tree. We have a common data + * type to track the tree heirachy so we can share code... */ +typedef struct _CoglPipelineNode CoglPipelineNode; +struct _CoglPipelineNode +{ + /* the parent in terms of class hierarchy, so anything inheriting + * from CoglPipelineNode also inherits from CoglObject. */ + CoglObject _parent; + + /* The parent pipeline/layer */ + CoglPipelineNode *parent; + + /* TRUE if the node took a strong reference on its parent. Weak + * pipelines for instance don't take a reference on their parent. */ + gboolean has_parent_reference; + + /* As an optimization for creating leaf node pipelines/layers (the + * most common) we don't require any list node allocations to link + * to a single descendant. */ + CoglPipelineNode *first_child; + + /* Determines if node->first_child and node->children are + * initialized pointers. */ + gboolean has_children; + + /* Materials and layers are sparse structures defined as a diff + * against their parent and may have multiple children which depend + * on them to define the values of properties which they don't + * change. */ + GList *children; +}; + +#define COGL_PIPELINE_NODE(X) ((CoglPipelineNode *)(X)) + +typedef void (*CoglPipelineNodeUnparentVFunc) (CoglPipelineNode *node); + +typedef gboolean (*CoglPipelineNodeChildCallback) (CoglPipelineNode *child, + void *user_data); + +void +_cogl_pipeline_node_foreach_child (CoglPipelineNode *node, + CoglPipelineNodeChildCallback callback, + void *user_data); + +struct _CoglPipelineLayer +{ + /* XXX: Please think twice about adding members that *have* be + * initialized during a _cogl_pipeline_layer_copy. We are aiming + * to have copies be as cheap as possible and copies may be + * done by the primitives APIs which means they may happen + * in performance critical code paths. + * + * XXX: If you are extending the state we track please consider if + * the state is expected to vary frequently across many pipelines or + * if the state can be shared among many derived pipelines instead. + * This will determine if the state should be added directly to this + * structure which will increase the memory overhead for *all* + * layers or if instead it can go under ->big_state. + */ + + /* Layers represent their state in a tree structure where some of + * the state relating to a given pipeline or layer may actually be + * owned by one if is ancestors in the tree. We have a common data + * type to track the tree heirachy so we can share code... */ + CoglPipelineNode _parent; + + /* Some layers have a pipeline owner, which is to say that the layer + * is referenced in that pipelines->layer_differences list. A layer + * doesn't always have an owner and may simply be an ancestor for + * other layers that keeps track of some shared state. */ + CoglPipeline *owner; + + /* The lowest index is blended first then others on top */ + int index; + + /* Different pipeline backends (GLSL/ARBfp/Fixed Function) may + * want to associate private data with a layer... + * + * NB: we have per backend pointers because a layer may be + * associated with multiple pipelines with different backends. + */ + void *backend_priv[COGL_PIPELINE_N_BACKENDS]; + + /* A mask of which state groups are different in this layer + * in comparison to its parent. */ + unsigned long differences; + + /* Common differences + * + * As a basic way to reduce memory usage we divide the layer + * state into two groups; the minimal state modified in 90% of + * all layers and the rest, so that the second group can + * be allocated dynamically when required. + */ + + /* Each layer is directly associated with a single texture unit */ + int unit_index; + + /* The texture for this layer, or COGL_INVALID_HANDLE for an empty + * layer */ + CoglHandle texture; + gboolean texture_overridden; + /* If ->texture_overridden == TRUE then the texture is instead + * defined by these... */ + GLuint slice_gl_texture; + GLenum slice_gl_target; + + CoglPipelineFilter mag_filter; + CoglPipelineFilter min_filter; + + CoglPipelineWrapMode wrap_mode_s; + CoglPipelineWrapMode wrap_mode_t; + CoglPipelineWrapMode wrap_mode_p; + + /* Infrequent differences aren't currently tracked in + * a separate, dynamically allocated structure as they are + * for pipelines... */ + CoglPipelineLayerBigState *big_state; + + /* bitfields */ + + /* Determines if layer->big_state is valid */ + unsigned int has_big_state:1; + +}; + +/* Used in pipeline->differences masks and for notifying pipeline + * state changes... */ +typedef enum _CoglPipelineState +{ + COGL_PIPELINE_STATE_COLOR = 1L<<0, + COGL_PIPELINE_STATE_BLEND_ENABLE = 1L<<1, + COGL_PIPELINE_STATE_LAYERS = 1L<<2, + + COGL_PIPELINE_STATE_LIGHTING = 1L<<3, + COGL_PIPELINE_STATE_ALPHA_FUNC = 1L<<4, + COGL_PIPELINE_STATE_BLEND = 1L<<5, + COGL_PIPELINE_STATE_USER_SHADER = 1L<<6, + COGL_PIPELINE_STATE_DEPTH = 1L<<7, + COGL_PIPELINE_STATE_FOG = 1L<<8, + COGL_PIPELINE_STATE_POINT_SIZE = 1L<<9, + + COGL_PIPELINE_STATE_REAL_BLEND_ENABLE = 1L<<10, + + COGL_PIPELINE_STATE_ALL_SPARSE = + COGL_PIPELINE_STATE_COLOR | + COGL_PIPELINE_STATE_BLEND_ENABLE | + COGL_PIPELINE_STATE_LAYERS | + COGL_PIPELINE_STATE_LIGHTING | + COGL_PIPELINE_STATE_ALPHA_FUNC | + COGL_PIPELINE_STATE_BLEND | + COGL_PIPELINE_STATE_USER_SHADER | + COGL_PIPELINE_STATE_DEPTH | + COGL_PIPELINE_STATE_FOG | + COGL_PIPELINE_STATE_POINT_SIZE, + + COGL_PIPELINE_STATE_AFFECTS_BLENDING = + COGL_PIPELINE_STATE_COLOR | + COGL_PIPELINE_STATE_BLEND_ENABLE | + COGL_PIPELINE_STATE_LAYERS | + COGL_PIPELINE_STATE_LIGHTING | + COGL_PIPELINE_STATE_BLEND | + COGL_PIPELINE_STATE_USER_SHADER, + + COGL_PIPELINE_STATE_NEEDS_BIG_STATE = + COGL_PIPELINE_STATE_LIGHTING | + COGL_PIPELINE_STATE_ALPHA_FUNC | + COGL_PIPELINE_STATE_BLEND | + COGL_PIPELINE_STATE_USER_SHADER | + COGL_PIPELINE_STATE_DEPTH | + COGL_PIPELINE_STATE_FOG | + COGL_PIPELINE_STATE_POINT_SIZE + +} CoglPipelineState; + +typedef enum +{ + COGL_PIPELINE_LIGHTING_STATE_PROPERTY_AMBIENT = 1, + COGL_PIPELINE_LIGHTING_STATE_PROPERTY_DIFFUSE, + COGL_PIPELINE_LIGHTING_STATE_PROPERTY_SPECULAR, + COGL_PIPELINE_LIGHTING_STATE_PROPERTY_EMISSION, + COGL_PIPELINE_LIGHTING_STATE_PROPERTY_SHININESS +} CoglPipelineLightingStateProperty; + +typedef struct +{ + /* Standard OpenGL lighting model attributes */ + float ambient[4]; + float diffuse[4]; + float specular[4]; + float emission[4]; + float shininess; +} CoglPipelineLightingState; + +typedef struct +{ + /* Determines what fragments are discarded based on their alpha */ + CoglPipelineAlphaFunc alpha_func; + GLfloat alpha_func_reference; +} CoglPipelineAlphaFuncState; + +typedef enum _CoglPipelineBlendEnable +{ + /* XXX: we want to detect users mistakenly using TRUE or FALSE + * so start the enum at 2. */ + COGL_PIPELINE_BLEND_ENABLE_ENABLED = 2, + COGL_PIPELINE_BLEND_ENABLE_DISABLED, + COGL_PIPELINE_BLEND_ENABLE_AUTOMATIC +} CoglPipelineBlendEnable; + +typedef struct +{ + /* Determines how this pipeline is blended with other primitives */ +#ifndef HAVE_COGL_GLES + GLenum blend_equation_rgb; + GLenum blend_equation_alpha; + GLint blend_src_factor_alpha; + GLint blend_dst_factor_alpha; + CoglColor blend_constant; +#endif + GLint blend_src_factor_rgb; + GLint blend_dst_factor_rgb; +} CoglPipelineBlendState; + +typedef struct +{ + gboolean depth_test_enabled; + CoglDepthTestFunction depth_test_function; + gboolean depth_writing_enabled; + float depth_range_near; + float depth_range_far; +} CoglPipelineDepthState; + +typedef struct +{ + gboolean enabled; + CoglColor color; + CoglFogMode mode; + float density; + float z_near; + float z_far; +} CoglPipelineFogState; + +typedef struct +{ + CoglPipelineLightingState lighting_state; + CoglPipelineAlphaFuncState alpha_state; + CoglPipelineBlendState blend_state; + CoglHandle user_program; + CoglPipelineDepthState depth_state; + CoglPipelineFogState fog_state; + float point_size; +} CoglPipelineBigState; + +typedef enum +{ + COGL_PIPELINE_FLAG_DIRTY_LAYERS_CACHE = 1L<<0, + COGL_PIPELINE_FLAG_DIRTY_GET_LAYERS_LIST = 1L<<1 +} CoglPipelineFlag; + +typedef struct +{ + CoglPipeline *owner; + CoglPipelineLayer *layer; +} CoglPipelineLayerCacheEntry; + +/* + * CoglPipelineDestroyCallback + * @pipeline: The #CoglPipeline that has been destroyed + * @user_data: The private data associated with the callback + * + * Notifies when a weak pipeline has been destroyed because one + * of its ancestors has been freed or modified. + */ +typedef void (*CoglPipelineDestroyCallback)(CoglPipeline *pipeline, + void *user_data); + +struct _CoglPipeline +{ + /* XXX: Please think twice about adding members that *have* be + * initialized during a cogl_pipeline_copy. We are aiming to have + * copies be as cheap as possible and copies may be done by the + * primitives APIs which means they may happen in performance + * critical code paths. + * + * XXX: If you are extending the state we track please consider if + * the state is expected to vary frequently across many pipelines or + * if the state can be shared among many derived pipelines instead. + * This will determine if the state should be added directly to this + * structure which will increase the memory overhead for *all* + * pipelines or if instead it can go under ->big_state. + */ + + /* Layers represent their state in a tree structure where some of + * the state relating to a given pipeline or layer may actually be + * owned by one if is ancestors in the tree. We have a common data + * type to track the tree heirachy so we can share code... */ + CoglPipelineNode _parent; + + /* We need to track if a pipeline is referenced in the journal + * because we can't allow modification to these pipelines without + * flushing the journal first */ + unsigned long journal_ref_count; + + /* When weak pipelines are destroyed the user is notified via this + * callback */ + CoglPipelineDestroyCallback destroy_callback; + + /* When notifying that a weak pipeline has been destroyed this + * private data is passed to the above callback */ + void *destroy_data; + + /* A mask of which sparse state groups are different in this + * pipeline in comparison to its parent. */ + unsigned long differences; + + /* The fragment processing backends can associate private data with a + * pipeline. */ + void *backend_privs[COGL_PIPELINE_N_BACKENDS]; + + /* Whenever a pipeline is modified we increment the age. There's no + * guarantee that it won't wrap but it can nevertheless be a + * convenient mechanism to determine when a pipeline has been + * changed to you can invalidate some some associated cache that + * depends on the old state. */ + unsigned long age; + + /* This is the primary color of the pipeline. + * + * This is a sparse property, ref COGL_PIPELINE_STATE_COLOR */ + CoglColor color; + + /* A pipeline may be made up with multiple layers used to combine + * textures together. + * + * This is sparse state, ref COGL_PIPELINE_STATE_LAYERS */ + GList *layer_differences; + unsigned int n_layers; + + /* As a basic way to reduce memory usage we divide the pipeline + * state into two groups; the minimal state modified in 90% of + * all pipelines and the rest, so that the second group can + * be allocated dynamically when required... */ + CoglPipelineBigState *big_state; + + /* For debugging purposes it's possible to associate a static const + * string with a pipeline which can be an aid when trying to trace + * where the pipeline originates from */ + const char *static_breadcrumb; + + /* Cached state... */ + + /* A cached, complete list of the layers this pipeline depends + * on sorted by layer->unit_index. */ + CoglPipelineLayer **layers_cache; + /* To avoid a separate ->layers_cache allocation for common + * pipelines with only a few layers... */ + CoglPipelineLayer *short_layers_cache[3]; + + /* The deprecated cogl_pipeline_get_layers() API returns a + * const GList of layers, which we track here... */ + GList *deprecated_get_layers_list; + + /* XXX: consider adding an authorities cache to speed up sparse + * property value lookups: + * CoglPipeline *authorities_cache[COGL_PIPELINE_N_SPARSE_PROPERTIES]; + * and corresponding authorities_cache_dirty:1 bitfield + */ + + /* bitfields */ + + /* A pipeline can have private data associated with it for multiple + * fragment processing backends. Although only one backend is + * associated with a pipeline the backends may want to cache private + * state with the ancestors of other pipelines and those ancestors + * could currently be associated with different backends. + * + * Each set bit indicates if the correspondong ->backend_privs[] + * entry is valid. + */ + unsigned int backend_priv_set_mask:COGL_PIPELINE_N_BACKENDS; + + /* Weak pipelines don't count as dependants on their parents which + * means that the parent pipeline can be modified without + * considering how the modifications may affect the weak pipeline. + */ + unsigned int is_weak:1; + + /* Determines if pipeline->big_state is valid */ + unsigned int has_big_state:1; + + /* By default blending is enabled automatically depending on the + * unlit color, the lighting colors or the texture format. The user + * can override this to explicitly enable or disable blending. + * + * This is a sparse property */ + unsigned int blend_enable:3; + + /* There are many factors that can determine if we need to enable + * blending, this holds our final decision */ + unsigned int real_blend_enable:1; + + unsigned int layers_cache_dirty:1; + unsigned int deprecated_get_layers_list_dirty:1; + + /* For debugging purposes it's possible to associate a static const + * string with a pipeline which can be an aid when trying to trace + * where the pipeline originates from */ + unsigned int has_static_breadcrumb:1; + + /* There are multiple fragment processing backends for CoglPipeline, + * glsl, arbfp and fixed. This identifies the backend being used for + * the pipeline and any private state the backend has associated + * with the pipeline. */ + unsigned int backend:3; +}; + +typedef struct _CoglPipelineBackend +{ + int (*get_max_texture_units) (void); + + gboolean (*start) (CoglPipeline *pipeline, + int n_layers, + unsigned long pipelines_difference); + gboolean (*add_layer) (CoglPipeline *pipeline, + CoglPipelineLayer *layer, + unsigned long layers_difference); + gboolean (*passthrough) (CoglPipeline *pipeline); + gboolean (*end) (CoglPipeline *pipeline, + unsigned long pipelines_difference); + + void (*pipeline_pre_change_notify) (CoglPipeline *pipeline, + CoglPipelineState change, + const CoglColor *new_color); + void (*pipeline_set_parent_notify) (CoglPipeline *pipeline); + void (*layer_pre_change_notify) (CoglPipeline *owner, + CoglPipelineLayer *layer, + CoglPipelineLayerState change); + + void (*free_priv) (CoglPipeline *pipeline); + void (*free_layer_priv) (CoglPipelineLayer *layer); +} CoglPipelineBackend; + +typedef enum +{ + COGL_PIPELINE_PROGRAM_TYPE_GLSL = 1, + COGL_PIPELINE_PROGRAM_TYPE_ARBFP, + COGL_PIPELINE_PROGRAM_TYPE_FIXED +} CoglPipelineProgramType; + +extern const CoglPipelineBackend * +_cogl_pipeline_backends[COGL_PIPELINE_N_BACKENDS]; + +void +_cogl_pipeline_init_default_pipeline (void); + +void +_cogl_pipeline_init_default_layers (void); + +/* + * SECTION:cogl-pipeline-internals + * @short_description: Functions for creating custom primitives that make use + * of Cogl pipelines for filling. + * + * Normally you shouldn't need to use this API directly, but if you need to + * developing a custom/specialised primitive - probably using raw OpenGL - then + * this API aims to expose enough of the pipeline internals to support being + * able to fill your geometry according to a given Cogl pipeline. + */ + +gboolean +_cogl_pipeline_get_real_blend_enabled (CoglPipeline *pipeline); + +gboolean +_cogl_pipeline_layer_has_user_matrix (CoglPipelineLayer *layer); + +/* + * Calls the pre_paint method on the layer texture if there is + * one. This will determine whether mipmaps are needed based on the + * filter settings. + */ +void +_cogl_pipeline_layer_pre_paint (CoglPipelineLayer *layerr); + +/* + * Calls the pre_paint method on the layer texture if there is + * one. This will determine whether mipmaps are needed based on the + * filter settings. + */ +void +_cogl_pipeline_pre_paint_for_layer (CoglPipeline *pipeline, + int layer_id); + +/* + * CoglPipelineFlushFlag: + * @COGL_PIPELINE_FLUSH_FALLBACK_MASK: The fallback_layers member is set to + * a guint32 mask of the layers that can't be supported with the user + * supplied texture and need to be replaced with fallback textures. (1 = + * fallback, and the least significant bit = layer 0) + * @COGL_PIPELINE_FLUSH_DISABLE_MASK: The disable_layers member is set to + * a guint32 mask of the layers that you want to completly disable + * texturing for (1 = fallback, and the least significant bit = layer 0) + * @COGL_PIPELINE_FLUSH_LAYER0_OVERRIDE: The layer0_override_texture member is + * set to a GLuint OpenGL texture name to override the texture used for + * layer 0 of the pipeline. This is intended for dealing with sliced + * textures where you will need to point to each of the texture slices in + * turn when drawing your geometry. Passing a value of 0 is the same as + * not passing the option at all. + * @COGL_PIPELINE_FLUSH_SKIP_GL_COLOR: When flushing the GL state for the + * pipeline don't call glColor. + * @COGL_PIPELINE_FLUSH_WRAP_MODE_OVERRIDES: Specifies that a bitmask + * of overrides for the wrap modes for some or all layers is + * given. + */ +typedef enum _CoglPipelineFlushFlag +{ + COGL_PIPELINE_FLUSH_FALLBACK_MASK = 1L<<0, + COGL_PIPELINE_FLUSH_DISABLE_MASK = 1L<<1, + COGL_PIPELINE_FLUSH_LAYER0_OVERRIDE = 1L<<2, + COGL_PIPELINE_FLUSH_SKIP_GL_COLOR = 1L<<3, + COGL_PIPELINE_FLUSH_WRAP_MODE_OVERRIDES = 1L<<4 +} CoglPipelineFlushFlag; + +/* This isn't defined in the GLES headers */ +#ifndef GL_CLAMP_TO_BORDER +#define GL_CLAMP_TO_BORDER 0x812d +#endif + +/* GL_ALWAYS is just used here as a value that is known not to clash + * with any valid GL wrap modes. + * + * XXX: keep the values in sync with the CoglPipelineWrapMode enum + * so no conversion is actually needed. + */ +typedef enum _CoglPipelineWrapModeInternal +{ + COGL_PIPELINE_WRAP_MODE_INTERNAL_REPEAT = GL_REPEAT, + COGL_PIPELINE_WRAP_MODE_INTERNAL_CLAMP_TO_EDGE = GL_CLAMP_TO_EDGE, + COGL_PIPELINE_WRAP_MODE_INTERNAL_CLAMP_TO_BORDER = GL_CLAMP_TO_BORDER, + COGL_PIPELINE_WRAP_MODE_INTERNAL_AUTOMATIC = GL_ALWAYS +} CoglPipelineWrapModeInternal; + +typedef enum _CoglPipelineWrapModeOverride +{ + COGL_PIPELINE_WRAP_MODE_OVERRIDE_NONE = 0, + COGL_PIPELINE_WRAP_MODE_OVERRIDE_REPEAT = + COGL_PIPELINE_WRAP_MODE_INTERNAL_REPEAT, + COGL_PIPELINE_WRAP_MODE_OVERRIDE_CLAMP_TO_EDGE = + COGL_PIPELINE_WRAP_MODE_INTERNAL_CLAMP_TO_EDGE, + COGL_PIPELINE_WRAP_MODE_OVERRIDE_CLAMP_TO_BORDER = + COGL_PIPELINE_WRAP_MODE_INTERNAL_CLAMP_TO_BORDER, +} CoglPipelineWrapModeOverride; + +/* There can't be more than 32 layers because we need to fit a bitmask + of the layers into a guint32 */ +#define COGL_PIPELINE_MAX_LAYERS 32 + +typedef struct _CoglPipelineWrapModeOverrides +{ + struct + { + CoglPipelineWrapModeOverride s; + CoglPipelineWrapModeOverride t; + CoglPipelineWrapModeOverride p; + } values[COGL_PIPELINE_MAX_LAYERS]; +} CoglPipelineWrapModeOverrides; + +/* + * CoglPipelineFlushOptions: + * + */ +typedef struct _CoglPipelineFlushOptions +{ + CoglPipelineFlushFlag flags; + + guint32 fallback_layers; + guint32 disable_layers; + GLuint layer0_override_texture; + CoglPipelineWrapModeOverrides wrap_mode_overrides; +} CoglPipelineFlushOptions; + + +int +_cogl_get_max_texture_image_units (void); + + +void +_cogl_use_program (GLuint gl_program, CoglPipelineProgramType type); + +unsigned int +_cogl_get_n_args_for_combine_func (GLint func); + +/* + * _cogl_pipeline_weak_copy: + * @pipeline: A #CoglPipeline object + * @callback: A callback to notify when your weak pipeline is destroyed + * @user_data: Private data to pass to your given callback. + * + * Returns a weak copy of the given source @pipeline. Unlike a normal + * copy no internal reference is taken on the source @pipeline and you + * can expect that later modifications of the source pipeline (or in + * fact any other pipeline) can result in the weak pipeline being + * destroyed. + * + * To understand this better its good to know a bit about the internal + * design of #CoglPipeline... + * + * Internally #CoglPipelines are represented as a graph of + * property diff's, where each node is a diff of properties that gets + * applied on top of its parent. Copying a pipeline creates an empty + * diff and a child->parent relationship between the empty diff and + * the source @pipeline, parent. + * + * Because of this internal graph design a single #CoglPipeline may + * indirectly depend on a chain of ancestors to fully define all of + * its properties. Because a node depends on its ancestors it normally + * owns a reference to its parent to stop it from being freed. Also if + * you try to modify a pipeline with children we internally use a + * copy-on-write mechanism to ensure that you don't indirectly change + * the properties those children. + * + * Weak pipelines avoid the use of copy-on-write to preserve the + * integrity of weak dependants and instead weak dependants are + * simply destroyed allowing the parent to be modified directly. Also + * because weak pipelines don't own a reference to their parent they + * won't stop the source @pipeline from being freed when the user + * releases their reference on it. + * + * Because weak pipelines don't own a reference on their parent they + * are the recommended mechanism for creating derived pipelines that you + * want to cache as a private property of the original pipeline + * because they won't result in a circular dependency. + * + * An example use case: + * + * Consider for example you are implementing a custom primitive that is + * not compatible with certain source pipelines. To handle this you + * implement a validation stage that given an arbitrary pipeline as + * input will create a derived pipeline that is suitable for drawing + * your primitive. + * + * Because you don't want to have to repeat this validation every time + * the same incompatible pipeline is given as input you want to cache + * the result as a private property of the original pipeline. If the + * derived pipeline were created using cogl_pipeline_copy that would + * create a circular dependency so the original pipeline can never be + * freed. + * + * If you instead create a weak copy you won't stop the original pipeline + * from being freed if it's no longer needed, and you will instead simply + * be notified that your weak pipeline has been destroyed. + * + * This is the recommended coding pattern for validating an input + * pipeline and caching a derived result: + * |[ + * static CoglUserDataKey _cogl_my_cache_key; + * + * typedef struct { + * CoglPipeline *validated_source; + * } MyValidatedMaterialCache; + * + * static void + * destroy_cache_cb (CoglObject *object, void *user_data) + * { + * g_slice_free (MyValidatedMaterialCache, user_data); + * } + * + * static void + * invalidate_cache_cb (CoglPipeline *destroyed, void *user_data) + * { + * MyValidatedMaterialCache *cache = user_data; + * cogl_object_unref (cache->validated_source); + * cache->validated_source = NULL; + * } + * + * static CoglPipeline * + * get_validated_pipeline (CoglPipeline *source) + * { + * MyValidatedMaterialCache *cache = + * cogl_object_get_user_data (COGL_OBJECT (source), + * &_cogl_my_cache_key); + * if (G_UNLIKELY (cache == NULL)) + * { + * cache = g_slice_new (MyValidatedMaterialCache); + * cogl_object_set_user_data (COGL_OBJECT (source), + * &_cogl_my_cache_key, + * cache, destroy_cache_cb); + * cache->validated_source = source; + * } + * + * if (G_UNLIKELY (cache->validated_source == NULL)) + * { + * cache->validated_source = source; + * + * / * Start validating source... * / + * + * / * If you find you need to change something... * / + * if (cache->validated_source == source) + * cache->validated_source = + * cogl_pipeline_weak_copy (source, + * invalidate_cache_cb, + * cache); + * + * / * Modify cache->validated_source * / + * } + * + * return cache->validated_source; + * } + * ]| + */ +CoglPipeline * +_cogl_pipeline_weak_copy (CoglPipeline *pipeline, + CoglPipelineDestroyCallback callback, + void *user_data); + +void +_cogl_pipeline_set_backend (CoglPipeline *pipeline, int backend); + +CoglPipeline * +_cogl_pipeline_get_parent (CoglPipeline *pipeline); + +void +_cogl_pipeline_get_colorubv (CoglPipeline *pipeline, + guint8 *color); + +unsigned long +_cogl_pipeline_compare_differences (CoglPipeline *pipeline0, + CoglPipeline *pipeline1); + +gboolean +_cogl_pipeline_equal (CoglPipeline *pipeline0, + CoglPipeline *pipeline1, + gboolean skip_gl_color); + +CoglPipeline * +_cogl_pipeline_journal_ref (CoglPipeline *pipeline); + +void +_cogl_pipeline_journal_unref (CoglPipeline *pipeline); + +CoglPipelineFilter +_cogl_pipeline_get_layer_min_filter (CoglPipeline *pipeline, + int layer_index); + +CoglPipelineFilter +_cogl_pipeline_get_layer_mag_filter (CoglPipeline *pipeline, + int layer_index); + +void +_cogl_pipeline_texture_storage_change_notify (CoglHandle texture); + +void +_cogl_pipeline_apply_legacy_state (CoglPipeline *pipeline); + +void +_cogl_pipeline_apply_overrides (CoglPipeline *pipeline, + CoglPipelineFlushOptions *options); + +CoglPipelineBlendEnable +_cogl_pipeline_get_blend_enabled (CoglPipeline *pipeline); + +void +_cogl_pipeline_set_blend_enabled (CoglPipeline *pipeline, + CoglPipelineBlendEnable enable); + +void +_cogl_pipeline_set_static_breadcrumb (CoglPipeline *pipeline, + const char *breadcrumb); + +unsigned long +_cogl_pipeline_get_age (CoglPipeline *pipeline); + +CoglPipeline * +_cogl_pipeline_get_authority (CoglPipeline *pipeline, + unsigned long difference); + +CoglHandle +_cogl_pipeline_get_layer_texture (CoglPipeline *pipeline, + int layer_index); + +void +_cogl_pipeline_get_layer_combine_constant (CoglPipeline *pipeline, + int layer_index, + float *constant); + +void +_cogl_pipeline_prune_to_n_layers (CoglPipeline *pipeline, int n); + + +/* + * API to support the deprecate cogl_pipeline_layer_xyz functions... + */ + +G_CONST_RETURN GList * +_cogl_pipeline_get_layers (CoglPipeline *pipeline); + +void +_cogl_pipeline_layer_get_wrap_modes (CoglPipelineLayer *layer, + CoglPipelineWrapModeInternal *wrap_mode_s, + CoglPipelineWrapModeInternal *wrap_mode_t, + CoglPipelineWrapModeInternal *wrap_mode_r); + +void +_cogl_pipeline_layer_get_filters (CoglPipelineLayer *layer, + CoglPipelineFilter *min_filter, + CoglPipelineFilter *mag_filter); + +void +_cogl_pipeline_get_layer_filters (CoglPipeline *pipeline, + int layer_index, + CoglPipelineFilter *min_filter, + CoglPipelineFilter *mag_filter); + +typedef enum { + COGL_PIPELINE_LAYER_TYPE_TEXTURE +} CoglPipelineLayerType; + +CoglPipelineLayerType +_cogl_pipeline_layer_get_type (CoglPipelineLayer *layer); + +CoglHandle +_cogl_pipeline_layer_get_texture (CoglPipelineLayer *layer); + +CoglPipelineFilter +_cogl_pipeline_layer_get_min_filter (CoglPipelineLayer *layer); + +CoglPipelineFilter +_cogl_pipeline_layer_get_mag_filter (CoglPipelineLayer *layer); + +CoglPipelineWrapMode +_cogl_pipeline_layer_get_wrap_mode_s (CoglPipelineLayer *layer); + +CoglPipelineWrapMode +_cogl_pipeline_layer_get_wrap_mode_t (CoglPipelineLayer *layer); + +CoglPipelineWrapMode +_cogl_pipeline_layer_get_wrap_mode_p (CoglPipelineLayer *layer); + +unsigned long +_cogl_pipeline_layer_compare_differences (CoglPipelineLayer *layer0, + CoglPipelineLayer *layer1); + +CoglPipelineLayer * +_cogl_pipeline_layer_get_authority (CoglPipelineLayer *layer, + unsigned long difference); + +CoglHandle +_cogl_pipeline_layer_get_texture (CoglPipelineLayer *layer); + +typedef gboolean (*CoglPipelineInternalLayerCallback) (CoglPipelineLayer *layer, + void *user_data); + +void +_cogl_pipeline_foreach_layer_internal (CoglPipeline *pipeline, + CoglPipelineInternalLayerCallback callback, + void *user_data); + +int +_cogl_pipeline_layer_get_unit_index (CoglPipelineLayer *layer); + +#endif /* __COGL_PIPELINE_PRIVATE_H */ + diff --git a/clutter/cogl/cogl/cogl-material.c b/clutter/cogl/cogl/cogl-pipeline.c similarity index 54% rename from clutter/cogl/cogl/cogl-material.c rename to clutter/cogl/cogl/cogl-pipeline.c index 720350821..bde53f117 100644 --- a/clutter/cogl/cogl/cogl-material.c +++ b/clutter/cogl/cogl/cogl-pipeline.c @@ -35,8 +35,8 @@ #include "cogl-context.h" #include "cogl-object.h" -#include "cogl-material-private.h" -#include "cogl-material-opengl-private.h" +#include "cogl-pipeline-private.h" +#include "cogl-pipeline-opengl-private.h" #include "cogl-texture-private.h" #include "cogl-blend-string.h" #include "cogl-journal-private.h" @@ -47,60 +47,57 @@ #include #include -#define COGL_MATERIAL_LAYER(X) ((CoglMaterialLayer *)(X)) +typedef gboolean (*CoglPipelineStateComparitor) (CoglPipeline *authority0, + CoglPipeline *authority1); -typedef gboolean (*CoglMaterialStateComparitor) (CoglMaterial *authority0, - CoglMaterial *authority1); +static CoglPipelineLayer *_cogl_pipeline_layer_copy (CoglPipelineLayer *layer); -static CoglMaterialLayer *_cogl_material_layer_copy (CoglMaterialLayer *layer); - -static void _cogl_material_free (CoglMaterial *tex); -static void _cogl_material_layer_free (CoglMaterialLayer *layer); -static void _cogl_material_add_layer_difference (CoglMaterial *material, - CoglMaterialLayer *layer, +static void _cogl_pipeline_free (CoglPipeline *tex); +static void _cogl_pipeline_layer_free (CoglPipelineLayer *layer); +static void _cogl_pipeline_add_layer_difference (CoglPipeline *pipeline, + CoglPipelineLayer *layer, gboolean inc_n_layers); -static void handle_automatic_blend_enable (CoglMaterial *material, - CoglMaterialState changes); -static void recursively_free_layer_caches (CoglMaterial *material); -static gboolean _cogl_material_is_weak (CoglMaterial *material); +static void handle_automatic_blend_enable (CoglPipeline *pipeline, + CoglPipelineState changes); +static void recursively_free_layer_caches (CoglPipeline *pipeline); +static gboolean _cogl_pipeline_is_weak (CoglPipeline *pipeline); -const CoglMaterialBackend *_cogl_material_backends[COGL_MATERIAL_N_BACKENDS]; +const CoglPipelineBackend *_cogl_pipeline_backends[COGL_PIPELINE_N_BACKENDS]; -#ifdef COGL_MATERIAL_BACKEND_GLSL -#include "cogl-material-glsl-private.h" +#ifdef COGL_PIPELINE_BACKEND_GLSL +#include "cogl-pipeline-glsl-private.h" #endif -#ifdef COGL_MATERIAL_BACKEND_ARBFP -#include "cogl-material-arbfp-private.h" +#ifdef COGL_PIPELINE_BACKEND_ARBFP +#include "cogl-pipeline-arbfp-private.h" #endif -#ifdef COGL_MATERIAL_BACKEND_FIXED -#include "cogl-material-fixed-private.h" +#ifdef COGL_PIPELINE_BACKEND_FIXED +#include "cogl-pipeline-fixed-private.h" #endif -COGL_OBJECT_DEFINE (Material, material); -COGL_OBJECT_DEFINE_DEPRECATED_REF_COUNTING (material); -/* This type was made deprecated before the cogl_is_material_layer +COGL_OBJECT_DEFINE (Pipeline, pipeline); +/* This type was made deprecated before the cogl_is_pipeline_layer function was ever exposed in the public headers so there's no need - to make the cogl_is_material_layer function public. We use INTERNAL + to make the cogl_is_pipeline_layer function public. We use INTERNAL so that the cogl_is_* function won't get defined */ -COGL_OBJECT_INTERNAL_DEFINE (MaterialLayer, material_layer); +COGL_OBJECT_INTERNAL_DEFINE (PipelineLayer, pipeline_layer); GQuark -_cogl_material_error_quark (void) +_cogl_pipeline_error_quark (void) { - return g_quark_from_static_string ("cogl-material-error-quark"); + return g_quark_from_static_string ("cogl-pipeline-error-quark"); } static void -_cogl_material_node_init (CoglMaterialNode *node) +_cogl_pipeline_node_init (CoglPipelineNode *node) { node->parent = NULL; node->has_children = FALSE; } static void -_cogl_material_node_set_parent_real (CoglMaterialNode *node, - CoglMaterialNode *parent, - CoglMaterialNodeUnparentVFunc unparent, +_cogl_pipeline_node_set_parent_real (CoglPipelineNode *node, + CoglPipelineNode *parent, + CoglPipelineNodeUnparentVFunc unparent, gboolean take_strong_reference) { /* NB: the old parent may indirectly be keeping the new parent alive @@ -138,9 +135,9 @@ _cogl_material_node_set_parent_real (CoglMaterialNode *node, } static void -_cogl_material_node_unparent_real (CoglMaterialNode *node) +_cogl_pipeline_node_unparent_real (CoglPipelineNode *node) { - CoglMaterialNode *parent = node->parent; + CoglPipelineNode *parent = node->parent; if (parent == NULL) return; @@ -168,8 +165,8 @@ _cogl_material_node_unparent_real (CoglMaterialNode *node) } void -_cogl_material_node_foreach_child (CoglMaterialNode *node, - CoglMaterialNodeChildCallback callback, +_cogl_pipeline_node_foreach_child (CoglPipelineNode *node, + CoglPipelineNodeChildCallback callback, void *user_data) { if (node->has_children) @@ -180,62 +177,62 @@ _cogl_material_node_foreach_child (CoglMaterialNode *node, } /* - * This initializes the first material owned by the Cogl context. All - * subsequently instantiated materials created via the cogl_material_new() - * API will initially be a copy of this material. + * This initializes the first pipeline owned by the Cogl context. All + * subsequently instantiated pipelines created via the cogl_pipeline_new() + * API will initially be a copy of this pipeline. * - * The default material is the topmost ancester for all materials. + * The default pipeline is the topmost ancester for all pipelines. */ void -_cogl_material_init_default_material (void) +_cogl_pipeline_init_default_pipeline (void) { - /* Create new - blank - material */ - CoglMaterial *material = g_slice_new0 (CoglMaterial); - CoglMaterialBigState *big_state = g_slice_new0 (CoglMaterialBigState); - CoglMaterialLightingState *lighting_state = &big_state->lighting_state; - CoglMaterialAlphaFuncState *alpha_state = &big_state->alpha_state; - CoglMaterialBlendState *blend_state = &big_state->blend_state; - CoglMaterialDepthState *depth_state = &big_state->depth_state; + /* Create new - blank - pipeline */ + CoglPipeline *pipeline = g_slice_new0 (CoglPipeline); + CoglPipelineBigState *big_state = g_slice_new0 (CoglPipelineBigState); + CoglPipelineLightingState *lighting_state = &big_state->lighting_state; + CoglPipelineAlphaFuncState *alpha_state = &big_state->alpha_state; + CoglPipelineBlendState *blend_state = &big_state->blend_state; + CoglPipelineDepthState *depth_state = &big_state->depth_state; _COGL_GET_CONTEXT (ctx, NO_RETVAL); /* Take this opportunity to setup the fragment processing backends... */ -#ifdef COGL_MATERIAL_BACKEND_GLSL - _cogl_material_backends[COGL_MATERIAL_BACKEND_GLSL] = - &_cogl_material_glsl_backend; +#ifdef COGL_PIPELINE_BACKEND_GLSL + _cogl_pipeline_backends[COGL_PIPELINE_BACKEND_GLSL] = + &_cogl_pipeline_glsl_backend; #endif -#ifdef COGL_MATERIAL_BACKEND_ARBFP - _cogl_material_backends[COGL_MATERIAL_BACKEND_ARBFP] = - &_cogl_material_arbfp_backend; +#ifdef COGL_PIPELINE_BACKEND_ARBFP + _cogl_pipeline_backends[COGL_PIPELINE_BACKEND_ARBFP] = + &_cogl_pipeline_arbfp_backend; #endif -#ifdef COGL_MATERIAL_BACKEND_FIXED - _cogl_material_backends[COGL_MATERIAL_BACKEND_FIXED] = - &_cogl_material_fixed_backend; +#ifdef COGL_PIPELINE_BACKEND_FIXED + _cogl_pipeline_backends[COGL_PIPELINE_BACKEND_FIXED] = + &_cogl_pipeline_fixed_backend; #endif - _cogl_material_node_init (COGL_MATERIAL_NODE (material)); + _cogl_pipeline_node_init (COGL_PIPELINE_NODE (pipeline)); - material->is_weak = FALSE; - material->journal_ref_count = 0; - material->backend = COGL_MATERIAL_BACKEND_UNDEFINED; - material->differences = COGL_MATERIAL_STATE_ALL_SPARSE; + pipeline->is_weak = FALSE; + pipeline->journal_ref_count = 0; + pipeline->backend = COGL_PIPELINE_BACKEND_UNDEFINED; + pipeline->differences = COGL_PIPELINE_STATE_ALL_SPARSE; - material->real_blend_enable = FALSE; + pipeline->real_blend_enable = FALSE; - material->blend_enable = COGL_MATERIAL_BLEND_ENABLE_AUTOMATIC; - material->layer_differences = NULL; - material->n_layers = 0; + pipeline->blend_enable = COGL_PIPELINE_BLEND_ENABLE_AUTOMATIC; + pipeline->layer_differences = NULL; + pipeline->n_layers = 0; - material->big_state = big_state; - material->has_big_state = TRUE; + pipeline->big_state = big_state; + pipeline->has_big_state = TRUE; - material->static_breadcrumb = "default material"; - material->has_static_breadcrumb = TRUE; + pipeline->static_breadcrumb = "default pipeline"; + pipeline->has_static_breadcrumb = TRUE; - material->age = 0; + pipeline->age = 0; /* Use the same defaults as the GL spec... */ - cogl_color_init_from_4ub (&material->color, 0xff, 0xff, 0xff, 0xff); + cogl_color_init_from_4ub (&pipeline->color, 0xff, 0xff, 0xff, 0xff); /* Use the same defaults as the GL spec... */ lighting_state->ambient[0] = 0.2; @@ -261,7 +258,7 @@ _cogl_material_init_default_material (void) lighting_state->shininess = 0.0f; /* Use the same defaults as the GL spec... */ - alpha_state->alpha_func = COGL_MATERIAL_ALPHA_FUNC_ALWAYS; + alpha_state->alpha_func = COGL_PIPELINE_ALPHA_FUNC_ALWAYS; alpha_state->alpha_func_reference = 0.0; /* Not the same as the GL default, but seems saner... */ @@ -287,387 +284,387 @@ _cogl_material_init_default_material (void) big_state->point_size = 1.0f; - ctx->default_material = _cogl_material_object_new (material); + ctx->default_pipeline = _cogl_pipeline_object_new (pipeline); } static void -_cogl_material_unparent (CoglMaterialNode *material) +_cogl_pipeline_unparent (CoglPipelineNode *pipeline) { /* Chain up */ - _cogl_material_node_unparent_real (material); + _cogl_pipeline_node_unparent_real (pipeline); } static gboolean -recursively_free_layer_caches_cb (CoglMaterialNode *node, +recursively_free_layer_caches_cb (CoglPipelineNode *node, void *user_data) { - recursively_free_layer_caches (COGL_MATERIAL (node)); + recursively_free_layer_caches (COGL_PIPELINE (node)); return TRUE; } -/* This recursively frees the layers_cache of a material and all of +/* This recursively frees the layers_cache of a pipeline and all of * its descendants. * - * For instance if we change a materials ->layer_differences list - * then that material and all of its descendants may now have + * For instance if we change a pipelines ->layer_differences list + * then that pipeline and all of its descendants may now have * incorrect layer caches. */ static void -recursively_free_layer_caches (CoglMaterial *material) +recursively_free_layer_caches (CoglPipeline *pipeline) { - /* Note: we maintain the invariable that if a material already has a + /* Note: we maintain the invariable that if a pipeline already has a * dirty layers_cache then so do all of its descendants. */ - if (material->layers_cache_dirty) + if (pipeline->layers_cache_dirty) return; - if (G_UNLIKELY (material->layers_cache != material->short_layers_cache)) - g_slice_free1 (sizeof (CoglMaterialLayer *) * material->n_layers, - material->layers_cache); - material->layers_cache_dirty = TRUE; + if (G_UNLIKELY (pipeline->layers_cache != pipeline->short_layers_cache)) + g_slice_free1 (sizeof (CoglPipelineLayer *) * pipeline->n_layers, + pipeline->layers_cache); + pipeline->layers_cache_dirty = TRUE; - _cogl_material_node_foreach_child (COGL_MATERIAL_NODE (material), + _cogl_pipeline_node_foreach_child (COGL_PIPELINE_NODE (pipeline), recursively_free_layer_caches_cb, NULL); } static void -_cogl_material_set_parent (CoglMaterial *material, - CoglMaterial *parent, +_cogl_pipeline_set_parent (CoglPipeline *pipeline, + CoglPipeline *parent, gboolean take_strong_reference) { /* Chain up */ - _cogl_material_node_set_parent_real (COGL_MATERIAL_NODE (material), - COGL_MATERIAL_NODE (parent), - _cogl_material_unparent, + _cogl_pipeline_node_set_parent_real (COGL_PIPELINE_NODE (pipeline), + COGL_PIPELINE_NODE (parent), + _cogl_pipeline_unparent, take_strong_reference); - /* Since we just changed the ancestry of the material its cache of + /* Since we just changed the ancestry of the pipeline its cache of * layers could now be invalid so free it... */ - if (material->differences & COGL_MATERIAL_STATE_LAYERS) - recursively_free_layer_caches (material); + if (pipeline->differences & COGL_PIPELINE_STATE_LAYERS) + recursively_free_layer_caches (pipeline); /* If the fragment processing backend is also caching state along - * with the material that depends on the material's ancestry then it + * with the pipeline that depends on the pipeline's ancestry then it * may be notified here... */ - if (material->backend != COGL_MATERIAL_BACKEND_UNDEFINED && - _cogl_material_backends[material->backend]->material_set_parent_notify) + if (pipeline->backend != COGL_PIPELINE_BACKEND_UNDEFINED && + _cogl_pipeline_backends[pipeline->backend]->pipeline_set_parent_notify) { - const CoglMaterialBackend *backend = - _cogl_material_backends[material->backend]; - backend->material_set_parent_notify (material); + const CoglPipelineBackend *backend = + _cogl_pipeline_backends[pipeline->backend]; + backend->pipeline_set_parent_notify (pipeline); } } static void -_cogl_material_promote_weak_ancestors (CoglMaterial *strong) +_cogl_pipeline_promote_weak_ancestors (CoglPipeline *strong) { - CoglMaterialNode *n; + CoglPipelineNode *n; g_return_if_fail (!strong->is_weak); - for (n = COGL_MATERIAL_NODE (strong)->parent; n; n = n->parent) + for (n = COGL_PIPELINE_NODE (strong)->parent; n; n = n->parent) { - CoglMaterial *material = COGL_MATERIAL (n); + CoglPipeline *pipeline = COGL_PIPELINE (n); - cogl_object_ref (material); + cogl_object_ref (pipeline); - if (!material->is_weak) + if (!pipeline->is_weak) return; } } static void -_cogl_material_revert_weak_ancestors (CoglMaterial *strong) +_cogl_pipeline_revert_weak_ancestors (CoglPipeline *strong) { - CoglMaterial *parent = _cogl_material_get_parent (strong); - CoglMaterialNode *n; + CoglPipeline *parent = _cogl_pipeline_get_parent (strong); + CoglPipelineNode *n; g_return_if_fail (!strong->is_weak); if (!parent || !parent->is_weak) return; - for (n = COGL_MATERIAL_NODE (strong)->parent; n; n = n->parent) + for (n = COGL_PIPELINE_NODE (strong)->parent; n; n = n->parent) { - CoglMaterial *material = COGL_MATERIAL (n); + CoglPipeline *pipeline = COGL_PIPELINE (n); - cogl_object_unref (material); + cogl_object_unref (pipeline); - if (!material->is_weak) + if (!pipeline->is_weak) return; } } /* XXX: Always have an eye out for opportunities to lower the cost of - * cogl_material_copy. */ -static CoglMaterial * -_cogl_material_copy (CoglMaterial *src, gboolean is_weak) + * cogl_pipeline_copy. */ +static CoglPipeline * +_cogl_pipeline_copy (CoglPipeline *src, gboolean is_weak) { - CoglMaterial *material = g_slice_new (CoglMaterial); + CoglPipeline *pipeline = g_slice_new (CoglPipeline); - _cogl_material_node_init (COGL_MATERIAL_NODE (material)); + _cogl_pipeline_node_init (COGL_PIPELINE_NODE (pipeline)); - material->is_weak = is_weak; + pipeline->is_weak = is_weak; - material->journal_ref_count = 0; + pipeline->journal_ref_count = 0; - material->differences = 0; + pipeline->differences = 0; - material->has_big_state = FALSE; + pipeline->has_big_state = FALSE; /* NB: real_blend_enable isn't a sparse property, it's valid for - * every material node so we have fast access to it. */ - material->real_blend_enable = src->real_blend_enable; + * every pipeline node so we have fast access to it. */ + pipeline->real_blend_enable = src->real_blend_enable; /* XXX: * consider generalizing the idea of "cached" properties. These * would still have an authority like other sparse properties but * you wouldn't have to walk up the ancestry to find the authority - * because the value would be cached directly in each material. + * because the value would be cached directly in each pipeline. */ - material->layers_cache_dirty = TRUE; - material->deprecated_get_layers_list_dirty = TRUE; + pipeline->layers_cache_dirty = TRUE; + pipeline->deprecated_get_layers_list_dirty = TRUE; - material->backend = src->backend; - material->backend_priv_set_mask = 0; + pipeline->backend = src->backend; + pipeline->backend_priv_set_mask = 0; - material->has_static_breadcrumb = FALSE; + pipeline->has_static_breadcrumb = FALSE; - material->age = 0; + pipeline->age = 0; - _cogl_material_set_parent (material, src, !is_weak); + _cogl_pipeline_set_parent (pipeline, src, !is_weak); - /* The semantics for copying a weak material are that we promote all - * weak ancestors to temporarily become strong materials until the + /* The semantics for copying a weak pipeline are that we promote all + * weak ancestors to temporarily become strong pipelines until the * copy is freed. */ if (!is_weak) - _cogl_material_promote_weak_ancestors (material); + _cogl_pipeline_promote_weak_ancestors (pipeline); - return _cogl_material_object_new (material); + return _cogl_pipeline_object_new (pipeline); } -CoglMaterial * -cogl_material_copy (CoglMaterial *src) +CoglPipeline * +cogl_pipeline_copy (CoglPipeline *src) { - return _cogl_material_copy (src, FALSE); + return _cogl_pipeline_copy (src, FALSE); } -CoglMaterial * -_cogl_material_weak_copy (CoglMaterial *material, - CoglMaterialDestroyCallback callback, +CoglPipeline * +_cogl_pipeline_weak_copy (CoglPipeline *pipeline, + CoglPipelineDestroyCallback callback, void *user_data) { - CoglMaterial *copy; - CoglMaterial *copy_material; + CoglPipeline *copy; + CoglPipeline *copy_pipeline; - copy = _cogl_material_copy (material, TRUE); - copy_material = COGL_MATERIAL (copy); - copy_material->destroy_callback = callback; - copy_material->destroy_data = user_data; + copy = _cogl_pipeline_copy (pipeline, TRUE); + copy_pipeline = COGL_PIPELINE (copy); + copy_pipeline->destroy_callback = callback; + copy_pipeline->destroy_data = user_data; return copy; } -CoglMaterial * -cogl_material_new (void) +CoglPipeline * +cogl_pipeline_new (void) { - CoglMaterial *new; + CoglPipeline *new; _COGL_GET_CONTEXT (ctx, NULL); - new = cogl_material_copy (ctx->default_material); - _cogl_material_set_static_breadcrumb (new, "new"); + new = cogl_pipeline_copy (ctx->default_pipeline); + _cogl_pipeline_set_static_breadcrumb (new, "new"); return new; } static void -_cogl_material_backend_free_priv (CoglMaterial *material) +_cogl_pipeline_backend_free_priv (CoglPipeline *pipeline) { - if (material->backend != COGL_MATERIAL_BACKEND_UNDEFINED && - _cogl_material_backends[material->backend]->free_priv) + if (pipeline->backend != COGL_PIPELINE_BACKEND_UNDEFINED && + _cogl_pipeline_backends[pipeline->backend]->free_priv) { - const CoglMaterialBackend *backend = - _cogl_material_backends[material->backend]; - backend->free_priv (material); + const CoglPipelineBackend *backend = + _cogl_pipeline_backends[pipeline->backend]; + backend->free_priv (pipeline); } } static gboolean -destroy_weak_children_cb (CoglMaterialNode *node, +destroy_weak_children_cb (CoglPipelineNode *node, void *user_data) { - CoglMaterial *material = COGL_MATERIAL (node); + CoglPipeline *pipeline = COGL_PIPELINE (node); - if (_cogl_material_is_weak (material)) + if (_cogl_pipeline_is_weak (pipeline)) { - _cogl_material_node_foreach_child (COGL_MATERIAL_NODE (material), + _cogl_pipeline_node_foreach_child (COGL_PIPELINE_NODE (pipeline), destroy_weak_children_cb, NULL); - material->destroy_callback (material, material->destroy_data); - _cogl_material_unparent (COGL_MATERIAL_NODE (material)); + pipeline->destroy_callback (pipeline, pipeline->destroy_data); + _cogl_pipeline_unparent (COGL_PIPELINE_NODE (pipeline)); } return TRUE; } static void -_cogl_material_free (CoglMaterial *material) +_cogl_pipeline_free (CoglPipeline *pipeline) { - if (!material->is_weak) - _cogl_material_revert_weak_ancestors (material); + if (!pipeline->is_weak) + _cogl_pipeline_revert_weak_ancestors (pipeline); - /* Weak materials don't take a reference on their parent */ - _cogl_material_node_foreach_child (COGL_MATERIAL_NODE (material), + /* Weak pipelines don't take a reference on their parent */ + _cogl_pipeline_node_foreach_child (COGL_PIPELINE_NODE (pipeline), destroy_weak_children_cb, NULL); - g_assert (!COGL_MATERIAL_NODE (material)->has_children); + g_assert (!COGL_PIPELINE_NODE (pipeline)->has_children); - _cogl_material_backend_free_priv (material); + _cogl_pipeline_backend_free_priv (pipeline); - _cogl_material_unparent (COGL_MATERIAL_NODE (material)); + _cogl_pipeline_unparent (COGL_PIPELINE_NODE (pipeline)); - if (material->differences & COGL_MATERIAL_STATE_USER_SHADER && - material->big_state->user_program) - cogl_handle_unref (material->big_state->user_program); + if (pipeline->differences & COGL_PIPELINE_STATE_USER_SHADER && + pipeline->big_state->user_program) + cogl_handle_unref (pipeline->big_state->user_program); - if (material->differences & COGL_MATERIAL_STATE_NEEDS_BIG_STATE) - g_slice_free (CoglMaterialBigState, material->big_state); + if (pipeline->differences & COGL_PIPELINE_STATE_NEEDS_BIG_STATE) + g_slice_free (CoglPipelineBigState, pipeline->big_state); - if (material->differences & COGL_MATERIAL_STATE_LAYERS) + if (pipeline->differences & COGL_PIPELINE_STATE_LAYERS) { - g_list_foreach (material->layer_differences, + g_list_foreach (pipeline->layer_differences, (GFunc)cogl_object_unref, NULL); - g_list_free (material->layer_differences); + g_list_free (pipeline->layer_differences); } - g_slice_free (CoglMaterial, material); + g_slice_free (CoglPipeline, pipeline); } gboolean -_cogl_material_get_real_blend_enabled (CoglMaterial *material) +_cogl_pipeline_get_real_blend_enabled (CoglPipeline *pipeline) { - g_return_val_if_fail (cogl_is_material (material), FALSE); + g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); - return material->real_blend_enable; + return pipeline->real_blend_enable; } -inline CoglMaterial * -_cogl_material_get_parent (CoglMaterial *material) +inline CoglPipeline * +_cogl_pipeline_get_parent (CoglPipeline *pipeline) { - CoglMaterialNode *parent_node = COGL_MATERIAL_NODE (material)->parent; - return COGL_MATERIAL (parent_node); + CoglPipelineNode *parent_node = COGL_PIPELINE_NODE (pipeline)->parent; + return COGL_PIPELINE (parent_node); } -CoglMaterial * -_cogl_material_get_authority (CoglMaterial *material, +CoglPipeline * +_cogl_pipeline_get_authority (CoglPipeline *pipeline, unsigned long difference) { - CoglMaterial *authority = material; + CoglPipeline *authority = pipeline; while (!(authority->differences & difference)) - authority = _cogl_material_get_parent (authority); + authority = _cogl_pipeline_get_parent (authority); return authority; } /* XXX: Think twice before making this non static since it is used * heavily and we expect the compiler to inline it... */ -static CoglMaterialLayer * -_cogl_material_layer_get_parent (CoglMaterialLayer *layer) +static CoglPipelineLayer * +_cogl_pipeline_layer_get_parent (CoglPipelineLayer *layer) { - CoglMaterialNode *parent_node = COGL_MATERIAL_NODE (layer)->parent; - return COGL_MATERIAL_LAYER (parent_node); + CoglPipelineNode *parent_node = COGL_PIPELINE_NODE (layer)->parent; + return COGL_PIPELINE_LAYER (parent_node); } -CoglMaterialLayer * -_cogl_material_layer_get_authority (CoglMaterialLayer *layer, +CoglPipelineLayer * +_cogl_pipeline_layer_get_authority (CoglPipelineLayer *layer, unsigned long difference) { - CoglMaterialLayer *authority = layer; + CoglPipelineLayer *authority = layer; while (!(authority->differences & difference)) - authority = _cogl_material_layer_get_parent (authority); + authority = _cogl_pipeline_layer_get_parent (authority); return authority; } int -_cogl_material_layer_get_unit_index (CoglMaterialLayer *layer) +_cogl_pipeline_layer_get_unit_index (CoglPipelineLayer *layer) { - CoglMaterialLayer *authority = - _cogl_material_layer_get_authority (layer, COGL_MATERIAL_LAYER_STATE_UNIT); + CoglPipelineLayer *authority = + _cogl_pipeline_layer_get_authority (layer, COGL_PIPELINE_LAYER_STATE_UNIT); return authority->unit_index; } static void -_cogl_material_update_layers_cache (CoglMaterial *material) +_cogl_pipeline_update_layers_cache (CoglPipeline *pipeline) { - /* Note: we assume this material is a _LAYERS authority */ + /* Note: we assume this pipeline is a _LAYERS authority */ int n_layers; - CoglMaterial *current; + CoglPipeline *current; int layers_found; - if (G_LIKELY (!material->layers_cache_dirty) || - material->n_layers == 0) + if (G_LIKELY (!pipeline->layers_cache_dirty) || + pipeline->n_layers == 0) return; - material->layers_cache_dirty = FALSE; + pipeline->layers_cache_dirty = FALSE; - n_layers = material->n_layers; - if (G_LIKELY (n_layers < G_N_ELEMENTS (material->short_layers_cache))) + n_layers = pipeline->n_layers; + if (G_LIKELY (n_layers < G_N_ELEMENTS (pipeline->short_layers_cache))) { - material->layers_cache = material->short_layers_cache; - memset (material->layers_cache, 0, - sizeof (CoglMaterialLayer *) * - G_N_ELEMENTS (material->short_layers_cache)); + pipeline->layers_cache = pipeline->short_layers_cache; + memset (pipeline->layers_cache, 0, + sizeof (CoglPipelineLayer *) * + G_N_ELEMENTS (pipeline->short_layers_cache)); } else { - material->layers_cache = - g_slice_alloc0 (sizeof (CoglMaterialLayer *) * n_layers); + pipeline->layers_cache = + g_slice_alloc0 (sizeof (CoglPipelineLayer *) * n_layers); } /* Notes: * - * Each material doesn't have to contain a complete list of the layers + * Each pipeline doesn't have to contain a complete list of the layers * it depends on, some of them are indirectly referenced through the - * material's ancestors. + * pipeline's ancestors. * - * material->layer_differences only contains a list of layers that + * pipeline->layer_differences only contains a list of layers that * have changed in relation to its parent. * - * material->layer_differences is not maintained sorted, but it + * pipeline->layer_differences is not maintained sorted, but it * won't contain multiple layers corresponding to a particular * ->unit_index. * - * Some of the ancestor materials may reference layers with + * Some of the ancestor pipelines may reference layers with * ->unit_index values >= n_layers so we ignore them. * * As we ascend through the ancestors we are searching for any - * CoglMaterialLayers corresponding to the texture ->unit_index + * CoglPipelineLayers corresponding to the texture ->unit_index * values in the range [0,n_layers-1]. As soon as a pointer is found * we ignore layers of further ancestors with the same ->unit_index * values. */ layers_found = 0; - for (current = material; - _cogl_material_get_parent (current); - current = _cogl_material_get_parent (current)) + for (current = pipeline; + _cogl_pipeline_get_parent (current); + current = _cogl_pipeline_get_parent (current)) { GList *l; - if (!(current->differences & COGL_MATERIAL_STATE_LAYERS)) + if (!(current->differences & COGL_PIPELINE_STATE_LAYERS)) continue; for (l = current->layer_differences; l; l = l->next) { - CoglMaterialLayer *layer = l->data; - int unit_index = _cogl_material_layer_get_unit_index (layer); + CoglPipelineLayer *layer = l->data; + int unit_index = _cogl_pipeline_layer_get_unit_index (layer); - if (unit_index < n_layers && !material->layers_cache[unit_index]) + if (unit_index < n_layers && !pipeline->layers_cache[unit_index]) { - material->layers_cache[unit_index] = layer; + pipeline->layers_cache[unit_index] = layer; layers_found++; if (layers_found == n_layers) return; @@ -681,12 +678,12 @@ _cogl_material_update_layers_cache (CoglMaterial *material) /* XXX: Be carefull when using this API that the callback given doesn't result * in the layer cache being invalidated during the iteration! */ void -_cogl_material_foreach_layer_internal (CoglMaterial *material, - CoglMaterialInternalLayerCallback callback, +_cogl_pipeline_foreach_layer_internal (CoglPipeline *pipeline, + CoglPipelineInternalLayerCallback callback, void *user_data) { - CoglMaterial *authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_LAYERS); + CoglPipeline *authority = + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LAYERS); int n_layers; int i; gboolean cont; @@ -695,7 +692,7 @@ _cogl_material_foreach_layer_internal (CoglMaterial *material, if (n_layers == 0) return; - _cogl_material_update_layers_cache (authority); + _cogl_pipeline_update_layers_cache (authority); for (i = 0, cont = TRUE; i < n_layers && cont == TRUE; i++) { @@ -711,7 +708,7 @@ typedef struct } AppendLayerIndexState; static gboolean -append_layer_index_cb (CoglMaterialLayer *layer, +append_layer_index_cb (CoglPipelineLayer *layer, void *user_data) { AppendLayerIndexState *state = user_data; @@ -720,41 +717,41 @@ append_layer_index_cb (CoglMaterialLayer *layer, } void -cogl_material_foreach_layer (CoglMaterial *material, - CoglMaterialLayerCallback callback, +cogl_pipeline_foreach_layer (CoglPipeline *pipeline, + CoglPipelineLayerCallback callback, void *user_data) { - CoglMaterial *authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_LAYERS); + CoglPipeline *authority = + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LAYERS); AppendLayerIndexState state; gboolean cont; int i; /* XXX: We don't know what the user is going to want to do to the layers * but any modification of layers can result in the layer graph changing - * which could confuse _cogl_material_foreach_layer_internal(). We first + * which could confuse _cogl_pipeline_foreach_layer_internal(). We first * get a list of layer indices which will remain valid so long as the * user doesn't remove layers. */ state.i = 0; state.indices = g_alloca (authority->n_layers * sizeof (int)); - _cogl_material_foreach_layer_internal (material, + _cogl_pipeline_foreach_layer_internal (pipeline, append_layer_index_cb, &state); for (i = 0, cont = TRUE; i < authority->n_layers && cont; i++) - cont = callback (material, state.indices[i], user_data); + cont = callback (pipeline, state.indices[i], user_data); } static gboolean -layer_has_alpha_cb (CoglMaterialLayer *layer, void *data) +layer_has_alpha_cb (CoglPipelineLayer *layer, void *data) { - CoglMaterialLayer *combine_authority = - _cogl_material_layer_get_authority (layer, - COGL_MATERIAL_LAYER_STATE_COMBINE); - CoglMaterialLayerBigState *big_state = combine_authority->big_state; - CoglMaterialLayer *tex_authority; + CoglPipelineLayer *combine_authority = + _cogl_pipeline_layer_get_authority (layer, + COGL_PIPELINE_LAYER_STATE_COMBINE); + CoglPipelineLayerBigState *big_state = combine_authority->big_state; + CoglPipelineLayer *tex_authority; gboolean *has_alpha = data; /* has_alpha maintains the alpha status for the GL_PREVIOUS layer */ @@ -779,8 +776,8 @@ layer_has_alpha_cb (CoglMaterialLayer *layer, void *data) * to the default texture which doesn't have an alpha component */ tex_authority = - _cogl_material_layer_get_authority (layer, - COGL_MATERIAL_LAYER_STATE_TEXTURE); + _cogl_pipeline_layer_get_authority (layer, + COGL_PIPELINE_LAYER_STATE_TEXTURE); if (tex_authority->texture && cogl_texture_get_format (tex_authority->texture) & COGL_A_BIT) { @@ -794,42 +791,42 @@ layer_has_alpha_cb (CoglMaterialLayer *layer, void *data) return TRUE; } -static CoglMaterial * -_cogl_material_get_user_program (CoglMaterial *material) +static CoglPipeline * +_cogl_pipeline_get_user_program (CoglPipeline *pipeline) { - CoglMaterial *authority; + CoglPipeline *authority; - g_return_val_if_fail (cogl_is_material (material), NULL); + g_return_val_if_fail (cogl_is_pipeline (pipeline), NULL); authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_USER_SHADER); + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_USER_SHADER); return authority->big_state->user_program; } static gboolean -_cogl_material_needs_blending_enabled (CoglMaterial *material, +_cogl_pipeline_needs_blending_enabled (CoglPipeline *pipeline, unsigned long changes, const CoglColor *override_color) { - CoglMaterial *enable_authority; - CoglMaterial *blend_authority; - CoglMaterialBlendState *blend_state; - CoglMaterialBlendEnable enabled; + CoglPipeline *enable_authority; + CoglPipeline *blend_authority; + CoglPipelineBlendState *blend_state; + CoglPipelineBlendEnable enabled; unsigned long other_state; if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_BLENDING)) return FALSE; enable_authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_BLEND_ENABLE); + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_BLEND_ENABLE); enabled = enable_authority->blend_enable; - if (enabled != COGL_MATERIAL_BLEND_ENABLE_AUTOMATIC) - return enabled == COGL_MATERIAL_BLEND_ENABLE_ENABLED ? TRUE : FALSE; + if (enabled != COGL_PIPELINE_BLEND_ENABLE_AUTOMATIC) + return enabled == COGL_PIPELINE_BLEND_ENABLE_ENABLED ? TRUE : FALSE; blend_authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_BLEND); + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_BLEND); blend_state = &blend_authority->big_state->blend_state; @@ -864,19 +861,19 @@ _cogl_material_needs_blending_enabled (CoglMaterial *material, /* In the case of a layer state change we need to check everything * else first since they contribute to the has_alpha status of the * GL_PREVIOUS layer. */ - if (changes & COGL_MATERIAL_STATE_LAYERS) - changes = COGL_MATERIAL_STATE_AFFECTS_BLENDING; + if (changes & COGL_PIPELINE_STATE_LAYERS) + changes = COGL_PIPELINE_STATE_AFFECTS_BLENDING; /* XXX: we don't currently handle specific changes in an optimal way*/ - changes = COGL_MATERIAL_STATE_AFFECTS_BLENDING; + changes = COGL_PIPELINE_STATE_AFFECTS_BLENDING; if ((override_color && cogl_color_get_alpha_byte (override_color) != 0xff)) return TRUE; - if (changes & COGL_MATERIAL_STATE_COLOR) + if (changes & COGL_PIPELINE_STATE_COLOR) { CoglColor tmp; - cogl_material_get_color (material, &tmp); + cogl_pipeline_get_color (pipeline, &tmp); if (cogl_color_get_alpha_byte (&tmp) != 0xff) return TRUE; } @@ -886,39 +883,39 @@ _cogl_material_needs_blending_enabled (CoglMaterial *material, * * TODO: check that it isn't just a vertex shader! */ - if (changes & COGL_MATERIAL_STATE_USER_SHADER) + if (changes & COGL_PIPELINE_STATE_USER_SHADER) { - if (_cogl_material_get_user_program (material) != COGL_INVALID_HANDLE) + if (_cogl_pipeline_get_user_program (pipeline) != COGL_INVALID_HANDLE) return TRUE; } /* XXX: we should only need to look at these if lighting is enabled */ - if (changes & COGL_MATERIAL_STATE_LIGHTING) + if (changes & COGL_PIPELINE_STATE_LIGHTING) { CoglColor tmp; - cogl_material_get_ambient (material, &tmp); + cogl_pipeline_get_ambient (pipeline, &tmp); if (cogl_color_get_alpha_byte (&tmp) != 0xff) return TRUE; - cogl_material_get_diffuse (material, &tmp); + cogl_pipeline_get_diffuse (pipeline, &tmp); if (cogl_color_get_alpha_byte (&tmp) != 0xff) return TRUE; - cogl_material_get_specular (material, &tmp); + cogl_pipeline_get_specular (pipeline, &tmp); if (cogl_color_get_alpha_byte (&tmp) != 0xff) return TRUE; - cogl_material_get_emission (material, &tmp); + cogl_pipeline_get_emission (pipeline, &tmp); if (cogl_color_get_alpha_byte (&tmp) != 0xff) return TRUE; } - if (changes & COGL_MATERIAL_STATE_LAYERS) + if (changes & COGL_PIPELINE_STATE_LAYERS) { /* has_alpha tracks the alpha status of the GL_PREVIOUS layer. - * To start with that's defined by the material color which + * To start with that's defined by the pipeline color which * must be fully opaque if we got this far. */ gboolean has_alpha = FALSE; - _cogl_material_foreach_layer_internal (material, + _cogl_pipeline_foreach_layer_internal (pipeline, layer_has_alpha_cb, &has_alpha); if (has_alpha) @@ -927,9 +924,9 @@ _cogl_material_needs_blending_enabled (CoglMaterial *material, /* So far we have only checked the property that has been changed so * we now need to check all the other properties too. */ - other_state = COGL_MATERIAL_STATE_AFFECTS_BLENDING & ~changes; + other_state = COGL_PIPELINE_STATE_AFFECTS_BLENDING & ~changes; if (other_state && - _cogl_material_needs_blending_enabled (material, + _cogl_pipeline_needs_blending_enabled (pipeline, other_state, NULL)) return TRUE; @@ -938,30 +935,30 @@ _cogl_material_needs_blending_enabled (CoglMaterial *material, } void -_cogl_material_set_backend (CoglMaterial *material, int backend) +_cogl_pipeline_set_backend (CoglPipeline *pipeline, int backend) { - _cogl_material_backend_free_priv (material); - material->backend = backend; + _cogl_pipeline_backend_free_priv (pipeline); + pipeline->backend = backend; } static void -_cogl_material_copy_differences (CoglMaterial *dest, - CoglMaterial *src, +_cogl_pipeline_copy_differences (CoglPipeline *dest, + CoglPipeline *src, unsigned long differences) { - CoglMaterialBigState *big_state; + CoglPipelineBigState *big_state; - if (differences & COGL_MATERIAL_STATE_COLOR) + if (differences & COGL_PIPELINE_STATE_COLOR) dest->color = src->color; - if (differences & COGL_MATERIAL_STATE_BLEND_ENABLE) + if (differences & COGL_PIPELINE_STATE_BLEND_ENABLE) dest->blend_enable = src->blend_enable; - if (differences & COGL_MATERIAL_STATE_LAYERS) + if (differences & COGL_PIPELINE_STATE_LAYERS) { GList *l; - if (dest->differences & COGL_MATERIAL_STATE_LAYERS && + if (dest->differences & COGL_PIPELINE_STATE_LAYERS && dest->layer_differences) { g_list_foreach (dest->layer_differences, @@ -976,8 +973,8 @@ _cogl_material_copy_differences (CoglMaterial *dest, * simply take a references on each of the original * layer_differences, we have to derive new layers from the * originals instead. */ - CoglMaterialLayer *copy = _cogl_material_layer_copy (l->data); - _cogl_material_add_layer_difference (dest, copy, FALSE); + CoglPipelineLayer *copy = _cogl_pipeline_layer_copy (l->data); + _cogl_pipeline_add_layer_difference (dest, copy, FALSE); cogl_object_unref (copy); } @@ -987,11 +984,11 @@ _cogl_material_copy_differences (CoglMaterial *dest, dest->n_layers = src->n_layers; } - if (differences & COGL_MATERIAL_STATE_NEEDS_BIG_STATE) + if (differences & COGL_PIPELINE_STATE_NEEDS_BIG_STATE) { if (!dest->has_big_state) { - dest->big_state = g_slice_new (CoglMaterialBigState); + dest->big_state = g_slice_new (CoglPipelineBigState); dest->has_big_state = TRUE; } big_state = dest->big_state; @@ -999,28 +996,28 @@ _cogl_material_copy_differences (CoglMaterial *dest, else goto check_for_blending_change; - if (differences & COGL_MATERIAL_STATE_LIGHTING) + if (differences & COGL_PIPELINE_STATE_LIGHTING) { memcpy (&big_state->lighting_state, &src->big_state->lighting_state, - sizeof (CoglMaterialLightingState)); + sizeof (CoglPipelineLightingState)); } - if (differences & COGL_MATERIAL_STATE_ALPHA_FUNC) + if (differences & COGL_PIPELINE_STATE_ALPHA_FUNC) { memcpy (&big_state->alpha_state, &src->big_state->alpha_state, - sizeof (CoglMaterialAlphaFuncState)); + sizeof (CoglPipelineAlphaFuncState)); } - if (differences & COGL_MATERIAL_STATE_BLEND) + if (differences & COGL_PIPELINE_STATE_BLEND) { memcpy (&big_state->blend_state, &src->big_state->blend_state, - sizeof (CoglMaterialBlendState)); + sizeof (CoglPipelineBlendState)); } - if (differences & COGL_MATERIAL_STATE_USER_SHADER) + if (differences & COGL_PIPELINE_STATE_USER_SHADER) { if (src->big_state->user_program) big_state->user_program = @@ -1029,47 +1026,47 @@ _cogl_material_copy_differences (CoglMaterial *dest, big_state->user_program = COGL_INVALID_HANDLE; } - if (differences & COGL_MATERIAL_STATE_DEPTH) + if (differences & COGL_PIPELINE_STATE_DEPTH) { memcpy (&big_state->depth_state, &src->big_state->depth_state, - sizeof (CoglMaterialDepthState)); + sizeof (CoglPipelineDepthState)); } - if (differences & COGL_MATERIAL_STATE_FOG) + if (differences & COGL_PIPELINE_STATE_FOG) { memcpy (&big_state->fog_state, &src->big_state->fog_state, - sizeof (CoglMaterialFogState)); + sizeof (CoglPipelineFogState)); } - if (differences & COGL_MATERIAL_STATE_POINT_SIZE) + if (differences & COGL_PIPELINE_STATE_POINT_SIZE) big_state->point_size = src->big_state->point_size; /* XXX: we shouldn't bother doing this in most cases since - * _copy_differences is typically used to initialize material state + * _copy_differences is typically used to initialize pipeline state * by copying it from the current authority, so it's not actually * *changing* anything. */ check_for_blending_change: - if (differences & COGL_MATERIAL_STATE_AFFECTS_BLENDING) + if (differences & COGL_PIPELINE_STATE_AFFECTS_BLENDING) handle_automatic_blend_enable (dest, differences); dest->differences |= differences; } static void -_cogl_material_initialize_sparse_state (CoglMaterial *dest, - CoglMaterial *src, - CoglMaterialState state) +_cogl_pipeline_initialize_sparse_state (CoglPipeline *dest, + CoglPipeline *src, + CoglPipelineState state) { if (dest == src) return; - g_return_if_fail (state & COGL_MATERIAL_STATE_ALL_SPARSE); + g_return_if_fail (state & COGL_PIPELINE_STATE_ALL_SPARSE); - if (state != COGL_MATERIAL_STATE_LAYERS) - _cogl_material_copy_differences (dest, src, state); + if (state != COGL_PIPELINE_STATE_LAYERS) + _cogl_pipeline_copy_differences (dest, src, state); else { dest->n_layers = src->n_layers; @@ -1078,12 +1075,12 @@ _cogl_material_initialize_sparse_state (CoglMaterial *dest, } static gboolean -check_if_strong_cb (CoglMaterialNode *node, void *user_data) +check_if_strong_cb (CoglPipelineNode *node, void *user_data) { - CoglMaterial *material = COGL_MATERIAL (node); + CoglPipeline *pipeline = COGL_PIPELINE (node); gboolean *has_strong_child = user_data; - if (!_cogl_material_is_weak (material)) + if (!_cogl_pipeline_is_weak (pipeline)) { *has_strong_child = TRUE; return FALSE; @@ -1093,64 +1090,64 @@ check_if_strong_cb (CoglMaterialNode *node, void *user_data) } static gboolean -has_strong_children (CoglMaterial *material) +has_strong_children (CoglPipeline *pipeline) { gboolean has_strong_child = FALSE; - _cogl_material_node_foreach_child (COGL_MATERIAL_NODE (material), + _cogl_pipeline_node_foreach_child (COGL_PIPELINE_NODE (pipeline), check_if_strong_cb, &has_strong_child); return has_strong_child; } static gboolean -_cogl_material_is_weak (CoglMaterial *material) +_cogl_pipeline_is_weak (CoglPipeline *pipeline) { - if (material->is_weak && !has_strong_children (material)) + if (pipeline->is_weak && !has_strong_children (pipeline)) return TRUE; else return FALSE; } static gboolean -reparent_children_cb (CoglMaterialNode *node, +reparent_children_cb (CoglPipelineNode *node, void *user_data) { - CoglMaterial *material = COGL_MATERIAL (node); - CoglMaterial *parent = user_data; + CoglPipeline *pipeline = COGL_PIPELINE (node); + CoglPipeline *parent = user_data; - _cogl_material_set_parent (material, parent, TRUE); + _cogl_pipeline_set_parent (pipeline, parent, TRUE); return TRUE; } static void -_cogl_material_pre_change_notify (CoglMaterial *material, - CoglMaterialState change, +_cogl_pipeline_pre_change_notify (CoglPipeline *pipeline, + CoglPipelineState change, const CoglColor *new_color, gboolean from_layer_change) { - CoglMaterial *authority; + CoglPipeline *authority; _COGL_GET_CONTEXT (ctx, NO_RETVAL); /* If primitives have been logged in the journal referencing the - * current state of this material we need to flush the journal + * current state of this pipeline we need to flush the journal * before we can modify it... */ - if (material->journal_ref_count) + if (pipeline->journal_ref_count) { gboolean skip_journal_flush = FALSE; /* XXX: We don't usually need to flush the journal just due to - * color changes since material colors are logged in the + * color changes since pipeline colors are logged in the * journal's vertex buffer. The exception is when the change in * color enables or disables the need for blending. */ - if (change == COGL_MATERIAL_STATE_COLOR) + if (change == COGL_PIPELINE_STATE_COLOR) { gboolean will_need_blending = - _cogl_material_needs_blending_enabled (material, + _cogl_pipeline_needs_blending_enabled (pipeline, change, new_color); - gboolean blend_enable = material->real_blend_enable ? TRUE : FALSE; + gboolean blend_enable = pipeline->real_blend_enable ? TRUE : FALSE; if (will_need_blending == blend_enable) skip_journal_flush = TRUE; @@ -1161,22 +1158,22 @@ _cogl_material_pre_change_notify (CoglMaterial *material, } /* The fixed function backend has no private state and can't - * do anything special to handle small material changes so we may as - * well try to find a better backend whenever the material changes. + * do anything special to handle small pipeline changes so we may as + * well try to find a better backend whenever the pipeline changes. * * The programmable backends may be able to cache a lot of the code * they generate and only need to update a small section of that - * code in response to a material change therefore we don't want to - * try searching for another backend when the material changes. + * code in response to a pipeline change therefore we don't want to + * try searching for another backend when the pipeline changes. */ - if (material->backend == COGL_MATERIAL_BACKEND_FIXED) - _cogl_material_set_backend (material, COGL_MATERIAL_BACKEND_UNDEFINED); + if (pipeline->backend == COGL_PIPELINE_BACKEND_FIXED) + _cogl_pipeline_set_backend (pipeline, COGL_PIPELINE_BACKEND_UNDEFINED); - if (material->backend != COGL_MATERIAL_BACKEND_UNDEFINED && - _cogl_material_backends[material->backend]->material_pre_change_notify) + if (pipeline->backend != COGL_PIPELINE_BACKEND_UNDEFINED && + _cogl_pipeline_backends[pipeline->backend]->pipeline_pre_change_notify) { - const CoglMaterialBackend *backend = - _cogl_material_backends[material->backend]; + const CoglPipelineBackend *backend = + _cogl_pipeline_backends[pipeline->backend]; /* To simplify things for the backends we are careful about how * we report STATE_LAYERS changes. @@ -1186,76 +1183,76 @@ _cogl_material_pre_change_notify (CoglMaterial *material, * backends that perform code generation for fragment processing * they typically need to understand the details of how layers * get changed to determine if they need to repeat codegen. It - * doesn't help them to report a material STATE_LAYERS change + * doesn't help them to report a pipeline STATE_LAYERS change * for all layer changes since it's so broad, they really need * to wait for the layer change to be notified. What does help * though is to report a STATE_LAYERS change for a change in * ->n_layers because they typically do need to repeat codegen * in that case. * - * This just ensures backends only get a single material or + * This just ensures backends only get a single pipeline or * layer pre-change notification for any particular change. */ if (!from_layer_change) - backend->material_pre_change_notify (material, change, new_color); + backend->pipeline_pre_change_notify (pipeline, change, new_color); } - /* There may be an arbitrary tree of descendants of this material; - * any of which may indirectly depend on this material as the + /* There may be an arbitrary tree of descendants of this pipeline; + * any of which may indirectly depend on this pipeline as the * authority for some set of properties. (Meaning for example that * one of its descendants derives its color or blending state from - * this material.) + * this pipeline.) * - * We can't modify any property that this material is the authority - * for unless we create another material to take its place first and - * make sure descendants reference this new material instead. + * We can't modify any property that this pipeline is the authority + * for unless we create another pipeline to take its place first and + * make sure descendants reference this new pipeline instead. */ - /* The simplest descendants to handle are weak materials; we simply - * destroy them if we are modifying a material they depend on. This - * means weak materials never cause us to do a copy-on-write. */ - _cogl_material_node_foreach_child (COGL_MATERIAL_NODE (material), + /* The simplest descendants to handle are weak pipelines; we simply + * destroy them if we are modifying a pipeline they depend on. This + * means weak pipelines never cause us to do a copy-on-write. */ + _cogl_pipeline_node_foreach_child (COGL_PIPELINE_NODE (pipeline), destroy_weak_children_cb, NULL); /* If there are still children remaining though we'll need to * perform a copy-on-write and reparent the dependants as children * of the copy. */ - if (COGL_MATERIAL_NODE (material)->has_children) + if (COGL_PIPELINE_NODE (pipeline)->has_children) { - CoglMaterial *new_authority; + CoglPipeline *new_authority; - COGL_STATIC_COUNTER (material_copy_on_write_counter, - "material copy on write counter", - "Increments each time a material " + COGL_STATIC_COUNTER (pipeline_copy_on_write_counter, + "pipeline copy on write counter", + "Increments each time a pipeline " "must be copied to allow modification", 0 /* no application private data */); - COGL_COUNTER_INC (_cogl_uprof_context, material_copy_on_write_counter); + COGL_COUNTER_INC (_cogl_uprof_context, pipeline_copy_on_write_counter); new_authority = - cogl_material_copy (_cogl_material_get_parent (material)); - _cogl_material_set_static_breadcrumb (new_authority, + cogl_pipeline_copy (_cogl_pipeline_get_parent (pipeline)); + _cogl_pipeline_set_static_breadcrumb (new_authority, "pre_change_notify:copy-on-write"); /* We could explicitly walk the descendants, OR together the set - * of differences that we determine this material is the + * of differences that we determine this pipeline is the * authority on and only copy those differences copied across. * * Or, if we don't explicitly walk the descendants we at least - * know that material->differences represents the largest set of - * differences that this material could possibly be an authority + * know that pipeline->differences represents the largest set of + * differences that this pipeline could possibly be an authority * on. * * We do the later just because it's simplest, but we might need * to come back to this later... */ - _cogl_material_copy_differences (new_authority, material, - material->differences); + _cogl_pipeline_copy_differences (new_authority, pipeline, + pipeline->differences); - /* Reparent the dependants of material to be children of + /* Reparent the dependants of pipeline to be children of * new_authority instead... */ - _cogl_material_node_foreach_child (COGL_MATERIAL_NODE (material), + _cogl_pipeline_node_foreach_child (COGL_PIPELINE_NODE (pipeline), reparent_children_cb, new_authority); @@ -1264,106 +1261,106 @@ _cogl_material_pre_change_notify (CoglMaterial *material, cogl_object_unref (new_authority); } - /* At this point we know we have a material with no strong + /* At this point we know we have a pipeline with no strong * dependants (though we may have some weak children) so we are now - * free to modify the material. */ + * free to modify the pipeline. */ - material->age++; + pipeline->age++; - /* If changing a sparse property and if the material isn't already an + /* If changing a sparse property and if the pipeline isn't already an * authority for the state group being modified then we need to * initialize the corresponding state. */ - if (change & COGL_MATERIAL_STATE_ALL_SPARSE && - !(material->differences & change)) + if (change & COGL_PIPELINE_STATE_ALL_SPARSE && + !(pipeline->differences & change)) { - authority = _cogl_material_get_authority (material, change); - _cogl_material_initialize_sparse_state (material, authority, change); + authority = _cogl_pipeline_get_authority (pipeline, change); + _cogl_pipeline_initialize_sparse_state (pipeline, authority, change); } - /* Each material has a sorted cache of the layers it depends on - * which will need updating via _cogl_material_update_layers_cache - * if a material's layers are changed. */ - if (change == COGL_MATERIAL_STATE_LAYERS) - recursively_free_layer_caches (material); + /* Each pipeline has a sorted cache of the layers it depends on + * which will need updating via _cogl_pipeline_update_layers_cache + * if a pipeline's layers are changed. */ + if (change == COGL_PIPELINE_STATE_LAYERS) + recursively_free_layer_caches (pipeline); - /* If the material being changed is the same as the last material we + /* If the pipeline being changed is the same as the last pipeline we * flushed then we keep a track of the changes so we can try to - * minimize redundant OpenGL calls if the same material is flushed + * minimize redundant OpenGL calls if the same pipeline is flushed * again. */ - if (ctx->current_material == material) - ctx->current_material_changes_since_flush |= change; + if (ctx->current_pipeline == pipeline) + ctx->current_pipeline_changes_since_flush |= change; } static void -_cogl_material_add_layer_difference (CoglMaterial *material, - CoglMaterialLayer *layer, +_cogl_pipeline_add_layer_difference (CoglPipeline *pipeline, + CoglPipelineLayer *layer, gboolean inc_n_layers) { g_return_if_fail (layer->owner == NULL); - layer->owner = material; + layer->owner = pipeline; cogl_object_ref (layer); /* - Flush journal primitives referencing the current state. - * - Make sure the material has no dependants so it may be modified. - * - If the material isn't currently an authority for the state being + * - Make sure the pipeline has no dependants so it may be modified. + * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ - _cogl_material_pre_change_notify (material, - COGL_MATERIAL_STATE_LAYERS, + _cogl_pipeline_pre_change_notify (pipeline, + COGL_PIPELINE_STATE_LAYERS, NULL, FALSE); - material->differences |= COGL_MATERIAL_STATE_LAYERS; + pipeline->differences |= COGL_PIPELINE_STATE_LAYERS; - material->layer_differences = - g_list_prepend (material->layer_differences, layer); + pipeline->layer_differences = + g_list_prepend (pipeline->layer_differences, layer); if (inc_n_layers) - material->n_layers++; + pipeline->n_layers++; } /* NB: If you are calling this it's your responsibility to have * already called: - * _cogl_material_pre_change_notify (m, _CHANGE_LAYERS, NULL); + * _cogl_pipeline_pre_change_notify (m, _CHANGE_LAYERS, NULL); */ static void -_cogl_material_remove_layer_difference (CoglMaterial *material, - CoglMaterialLayer *layer, +_cogl_pipeline_remove_layer_difference (CoglPipeline *pipeline, + CoglPipelineLayer *layer, gboolean dec_n_layers) { - g_return_if_fail (layer->owner == material); + g_return_if_fail (layer->owner == pipeline); /* - Flush journal primitives referencing the current state. - * - Make sure the material has no dependants so it may be modified. - * - If the material isn't currently an authority for the state being + * - Make sure the pipeline has no dependants so it may be modified. + * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ - _cogl_material_pre_change_notify (material, - COGL_MATERIAL_STATE_LAYERS, + _cogl_pipeline_pre_change_notify (pipeline, + COGL_PIPELINE_STATE_LAYERS, NULL, FALSE); layer->owner = NULL; cogl_object_unref (layer); - material->differences |= COGL_MATERIAL_STATE_LAYERS; + pipeline->differences |= COGL_PIPELINE_STATE_LAYERS; - material->layer_differences = - g_list_remove (material->layer_differences, layer); + pipeline->layer_differences = + g_list_remove (pipeline->layer_differences, layer); if (dec_n_layers) - material->n_layers--; + pipeline->n_layers--; } static void -_cogl_material_try_reverting_layers_authority (CoglMaterial *authority, - CoglMaterial *old_authority) +_cogl_pipeline_try_reverting_layers_authority (CoglPipeline *authority, + CoglPipeline *old_authority) { if (authority->layer_differences == NULL && - _cogl_material_get_parent (authority)) + _cogl_pipeline_get_parent (authority)) { /* If the previous _STATE_LAYERS authority has the same * ->n_layers then we can revert to that being the authority @@ -1371,37 +1368,37 @@ _cogl_material_try_reverting_layers_authority (CoglMaterial *authority, if (!old_authority) { old_authority = - _cogl_material_get_authority (_cogl_material_get_parent (authority), - COGL_MATERIAL_STATE_LAYERS); + _cogl_pipeline_get_authority (_cogl_pipeline_get_parent (authority), + COGL_PIPELINE_STATE_LAYERS); } if (old_authority->n_layers == authority->n_layers) - authority->differences &= ~COGL_MATERIAL_STATE_LAYERS; + authority->differences &= ~COGL_PIPELINE_STATE_LAYERS; } } static void -handle_automatic_blend_enable (CoglMaterial *material, - CoglMaterialState change) +handle_automatic_blend_enable (CoglPipeline *pipeline, + CoglPipelineState change) { gboolean blend_enable = - _cogl_material_needs_blending_enabled (material, change, NULL); + _cogl_pipeline_needs_blending_enabled (pipeline, change, NULL); - if (blend_enable != material->real_blend_enable) + if (blend_enable != pipeline->real_blend_enable) { /* - Flush journal primitives referencing the current state. - * - Make sure the material has no dependants so it may be + * - Make sure the pipeline has no dependants so it may be * modified. - * - If the material isn't currently an authority for the state + * - If the pipeline isn't currently an authority for the state * being changed, then initialize that state from the current * authority. */ - _cogl_material_pre_change_notify (material, - COGL_MATERIAL_STATE_REAL_BLEND_ENABLE, + _cogl_pipeline_pre_change_notify (pipeline, + COGL_PIPELINE_STATE_REAL_BLEND_ENABLE, NULL, FALSE); - material->real_blend_enable = blend_enable; + pipeline->real_blend_enable = blend_enable; } } @@ -1411,12 +1408,12 @@ typedef struct int current_pos; gboolean needs_pruning; int first_index_to_prune; -} CoglMaterialPruneLayersInfo; +} CoglPipelinePruneLayersInfo; static gboolean -update_prune_layers_info_cb (CoglMaterialLayer *layer, void *user_data) +update_prune_layers_info_cb (CoglPipelineLayer *layer, void *user_data) { - CoglMaterialPruneLayersInfo *state = user_data; + CoglPipelinePruneLayersInfo *state = user_data; if (state->current_pos == state->keep_n) { @@ -1429,9 +1426,9 @@ update_prune_layers_info_cb (CoglMaterialLayer *layer, void *user_data) } void -_cogl_material_prune_to_n_layers (CoglMaterial *material, int n) +_cogl_pipeline_prune_to_n_layers (CoglPipeline *pipeline, int n) { - CoglMaterialPruneLayersInfo state; + CoglPipelinePruneLayersInfo state; gboolean notified_change = TRUE; GList *l; GList *next; @@ -1439,23 +1436,23 @@ _cogl_material_prune_to_n_layers (CoglMaterial *material, int n) state.keep_n = n; state.current_pos = 0; state.needs_pruning = FALSE; - _cogl_material_foreach_layer_internal (material, + _cogl_pipeline_foreach_layer_internal (pipeline, update_prune_layers_info_cb, &state); - material->n_layers = n; + pipeline->n_layers = n; if (!state.needs_pruning) return; - if (!(material->differences & COGL_MATERIAL_STATE_LAYERS)) + if (!(pipeline->differences & COGL_PIPELINE_STATE_LAYERS)) return; - /* It's possible that this material owns some of the layers being + /* It's possible that this pipeline owns some of the layers being * discarded, so we'll need to unlink them... */ - for (l = material->layer_differences; l; l = next) + for (l = pipeline->layer_differences; l; l = next) { - CoglMaterialLayer *layer = l->data; + CoglPipelineLayer *layer = l->data; next = l->next; /* we're modifying the list we're iterating */ if (layer->index > state.first_index_to_prune) @@ -1464,42 +1461,42 @@ _cogl_material_prune_to_n_layers (CoglMaterial *material, int n) { /* - Flush journal primitives referencing the current * state. - * - Make sure the material has no dependants so it may + * - Make sure the pipeline has no dependants so it may * be modified. - * - If the material isn't currently an authority for + * - If the pipeline isn't currently an authority for * the state being changed, then initialize that state * from the current authority. */ - _cogl_material_pre_change_notify (material, - COGL_MATERIAL_STATE_LAYERS, + _cogl_pipeline_pre_change_notify (pipeline, + COGL_PIPELINE_STATE_LAYERS, NULL, FALSE); notified_change = TRUE; } - material->layer_differences = - g_list_delete_link (material->layer_differences, l); + pipeline->layer_differences = + g_list_delete_link (pipeline->layer_differences, l); } } } static void -_cogl_material_backend_layer_change_notify (CoglMaterial *owner, - CoglMaterialLayer *layer, - CoglMaterialLayerState change) +_cogl_pipeline_backend_layer_change_notify (CoglPipeline *owner, + CoglPipelineLayer *layer, + CoglPipelineLayerState change) { int i; - /* NB: layers may be used by multiple materials which may be using + /* NB: layers may be used by multiple pipelines which may be using * different backends, therefore we determine which backends to * notify based on the private state pointers for each backend... */ - for (i = 0; i < COGL_MATERIAL_N_BACKENDS; i++) + for (i = 0; i < COGL_PIPELINE_N_BACKENDS; i++) { if (layer->backend_priv[i] && - _cogl_material_backends[i]->layer_pre_change_notify) + _cogl_pipeline_backends[i]->layer_pre_change_notify) { - const CoglMaterialBackend *backend = _cogl_material_backends[i]; + const CoglPipelineBackend *backend = _cogl_pipeline_backends[i]; backend->layer_pre_change_notify (owner, layer, change); } } @@ -1526,38 +1523,38 @@ _cogl_get_n_args_for_combine_func (GLint func) } static void -_cogl_material_layer_initialize_state (CoglMaterialLayer *dest, - CoglMaterialLayer *src, +_cogl_pipeline_layer_initialize_state (CoglPipelineLayer *dest, + CoglPipelineLayer *src, unsigned long differences) { - CoglMaterialLayerBigState *big_state; + CoglPipelineLayerBigState *big_state; dest->differences |= differences; - if (differences & COGL_MATERIAL_LAYER_STATE_UNIT) + if (differences & COGL_PIPELINE_LAYER_STATE_UNIT) dest->unit_index = src->unit_index; - if (differences & COGL_MATERIAL_LAYER_STATE_TEXTURE) + if (differences & COGL_PIPELINE_LAYER_STATE_TEXTURE) dest->texture = src->texture; - if (differences & COGL_MATERIAL_LAYER_STATE_FILTERS) + if (differences & COGL_PIPELINE_LAYER_STATE_FILTERS) { dest->min_filter = src->min_filter; dest->mag_filter = src->mag_filter; } - if (differences & COGL_MATERIAL_LAYER_STATE_WRAP_MODES) + if (differences & COGL_PIPELINE_LAYER_STATE_WRAP_MODES) { dest->wrap_mode_s = src->wrap_mode_s; dest->wrap_mode_t = src->wrap_mode_t; dest->wrap_mode_p = src->wrap_mode_p; } - if (differences & COGL_MATERIAL_LAYER_STATE_NEEDS_BIG_STATE) + if (differences & COGL_PIPELINE_LAYER_STATE_NEEDS_BIG_STATE) { if (!dest->has_big_state) { - dest->big_state = g_slice_new (CoglMaterialLayerBigState); + dest->big_state = g_slice_new (CoglPipelineLayerBigState); dest->has_big_state = TRUE; } big_state = dest->big_state; @@ -1565,7 +1562,7 @@ _cogl_material_layer_initialize_state (CoglMaterialLayer *dest, else return; - if (differences & COGL_MATERIAL_LAYER_STATE_COMBINE) + if (differences & COGL_PIPELINE_LAYER_STATE_COMBINE) { int n_args; int i; @@ -1592,15 +1589,15 @@ _cogl_material_layer_initialize_state (CoglMaterialLayer *dest, } } - if (differences & COGL_MATERIAL_LAYER_STATE_COMBINE_CONSTANT) + if (differences & COGL_PIPELINE_LAYER_STATE_COMBINE_CONSTANT) memcpy (dest->big_state->texture_combine_constant, src->big_state->texture_combine_constant, sizeof (float) * 4); - if (differences & COGL_MATERIAL_LAYER_STATE_USER_MATRIX) + if (differences & COGL_PIPELINE_LAYER_STATE_USER_MATRIX) dest->big_state->matrix = src->big_state->matrix; - if (differences & COGL_MATERIAL_LAYER_STATE_POINT_SPRITE_COORDS) + if (differences & COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS) dest->big_state->point_sprite_coords = src->big_state->point_sprite_coords; } @@ -1613,17 +1610,17 @@ _cogl_material_layer_initialize_state (CoglMaterialLayer *dest, * required_owner can only by NULL for new, currently unowned layers * with no dependants. */ -static CoglMaterialLayer * -_cogl_material_layer_pre_change_notify (CoglMaterial *required_owner, - CoglMaterialLayer *layer, - CoglMaterialLayerState change) +static CoglPipelineLayer * +_cogl_pipeline_layer_pre_change_notify (CoglPipeline *required_owner, + CoglPipelineLayer *layer, + CoglPipelineLayerState change) { CoglTextureUnit *unit; - CoglMaterialLayer *authority; + CoglPipelineLayer *authority; /* Identify the case where the layer is new with no owner or * dependants and so we don't need to do anything. */ - if (COGL_MATERIAL_NODE (layer)->has_children == FALSE && + if (COGL_PIPELINE_NODE (layer)->has_children == FALSE && layer->owner == NULL) goto init_layer_state; @@ -1636,39 +1633,39 @@ _cogl_material_layer_pre_change_notify (CoglMaterial *required_owner, * references to the current owner state and if necessary perform * a copy-on-write for the required_owner if it has dependants. */ - _cogl_material_pre_change_notify (required_owner, - COGL_MATERIAL_STATE_LAYERS, + _cogl_pipeline_pre_change_notify (required_owner, + COGL_PIPELINE_STATE_LAYERS, NULL, TRUE); - /* Unlike materials; layers are simply considered immutable once + /* Unlike pipelines; layers are simply considered immutable once * they have dependants - either direct children, or another - * material as an owner. + * pipeline as an owner. */ - if (COGL_MATERIAL_NODE (layer)->has_children || + if (COGL_PIPELINE_NODE (layer)->has_children || layer->owner != required_owner) { - CoglMaterialLayer *new = _cogl_material_layer_copy (layer); + CoglPipelineLayer *new = _cogl_pipeline_layer_copy (layer); if (layer->owner == required_owner) - _cogl_material_remove_layer_difference (required_owner, layer, FALSE); - _cogl_material_add_layer_difference (required_owner, new, FALSE); + _cogl_pipeline_remove_layer_difference (required_owner, layer, FALSE); + _cogl_pipeline_add_layer_difference (required_owner, new, FALSE); cogl_object_unref (new); layer = new; goto init_layer_state; } - /* Note: At this point we know there is only one material dependant on + /* Note: At this point we know there is only one pipeline dependant on * this layer (required_owner), and there are no other layers * dependant on this layer so it's ok to modify it. */ - _cogl_material_backend_layer_change_notify (required_owner, layer, change); + _cogl_pipeline_backend_layer_change_notify (required_owner, layer, change); /* If the layer being changed is the same as the last layer we * flushed to the corresponding texture unit then we keep a track of * the changes so we can try to minimize redundant OpenGL calls if * the same layer is flushed again. */ - unit = _cogl_get_texture_unit (_cogl_material_layer_get_unit_index (layer)); + unit = _cogl_get_texture_unit (_cogl_pipeline_layer_get_unit_index (layer)); if (unit->layer == layer) unit->layer_changes_since_flush |= change; @@ -1677,49 +1674,49 @@ init_layer_state: if (required_owner) required_owner->age++; - /* If the material isn't already an authority for the state group + /* If the pipeline isn't already an authority for the state group * being modified then we need to initialize the corresponding * state. */ - authority = _cogl_material_layer_get_authority (layer, change); - _cogl_material_layer_initialize_state (layer, authority, change); + authority = _cogl_pipeline_layer_get_authority (layer, change); + _cogl_pipeline_layer_initialize_state (layer, authority, change); return layer; } static void -_cogl_material_layer_unparent (CoglMaterialNode *layer) +_cogl_pipeline_layer_unparent (CoglPipelineNode *layer) { /* Chain up */ - _cogl_material_node_unparent_real (layer); + _cogl_pipeline_node_unparent_real (layer); } static void -_cogl_material_layer_set_parent (CoglMaterialLayer *layer, - CoglMaterialLayer *parent) +_cogl_pipeline_layer_set_parent (CoglPipelineLayer *layer, + CoglPipelineLayer *parent) { /* Chain up */ - _cogl_material_node_set_parent_real (COGL_MATERIAL_NODE (layer), - COGL_MATERIAL_NODE (parent), - _cogl_material_layer_unparent, + _cogl_pipeline_node_set_parent_real (COGL_PIPELINE_NODE (layer), + COGL_PIPELINE_NODE (parent), + _cogl_pipeline_layer_unparent, TRUE); } /* XXX: This is duplicated logic; the same as for - * _cogl_material_prune_redundant_ancestry it would be nice to find a + * _cogl_pipeline_prune_redundant_ancestry it would be nice to find a * way to consolidate these functions! */ static void -_cogl_material_layer_prune_redundant_ancestry (CoglMaterialLayer *layer) +_cogl_pipeline_layer_prune_redundant_ancestry (CoglPipelineLayer *layer) { - CoglMaterialLayer *new_parent = _cogl_material_layer_get_parent (layer); + CoglPipelineLayer *new_parent = _cogl_pipeline_layer_get_parent (layer); /* walk up past ancestors that are now redundant and potentially * reparent the layer. */ - while (_cogl_material_layer_get_parent (new_parent) && + while (_cogl_pipeline_layer_get_parent (new_parent) && (new_parent->differences | layer->differences) == layer->differences) - new_parent = _cogl_material_layer_get_parent (new_parent); + new_parent = _cogl_pipeline_layer_get_parent (new_parent); - _cogl_material_layer_set_parent (layer, new_parent); + _cogl_pipeline_layer_set_parent (layer, new_parent); } /* @@ -1727,28 +1724,28 @@ _cogl_material_layer_prune_redundant_ancestry (CoglMaterialLayer *layer) * property so instead we can assume it's valid for all layer * instances. * - We would need to initialize ->unit_index in - * _cogl_material_layer_copy (). + * _cogl_pipeline_layer_copy (). * * XXX: If you use this API you should consider that the given layer * might not be writeable and so a new derived layer will be allocated * and modified instead. The layer modified will be returned so you * can identify when this happens. */ -static CoglMaterialLayer * -_cogl_material_set_layer_unit (CoglMaterial *required_owner, - CoglMaterialLayer *layer, +static CoglPipelineLayer * +_cogl_pipeline_set_layer_unit (CoglPipeline *required_owner, + CoglPipelineLayer *layer, int unit_index) { - CoglMaterialLayerState change = COGL_MATERIAL_LAYER_STATE_UNIT; - CoglMaterialLayer *authority = - _cogl_material_layer_get_authority (layer, change); - CoglMaterialLayer *new; + CoglPipelineLayerState change = COGL_PIPELINE_LAYER_STATE_UNIT; + CoglPipelineLayer *authority = + _cogl_pipeline_layer_get_authority (layer, change); + CoglPipelineLayer *new; if (authority->unit_index == unit_index) return layer; new = - _cogl_material_layer_pre_change_notify (required_owner, + _cogl_pipeline_layer_pre_change_notify (required_owner, layer, change); if (new != layer) @@ -1759,12 +1756,12 @@ _cogl_material_set_layer_unit (CoglMaterial *required_owner, * we are changing see if we can revert to one of our ancestors * being the authority. */ if (layer == authority && - _cogl_material_layer_get_parent (authority) != NULL) + _cogl_pipeline_layer_get_parent (authority) != NULL) { - CoglMaterialLayer *parent = - _cogl_material_layer_get_parent (authority); - CoglMaterialLayer *old_authority = - _cogl_material_layer_get_authority (parent, change); + CoglPipelineLayer *parent = + _cogl_pipeline_layer_get_parent (authority); + CoglPipelineLayer *old_authority = + _cogl_pipeline_layer_get_authority (parent, change); if (old_authority->unit_index == unit_index) { @@ -1783,7 +1780,7 @@ _cogl_material_set_layer_unit (CoglMaterial *required_owner, if (layer != authority) { layer->differences |= change; - _cogl_material_layer_prune_redundant_ancestry (layer); + _cogl_pipeline_layer_prune_redundant_ancestry (layer); } return layer; @@ -1795,7 +1792,7 @@ typedef struct int layer_index; /* The layer we find or untouched if not found */ - CoglMaterialLayer *layer; + CoglPipelineLayer *layer; /* If the layer can't be found then a new layer should be * inserted after this texture unit index... */ @@ -1806,7 +1803,7 @@ typedef struct * layers to shift down. * * Note: the list isn't sorted */ - CoglMaterialLayer **layers_to_shift; + CoglPipelineLayer **layers_to_shift; int n_layers_to_shift; /* When adding a layer we don't need a complete list of @@ -1814,12 +1811,12 @@ typedef struct * layer_index. */ gboolean ignore_shift_layers_if_found; -} CoglMaterialLayerInfo; +} CoglPipelineLayerInfo; /* Returns TRUE once we know there is nothing more to update */ static gboolean -update_layer_info (CoglMaterialLayer *layer, - CoglMaterialLayerInfo *layer_info) +update_layer_info (CoglPipelineLayer *layer, + CoglPipelineLayerInfo *layer_info) { if (layer->index == layer_info->layer_index) { @@ -1829,7 +1826,7 @@ update_layer_info (CoglMaterialLayer *layer, } else if (layer->index < layer_info->layer_index) { - int unit_index = _cogl_material_layer_get_unit_index (layer); + int unit_index = _cogl_pipeline_layer_get_unit_index (layer); layer_info->insert_after = unit_index; } else @@ -1841,10 +1838,10 @@ update_layer_info (CoglMaterialLayer *layer, /* Returns FALSE to break out of a _foreach_layer () iteration */ static gboolean -update_layer_info_cb (CoglMaterialLayer *layer, +update_layer_info_cb (CoglPipelineLayer *layer, void *user_data) { - CoglMaterialLayerInfo *layer_info = user_data; + CoglPipelineLayerInfo *layer_info = user_data; if (update_layer_info (layer, layer_info)) return FALSE; /* break */ @@ -1853,50 +1850,50 @@ update_layer_info_cb (CoglMaterialLayer *layer, } static void -_cogl_material_get_layer_info (CoglMaterial *material, - CoglMaterialLayerInfo *layer_info) +_cogl_pipeline_get_layer_info (CoglPipeline *pipeline, + CoglPipelineLayerInfo *layer_info) { - /* Note: we are assuming this material is a _STATE_LAYERS authority */ - int n_layers = material->n_layers; + /* Note: we are assuming this pipeline is a _STATE_LAYERS authority */ + int n_layers = pipeline->n_layers; int i; - /* FIXME: _cogl_material_foreach_layer_internal now calls - * _cogl_material_update_layers_cache anyway so this codepath is + /* FIXME: _cogl_pipeline_foreach_layer_internal now calls + * _cogl_pipeline_update_layers_cache anyway so this codepath is * pointless! */ if (layer_info->ignore_shift_layers_if_found && - material->layers_cache_dirty) + pipeline->layers_cache_dirty) { /* The expectation is that callers of - * _cogl_material_get_layer_info are likely to be modifying the - * list of layers associated with a material so in this case + * _cogl_pipeline_get_layer_info are likely to be modifying the + * list of layers associated with a pipeline so in this case * where we don't have a cache of the layers and we don't - * necessarily have to iterate all the layers of the material we + * necessarily have to iterate all the layers of the pipeline we * use a foreach_layer callback instead of updating the cache * and iterating that as below. */ - _cogl_material_foreach_layer_internal (material, + _cogl_pipeline_foreach_layer_internal (pipeline, update_layer_info_cb, layer_info); return; } - _cogl_material_update_layers_cache (material); + _cogl_pipeline_update_layers_cache (pipeline); for (i = 0; i < n_layers; i++) { - CoglMaterialLayer *layer = material->layers_cache[i]; + CoglPipelineLayer *layer = pipeline->layers_cache[i]; if (update_layer_info (layer, layer_info)) return; } } -static CoglMaterialLayer * -_cogl_material_get_layer (CoglMaterial *material, +static CoglPipelineLayer * +_cogl_pipeline_get_layer (CoglPipeline *pipeline, int layer_index) { - CoglMaterial *authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_LAYERS); - CoglMaterialLayerInfo layer_info; - CoglMaterialLayer *layer; + CoglPipeline *authority = + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LAYERS); + CoglPipelineLayerInfo layer_info; + CoglPipelineLayer *layer; int unit_index; int i; @@ -1917,26 +1914,26 @@ _cogl_material_get_layer (CoglMaterial *material, * and bump up the texture unit for all layers with an index * > layer_index. */ layer_info.layers_to_shift = - g_alloca (sizeof (CoglMaterialLayer *) * authority->n_layers); + g_alloca (sizeof (CoglPipelineLayer *) * authority->n_layers); layer_info.n_layers_to_shift = 0; /* If an exact match is found though we don't need a complete * list of layers with indices > layer_index... */ layer_info.ignore_shift_layers_if_found = TRUE; - _cogl_material_get_layer_info (authority, &layer_info); + _cogl_pipeline_get_layer_info (authority, &layer_info); if (layer_info.layer) return layer_info.layer; unit_index = layer_info.insert_after + 1; if (unit_index == 0) - layer = _cogl_material_layer_copy (ctx->default_layer_0); + layer = _cogl_pipeline_layer_copy (ctx->default_layer_0); else { - CoglMaterialLayer *new; - layer = _cogl_material_layer_copy (ctx->default_layer_n); - new = _cogl_material_set_layer_unit (NULL, layer, unit_index); + CoglPipelineLayer *new; + layer = _cogl_pipeline_layer_copy (ctx->default_layer_n); + new = _cogl_pipeline_set_layer_unit (NULL, layer, unit_index); /* Since we passed a newly allocated layer we wouldn't expect * _set_layer_unit() to have to allocate *another* layer. */ g_assert (new == layer); @@ -1945,17 +1942,17 @@ _cogl_material_get_layer (CoglMaterial *material, for (i = 0; i < layer_info.n_layers_to_shift; i++) { - CoglMaterialLayer *shift_layer = layer_info.layers_to_shift[i]; + CoglPipelineLayer *shift_layer = layer_info.layers_to_shift[i]; - unit_index = _cogl_material_layer_get_unit_index (shift_layer); - _cogl_material_set_layer_unit (material, shift_layer, unit_index + 1); + unit_index = _cogl_pipeline_layer_get_unit_index (shift_layer); + _cogl_pipeline_set_layer_unit (pipeline, shift_layer, unit_index + 1); /* NB: shift_layer may not be writeable so _set_layer_unit() * will allocate a derived layer internally which will become - * owned by material. Check the return value if we need to do + * owned by pipeline. Check the return value if we need to do * anything else with this layer. */ } - _cogl_material_add_layer_difference (material, layer, TRUE); + _cogl_pipeline_add_layer_difference (pipeline, layer, TRUE); cogl_object_unref (layer); @@ -1963,34 +1960,34 @@ _cogl_material_get_layer (CoglMaterial *material, } CoglHandle -_cogl_material_layer_get_texture (CoglMaterialLayer *layer) +_cogl_pipeline_layer_get_texture_real (CoglPipelineLayer *layer) { - CoglMaterialLayer *authority = - _cogl_material_layer_get_authority (layer, - COGL_MATERIAL_LAYER_STATE_TEXTURE); + CoglPipelineLayer *authority = + _cogl_pipeline_layer_get_authority (layer, + COGL_PIPELINE_LAYER_STATE_TEXTURE); return authority->texture; } CoglHandle -_cogl_material_get_layer_texture (CoglMaterial *material, +_cogl_pipeline_get_layer_texture (CoglPipeline *pipeline, int layer_index) { - CoglMaterialLayer *layer = - _cogl_material_get_layer (material, layer_index); - return _cogl_material_layer_get_texture (layer); + CoglPipelineLayer *layer = + _cogl_pipeline_get_layer (pipeline, layer_index); + return _cogl_pipeline_layer_get_texture (layer); } static void -_cogl_material_prune_empty_layer_difference (CoglMaterial *layers_authority, - CoglMaterialLayer *layer) +_cogl_pipeline_prune_empty_layer_difference (CoglPipeline *layers_authority, + CoglPipelineLayer *layer) { /* Find the GList link that references the empty layer */ GList *link = g_list_find (layers_authority->layer_differences, layer); - /* No material directly owns the root node layer so this is safe... */ - CoglMaterialLayer *layer_parent = _cogl_material_layer_get_parent (layer); - CoglMaterialLayerInfo layer_info; - CoglMaterial *old_layers_authority; + /* No pipeline directly owns the root node layer so this is safe... */ + CoglPipelineLayer *layer_parent = _cogl_pipeline_layer_get_parent (layer); + CoglPipelineLayerInfo layer_info; + CoglPipeline *old_layers_authority; g_return_if_fail (link != NULL); @@ -2001,7 +1998,7 @@ _cogl_material_prune_empty_layer_difference (CoglMaterial *layers_authority, if (layer_parent->index == layer->index && layer_parent->owner == NULL) { cogl_object_ref (layer_parent); - link->data = _cogl_material_layer_get_parent (layer); + link->data = _cogl_pipeline_layer_get_parent (layer); cogl_object_unref (layer); recursively_free_layer_caches (layers_authority); return; @@ -2023,22 +2020,22 @@ _cogl_material_prune_empty_layer_difference (CoglMaterial *layers_authority, * and bump up the texture unit for all layers with an index * > layer_index. */ layer_info.layers_to_shift = - g_alloca (sizeof (CoglMaterialLayer *) * layers_authority->n_layers); + g_alloca (sizeof (CoglPipelineLayer *) * layers_authority->n_layers); layer_info.n_layers_to_shift = 0; /* If an exact match is found though we don't need a complete * list of layers with indices > layer_index... */ layer_info.ignore_shift_layers_if_found = TRUE; - /* We know the default/root material isn't a LAYERS authority so it's - * safe to use the result of _cogl_material_get_parent (layers_authority) + /* We know the default/root pipeline isn't a LAYERS authority so it's + * safe to use the result of _cogl_pipeline_get_parent (layers_authority) * without checking it. */ old_layers_authority = - _cogl_material_get_authority (_cogl_material_get_parent (layers_authority), - COGL_MATERIAL_STATE_LAYERS); + _cogl_pipeline_get_authority (_cogl_pipeline_get_parent (layers_authority), + COGL_PIPELINE_STATE_LAYERS); - _cogl_material_get_layer_info (old_layers_authority, &layer_info); + _cogl_pipeline_get_layer_info (old_layers_authority, &layer_info); /* If layer is the defining layer for the corresponding ->index then * we can't get rid of it. */ @@ -2046,40 +2043,40 @@ _cogl_material_prune_empty_layer_difference (CoglMaterial *layers_authority, return; /* If the layer that would become the authority for layer->index is - * _cogl_material_layer_get_parent (layer) then we can simply remove the + * _cogl_pipeline_layer_get_parent (layer) then we can simply remove the * layer difference. */ - if (layer_info.layer == _cogl_material_layer_get_parent (layer)) + if (layer_info.layer == _cogl_pipeline_layer_get_parent (layer)) { - _cogl_material_remove_layer_difference (layers_authority, layer, FALSE); - _cogl_material_try_reverting_layers_authority (layers_authority, + _cogl_pipeline_remove_layer_difference (layers_authority, layer, FALSE); + _cogl_pipeline_try_reverting_layers_authority (layers_authority, old_layers_authority); } } static void -_cogl_material_set_layer_texture (CoglMaterial *material, +_cogl_pipeline_set_layer_texture (CoglPipeline *pipeline, int layer_index, CoglHandle texture, gboolean overriden, GLuint slice_gl_texture, GLenum slice_gl_target) { - CoglMaterialLayerState change = COGL_MATERIAL_LAYER_STATE_TEXTURE; - CoglMaterialLayer *layer; - CoglMaterialLayer *authority; - CoglMaterialLayer *new; + CoglPipelineLayerState change = COGL_PIPELINE_LAYER_STATE_TEXTURE; + CoglPipelineLayer *layer; + CoglPipelineLayer *authority; + CoglPipelineLayer *new; /* Note: this will ensure that the layer exists, creating one if it * doesn't already. * * Note: If the layer already existed it's possibly owned by another - * material. If the layer is created then it will be owned by - * material. */ - layer = _cogl_material_get_layer (material, layer_index); + * pipeline. If the layer is created then it will be owned by + * pipeline. */ + layer = _cogl_pipeline_get_layer (pipeline, layer_index); /* Now find the ancestor of the layer that is the authority for the * state we want to change */ - authority = _cogl_material_layer_get_authority (layer, change); + authority = _cogl_pipeline_layer_get_authority (layer, change); if (authority->texture_overridden == overriden && authority->texture == texture && @@ -2088,7 +2085,7 @@ _cogl_material_set_layer_texture (CoglMaterial *material, authority->slice_gl_target == slice_gl_target))) return; - new = _cogl_material_layer_pre_change_notify (material, layer, change); + new = _cogl_pipeline_layer_pre_change_notify (pipeline, layer, change); if (new != layer) layer = new; else @@ -2097,12 +2094,12 @@ _cogl_material_set_layer_texture (CoglMaterial *material, * the state we are changing see if we can revert to one of our * ancestors being the authority. */ if (layer == authority && - _cogl_material_layer_get_parent (authority) != NULL) + _cogl_pipeline_layer_get_parent (authority) != NULL) { - CoglMaterialLayer *parent = - _cogl_material_layer_get_parent (authority); - CoglMaterialLayer *old_authority = - _cogl_material_layer_get_authority (parent, change); + CoglPipelineLayer *parent = + _cogl_pipeline_layer_get_parent (authority); + CoglPipelineLayer *old_authority = + _cogl_pipeline_layer_get_authority (parent, change); if (old_authority->texture_overridden == overriden && old_authority->texture == texture && @@ -2115,9 +2112,9 @@ _cogl_material_set_layer_texture (CoglMaterial *material, if (layer->texture != COGL_INVALID_HANDLE) cogl_handle_unref (layer->texture); - g_assert (layer->owner == material); + g_assert (layer->owner == pipeline); if (layer->differences == 0) - _cogl_material_prune_empty_layer_difference (material, + _cogl_pipeline_prune_empty_layer_difference (pipeline, layer); goto changed; } @@ -2141,27 +2138,27 @@ _cogl_material_set_layer_texture (CoglMaterial *material, if (layer != authority) { layer->differences |= change; - _cogl_material_layer_prune_redundant_ancestry (layer); + _cogl_pipeline_layer_prune_redundant_ancestry (layer); } changed: - handle_automatic_blend_enable (material, COGL_MATERIAL_STATE_LAYERS); + handle_automatic_blend_enable (pipeline, COGL_PIPELINE_STATE_LAYERS); } static void -_cogl_material_set_layer_gl_texture_slice (CoglMaterial *material, +_cogl_pipeline_set_layer_gl_texture_slice (CoglPipeline *pipeline, int layer_index, CoglHandle texture, GLuint slice_gl_texture, GLenum slice_gl_target) { - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); /* GL texture overrides can only be set in association with a parent * CoglTexture */ g_return_if_fail (cogl_is_texture (texture)); - _cogl_material_set_layer_texture (material, + _cogl_pipeline_set_layer_texture (pipeline, layer_index, texture, TRUE, /* slice override */ @@ -2169,23 +2166,16 @@ _cogl_material_set_layer_gl_texture_slice (CoglMaterial *material, slice_gl_target); } -/* XXX: deprecate and replace with cogl_material_set_layer_texture? - * - * Originally I was planning on allowing users to set shaders somehow - * on layers (thus the ambiguous name), but now I wonder if we will do - * that with a more explicit "snippets" API and materials will have - * hooks defined to receive these snippets. - */ void -cogl_material_set_layer (CoglMaterial *material, - int layer_index, - CoglHandle texture) +cogl_pipeline_set_layer_texture (CoglPipeline *pipeline, + int layer_index, + CoglHandle texture) { - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (texture == COGL_INVALID_HANDLE || cogl_is_texture (texture)); - _cogl_material_set_layer_texture (material, + _cogl_pipeline_set_layer_texture (pipeline, layer_index, texture, FALSE, /* slice override */ @@ -2196,16 +2186,16 @@ cogl_material_set_layer (CoglMaterial *material, typedef struct { int i; - CoglMaterial *material; + CoglPipeline *pipeline; unsigned long fallback_layers; -} CoglMaterialFallbackState; +} CoglPipelineFallbackState; static gboolean -fallback_layer_cb (CoglMaterialLayer *layer, void *user_data) +fallback_layer_cb (CoglPipelineLayer *layer, void *user_data) { - CoglMaterialFallbackState *state = user_data; - CoglMaterial *material = state->material; - CoglHandle texture = _cogl_material_layer_get_texture (layer); + CoglPipelineFallbackState *state = user_data; + CoglPipeline *pipeline = state->pipeline; + CoglHandle texture = _cogl_pipeline_layer_get_texture (layer); GLenum gl_target; COGL_STATIC_COUNTER (layer_fallback_counter, "layer fallback counter", @@ -2234,13 +2224,13 @@ fallback_layer_cb (CoglMaterialLayer *layer, void *user_data) else { g_warning ("We don't have a fallback texture we can use to fill " - "in for an invalid material layer, since it was " + "in for an invalid pipeline layer, since it was " "using an unsupported texture target "); /* might get away with this... */ texture = ctx->default_gl_texture_2d_tex; } - cogl_material_set_layer (material, layer->index, texture); + cogl_pipeline_set_layer_texture (pipeline, layer->index, texture); state->i++; @@ -2248,22 +2238,22 @@ fallback_layer_cb (CoglMaterialLayer *layer, void *user_data) } void -_cogl_material_set_layer_wrap_modes (CoglMaterial *material, - CoglMaterialLayer *layer, - CoglMaterialLayer *authority, - CoglMaterialWrapModeInternal wrap_mode_s, - CoglMaterialWrapModeInternal wrap_mode_t, - CoglMaterialWrapModeInternal wrap_mode_p) +_cogl_pipeline_set_layer_wrap_modes (CoglPipeline *pipeline, + CoglPipelineLayer *layer, + CoglPipelineLayer *authority, + CoglPipelineWrapModeInternal wrap_mode_s, + CoglPipelineWrapModeInternal wrap_mode_t, + CoglPipelineWrapModeInternal wrap_mode_p) { - CoglMaterialLayer *new; - CoglMaterialLayerState change = COGL_MATERIAL_LAYER_STATE_WRAP_MODES; + CoglPipelineLayer *new; + CoglPipelineLayerState change = COGL_PIPELINE_LAYER_STATE_WRAP_MODES; if (authority->wrap_mode_s == wrap_mode_s && authority->wrap_mode_t == wrap_mode_t && authority->wrap_mode_p == wrap_mode_p) return; - new = _cogl_material_layer_pre_change_notify (material, layer, change); + new = _cogl_pipeline_layer_pre_change_notify (pipeline, layer, change); if (new != layer) layer = new; else @@ -2272,12 +2262,12 @@ _cogl_material_set_layer_wrap_modes (CoglMaterial *material, * the state we are changing see if we can revert to one of our * ancestors being the authority. */ if (layer == authority && - _cogl_material_layer_get_parent (authority) != NULL) + _cogl_pipeline_layer_get_parent (authority) != NULL) { - CoglMaterialLayer *parent = - _cogl_material_layer_get_parent (authority); - CoglMaterialLayer *old_authority = - _cogl_material_layer_get_authority (parent, change); + CoglPipelineLayer *parent = + _cogl_pipeline_layer_get_parent (authority); + CoglPipelineLayer *old_authority = + _cogl_pipeline_layer_get_authority (parent, change); if (old_authority->wrap_mode_s == wrap_mode_s && old_authority->wrap_mode_t == wrap_mode_t && @@ -2285,9 +2275,9 @@ _cogl_material_set_layer_wrap_modes (CoglMaterial *material, { layer->differences &= ~change; - g_assert (layer->owner == material); + g_assert (layer->owner == pipeline); if (layer->differences == 0) - _cogl_material_prune_empty_layer_difference (material, + _cogl_pipeline_prune_empty_layer_difference (pipeline, layer); return; } @@ -2305,82 +2295,82 @@ _cogl_material_set_layer_wrap_modes (CoglMaterial *material, if (layer != authority) { layer->differences |= change; - _cogl_material_layer_prune_redundant_ancestry (layer); + _cogl_pipeline_layer_prune_redundant_ancestry (layer); } } -static CoglMaterialWrapModeInternal -public_to_internal_wrap_mode (CoglMaterialWrapMode mode) +static CoglPipelineWrapModeInternal +public_to_internal_wrap_mode (CoglPipelineWrapMode mode) { - return (CoglMaterialWrapModeInternal)mode; + return (CoglPipelineWrapModeInternal)mode; } -static CoglMaterialWrapMode -internal_to_public_wrap_mode (CoglMaterialWrapModeInternal internal_mode) +static CoglPipelineWrapMode +internal_to_public_wrap_mode (CoglPipelineWrapModeInternal internal_mode) { g_return_val_if_fail (internal_mode != - COGL_MATERIAL_WRAP_MODE_INTERNAL_CLAMP_TO_BORDER, - COGL_MATERIAL_WRAP_MODE_AUTOMATIC); - return (CoglMaterialWrapMode)internal_mode; + COGL_PIPELINE_WRAP_MODE_INTERNAL_CLAMP_TO_BORDER, + COGL_PIPELINE_WRAP_MODE_AUTOMATIC); + return (CoglPipelineWrapMode)internal_mode; } void -cogl_material_set_layer_wrap_mode_s (CoglMaterial *material, +cogl_pipeline_set_layer_wrap_mode_s (CoglPipeline *pipeline, int layer_index, - CoglMaterialWrapMode mode) + CoglPipelineWrapMode mode) { - CoglMaterialLayerState change = COGL_MATERIAL_LAYER_STATE_WRAP_MODES; - CoglMaterialLayer *layer; - CoglMaterialLayer *authority; - CoglMaterialWrapModeInternal internal_mode = + CoglPipelineLayerState change = COGL_PIPELINE_LAYER_STATE_WRAP_MODES; + CoglPipelineLayer *layer; + CoglPipelineLayer *authority; + CoglPipelineWrapModeInternal internal_mode = public_to_internal_wrap_mode (mode); - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. * * Note: If the layer already existed it's possibly owned by another - * material. If the layer is created then it will be owned by - * material. */ - layer = _cogl_material_get_layer (material, layer_index); + * pipeline. If the layer is created then it will be owned by + * pipeline. */ + layer = _cogl_pipeline_get_layer (pipeline, layer_index); /* Now find the ancestor of the layer that is the authority for the * state we want to change */ - authority = _cogl_material_layer_get_authority (layer, change); + authority = _cogl_pipeline_layer_get_authority (layer, change); - _cogl_material_set_layer_wrap_modes (material, layer, authority, + _cogl_pipeline_set_layer_wrap_modes (pipeline, layer, authority, internal_mode, authority->wrap_mode_t, authority->wrap_mode_p); } void -cogl_material_set_layer_wrap_mode_t (CoglMaterial *material, +cogl_pipeline_set_layer_wrap_mode_t (CoglPipeline *pipeline, int layer_index, - CoglMaterialWrapMode mode) + CoglPipelineWrapMode mode) { - CoglMaterialLayerState change = COGL_MATERIAL_LAYER_STATE_WRAP_MODES; - CoglMaterialLayer *layer; - CoglMaterialLayer *authority; - CoglMaterialWrapModeInternal internal_mode = + CoglPipelineLayerState change = COGL_PIPELINE_LAYER_STATE_WRAP_MODES; + CoglPipelineLayer *layer; + CoglPipelineLayer *authority; + CoglPipelineWrapModeInternal internal_mode = public_to_internal_wrap_mode (mode); - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. * * Note: If the layer already existed it's possibly owned by another - * material. If the layer is created then it will be owned by - * material. */ - layer = _cogl_material_get_layer (material, layer_index); + * pipeline. If the layer is created then it will be owned by + * pipeline. */ + layer = _cogl_pipeline_get_layer (pipeline, layer_index); /* Now find the ancestor of the layer that is the authority for the * state we want to change */ - authority = _cogl_material_layer_get_authority (layer, change); + authority = _cogl_pipeline_layer_get_authority (layer, change); - _cogl_material_set_layer_wrap_modes (material, layer, authority, + _cogl_pipeline_set_layer_wrap_modes (pipeline, layer, authority, authority->wrap_mode_s, internal_mode, authority->wrap_mode_p); @@ -2399,62 +2389,62 @@ cogl_material_set_layer_wrap_mode_t (CoglMaterial *material, the w component conflicts with the w component of a position vertex. */ void -cogl_material_set_layer_wrap_mode_p (CoglMaterial *material, +cogl_pipeline_set_layer_wrap_mode_p (CoglPipeline *pipeline, int layer_index, - CoglMaterialWrapMode mode) + CoglPipelineWrapMode mode) { - CoglMaterialLayerState change = COGL_MATERIAL_LAYER_STATE_WRAP_MODES; - CoglMaterialLayer *layer; - CoglMaterialLayer *authority; - CoglMaterialWrapModeInternal internal_mode = + CoglPipelineLayerState change = COGL_PIPELINE_LAYER_STATE_WRAP_MODES; + CoglPipelineLayer *layer; + CoglPipelineLayer *authority; + CoglPipelineWrapModeInternal internal_mode = public_to_internal_wrap_mode (mode); - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. * * Note: If the layer already existed it's possibly owned by another - * material. If the layer is created then it will be owned by - * material. */ - layer = _cogl_material_get_layer (material, layer_index); + * pipeline. If the layer is created then it will be owned by + * pipeline. */ + layer = _cogl_pipeline_get_layer (pipeline, layer_index); /* Now find the ancestor of the layer that is the authority for the * state we want to change */ - authority = _cogl_material_layer_get_authority (layer, change); + authority = _cogl_pipeline_layer_get_authority (layer, change); - _cogl_material_set_layer_wrap_modes (material, layer, authority, + _cogl_pipeline_set_layer_wrap_modes (pipeline, layer, authority, authority->wrap_mode_s, authority->wrap_mode_t, internal_mode); } void -cogl_material_set_layer_wrap_mode (CoglMaterial *material, +cogl_pipeline_set_layer_wrap_mode (CoglPipeline *pipeline, int layer_index, - CoglMaterialWrapMode mode) + CoglPipelineWrapMode mode) { - CoglMaterialLayerState change = COGL_MATERIAL_LAYER_STATE_WRAP_MODES; - CoglMaterialLayer *layer; - CoglMaterialLayer *authority; - CoglMaterialWrapModeInternal internal_mode = + CoglPipelineLayerState change = COGL_PIPELINE_LAYER_STATE_WRAP_MODES; + CoglPipelineLayer *layer; + CoglPipelineLayer *authority; + CoglPipelineWrapModeInternal internal_mode = public_to_internal_wrap_mode (mode); - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. * * Note: If the layer already existed it's possibly owned by another - * material. If the layer is created then it will be owned by - * material. */ - layer = _cogl_material_get_layer (material, layer_index); + * pipeline. If the layer is created then it will be owned by + * pipeline. */ + layer = _cogl_pipeline_get_layer (pipeline, layer_index); /* Now find the ancestor of the layer that is the authority for the * state we want to change */ - authority = _cogl_material_layer_get_authority (layer, change); + authority = _cogl_pipeline_layer_get_authority (layer, change); - _cogl_material_set_layer_wrap_modes (material, layer, authority, + _cogl_pipeline_set_layer_wrap_modes (pipeline, layer, authority, internal_mode, internal_mode, internal_mode); @@ -2463,112 +2453,112 @@ cogl_material_set_layer_wrap_mode (CoglMaterial *material, } /* FIXME: deprecate this API */ -CoglMaterialWrapMode -cogl_material_layer_get_wrap_mode_s (CoglMaterialLayer *layer) +CoglPipelineWrapMode +_cogl_pipeline_layer_get_wrap_mode_s (CoglPipelineLayer *layer) { - CoglMaterialLayerState change = COGL_MATERIAL_LAYER_STATE_WRAP_MODES; - CoglMaterialLayer *authority; + CoglPipelineLayerState change = COGL_PIPELINE_LAYER_STATE_WRAP_MODES; + CoglPipelineLayer *authority; - g_return_val_if_fail (_cogl_is_material_layer (layer), FALSE); + g_return_val_if_fail (_cogl_is_pipeline_layer (layer), FALSE); /* Now find the ancestor of the layer that is the authority for the * state we want to change */ - authority = _cogl_material_layer_get_authority (layer, change); + authority = _cogl_pipeline_layer_get_authority (layer, change); return internal_to_public_wrap_mode (authority->wrap_mode_s); } -CoglMaterialWrapMode -cogl_material_get_layer_wrap_mode_s (CoglMaterial *material, int layer_index) +CoglPipelineWrapMode +cogl_pipeline_get_layer_wrap_mode_s (CoglPipeline *pipeline, int layer_index) { - CoglMaterialLayer *layer; + CoglPipelineLayer *layer; - g_return_val_if_fail (cogl_is_material (material), FALSE); + g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. * * Note: If the layer already existed it's possibly owned by another - * material. If the layer is created then it will be owned by - * material. */ - layer = _cogl_material_get_layer (material, layer_index); + * pipeline. If the layer is created then it will be owned by + * pipeline. */ + layer = _cogl_pipeline_get_layer (pipeline, layer_index); /* FIXME: we shouldn't ever construct a layer in a getter function */ - return cogl_material_layer_get_wrap_mode_s (layer); + return _cogl_pipeline_layer_get_wrap_mode_s (layer); } /* FIXME: deprecate this API */ -CoglMaterialWrapMode -cogl_material_layer_get_wrap_mode_t (CoglMaterialLayer *layer) +CoglPipelineWrapMode +_cogl_pipeline_layer_get_wrap_mode_t (CoglPipelineLayer *layer) { - CoglMaterialLayerState change = COGL_MATERIAL_LAYER_STATE_WRAP_MODES; - CoglMaterialLayer *authority; + CoglPipelineLayerState change = COGL_PIPELINE_LAYER_STATE_WRAP_MODES; + CoglPipelineLayer *authority; - g_return_val_if_fail (_cogl_is_material_layer (layer), FALSE); + g_return_val_if_fail (_cogl_is_pipeline_layer (layer), FALSE); /* Now find the ancestor of the layer that is the authority for the * state we want to change */ - authority = _cogl_material_layer_get_authority (layer, change); + authority = _cogl_pipeline_layer_get_authority (layer, change); return internal_to_public_wrap_mode (authority->wrap_mode_t); } -CoglMaterialWrapMode -cogl_material_get_layer_wrap_mode_t (CoglMaterial *material, int layer_index) +CoglPipelineWrapMode +cogl_pipeline_get_layer_wrap_mode_t (CoglPipeline *pipeline, int layer_index) { - CoglMaterialLayer *layer; + CoglPipelineLayer *layer; - g_return_val_if_fail (cogl_is_material (material), FALSE); + g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. * * Note: If the layer already existed it's possibly owned by another - * material. If the layer is created then it will be owned by - * material. */ - layer = _cogl_material_get_layer (material, layer_index); + * pipeline. If the layer is created then it will be owned by + * pipeline. */ + layer = _cogl_pipeline_get_layer (pipeline, layer_index); /* FIXME: we shouldn't ever construct a layer in a getter function */ - return cogl_material_layer_get_wrap_mode_t (layer); + return _cogl_pipeline_layer_get_wrap_mode_t (layer); } -CoglMaterialWrapMode -cogl_material_layer_get_wrap_mode_p (CoglMaterialLayer *layer) +CoglPipelineWrapMode +_cogl_pipeline_layer_get_wrap_mode_p (CoglPipelineLayer *layer) { - CoglMaterialLayerState change = COGL_MATERIAL_LAYER_STATE_WRAP_MODES; - CoglMaterialLayer *authority = - _cogl_material_layer_get_authority (layer, change); + CoglPipelineLayerState change = COGL_PIPELINE_LAYER_STATE_WRAP_MODES; + CoglPipelineLayer *authority = + _cogl_pipeline_layer_get_authority (layer, change); return internal_to_public_wrap_mode (authority->wrap_mode_p); } -CoglMaterialWrapMode -cogl_material_get_layer_wrap_mode_p (CoglMaterial *material, int layer_index) +CoglPipelineWrapMode +cogl_pipeline_get_layer_wrap_mode_p (CoglPipeline *pipeline, int layer_index) { - CoglMaterialLayer *layer; + CoglPipelineLayer *layer; - g_return_val_if_fail (cogl_is_material (material), FALSE); + g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. * * Note: If the layer already existed it's possibly owned by another - * material. If the layer is created then it will be owned by - * material. */ - layer = _cogl_material_get_layer (material, layer_index); + * pipeline. If the layer is created then it will be owned by + * pipeline. */ + layer = _cogl_pipeline_get_layer (pipeline, layer_index); - return cogl_material_layer_get_wrap_mode_p (layer); + return _cogl_pipeline_layer_get_wrap_mode_p (layer); } void -_cogl_material_layer_get_wrap_modes (CoglMaterialLayer *layer, - CoglMaterialWrapModeInternal *wrap_mode_s, - CoglMaterialWrapModeInternal *wrap_mode_t, - CoglMaterialWrapModeInternal *wrap_mode_p) +_cogl_pipeline_layer_get_wrap_modes (CoglPipelineLayer *layer, + CoglPipelineWrapModeInternal *wrap_mode_s, + CoglPipelineWrapModeInternal *wrap_mode_t, + CoglPipelineWrapModeInternal *wrap_mode_p) { - CoglMaterialLayer *authority = - _cogl_material_layer_get_authority (layer, - COGL_MATERIAL_LAYER_STATE_WRAP_MODES); + CoglPipelineLayer *authority = + _cogl_pipeline_layer_get_authority (layer, + COGL_PIPELINE_LAYER_STATE_WRAP_MODES); *wrap_mode_s = authority->wrap_mode_s; *wrap_mode_t = authority->wrap_mode_t; @@ -2576,18 +2566,18 @@ _cogl_material_layer_get_wrap_modes (CoglMaterialLayer *layer, } gboolean -cogl_material_set_layer_point_sprite_coords_enabled (CoglMaterial *material, +cogl_pipeline_set_layer_point_sprite_coords_enabled (CoglPipeline *pipeline, int layer_index, gboolean enable, GError **error) { - CoglMaterialLayerState change = - COGL_MATERIAL_LAYER_STATE_POINT_SPRITE_COORDS; - CoglMaterialLayer *layer; - CoglMaterialLayer *new; - CoglMaterialLayer *authority; + CoglPipelineLayerState change = + COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS; + CoglPipelineLayer *layer; + CoglPipelineLayer *new; + CoglPipelineLayer *authority; - g_return_val_if_fail (cogl_is_material (material), FALSE); + g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); /* Don't allow point sprite coordinates to be enabled if the driver doesn't support it */ @@ -2615,18 +2605,18 @@ cogl_material_set_layer_point_sprite_coords_enabled (CoglMaterial *material, * doesn't already. * * Note: If the layer already existed it's possibly owned by another - * material. If the layer is created then it will be owned by - * material. */ - layer = _cogl_material_get_layer (material, layer_index); + * pipeline. If the layer is created then it will be owned by + * pipeline. */ + layer = _cogl_pipeline_get_layer (pipeline, layer_index); /* Now find the ancestor of the layer that is the authority for the * state we want to change */ - authority = _cogl_material_layer_get_authority (layer, change); + authority = _cogl_pipeline_layer_get_authority (layer, change); if (authority->big_state->point_sprite_coords == enable) return TRUE; - new = _cogl_material_layer_pre_change_notify (material, layer, change); + new = _cogl_pipeline_layer_pre_change_notify (pipeline, layer, change); if (new != layer) layer = new; else @@ -2635,20 +2625,20 @@ cogl_material_set_layer_point_sprite_coords_enabled (CoglMaterial *material, * the state we are changing see if we can revert to one of our * ancestors being the authority. */ if (layer == authority && - _cogl_material_layer_get_parent (authority) != NULL) + _cogl_pipeline_layer_get_parent (authority) != NULL) { - CoglMaterialLayer *parent = - _cogl_material_layer_get_parent (authority); - CoglMaterialLayer *old_authority = - _cogl_material_layer_get_authority (parent, change); + CoglPipelineLayer *parent = + _cogl_pipeline_layer_get_parent (authority); + CoglPipelineLayer *old_authority = + _cogl_pipeline_layer_get_authority (parent, change); if (old_authority->big_state->point_sprite_coords == enable) { layer->differences &= ~change; - g_assert (layer->owner == material); + g_assert (layer->owner == pipeline); if (layer->differences == 0) - _cogl_material_prune_empty_layer_difference (material, + _cogl_pipeline_prune_empty_layer_difference (pipeline, layer); return TRUE; } @@ -2664,69 +2654,69 @@ cogl_material_set_layer_point_sprite_coords_enabled (CoglMaterial *material, if (layer != authority) { layer->differences |= change; - _cogl_material_layer_prune_redundant_ancestry (layer); + _cogl_pipeline_layer_prune_redundant_ancestry (layer); } return TRUE; } gboolean -cogl_material_get_layer_point_sprite_coords_enabled (CoglMaterial *material, +cogl_pipeline_get_layer_point_sprite_coords_enabled (CoglPipeline *pipeline, int layer_index) { - CoglMaterialLayerState change = - COGL_MATERIAL_LAYER_STATE_POINT_SPRITE_COORDS; - CoglMaterialLayer *layer; - CoglMaterialLayer *authority; + CoglPipelineLayerState change = + COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS; + CoglPipelineLayer *layer; + CoglPipelineLayer *authority; - g_return_val_if_fail (cogl_is_material (material), FALSE); + g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. * * Note: If the layer already existed it's possibly owned by another - * material. If the layer is created then it will be owned by - * material. */ - layer = _cogl_material_get_layer (material, layer_index); + * pipeline. If the layer is created then it will be owned by + * pipeline. */ + layer = _cogl_pipeline_get_layer (pipeline, layer_index); /* FIXME: we shouldn't ever construct a layer in a getter function */ - authority = _cogl_material_layer_get_authority (layer, change); + authority = _cogl_pipeline_layer_get_authority (layer, change); return authority->big_state->point_sprite_coords; } typedef struct { - CoglMaterial *material; - CoglMaterialWrapModeOverrides *wrap_mode_overrides; + CoglPipeline *pipeline; + CoglPipelineWrapModeOverrides *wrap_mode_overrides; int i; -} CoglMaterialWrapModeOverridesState; +} CoglPipelineWrapModeOverridesState; static gboolean -apply_wrap_mode_overrides_cb (CoglMaterialLayer *layer, +apply_wrap_mode_overrides_cb (CoglPipelineLayer *layer, void *user_data) { - CoglMaterialWrapModeOverridesState *state = user_data; - CoglMaterialLayer *authority = - _cogl_material_layer_get_authority (layer, - COGL_MATERIAL_LAYER_STATE_WRAP_MODES); - CoglMaterialWrapModeInternal wrap_mode_s; - CoglMaterialWrapModeInternal wrap_mode_t; - CoglMaterialWrapModeInternal wrap_mode_p; + CoglPipelineWrapModeOverridesState *state = user_data; + CoglPipelineLayer *authority = + _cogl_pipeline_layer_get_authority (layer, + COGL_PIPELINE_LAYER_STATE_WRAP_MODES); + CoglPipelineWrapModeInternal wrap_mode_s; + CoglPipelineWrapModeInternal wrap_mode_t; + CoglPipelineWrapModeInternal wrap_mode_p; g_return_val_if_fail (state->i < 32, FALSE); wrap_mode_s = state->wrap_mode_overrides->values[state->i].s; - if (wrap_mode_s == COGL_MATERIAL_WRAP_MODE_OVERRIDE_NONE) - wrap_mode_s = (CoglMaterialWrapModeInternal)authority->wrap_mode_s; + if (wrap_mode_s == COGL_PIPELINE_WRAP_MODE_OVERRIDE_NONE) + wrap_mode_s = (CoglPipelineWrapModeInternal)authority->wrap_mode_s; wrap_mode_t = state->wrap_mode_overrides->values[state->i].t; - if (wrap_mode_t == COGL_MATERIAL_WRAP_MODE_OVERRIDE_NONE) - wrap_mode_t = (CoglMaterialWrapModeInternal)authority->wrap_mode_t; + if (wrap_mode_t == COGL_PIPELINE_WRAP_MODE_OVERRIDE_NONE) + wrap_mode_t = (CoglPipelineWrapModeInternal)authority->wrap_mode_t; wrap_mode_p = state->wrap_mode_overrides->values[state->i].p; - if (wrap_mode_p == COGL_MATERIAL_WRAP_MODE_OVERRIDE_NONE) - wrap_mode_p = (CoglMaterialWrapModeInternal)authority->wrap_mode_p; + if (wrap_mode_p == COGL_PIPELINE_WRAP_MODE_OVERRIDE_NONE) + wrap_mode_p = (CoglPipelineWrapModeInternal)authority->wrap_mode_p; - _cogl_material_set_layer_wrap_modes (state->material, + _cogl_pipeline_set_layer_wrap_modes (state->pipeline, layer, authority, wrap_mode_s, @@ -2740,25 +2730,25 @@ apply_wrap_mode_overrides_cb (CoglMaterialLayer *layer, typedef struct { - CoglMaterial *material; + CoglPipeline *pipeline; GLuint gl_texture; -} CoglMaterialOverrideLayerState; +} CoglPipelineOverrideLayerState; static gboolean -override_layer_texture_cb (CoglMaterialLayer *layer, void *user_data) +override_layer_texture_cb (CoglPipelineLayer *layer, void *user_data) { - CoglMaterialOverrideLayerState *state = user_data; + CoglPipelineOverrideLayerState *state = user_data; CoglHandle texture; GLenum gl_target; - texture = _cogl_material_layer_get_texture (layer); + texture = _cogl_pipeline_layer_get_texture (layer); if (texture != COGL_INVALID_HANDLE) cogl_texture_get_gl_texture (texture, NULL, &gl_target); else gl_target = GL_TEXTURE_2D; - _cogl_material_set_layer_gl_texture_slice (state->material, + _cogl_pipeline_set_layer_gl_texture_slice (state->pipeline, layer->index, texture, state->gl_texture, @@ -2767,18 +2757,18 @@ override_layer_texture_cb (CoglMaterialLayer *layer, void *user_data) } void -_cogl_material_apply_overrides (CoglMaterial *material, - CoglMaterialFlushOptions *options) +_cogl_pipeline_apply_overrides (CoglPipeline *pipeline, + CoglPipelineFlushOptions *options) { COGL_STATIC_COUNTER (apply_overrides_counter, - "material overrides counter", + "pipeline overrides counter", "Increments each time we have to apply " - "override options to a material", + "override options to a pipeline", 0 /* no application private data */); COGL_COUNTER_INC (_cogl_uprof_context, apply_overrides_counter); - if (options->flags & COGL_MATERIAL_FLUSH_DISABLE_MASK) + if (options->flags & COGL_PIPELINE_FLUSH_DISABLE_MASK) { int i; @@ -2787,55 +2777,55 @@ _cogl_material_apply_overrides (CoglMaterial *material, for (i = 0; i < 32 && options->disable_layers & (1<flags & COGL_MATERIAL_FLUSH_FALLBACK_MASK) + if (options->flags & COGL_PIPELINE_FLUSH_FALLBACK_MASK) { - CoglMaterialFallbackState state; + CoglPipelineFallbackState state; state.i = 0; - state.material = material; + state.pipeline = pipeline; state.fallback_layers = options->fallback_layers; - _cogl_material_foreach_layer_internal (material, + _cogl_pipeline_foreach_layer_internal (pipeline, fallback_layer_cb, &state); } - if (options->flags & COGL_MATERIAL_FLUSH_LAYER0_OVERRIDE) + if (options->flags & COGL_PIPELINE_FLUSH_LAYER0_OVERRIDE) { - CoglMaterialOverrideLayerState state; + CoglPipelineOverrideLayerState state; - _cogl_material_prune_to_n_layers (material, 1); + _cogl_pipeline_prune_to_n_layers (pipeline, 1); /* NB: we are overriding the first layer, but we don't know * the user's given layer_index, which is why we use - * _cogl_material_foreach_layer_internal() here even though we know + * _cogl_pipeline_foreach_layer_internal() here even though we know * there's only one layer. */ - state.material = material; + state.pipeline = pipeline; state.gl_texture = options->layer0_override_texture; - _cogl_material_foreach_layer_internal (material, + _cogl_pipeline_foreach_layer_internal (pipeline, override_layer_texture_cb, &state); } - if (options->flags & COGL_MATERIAL_FLUSH_WRAP_MODE_OVERRIDES) + if (options->flags & COGL_PIPELINE_FLUSH_WRAP_MODE_OVERRIDES) { - CoglMaterialWrapModeOverridesState state; + CoglPipelineWrapModeOverridesState state; - state.material = material; + state.pipeline = pipeline; state.wrap_mode_overrides = &options->wrap_mode_overrides; state.i = 0; - _cogl_material_foreach_layer_internal (material, + _cogl_pipeline_foreach_layer_internal (pipeline, apply_wrap_mode_overrides_cb, &state); } } static gboolean -_cogl_material_layer_texture_equal (CoglMaterialLayer *authority0, - CoglMaterialLayer *authority1) +_cogl_pipeline_layer_texture_equal (CoglPipelineLayer *authority0, + CoglPipelineLayer *authority1) { GLuint gl_handle0, gl_handle1; GLenum gl_target0, gl_target1; @@ -2861,23 +2851,23 @@ _cogl_material_layer_texture_equal (CoglMaterialLayer *authority0, /* Determine the mask of differences between two layers. * - * XXX: If layers and materials could both be cast to a common Tree + * XXX: If layers and pipelines could both be cast to a common Tree * type of some kind then we could have a unified * compare_differences() function. */ unsigned long -_cogl_material_layer_compare_differences (CoglMaterialLayer *layer0, - CoglMaterialLayer *layer1) +_cogl_pipeline_layer_compare_differences (CoglPipelineLayer *layer0, + CoglPipelineLayer *layer1) { - CoglMaterialLayer *node0; - CoglMaterialLayer *node1; + CoglPipelineLayer *node0; + CoglPipelineLayer *node1; int len0; int len1; int len0_index; int len1_index; int count; int i; - CoglMaterialLayer *common_ancestor = NULL; + CoglPipelineLayer *common_ancestor = NULL; unsigned long layers_difference = 0; _COGL_GET_CONTEXT (ctx, 0); @@ -2886,25 +2876,25 @@ _cogl_material_layer_compare_differences (CoglMaterialLayer *layer0, * * 1) Walk the ancestors of each layer to the root node, adding a * pointer to each ancester node to two GArrays: - * ctx->material0_nodes, and ctx->material1_nodes. + * ctx->pipeline0_nodes, and ctx->pipeline1_nodes. * * 2) Compare the arrays to find the nodes where they stop to * differ. * * 3) For each array now iterate from index 0 to the first node of * difference ORing that nodes ->difference mask into the final - * material_differences mask. + * pipeline_differences mask. */ - g_array_set_size (ctx->material0_nodes, 0); - g_array_set_size (ctx->material1_nodes, 0); - for (node0 = layer0; node0; node0 = _cogl_material_layer_get_parent (node0)) - g_array_append_vals (ctx->material0_nodes, &node0, 1); - for (node1 = layer1; node1; node1 = _cogl_material_layer_get_parent (node1)) - g_array_append_vals (ctx->material1_nodes, &node1, 1); + g_array_set_size (ctx->pipeline0_nodes, 0); + g_array_set_size (ctx->pipeline1_nodes, 0); + for (node0 = layer0; node0; node0 = _cogl_pipeline_layer_get_parent (node0)) + g_array_append_vals (ctx->pipeline0_nodes, &node0, 1); + for (node1 = layer1; node1; node1 = _cogl_pipeline_layer_get_parent (node1)) + g_array_append_vals (ctx->pipeline1_nodes, &node1, 1); - len0 = ctx->material0_nodes->len; - len1 = ctx->material1_nodes->len; + len0 = ctx->pipeline0_nodes->len; + len1 = ctx->pipeline1_nodes->len; /* There's no point looking at the last entries since we know both * layers must have the same default layer as their root node. */ len0_index = len0 - 2; @@ -2912,19 +2902,19 @@ _cogl_material_layer_compare_differences (CoglMaterialLayer *layer0, count = MIN (len0, len1) - 1; for (i = 0; i < count; i++) { - node0 = g_array_index (ctx->material0_nodes, - CoglMaterialLayer *, len0_index--); - node1 = g_array_index (ctx->material1_nodes, - CoglMaterialLayer *, len1_index--); + node0 = g_array_index (ctx->pipeline0_nodes, + CoglPipelineLayer *, len0_index--); + node1 = g_array_index (ctx->pipeline1_nodes, + CoglPipelineLayer *, len1_index--); if (node0 != node1) { - common_ancestor = _cogl_material_layer_get_parent (node0); + common_ancestor = _cogl_pipeline_layer_get_parent (node0); break; } } /* If we didn't already find the first the common_ancestor ancestor - * that's because one material is a direct descendant of the other + * that's because one pipeline is a direct descendant of the other * and in this case the first common ancestor is the last node we * looked at. */ if (!common_ancestor) @@ -2933,7 +2923,7 @@ _cogl_material_layer_compare_differences (CoglMaterialLayer *layer0, count = len0 - 1; for (i = 0; i < count; i++) { - node0 = g_array_index (ctx->material0_nodes, CoglMaterialLayer *, i); + node0 = g_array_index (ctx->pipeline0_nodes, CoglPipelineLayer *, i); if (node0 == common_ancestor) break; layers_difference |= node0->differences; @@ -2942,7 +2932,7 @@ _cogl_material_layer_compare_differences (CoglMaterialLayer *layer0, count = len1 - 1; for (i = 0; i < count; i++) { - node1 = g_array_index (ctx->material1_nodes, CoglMaterialLayer *, i); + node1 = g_array_index (ctx->pipeline1_nodes, CoglPipelineLayer *, i); if (node1 == common_ancestor) break; layers_difference |= node1->differences; @@ -2952,11 +2942,11 @@ _cogl_material_layer_compare_differences (CoglMaterialLayer *layer0, } static gboolean -_cogl_material_layer_combine_state_equal (CoglMaterialLayer *authority0, - CoglMaterialLayer *authority1) +_cogl_pipeline_layer_combine_state_equal (CoglPipelineLayer *authority0, + CoglPipelineLayer *authority1) { - CoglMaterialLayerBigState *big_state0 = authority0->big_state; - CoglMaterialLayerBigState *big_state1 = authority1->big_state; + CoglPipelineLayerBigState *big_state0 = authority0->big_state; + CoglPipelineLayerBigState *big_state1 = authority1->big_state; int n_args; int i; @@ -2994,8 +2984,8 @@ _cogl_material_layer_combine_state_equal (CoglMaterialLayer *authority0, } static gboolean -_cogl_material_layer_combine_constant_equal (CoglMaterialLayer *authority0, - CoglMaterialLayer *authority1) +_cogl_pipeline_layer_combine_constant_equal (CoglPipelineLayer *authority0, + CoglPipelineLayer *authority1) { return memcmp (authority0->big_state->texture_combine_constant, authority1->big_state->texture_combine_constant, @@ -3003,8 +2993,8 @@ _cogl_material_layer_combine_constant_equal (CoglMaterialLayer *authority0, } static gboolean -_cogl_material_layer_filters_equal (CoglMaterialLayer *authority0, - CoglMaterialLayer *authority1) +_cogl_pipeline_layer_filters_equal (CoglPipelineLayer *authority0, + CoglPipelineLayer *authority1) { if (authority0->mag_filter != authority1->mag_filter) return FALSE; @@ -3015,8 +3005,8 @@ _cogl_material_layer_filters_equal (CoglMaterialLayer *authority0, } static gboolean -_cogl_material_layer_wrap_modes_equal (CoglMaterialLayer *authority0, - CoglMaterialLayer *authority1) +_cogl_pipeline_layer_wrap_modes_equal (CoglPipelineLayer *authority0, + CoglPipelineLayer *authority1) { if (authority0->wrap_mode_s != authority1->wrap_mode_s || authority0->wrap_mode_t != authority1->wrap_mode_t || @@ -3027,11 +3017,11 @@ _cogl_material_layer_wrap_modes_equal (CoglMaterialLayer *authority0, } static gboolean -_cogl_material_layer_user_matrix_equal (CoglMaterialLayer *authority0, - CoglMaterialLayer *authority1) +_cogl_pipeline_layer_user_matrix_equal (CoglPipelineLayer *authority0, + CoglPipelineLayer *authority1) { - CoglMaterialLayerBigState *big_state0 = authority0->big_state; - CoglMaterialLayerBigState *big_state1 = authority1->big_state; + CoglPipelineLayerBigState *big_state0 = authority0->big_state; + CoglPipelineLayerBigState *big_state1 = authority1->big_state; if (!cogl_matrix_equal (&big_state0->matrix, &big_state1->matrix)) return FALSE; @@ -3040,36 +3030,36 @@ _cogl_material_layer_user_matrix_equal (CoglMaterialLayer *authority0, } static gboolean -_cogl_material_layer_point_sprite_coords_equal (CoglMaterialLayer *authority0, - CoglMaterialLayer *authority1) +_cogl_pipeline_layer_point_sprite_coords_equal (CoglPipelineLayer *authority0, + CoglPipelineLayer *authority1) { - CoglMaterialLayerBigState *big_state0 = authority0->big_state; - CoglMaterialLayerBigState *big_state1 = authority1->big_state; + CoglPipelineLayerBigState *big_state0 = authority0->big_state; + CoglPipelineLayerBigState *big_state1 = authority1->big_state; return big_state0->point_sprite_coords == big_state1->point_sprite_coords; } typedef gboolean -(*CoglMaterialLayerStateComparitor) (CoglMaterialLayer *authority0, - CoglMaterialLayer *authority1); +(*CoglPipelineLayerStateComparitor) (CoglPipelineLayer *authority0, + CoglPipelineLayer *authority1); static gboolean -layer_state_equal (CoglMaterialLayerState state, - CoglMaterialLayer *layer0, - CoglMaterialLayer *layer1, - CoglMaterialLayerStateComparitor comparitor) +layer_state_equal (CoglPipelineLayerState state, + CoglPipelineLayer *layer0, + CoglPipelineLayer *layer1, + CoglPipelineLayerStateComparitor comparitor) { - CoglMaterialLayer *authority0 = - _cogl_material_layer_get_authority (layer0, state); - CoglMaterialLayer *authority1 = - _cogl_material_layer_get_authority (layer1, state); + CoglPipelineLayer *authority0 = + _cogl_pipeline_layer_get_authority (layer0, state); + CoglPipelineLayer *authority1 = + _cogl_pipeline_layer_get_authority (layer1, state); return comparitor (authority0, authority1); } static gboolean -_cogl_material_layer_equal (CoglMaterialLayer *layer0, - CoglMaterialLayer *layer1) +_cogl_pipeline_layer_equal (CoglPipelineLayer *layer0, + CoglPipelineLayer *layer1) { unsigned long layers_difference; @@ -3077,66 +3067,66 @@ _cogl_material_layer_equal (CoglMaterialLayer *layer0, return TRUE; layers_difference = - _cogl_material_layer_compare_differences (layer0, layer1); + _cogl_pipeline_layer_compare_differences (layer0, layer1); - if (layers_difference & COGL_MATERIAL_LAYER_STATE_TEXTURE && - !layer_state_equal (COGL_MATERIAL_LAYER_STATE_TEXTURE, + if (layers_difference & COGL_PIPELINE_LAYER_STATE_TEXTURE && + !layer_state_equal (COGL_PIPELINE_LAYER_STATE_TEXTURE, layer0, layer1, - _cogl_material_layer_texture_equal)) + _cogl_pipeline_layer_texture_equal)) return FALSE; - if (layers_difference & COGL_MATERIAL_LAYER_STATE_COMBINE && - !layer_state_equal (COGL_MATERIAL_LAYER_STATE_COMBINE, + if (layers_difference & COGL_PIPELINE_LAYER_STATE_COMBINE && + !layer_state_equal (COGL_PIPELINE_LAYER_STATE_COMBINE, layer0, layer1, - _cogl_material_layer_combine_state_equal)) + _cogl_pipeline_layer_combine_state_equal)) return FALSE; - if (layers_difference & COGL_MATERIAL_LAYER_STATE_COMBINE_CONSTANT && - !layer_state_equal (COGL_MATERIAL_LAYER_STATE_COMBINE_CONSTANT, + if (layers_difference & COGL_PIPELINE_LAYER_STATE_COMBINE_CONSTANT && + !layer_state_equal (COGL_PIPELINE_LAYER_STATE_COMBINE_CONSTANT, layer0, layer1, - _cogl_material_layer_combine_constant_equal)) + _cogl_pipeline_layer_combine_constant_equal)) return FALSE; - if (layers_difference & COGL_MATERIAL_LAYER_STATE_FILTERS && - !layer_state_equal (COGL_MATERIAL_LAYER_STATE_FILTERS, + if (layers_difference & COGL_PIPELINE_LAYER_STATE_FILTERS && + !layer_state_equal (COGL_PIPELINE_LAYER_STATE_FILTERS, layer0, layer1, - _cogl_material_layer_filters_equal)) + _cogl_pipeline_layer_filters_equal)) return FALSE; - if (layers_difference & COGL_MATERIAL_LAYER_STATE_WRAP_MODES && - !layer_state_equal (COGL_MATERIAL_LAYER_STATE_WRAP_MODES, + if (layers_difference & COGL_PIPELINE_LAYER_STATE_WRAP_MODES && + !layer_state_equal (COGL_PIPELINE_LAYER_STATE_WRAP_MODES, layer0, layer1, - _cogl_material_layer_wrap_modes_equal)) + _cogl_pipeline_layer_wrap_modes_equal)) return FALSE; - if (layers_difference & COGL_MATERIAL_LAYER_STATE_USER_MATRIX && - !layer_state_equal (COGL_MATERIAL_LAYER_STATE_USER_MATRIX, + if (layers_difference & COGL_PIPELINE_LAYER_STATE_USER_MATRIX && + !layer_state_equal (COGL_PIPELINE_LAYER_STATE_USER_MATRIX, layer0, layer1, - _cogl_material_layer_user_matrix_equal)) + _cogl_pipeline_layer_user_matrix_equal)) return FALSE; - if (layers_difference & COGL_MATERIAL_LAYER_STATE_POINT_SPRITE_COORDS && - !layer_state_equal (COGL_MATERIAL_LAYER_STATE_POINT_SPRITE_COORDS, + if (layers_difference & COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS && + !layer_state_equal (COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS, layer0, layer1, - _cogl_material_layer_point_sprite_coords_equal)) + _cogl_pipeline_layer_point_sprite_coords_equal)) return FALSE; return TRUE; } static gboolean -_cogl_material_color_equal (CoglMaterial *authority0, - CoglMaterial *authority1) +_cogl_pipeline_color_equal (CoglPipeline *authority0, + CoglPipeline *authority1) { return cogl_color_equal (&authority0->color, &authority1->color); } static gboolean -_cogl_material_lighting_state_equal (CoglMaterial *authority0, - CoglMaterial *authority1) +_cogl_pipeline_lighting_state_equal (CoglPipeline *authority0, + CoglPipeline *authority1) { - CoglMaterialLightingState *state0 = &authority0->big_state->lighting_state; - CoglMaterialLightingState *state1 = &authority1->big_state->lighting_state; + CoglPipelineLightingState *state0 = &authority0->big_state->lighting_state; + CoglPipelineLightingState *state1 = &authority1->big_state->lighting_state; if (memcmp (state0->ambient, state1->ambient, sizeof (float) * 4) != 0) return FALSE; @@ -3153,12 +3143,12 @@ _cogl_material_lighting_state_equal (CoglMaterial *authority0, } static gboolean -_cogl_material_alpha_state_equal (CoglMaterial *authority0, - CoglMaterial *authority1) +_cogl_pipeline_alpha_state_equal (CoglPipeline *authority0, + CoglPipeline *authority1) { - CoglMaterialAlphaFuncState *alpha_state0 = + CoglPipelineAlphaFuncState *alpha_state0 = &authority0->big_state->alpha_state; - CoglMaterialAlphaFuncState *alpha_state1 = + CoglPipelineAlphaFuncState *alpha_state1 = &authority1->big_state->alpha_state; if (alpha_state0->alpha_func != alpha_state1->alpha_func || @@ -3169,11 +3159,11 @@ _cogl_material_alpha_state_equal (CoglMaterial *authority0, } static gboolean -_cogl_material_blend_state_equal (CoglMaterial *authority0, - CoglMaterial *authority1) +_cogl_pipeline_blend_state_equal (CoglPipeline *authority0, + CoglPipeline *authority1) { - CoglMaterialBlendState *blend_state0 = &authority0->big_state->blend_state; - CoglMaterialBlendState *blend_state1 = &authority1->big_state->blend_state; + CoglPipelineBlendState *blend_state0 = &authority0->big_state->blend_state; + CoglPipelineBlendState *blend_state1 = &authority1->big_state->blend_state; #ifndef HAVE_COGL_GLES if (blend_state0->blend_equation_rgb != blend_state1->blend_equation_rgb) @@ -3204,8 +3194,8 @@ _cogl_material_blend_state_equal (CoglMaterial *authority0, } static gboolean -_cogl_material_depth_state_equal (CoglMaterial *authority0, - CoglMaterial *authority1) +_cogl_pipeline_depth_state_equal (CoglPipeline *authority0, + CoglPipeline *authority1) { if (authority0->big_state->depth_state.depth_test_enabled == FALSE && authority1->big_state->depth_state.depth_test_enabled == FALSE) @@ -3213,15 +3203,15 @@ _cogl_material_depth_state_equal (CoglMaterial *authority0, else return memcmp (&authority0->big_state->depth_state, &authority1->big_state->depth_state, - sizeof (CoglMaterialDepthState)) == 0; + sizeof (CoglPipelineDepthState)) == 0; } static gboolean -_cogl_material_fog_state_equal (CoglMaterial *authority0, - CoglMaterial *authority1) +_cogl_pipeline_fog_state_equal (CoglPipeline *authority0, + CoglPipeline *authority1) { - CoglMaterialFogState *fog_state0 = &authority0->big_state->fog_state; - CoglMaterialFogState *fog_state1 = &authority1->big_state->fog_state; + CoglPipelineFogState *fog_state0 = &authority0->big_state->fog_state; + CoglPipelineFogState *fog_state1 = &authority1->big_state->fog_state; if (fog_state0->enabled == fog_state1->enabled && cogl_color_equal (&fog_state0->color, &fog_state1->color) && @@ -3235,56 +3225,56 @@ _cogl_material_fog_state_equal (CoglMaterial *authority0, } static gboolean -_cogl_material_point_size_equal (CoglMaterial *authority0, - CoglMaterial *authority1) +_cogl_pipeline_point_size_equal (CoglPipeline *authority0, + CoglPipeline *authority1) { return authority0->big_state->point_size == authority1->big_state->point_size; } static gboolean -_cogl_material_user_shader_equal (CoglMaterial *authority0, - CoglMaterial *authority1) +_cogl_pipeline_user_shader_equal (CoglPipeline *authority0, + CoglPipeline *authority1) { return (authority0->big_state->user_program == authority1->big_state->user_program); } static gboolean -_cogl_material_layers_equal (CoglMaterial *authority0, - CoglMaterial *authority1) +_cogl_pipeline_layers_equal (CoglPipeline *authority0, + CoglPipeline *authority1) { int i; if (authority0->n_layers != authority1->n_layers) return FALSE; - _cogl_material_update_layers_cache (authority0); - _cogl_material_update_layers_cache (authority1); + _cogl_pipeline_update_layers_cache (authority0); + _cogl_pipeline_update_layers_cache (authority1); for (i = 0; i < authority0->n_layers; i++) { - if (!_cogl_material_layer_equal (authority0->layers_cache[i], + if (!_cogl_pipeline_layer_equal (authority0->layers_cache[i], authority1->layers_cache[i])) return FALSE; } return TRUE; } -/* Determine the mask of differences between two materials */ +/* Determine the mask of differences between two pipelines */ unsigned long -_cogl_material_compare_differences (CoglMaterial *material0, - CoglMaterial *material1) +_cogl_pipeline_compare_differences (CoglPipeline *pipeline0, + CoglPipeline *pipeline1) { - CoglMaterial *node0; - CoglMaterial *node1; + CoglPipeline *node0; + CoglPipeline *node1; int len0; int len1; int len0_index; int len1_index; int count; int i; - CoglMaterial *common_ancestor = NULL; - unsigned long materials_difference = 0; + CoglPipeline *common_ancestor = NULL; + unsigned long pipelines_difference = 0; _COGL_GET_CONTEXT (ctx, 0); @@ -3292,25 +3282,25 @@ _cogl_material_compare_differences (CoglMaterial *material0, * * 1) Walk the ancestors of each layer to the root node, adding a * pointer to each ancester node to two GArrays: - * ctx->material0_nodes, and ctx->material1_nodes. + * ctx->pipeline0_nodes, and ctx->pipeline1_nodes. * * 2) Compare the arrays to find the nodes where they stop to * differ. * * 3) For each array now iterate from index 0 to the first node of * difference ORing that nodes ->difference mask into the final - * material_differences mask. + * pipeline_differences mask. */ - g_array_set_size (ctx->material0_nodes, 0); - g_array_set_size (ctx->material1_nodes, 0); - for (node0 = material0; node0; node0 = _cogl_material_get_parent (node0)) - g_array_append_vals (ctx->material0_nodes, &node0, 1); - for (node1 = material1; node1; node1 = _cogl_material_get_parent (node1)) - g_array_append_vals (ctx->material1_nodes, &node1, 1); + g_array_set_size (ctx->pipeline0_nodes, 0); + g_array_set_size (ctx->pipeline1_nodes, 0); + for (node0 = pipeline0; node0; node0 = _cogl_pipeline_get_parent (node0)) + g_array_append_vals (ctx->pipeline0_nodes, &node0, 1); + for (node1 = pipeline1; node1; node1 = _cogl_pipeline_get_parent (node1)) + g_array_append_vals (ctx->pipeline1_nodes, &node1, 1); - len0 = ctx->material0_nodes->len; - len1 = ctx->material1_nodes->len; + len0 = ctx->pipeline0_nodes->len; + len1 = ctx->pipeline1_nodes->len; /* There's no point looking at the last entries since we know both * layers must have the same default layer as their root node. */ len0_index = len0 - 2; @@ -3318,19 +3308,19 @@ _cogl_material_compare_differences (CoglMaterial *material0, count = MIN (len0, len1) - 1; for (i = 0; i < count; i++) { - node0 = g_array_index (ctx->material0_nodes, - CoglMaterial *, len0_index--); - node1 = g_array_index (ctx->material1_nodes, - CoglMaterial *, len1_index--); + node0 = g_array_index (ctx->pipeline0_nodes, + CoglPipeline *, len0_index--); + node1 = g_array_index (ctx->pipeline1_nodes, + CoglPipeline *, len1_index--); if (node0 != node1) { - common_ancestor = _cogl_material_get_parent (node0); + common_ancestor = _cogl_pipeline_get_parent (node0); break; } } /* If we didn't already find the first the common_ancestor ancestor - * that's because one material is a direct descendant of the other + * that's because one pipeline is a direct descendant of the other * and in this case the first common ancestor is the last node we * looked at. */ if (!common_ancestor) @@ -3339,82 +3329,82 @@ _cogl_material_compare_differences (CoglMaterial *material0, count = len0 - 1; for (i = 0; i < count; i++) { - node0 = g_array_index (ctx->material0_nodes, CoglMaterial *, i); + node0 = g_array_index (ctx->pipeline0_nodes, CoglPipeline *, i); if (node0 == common_ancestor) break; - materials_difference |= node0->differences; + pipelines_difference |= node0->differences; } count = len1 - 1; for (i = 0; i < count; i++) { - node1 = g_array_index (ctx->material1_nodes, CoglMaterial *, i); + node1 = g_array_index (ctx->pipeline1_nodes, CoglPipeline *, i); if (node1 == common_ancestor) break; - materials_difference |= node1->differences; + pipelines_difference |= node1->differences; } - return materials_difference; + return pipelines_difference; } static gboolean -simple_property_equal (CoglMaterial *material0, - CoglMaterial *material1, - unsigned long materials_difference, - CoglMaterialState state, - CoglMaterialStateComparitor comparitor) +simple_property_equal (CoglPipeline *pipeline0, + CoglPipeline *pipeline1, + unsigned long pipelines_difference, + CoglPipelineState state, + CoglPipelineStateComparitor comparitor) { - if (materials_difference & state) + if (pipelines_difference & state) { - if (!comparitor (_cogl_material_get_authority (material0, state), - _cogl_material_get_authority (material1, state))) + if (!comparitor (_cogl_pipeline_get_authority (pipeline0, state), + _cogl_pipeline_get_authority (pipeline1, state))) return FALSE; } return TRUE; } -/* Comparison of two arbitrary materials is done by: - * 1) walking up the parents of each material until a common +/* Comparison of two arbitrary pipelines is done by: + * 1) walking up the parents of each pipeline until a common * ancestor is found, and at each step ORing together the * difference masks. * * 2) using the final difference mask to determine which state * groups to compare. * - * This is used by the Cogl journal to compare materials so that it + * This is used by the Cogl journal to compare pipelines so that it * can split up geometry that needs different OpenGL state. * * It is acceptable to have false negatives - although they will result * in redundant OpenGL calls that try and update the state. * - * When comparing texture layers, _cogl_material_equal will actually + * When comparing texture layers, _cogl_pipeline_equal will actually * compare the underlying GL texture handle that the Cogl texture uses * so that atlas textures and sub textures will be considered equal if * they point to the same texture. This is useful for comparing - * materials in the journal but it means that _cogl_material_equal - * doesn't strictly compare whether the materials are the same. If we + * pipelines in the journal but it means that _cogl_pipeline_equal + * doesn't strictly compare whether the pipelines are the same. If we * needed those semantics we could perhaps add another function or * some flags to control the behaviour. * * False positives aren't allowed. */ gboolean -_cogl_material_equal (CoglMaterial *material0, - CoglMaterial *material1, +_cogl_pipeline_equal (CoglPipeline *pipeline0, + CoglPipeline *pipeline1, gboolean skip_gl_color) { - unsigned long materials_difference; + unsigned long pipelines_difference; gboolean ret; - COGL_STATIC_TIMER (material_equal_timer, + COGL_STATIC_TIMER (pipeline_equal_timer, "Mainloop", /* parent */ - "_cogl_material_equal", - "The time spent comparing cogl materials", + "_cogl_pipeline_equal", + "The time spent comparing cogl pipelines", 0 /* no application private data */); - COGL_TIMER_START (_cogl_uprof_context, material_equal_timer); + COGL_TIMER_START (_cogl_uprof_context, pipeline_equal_timer); - if (material0 == material1) + if (pipeline0 == pipeline1) { ret = TRUE; goto done; @@ -3424,225 +3414,225 @@ _cogl_material_equal (CoglMaterial *material0, /* First check non-sparse properties */ - if (material0->real_blend_enable != material1->real_blend_enable) + if (pipeline0->real_blend_enable != pipeline1->real_blend_enable) goto done; /* Then check sparse properties */ - materials_difference = - _cogl_material_compare_differences (material0, material1); + pipelines_difference = + _cogl_pipeline_compare_differences (pipeline0, pipeline1); - if (materials_difference & COGL_MATERIAL_STATE_COLOR && + if (pipelines_difference & COGL_PIPELINE_STATE_COLOR && !skip_gl_color) { - CoglMaterialState state = COGL_MATERIAL_STATE_COLOR; - CoglMaterial *authority0 = - _cogl_material_get_authority (material0, state); - CoglMaterial *authority1 = - _cogl_material_get_authority (material1, state); + CoglPipelineState state = COGL_PIPELINE_STATE_COLOR; + CoglPipeline *authority0 = + _cogl_pipeline_get_authority (pipeline0, state); + CoglPipeline *authority1 = + _cogl_pipeline_get_authority (pipeline1, state); if (!cogl_color_equal (&authority0->color, &authority1->color)) goto done; } - if (!simple_property_equal (material0, material1, - materials_difference, - COGL_MATERIAL_STATE_LIGHTING, - _cogl_material_lighting_state_equal)) + if (!simple_property_equal (pipeline0, pipeline1, + pipelines_difference, + COGL_PIPELINE_STATE_LIGHTING, + _cogl_pipeline_lighting_state_equal)) goto done; - if (!simple_property_equal (material0, material1, - materials_difference, - COGL_MATERIAL_STATE_ALPHA_FUNC, - _cogl_material_alpha_state_equal)) + if (!simple_property_equal (pipeline0, pipeline1, + pipelines_difference, + COGL_PIPELINE_STATE_ALPHA_FUNC, + _cogl_pipeline_alpha_state_equal)) goto done; /* We don't need to compare the detailed blending state if we know - * blending is disabled for both materials. */ - if (material0->real_blend_enable && - materials_difference & COGL_MATERIAL_STATE_BLEND) + * blending is disabled for both pipelines. */ + if (pipeline0->real_blend_enable && + pipelines_difference & COGL_PIPELINE_STATE_BLEND) { - CoglMaterialState state = COGL_MATERIAL_STATE_BLEND; - CoglMaterial *authority0 = - _cogl_material_get_authority (material0, state); - CoglMaterial *authority1 = - _cogl_material_get_authority (material1, state); + CoglPipelineState state = COGL_PIPELINE_STATE_BLEND; + CoglPipeline *authority0 = + _cogl_pipeline_get_authority (pipeline0, state); + CoglPipeline *authority1 = + _cogl_pipeline_get_authority (pipeline1, state); - if (!_cogl_material_blend_state_equal (authority0, authority1)) + if (!_cogl_pipeline_blend_state_equal (authority0, authority1)) goto done; } /* XXX: we don't need to compare the BLEND_ENABLE state because it's * already reflected in ->real_blend_enable */ #if 0 - if (!simple_property_equal (material0, material1, - materials_difference, - COGL_MATERIAL_STATE_BLEND, - _cogl_material_blend_enable_equal)) + if (!simple_property_equal (pipeline0, pipeline1, + pipelines_difference, + COGL_PIPELINE_STATE_BLEND, + _cogl_pipeline_blend_enable_equal)) return FALSE; #endif - if (!simple_property_equal (material0, material1, - materials_difference, - COGL_MATERIAL_STATE_DEPTH, - _cogl_material_depth_state_equal)) + if (!simple_property_equal (pipeline0, pipeline1, + pipelines_difference, + COGL_PIPELINE_STATE_DEPTH, + _cogl_pipeline_depth_state_equal)) goto done; - if (!simple_property_equal (material0, material1, - materials_difference, - COGL_MATERIAL_STATE_FOG, - _cogl_material_fog_state_equal)) + if (!simple_property_equal (pipeline0, pipeline1, + pipelines_difference, + COGL_PIPELINE_STATE_FOG, + _cogl_pipeline_fog_state_equal)) goto done; - if (!simple_property_equal (material0, material1, - materials_difference, - COGL_MATERIAL_STATE_POINT_SIZE, - _cogl_material_point_size_equal)) + if (!simple_property_equal (pipeline0, pipeline1, + pipelines_difference, + COGL_PIPELINE_STATE_POINT_SIZE, + _cogl_pipeline_point_size_equal)) goto done; - if (!simple_property_equal (material0, material1, - materials_difference, - COGL_MATERIAL_STATE_USER_SHADER, - _cogl_material_user_shader_equal)) + if (!simple_property_equal (pipeline0, pipeline1, + pipelines_difference, + COGL_PIPELINE_STATE_USER_SHADER, + _cogl_pipeline_user_shader_equal)) goto done; - if (!simple_property_equal (material0, material1, - materials_difference, - COGL_MATERIAL_STATE_LAYERS, - _cogl_material_layers_equal)) + if (!simple_property_equal (pipeline0, pipeline1, + pipelines_difference, + COGL_PIPELINE_STATE_LAYERS, + _cogl_pipeline_layers_equal)) goto done; ret = TRUE; done: - COGL_TIMER_STOP (_cogl_uprof_context, material_equal_timer); + COGL_TIMER_STOP (_cogl_uprof_context, pipeline_equal_timer); return ret; } void -cogl_material_get_color (CoglMaterial *material, +cogl_pipeline_get_color (CoglPipeline *pipeline, CoglColor *color) { - CoglMaterial *authority; + CoglPipeline *authority; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_COLOR); + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_COLOR); *color = authority->color; } /* This is used heavily by the cogl journal when logging quads */ void -_cogl_material_get_colorubv (CoglMaterial *material, +_cogl_pipeline_get_colorubv (CoglPipeline *pipeline, guint8 *color) { - CoglMaterial *authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_COLOR); + CoglPipeline *authority = + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_COLOR); _cogl_color_get_rgba_4ubv (&authority->color, color); } static void -_cogl_material_prune_redundant_ancestry (CoglMaterial *material) +_cogl_pipeline_prune_redundant_ancestry (CoglPipeline *pipeline) { - CoglMaterial *new_parent = _cogl_material_get_parent (material); + CoglPipeline *new_parent = _cogl_pipeline_get_parent (pipeline); /* Before considering pruning redundant ancestry we check if this - * material is an authority for layer state and if so only consider + * pipeline is an authority for layer state and if so only consider * reparenting if it *owns* all the layers it depends on. NB: A - * material can be be a STATE_LAYERS authority but it may still + * pipeline can be be a STATE_LAYERS authority but it may still * defer to its ancestors to define the state for some of its * layers. * - * For example a material that derives from a parent with 5 layers + * For example a pipeline that derives from a parent with 5 layers * can become a STATE_LAYERS authority by simply changing it's * ->n_layers count to 4 and in that case it can still defer to its * ancestors to define the state of those 4 layers. * - * If a material depends on any ancestors for layer state then we + * If a pipeline depends on any ancestors for layer state then we * immediatly bail out. */ - if (material->differences & COGL_MATERIAL_STATE_LAYERS) + if (pipeline->differences & COGL_PIPELINE_STATE_LAYERS) { - if (material->n_layers != g_list_length (material->layer_differences)) + if (pipeline->n_layers != g_list_length (pipeline->layer_differences)) return; } /* walk up past ancestors that are now redundant and potentially - * reparent the material. */ - while (_cogl_material_get_parent (new_parent) && - (new_parent->differences | material->differences) == - material->differences) - new_parent = _cogl_material_get_parent (new_parent); + * reparent the pipeline. */ + while (_cogl_pipeline_get_parent (new_parent) && + (new_parent->differences | pipeline->differences) == + pipeline->differences) + new_parent = _cogl_pipeline_get_parent (new_parent); - if (new_parent != _cogl_material_get_parent (material)) + if (new_parent != _cogl_pipeline_get_parent (pipeline)) { - gboolean is_weak = _cogl_material_is_weak (material); - _cogl_material_set_parent (material, new_parent, is_weak ? FALSE : TRUE); + gboolean is_weak = _cogl_pipeline_is_weak (pipeline); + _cogl_pipeline_set_parent (pipeline, new_parent, is_weak ? FALSE : TRUE); } } static void -_cogl_material_update_authority (CoglMaterial *material, - CoglMaterial *authority, - CoglMaterialState state, - CoglMaterialStateComparitor comparitor) +_cogl_pipeline_update_authority (CoglPipeline *pipeline, + CoglPipeline *authority, + CoglPipelineState state, + CoglPipelineStateComparitor comparitor) { /* If we are the current authority see if we can revert to one of * our ancestors being the authority */ - if (material == authority && - _cogl_material_get_parent (authority) != NULL) + if (pipeline == authority && + _cogl_pipeline_get_parent (authority) != NULL) { - CoglMaterial *parent = _cogl_material_get_parent (authority); - CoglMaterial *old_authority = - _cogl_material_get_authority (parent, state); + CoglPipeline *parent = _cogl_pipeline_get_parent (authority); + CoglPipeline *old_authority = + _cogl_pipeline_get_authority (parent, state); if (comparitor (authority, old_authority)) - material->differences &= ~state; + pipeline->differences &= ~state; } - else if (material != authority) + else if (pipeline != authority) { /* If we weren't previously the authority on this state then we * need to extended our differences mask and so it's possible * that some of our ancestry will now become redundant, so we * aim to reparent ourselves if that's true... */ - material->differences |= state; - _cogl_material_prune_redundant_ancestry (material); + pipeline->differences |= state; + _cogl_pipeline_prune_redundant_ancestry (pipeline); } } void -cogl_material_set_color (CoglMaterial *material, +cogl_pipeline_set_color (CoglPipeline *pipeline, const CoglColor *color) { - CoglMaterialState state = COGL_MATERIAL_STATE_COLOR; - CoglMaterial *authority; + CoglPipelineState state = COGL_PIPELINE_STATE_COLOR; + CoglPipeline *authority; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); - authority = _cogl_material_get_authority (material, state); + authority = _cogl_pipeline_get_authority (pipeline, state); if (cogl_color_equal (color, &authority->color)) return; /* - Flush journal primitives referencing the current state. - * - Make sure the material has no dependants so it may be modified. - * - If the material isn't currently an authority for the state being + * - Make sure the pipeline has no dependants so it may be modified. + * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ - _cogl_material_pre_change_notify (material, state, color, FALSE); + _cogl_pipeline_pre_change_notify (pipeline, state, color, FALSE); - material->color = *color; + pipeline->color = *color; - _cogl_material_update_authority (material, authority, state, - _cogl_material_color_equal); + _cogl_pipeline_update_authority (pipeline, authority, state, + _cogl_pipeline_color_equal); - handle_automatic_blend_enable (material, state); + handle_automatic_blend_enable (pipeline, state); } void -cogl_material_set_color4ub (CoglMaterial *material, +cogl_pipeline_set_color4ub (CoglPipeline *pipeline, guint8 red, guint8 green, guint8 blue, @@ -3650,11 +3640,11 @@ cogl_material_set_color4ub (CoglMaterial *material, { CoglColor color; cogl_color_init_from_4ub (&color, red, green, blue, alpha); - cogl_material_set_color (material, &color); + cogl_pipeline_set_color (pipeline, &color); } void -cogl_material_set_color4f (CoglMaterial *material, +cogl_pipeline_set_color4f (CoglPipeline *pipeline, float red, float green, float blue, @@ -3662,248 +3652,248 @@ cogl_material_set_color4f (CoglMaterial *material, { CoglColor color; cogl_color_init_from_4f (&color, red, green, blue, alpha); - cogl_material_set_color (material, &color); + cogl_pipeline_set_color (pipeline, &color); } -CoglMaterialBlendEnable -_cogl_material_get_blend_enabled (CoglMaterial *material) +CoglPipelineBlendEnable +_cogl_pipeline_get_blend_enabled (CoglPipeline *pipeline) { - CoglMaterial *authority; + CoglPipeline *authority; - g_return_val_if_fail (cogl_is_material (material), FALSE); + g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_BLEND_ENABLE); + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_BLEND_ENABLE); return authority->blend_enable; } static gboolean -_cogl_material_blend_enable_equal (CoglMaterial *authority0, - CoglMaterial *authority1) +_cogl_pipeline_blend_enable_equal (CoglPipeline *authority0, + CoglPipeline *authority1) { return authority0->blend_enable == authority1->blend_enable ? TRUE : FALSE; } void -_cogl_material_set_blend_enabled (CoglMaterial *material, - CoglMaterialBlendEnable enable) +_cogl_pipeline_set_blend_enabled (CoglPipeline *pipeline, + CoglPipelineBlendEnable enable) { - CoglMaterialState state = COGL_MATERIAL_STATE_BLEND_ENABLE; - CoglMaterial *authority; + CoglPipelineState state = COGL_PIPELINE_STATE_BLEND_ENABLE; + CoglPipeline *authority; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (enable > 1 && "don't pass TRUE or FALSE to _set_blend_enabled!"); - authority = _cogl_material_get_authority (material, state); + authority = _cogl_pipeline_get_authority (pipeline, state); if (authority->blend_enable == enable) return; /* - Flush journal primitives referencing the current state. - * - Make sure the material has no dependants so it may be modified. - * - If the material isn't currently an authority for the state being + * - Make sure the pipeline has no dependants so it may be modified. + * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ - _cogl_material_pre_change_notify (material, state, NULL, FALSE); + _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); - material->blend_enable = enable; + pipeline->blend_enable = enable; - _cogl_material_update_authority (material, authority, state, - _cogl_material_blend_enable_equal); + _cogl_pipeline_update_authority (pipeline, authority, state, + _cogl_pipeline_blend_enable_equal); - handle_automatic_blend_enable (material, state); + handle_automatic_blend_enable (pipeline, state); } void -cogl_material_get_ambient (CoglMaterial *material, +cogl_pipeline_get_ambient (CoglPipeline *pipeline, CoglColor *ambient) { - CoglMaterial *authority; + CoglPipeline *authority; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_LIGHTING); + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LIGHTING); cogl_color_init_from_4fv (ambient, authority->big_state->lighting_state.ambient); } void -cogl_material_set_ambient (CoglMaterial *material, +cogl_pipeline_set_ambient (CoglPipeline *pipeline, const CoglColor *ambient) { - CoglMaterialState state = COGL_MATERIAL_STATE_LIGHTING; - CoglMaterial *authority; - CoglMaterialLightingState *lighting_state; + CoglPipelineState state = COGL_PIPELINE_STATE_LIGHTING; + CoglPipeline *authority; + CoglPipelineLightingState *lighting_state; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); - authority = _cogl_material_get_authority (material, state); + authority = _cogl_pipeline_get_authority (pipeline, state); lighting_state = &authority->big_state->lighting_state; if (cogl_color_equal (ambient, &lighting_state->ambient)) return; /* - Flush journal primitives referencing the current state. - * - Make sure the material has no dependants so it may be modified. - * - If the material isn't currently an authority for the state being + * - Make sure the pipeline has no dependants so it may be modified. + * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ - _cogl_material_pre_change_notify (material, state, NULL, FALSE); + _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); - lighting_state = &material->big_state->lighting_state; + lighting_state = &pipeline->big_state->lighting_state; lighting_state->ambient[0] = cogl_color_get_red_float (ambient); lighting_state->ambient[1] = cogl_color_get_green_float (ambient); lighting_state->ambient[2] = cogl_color_get_blue_float (ambient); lighting_state->ambient[3] = cogl_color_get_alpha_float (ambient); - _cogl_material_update_authority (material, authority, state, - _cogl_material_lighting_state_equal); + _cogl_pipeline_update_authority (pipeline, authority, state, + _cogl_pipeline_lighting_state_equal); - handle_automatic_blend_enable (material, state); + handle_automatic_blend_enable (pipeline, state); } void -cogl_material_get_diffuse (CoglMaterial *material, +cogl_pipeline_get_diffuse (CoglPipeline *pipeline, CoglColor *diffuse) { - CoglMaterial *authority; + CoglPipeline *authority; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_LIGHTING); + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LIGHTING); cogl_color_init_from_4fv (diffuse, authority->big_state->lighting_state.diffuse); } void -cogl_material_set_diffuse (CoglMaterial *material, +cogl_pipeline_set_diffuse (CoglPipeline *pipeline, const CoglColor *diffuse) { - CoglMaterialState state = COGL_MATERIAL_STATE_LIGHTING; - CoglMaterial *authority; - CoglMaterialLightingState *lighting_state; + CoglPipelineState state = COGL_PIPELINE_STATE_LIGHTING; + CoglPipeline *authority; + CoglPipelineLightingState *lighting_state; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); - authority = _cogl_material_get_authority (material, state); + authority = _cogl_pipeline_get_authority (pipeline, state); lighting_state = &authority->big_state->lighting_state; if (cogl_color_equal (diffuse, &lighting_state->diffuse)) return; /* - Flush journal primitives referencing the current state. - * - Make sure the material has no dependants so it may be modified. - * - If the material isn't currently an authority for the state being + * - Make sure the pipeline has no dependants so it may be modified. + * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ - _cogl_material_pre_change_notify (material, state, NULL, FALSE); + _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); - lighting_state = &material->big_state->lighting_state; + lighting_state = &pipeline->big_state->lighting_state; lighting_state->diffuse[0] = cogl_color_get_red_float (diffuse); lighting_state->diffuse[1] = cogl_color_get_green_float (diffuse); lighting_state->diffuse[2] = cogl_color_get_blue_float (diffuse); lighting_state->diffuse[3] = cogl_color_get_alpha_float (diffuse); - _cogl_material_update_authority (material, authority, state, - _cogl_material_lighting_state_equal); + _cogl_pipeline_update_authority (pipeline, authority, state, + _cogl_pipeline_lighting_state_equal); - handle_automatic_blend_enable (material, state); + handle_automatic_blend_enable (pipeline, state); } void -cogl_material_set_ambient_and_diffuse (CoglMaterial *material, +cogl_pipeline_set_ambient_and_diffuse (CoglPipeline *pipeline, const CoglColor *color) { - cogl_material_set_ambient (material, color); - cogl_material_set_diffuse (material, color); + cogl_pipeline_set_ambient (pipeline, color); + cogl_pipeline_set_diffuse (pipeline, color); } void -cogl_material_get_specular (CoglMaterial *material, +cogl_pipeline_get_specular (CoglPipeline *pipeline, CoglColor *specular) { - CoglMaterial *authority; + CoglPipeline *authority; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_LIGHTING); + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LIGHTING); cogl_color_init_from_4fv (specular, authority->big_state->lighting_state.specular); } void -cogl_material_set_specular (CoglMaterial *material, const CoglColor *specular) +cogl_pipeline_set_specular (CoglPipeline *pipeline, const CoglColor *specular) { - CoglMaterial *authority; - CoglMaterialState state = COGL_MATERIAL_STATE_LIGHTING; - CoglMaterialLightingState *lighting_state; + CoglPipeline *authority; + CoglPipelineState state = COGL_PIPELINE_STATE_LIGHTING; + CoglPipelineLightingState *lighting_state; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); - authority = _cogl_material_get_authority (material, state); + authority = _cogl_pipeline_get_authority (pipeline, state); lighting_state = &authority->big_state->lighting_state; if (cogl_color_equal (specular, &lighting_state->specular)) return; /* - Flush journal primitives referencing the current state. - * - Make sure the material has no dependants so it may be modified. - * - If the material isn't currently an authority for the state being + * - Make sure the pipeline has no dependants so it may be modified. + * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ - _cogl_material_pre_change_notify (material, state, NULL, FALSE); + _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); - lighting_state = &material->big_state->lighting_state; + lighting_state = &pipeline->big_state->lighting_state; lighting_state->specular[0] = cogl_color_get_red_float (specular); lighting_state->specular[1] = cogl_color_get_green_float (specular); lighting_state->specular[2] = cogl_color_get_blue_float (specular); lighting_state->specular[3] = cogl_color_get_alpha_float (specular); - _cogl_material_update_authority (material, authority, state, - _cogl_material_lighting_state_equal); + _cogl_pipeline_update_authority (pipeline, authority, state, + _cogl_pipeline_lighting_state_equal); - handle_automatic_blend_enable (material, state); + handle_automatic_blend_enable (pipeline, state); } float -cogl_material_get_shininess (CoglMaterial *material) +cogl_pipeline_get_shininess (CoglPipeline *pipeline) { - CoglMaterial *authority; + CoglPipeline *authority; - g_return_val_if_fail (cogl_is_material (material), 0); + g_return_val_if_fail (cogl_is_pipeline (pipeline), 0); authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_LIGHTING); + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LIGHTING); return authority->big_state->lighting_state.shininess; } void -cogl_material_set_shininess (CoglMaterial *material, +cogl_pipeline_set_shininess (CoglPipeline *pipeline, float shininess) { - CoglMaterial *authority; - CoglMaterialState state = COGL_MATERIAL_STATE_LIGHTING; - CoglMaterialLightingState *lighting_state; + CoglPipeline *authority; + CoglPipelineState state = COGL_PIPELINE_STATE_LIGHTING; + CoglPipelineLightingState *lighting_state; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); if (shininess < 0.0) { - g_warning ("Out of range shininess %f supplied for material\n", + g_warning ("Out of range shininess %f supplied for pipeline\n", shininess); return; } - authority = _cogl_material_get_authority (material, state); + authority = _cogl_pipeline_get_authority (pipeline, state); lighting_state = &authority->big_state->lighting_state; @@ -3911,80 +3901,80 @@ cogl_material_set_shininess (CoglMaterial *material, return; /* - Flush journal primitives referencing the current state. - * - Make sure the material has no dependants so it may be modified. - * - If the material isn't currently an authority for the state being + * - Make sure the pipeline has no dependants so it may be modified. + * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ - _cogl_material_pre_change_notify (material, state, NULL, FALSE); + _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); - lighting_state = &material->big_state->lighting_state; + lighting_state = &pipeline->big_state->lighting_state; lighting_state->shininess = shininess; - _cogl_material_update_authority (material, authority, state, - _cogl_material_lighting_state_equal); + _cogl_pipeline_update_authority (pipeline, authority, state, + _cogl_pipeline_lighting_state_equal); } void -cogl_material_get_emission (CoglMaterial *material, +cogl_pipeline_get_emission (CoglPipeline *pipeline, CoglColor *emission) { - CoglMaterial *authority; + CoglPipeline *authority; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_LIGHTING); + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LIGHTING); cogl_color_init_from_4fv (emission, authority->big_state->lighting_state.emission); } void -cogl_material_set_emission (CoglMaterial *material, const CoglColor *emission) +cogl_pipeline_set_emission (CoglPipeline *pipeline, const CoglColor *emission) { - CoglMaterial *authority; - CoglMaterialState state = COGL_MATERIAL_STATE_LIGHTING; - CoglMaterialLightingState *lighting_state; + CoglPipeline *authority; + CoglPipelineState state = COGL_PIPELINE_STATE_LIGHTING; + CoglPipelineLightingState *lighting_state; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); - authority = _cogl_material_get_authority (material, state); + authority = _cogl_pipeline_get_authority (pipeline, state); lighting_state = &authority->big_state->lighting_state; if (cogl_color_equal (emission, &lighting_state->emission)) return; /* - Flush journal primitives referencing the current state. - * - Make sure the material has no dependants so it may be modified. - * - If the material isn't currently an authority for the state being + * - Make sure the pipeline has no dependants so it may be modified. + * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ - _cogl_material_pre_change_notify (material, state, NULL, FALSE); + _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); - lighting_state = &material->big_state->lighting_state; + lighting_state = &pipeline->big_state->lighting_state; lighting_state->emission[0] = cogl_color_get_red_float (emission); lighting_state->emission[1] = cogl_color_get_green_float (emission); lighting_state->emission[2] = cogl_color_get_blue_float (emission); lighting_state->emission[3] = cogl_color_get_alpha_float (emission); - _cogl_material_update_authority (material, authority, state, - _cogl_material_lighting_state_equal); + _cogl_pipeline_update_authority (pipeline, authority, state, + _cogl_pipeline_lighting_state_equal); - handle_automatic_blend_enable (material, state); + handle_automatic_blend_enable (pipeline, state); } void -cogl_material_set_alpha_test_function (CoglMaterial *material, - CoglMaterialAlphaFunc alpha_func, +cogl_pipeline_set_alpha_test_function (CoglPipeline *pipeline, + CoglPipelineAlphaFunc alpha_func, float alpha_reference) { - CoglMaterialState state = COGL_MATERIAL_STATE_ALPHA_FUNC; - CoglMaterial *authority; - CoglMaterialAlphaFuncState *alpha_state; + CoglPipelineState state = COGL_PIPELINE_STATE_ALPHA_FUNC; + CoglPipeline *authority; + CoglPipelineAlphaFuncState *alpha_state; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); - authority = _cogl_material_get_authority (material, state); + authority = _cogl_pipeline_get_authority (pipeline, state); alpha_state = &authority->big_state->alpha_state; if (alpha_state->alpha_func == alpha_func && @@ -3992,18 +3982,18 @@ cogl_material_set_alpha_test_function (CoglMaterial *material, return; /* - Flush journal primitives referencing the current state. - * - Make sure the material has no dependants so it may be modified. - * - If the material isn't currently an authority for the state being + * - Make sure the pipeline has no dependants so it may be modified. + * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ - _cogl_material_pre_change_notify (material, state, NULL, FALSE); + _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); - alpha_state = &material->big_state->alpha_state; + alpha_state = &pipeline->big_state->alpha_state; alpha_state->alpha_func = alpha_func; alpha_state->alpha_func_reference = alpha_reference; - _cogl_material_update_authority (material, authority, state, - _cogl_material_alpha_state_equal); + _cogl_pipeline_update_authority (pipeline, authority, state, + _cogl_pipeline_alpha_state_equal); } GLenum @@ -4100,20 +4090,20 @@ setup_blend_state (CoglBlendStringStatement *statement, } gboolean -cogl_material_set_blend (CoglMaterial *material, +cogl_pipeline_set_blend (CoglPipeline *pipeline, const char *blend_description, GError **error) { - CoglMaterialState state = COGL_MATERIAL_STATE_BLEND; - CoglMaterial *authority; + CoglPipelineState state = COGL_PIPELINE_STATE_BLEND; + CoglPipeline *authority; CoglBlendStringStatement statements[2]; CoglBlendStringStatement *rgb; CoglBlendStringStatement *a; GError *internal_error = NULL; int count; - CoglMaterialBlendState *blend_state; + CoglPipelineBlendState *blend_state; - g_return_val_if_fail (cogl_is_material (material), FALSE); + g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); count = _cogl_blend_string_compile (blend_description, @@ -4142,16 +4132,16 @@ cogl_material_set_blend (CoglMaterial *material, } authority = - _cogl_material_get_authority (material, state); + _cogl_pipeline_get_authority (pipeline, state); /* - Flush journal primitives referencing the current state. - * - Make sure the material has no dependants so it may be modified. - * - If the material isn't currently an authority for the state being + * - Make sure the pipeline has no dependants so it may be modified. + * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ - _cogl_material_pre_change_notify (material, state, NULL, FALSE); + _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); - blend_state = &material->big_state->blend_state; + blend_state = &pipeline->big_state->blend_state; #ifndef HAVE_COGL_GLES setup_blend_state (rgb, &blend_state->blend_equation_rgb, @@ -4170,75 +4160,75 @@ cogl_material_set_blend (CoglMaterial *material, /* If we are the current authority see if we can revert to one of our * ancestors being the authority */ - if (material == authority && - _cogl_material_get_parent (authority) != NULL) + if (pipeline == authority && + _cogl_pipeline_get_parent (authority) != NULL) { - CoglMaterial *parent = _cogl_material_get_parent (authority); - CoglMaterial *old_authority = - _cogl_material_get_authority (parent, state); + CoglPipeline *parent = _cogl_pipeline_get_parent (authority); + CoglPipeline *old_authority = + _cogl_pipeline_get_authority (parent, state); - if (_cogl_material_blend_state_equal (authority, old_authority)) - material->differences &= ~state; + if (_cogl_pipeline_blend_state_equal (authority, old_authority)) + pipeline->differences &= ~state; } /* If we weren't previously the authority on this state then we need * to extended our differences mask and so it's possible that some * of our ancestry will now become redundant, so we aim to reparent * ourselves if that's true... */ - if (material != authority) + if (pipeline != authority) { - material->differences |= state; - _cogl_material_prune_redundant_ancestry (material); + pipeline->differences |= state; + _cogl_pipeline_prune_redundant_ancestry (pipeline); } - handle_automatic_blend_enable (material, state); + handle_automatic_blend_enable (pipeline, state); return TRUE; } void -cogl_material_set_blend_constant (CoglMaterial *material, +cogl_pipeline_set_blend_constant (CoglPipeline *pipeline, const CoglColor *constant_color) { #ifndef HAVE_COGL_GLES - CoglMaterialState state = COGL_MATERIAL_STATE_BLEND; - CoglMaterial *authority; - CoglMaterialBlendState *blend_state; + CoglPipelineState state = COGL_PIPELINE_STATE_BLEND; + CoglPipeline *authority; + CoglPipelineBlendState *blend_state; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); - authority = _cogl_material_get_authority (material, state); + authority = _cogl_pipeline_get_authority (pipeline, state); blend_state = &authority->big_state->blend_state; if (cogl_color_equal (constant_color, &blend_state->blend_constant)) return; /* - Flush journal primitives referencing the current state. - * - Make sure the material has no dependants so it may be modified. - * - If the material isn't currently an authority for the state being + * - Make sure the pipeline has no dependants so it may be modified. + * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ - _cogl_material_pre_change_notify (material, state, NULL, FALSE); + _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); - blend_state = &material->big_state->blend_state; + blend_state = &pipeline->big_state->blend_state; blend_state->blend_constant = *constant_color; - _cogl_material_update_authority (material, authority, state, - _cogl_material_blend_state_equal); + _cogl_pipeline_update_authority (pipeline, authority, state, + _cogl_pipeline_blend_state_equal); - handle_automatic_blend_enable (material, state); + handle_automatic_blend_enable (pipeline, state); #endif } CoglHandle -cogl_material_get_user_program (CoglMaterial *material) +cogl_pipeline_get_user_program (CoglPipeline *pipeline) { - CoglMaterial *authority; + CoglPipeline *authority; - g_return_val_if_fail (cogl_is_material (material), COGL_INVALID_HANDLE); + g_return_val_if_fail (cogl_is_pipeline (pipeline), COGL_INVALID_HANDLE); authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_USER_SHADER); + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_USER_SHADER); return authority->big_state->user_program; } @@ -4250,203 +4240,203 @@ cogl_material_get_user_program (CoglMaterial *material) * processing. */ void -cogl_material_set_user_program (CoglMaterial *material, +cogl_pipeline_set_user_program (CoglPipeline *pipeline, CoglHandle program) { - CoglMaterialState state = COGL_MATERIAL_STATE_USER_SHADER; - CoglMaterial *authority; + CoglPipelineState state = COGL_PIPELINE_STATE_USER_SHADER; + CoglPipeline *authority; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); - authority = _cogl_material_get_authority (material, state); + authority = _cogl_pipeline_get_authority (pipeline, state); if (authority->big_state->user_program == program) return; /* - Flush journal primitives referencing the current state. - * - Make sure the material has no dependants so it may be modified. - * - If the material isn't currently an authority for the state being + * - Make sure the pipeline has no dependants so it may be modified. + * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ - _cogl_material_pre_change_notify (material, state, NULL, FALSE); + _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); if (program != COGL_INVALID_HANDLE) - _cogl_material_set_backend (material, COGL_MATERIAL_BACKEND_DEFAULT); + _cogl_pipeline_set_backend (pipeline, COGL_PIPELINE_BACKEND_DEFAULT); /* If we are the current authority see if we can revert to one of our * ancestors being the authority */ - if (material == authority && - _cogl_material_get_parent (authority) != NULL) + if (pipeline == authority && + _cogl_pipeline_get_parent (authority) != NULL) { - CoglMaterial *parent = _cogl_material_get_parent (authority); - CoglMaterial *old_authority = - _cogl_material_get_authority (parent, state); + CoglPipeline *parent = _cogl_pipeline_get_parent (authority); + CoglPipeline *old_authority = + _cogl_pipeline_get_authority (parent, state); if (old_authority->big_state->user_program == program) - material->differences &= ~state; + pipeline->differences &= ~state; } - else if (material != authority) + else if (pipeline != authority) { /* If we weren't previously the authority on this state then we * need to extended our differences mask and so it's possible * that some of our ancestry will now become redundant, so we * aim to reparent ourselves if that's true... */ - material->differences |= state; - _cogl_material_prune_redundant_ancestry (material); + pipeline->differences |= state; + _cogl_pipeline_prune_redundant_ancestry (pipeline); } if (program != COGL_INVALID_HANDLE) cogl_handle_ref (program); - if (authority == material && - material->big_state->user_program != COGL_INVALID_HANDLE) - cogl_handle_unref (material->big_state->user_program); - material->big_state->user_program = program; + if (authority == pipeline && + pipeline->big_state->user_program != COGL_INVALID_HANDLE) + cogl_handle_unref (pipeline->big_state->user_program); + pipeline->big_state->user_program = program; - handle_automatic_blend_enable (material, state); + handle_automatic_blend_enable (pipeline, state); } void -cogl_material_set_depth_test_enabled (CoglMaterial *material, +cogl_pipeline_set_depth_test_enabled (CoglPipeline *pipeline, gboolean enable) { - CoglMaterialState state = COGL_MATERIAL_STATE_DEPTH; - CoglMaterial *authority; - CoglMaterialDepthState *depth_state; + CoglPipelineState state = COGL_PIPELINE_STATE_DEPTH; + CoglPipeline *authority; + CoglPipelineDepthState *depth_state; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); - authority = _cogl_material_get_authority (material, state); + authority = _cogl_pipeline_get_authority (pipeline, state); depth_state = &authority->big_state->depth_state; if (depth_state->depth_test_enabled == enable) return; /* - Flush journal primitives referencing the current state. - * - Make sure the material has no dependants so it may be modified. - * - If the material isn't currently an authority for the state being + * - Make sure the pipeline has no dependants so it may be modified. + * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ - _cogl_material_pre_change_notify (material, state, NULL, FALSE); + _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); - material->big_state->depth_state.depth_test_enabled = enable; + pipeline->big_state->depth_state.depth_test_enabled = enable; - _cogl_material_update_authority (material, authority, state, - _cogl_material_depth_state_equal); + _cogl_pipeline_update_authority (pipeline, authority, state, + _cogl_pipeline_depth_state_equal); } gboolean -cogl_material_get_depth_test_enabled (CoglMaterial *material) +cogl_pipeline_get_depth_test_enabled (CoglPipeline *pipeline) { - CoglMaterial *authority; + CoglPipeline *authority; - g_return_val_if_fail (cogl_is_material (material), FALSE); + g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_DEPTH); + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_DEPTH); return authority->big_state->depth_state.depth_test_enabled; } void -cogl_material_set_depth_writing_enabled (CoglMaterial *material, +cogl_pipeline_set_depth_writing_enabled (CoglPipeline *pipeline, gboolean enable) { - CoglMaterialState state = COGL_MATERIAL_STATE_DEPTH; - CoglMaterial *authority; - CoglMaterialDepthState *depth_state; + CoglPipelineState state = COGL_PIPELINE_STATE_DEPTH; + CoglPipeline *authority; + CoglPipelineDepthState *depth_state; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); - authority = _cogl_material_get_authority (material, state); + authority = _cogl_pipeline_get_authority (pipeline, state); depth_state = &authority->big_state->depth_state; if (depth_state->depth_writing_enabled == enable) return; /* - Flush journal primitives referencing the current state. - * - Make sure the material has no dependants so it may be modified. - * - If the material isn't currently an authority for the state being + * - Make sure the pipeline has no dependants so it may be modified. + * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ - _cogl_material_pre_change_notify (material, state, NULL, FALSE); + _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); - material->big_state->depth_state.depth_writing_enabled = enable; + pipeline->big_state->depth_state.depth_writing_enabled = enable; - _cogl_material_update_authority (material, authority, state, - _cogl_material_depth_state_equal); + _cogl_pipeline_update_authority (pipeline, authority, state, + _cogl_pipeline_depth_state_equal); } gboolean -cogl_material_get_depth_writing_enabled (CoglMaterial *material) +cogl_pipeline_get_depth_writing_enabled (CoglPipeline *pipeline) { - CoglMaterial *authority; + CoglPipeline *authority; - g_return_val_if_fail (cogl_is_material (material), TRUE); + g_return_val_if_fail (cogl_is_pipeline (pipeline), TRUE); authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_DEPTH); + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_DEPTH); return authority->big_state->depth_state.depth_writing_enabled; } void -cogl_material_set_depth_test_function (CoglMaterial *material, +cogl_pipeline_set_depth_test_function (CoglPipeline *pipeline, CoglDepthTestFunction function) { - CoglMaterialState state = COGL_MATERIAL_STATE_DEPTH; - CoglMaterial *authority; - CoglMaterialDepthState *depth_state; + CoglPipelineState state = COGL_PIPELINE_STATE_DEPTH; + CoglPipeline *authority; + CoglPipelineDepthState *depth_state; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); - authority = _cogl_material_get_authority (material, state); + authority = _cogl_pipeline_get_authority (pipeline, state); depth_state = &authority->big_state->depth_state; if (depth_state->depth_test_function == function) return; /* - Flush journal primitives referencing the current state. - * - Make sure the material has no dependants so it may be modified. - * - If the material isn't currently an authority for the state being + * - Make sure the pipeline has no dependants so it may be modified. + * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ - _cogl_material_pre_change_notify (material, state, NULL, FALSE); + _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); - material->big_state->depth_state.depth_test_function = function; + pipeline->big_state->depth_state.depth_test_function = function; - _cogl_material_update_authority (material, authority, state, - _cogl_material_depth_state_equal); + _cogl_pipeline_update_authority (pipeline, authority, state, + _cogl_pipeline_depth_state_equal); } CoglDepthTestFunction -cogl_material_get_depth_test_function (CoglMaterial *material) +cogl_pipeline_get_depth_test_function (CoglPipeline *pipeline) { - CoglMaterial *authority; + CoglPipeline *authority; - g_return_val_if_fail (cogl_is_material (material), + g_return_val_if_fail (cogl_is_pipeline (pipeline), COGL_DEPTH_TEST_FUNCTION_LESS); authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_DEPTH); + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_DEPTH); return authority->big_state->depth_state.depth_test_function; } gboolean -cogl_material_set_depth_range (CoglMaterial *material, +cogl_pipeline_set_depth_range (CoglPipeline *pipeline, float near_val, float far_val, GError **error) { #ifndef COGL_HAS_GLES - CoglMaterialState state = COGL_MATERIAL_STATE_DEPTH; - CoglMaterial *authority; - CoglMaterialDepthState *depth_state; + CoglPipelineState state = COGL_PIPELINE_STATE_DEPTH; + CoglPipeline *authority; + CoglPipelineDepthState *depth_state; - g_return_val_if_fail (cogl_is_material (material), FALSE); + g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); - authority = _cogl_material_get_authority (material, state); + authority = _cogl_pipeline_get_authority (pipeline, state); depth_state = &authority->big_state->depth_state; if (depth_state->depth_range_near == near_val && @@ -4454,17 +4444,17 @@ cogl_material_set_depth_range (CoglMaterial *material, return TRUE; /* - Flush journal primitives referencing the current state. - * - Make sure the material has no dependants so it may be modified. - * - If the material isn't currently an authority for the state being + * - Make sure the pipeline has no dependants so it may be modified. + * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ - _cogl_material_pre_change_notify (material, state, NULL, FALSE); + _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); - material->big_state->depth_state.depth_range_near = near_val; - material->big_state->depth_state.depth_range_far = far_val; + pipeline->big_state->depth_state.depth_range_near = near_val; + pipeline->big_state->depth_state.depth_range_far = far_val; - _cogl_material_update_authority (material, authority, state, - _cogl_material_depth_state_equal); + _cogl_pipeline_update_authority (pipeline, authority, state, + _cogl_pipeline_depth_state_equal); return TRUE; #else g_set_error (error, @@ -4476,32 +4466,32 @@ cogl_material_set_depth_range (CoglMaterial *material, } void -cogl_material_get_depth_range (CoglMaterial *material, +cogl_pipeline_get_depth_range (CoglPipeline *pipeline, float *near_val, float *far_val) { - CoglMaterial *authority; + CoglPipeline *authority; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_DEPTH); + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_DEPTH); *near_val = authority->big_state->depth_state.depth_range_near; *far_val = authority->big_state->depth_state.depth_range_far; } static void -_cogl_material_set_fog_state (CoglMaterial *material, - const CoglMaterialFogState *fog_state) +_cogl_pipeline_set_fog_state (CoglPipeline *pipeline, + const CoglPipelineFogState *fog_state) { - CoglMaterialState state = COGL_MATERIAL_STATE_FOG; - CoglMaterial *authority; - CoglMaterialFogState *current_fog_state; + CoglPipelineState state = COGL_PIPELINE_STATE_FOG; + CoglPipeline *authority; + CoglPipelineFogState *current_fog_state; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); - authority = _cogl_material_get_authority (material, state); + authority = _cogl_pipeline_get_authority (pipeline, state); current_fog_state = &authority->big_state->fog_state; @@ -4514,76 +4504,76 @@ _cogl_material_set_fog_state (CoglMaterial *material, return; /* - Flush journal primitives referencing the current state. - * - Make sure the material has no dependants so it may be modified. - * - If the material isn't currently an authority for the state being + * - Make sure the pipeline has no dependants so it may be modified. + * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ - _cogl_material_pre_change_notify (material, state, NULL, FALSE); + _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); - material->big_state->fog_state = *fog_state; + pipeline->big_state->fog_state = *fog_state; - _cogl_material_update_authority (material, authority, state, - _cogl_material_fog_state_equal); + _cogl_pipeline_update_authority (pipeline, authority, state, + _cogl_pipeline_fog_state_equal); } unsigned long -_cogl_material_get_age (CoglMaterial *material) +_cogl_pipeline_get_age (CoglPipeline *pipeline) { - g_return_val_if_fail (cogl_is_material (material), 0); + g_return_val_if_fail (cogl_is_pipeline (pipeline), 0); - return material->age; + return pipeline->age; } -static CoglMaterialLayer * -_cogl_material_layer_copy (CoglMaterialLayer *src) +static CoglPipelineLayer * +_cogl_pipeline_layer_copy (CoglPipelineLayer *src) { - CoglMaterialLayer *layer = g_slice_new (CoglMaterialLayer); + CoglPipelineLayer *layer = g_slice_new (CoglPipelineLayer); int i; - _cogl_material_node_init (COGL_MATERIAL_NODE (layer)); + _cogl_pipeline_node_init (COGL_PIPELINE_NODE (layer)); layer->owner = NULL; layer->index = src->index; layer->differences = 0; layer->has_big_state = FALSE; - for (i = 0; i < COGL_MATERIAL_N_BACKENDS; i++) + for (i = 0; i < COGL_PIPELINE_N_BACKENDS; i++) layer->backend_priv[i] = NULL; - _cogl_material_layer_set_parent (layer, src); + _cogl_pipeline_layer_set_parent (layer, src); - return _cogl_material_layer_object_new (layer); + return _cogl_pipeline_layer_object_new (layer); } static void -_cogl_material_layer_free (CoglMaterialLayer *layer) +_cogl_pipeline_layer_free (CoglPipelineLayer *layer) { int i; - _cogl_material_layer_unparent (COGL_MATERIAL_NODE (layer)); + _cogl_pipeline_layer_unparent (COGL_PIPELINE_NODE (layer)); - /* NB: layers may be used by multiple materials which may be using + /* NB: layers may be used by multiple pipelines which may be using * different backends, therefore we determine which backends to * notify based on the private state pointers for each backend... */ - for (i = 0; i < COGL_MATERIAL_N_BACKENDS; i++) + for (i = 0; i < COGL_PIPELINE_N_BACKENDS; i++) { if (layer->backend_priv[i] && - _cogl_material_backends[i]->free_layer_priv) + _cogl_pipeline_backends[i]->free_layer_priv) { - const CoglMaterialBackend *backend = _cogl_material_backends[i]; + const CoglPipelineBackend *backend = _cogl_pipeline_backends[i]; backend->free_layer_priv (layer); } } - if (layer->differences & COGL_MATERIAL_LAYER_STATE_TEXTURE && + if (layer->differences & COGL_PIPELINE_LAYER_STATE_TEXTURE && layer->texture != COGL_INVALID_HANDLE) cogl_handle_unref (layer->texture); - if (layer->differences & COGL_MATERIAL_LAYER_STATE_NEEDS_BIG_STATE) - g_slice_free (CoglMaterialLayerBigState, layer->big_state); + if (layer->differences & COGL_PIPELINE_LAYER_STATE_NEEDS_BIG_STATE) + g_slice_free (CoglPipelineLayerBigState, layer->big_state); - g_slice_free (CoglMaterialLayer, layer); + g_slice_free (CoglPipelineLayer, layer); } /* If a layer has descendants we can't modify it freely @@ -4615,36 +4605,36 @@ _cogl_material_layer_free (CoglMaterialLayer *layer) */ void -_cogl_material_init_default_layers (void) +_cogl_pipeline_init_default_layers (void) { - CoglMaterialLayer *layer = g_slice_new0 (CoglMaterialLayer); - CoglMaterialLayerBigState *big_state = - g_slice_new0 (CoglMaterialLayerBigState); - CoglMaterialLayer *new; + CoglPipelineLayer *layer = g_slice_new0 (CoglPipelineLayer); + CoglPipelineLayerBigState *big_state = + g_slice_new0 (CoglPipelineLayerBigState); + CoglPipelineLayer *new; int i; _COGL_GET_CONTEXT (ctx, NO_RETVAL); - _cogl_material_node_init (COGL_MATERIAL_NODE (layer)); + _cogl_pipeline_node_init (COGL_PIPELINE_NODE (layer)); layer->index = 0; - for (i = 0; i < COGL_MATERIAL_N_BACKENDS; i++) + for (i = 0; i < COGL_PIPELINE_N_BACKENDS; i++) layer->backend_priv[i] = NULL; - layer->differences = COGL_MATERIAL_LAYER_STATE_ALL_SPARSE; + layer->differences = COGL_PIPELINE_LAYER_STATE_ALL_SPARSE; layer->unit_index = 0; layer->texture = COGL_INVALID_HANDLE; layer->texture_overridden = FALSE; - layer->mag_filter = COGL_MATERIAL_FILTER_LINEAR; - layer->min_filter = COGL_MATERIAL_FILTER_LINEAR; + layer->mag_filter = COGL_PIPELINE_FILTER_LINEAR; + layer->min_filter = COGL_PIPELINE_FILTER_LINEAR; - layer->wrap_mode_s = COGL_MATERIAL_WRAP_MODE_AUTOMATIC; - layer->wrap_mode_t = COGL_MATERIAL_WRAP_MODE_AUTOMATIC; - layer->wrap_mode_p = COGL_MATERIAL_WRAP_MODE_AUTOMATIC; + layer->wrap_mode_s = COGL_PIPELINE_WRAP_MODE_AUTOMATIC; + layer->wrap_mode_t = COGL_PIPELINE_WRAP_MODE_AUTOMATIC; + layer->wrap_mode_p = COGL_PIPELINE_WRAP_MODE_AUTOMATIC; layer->big_state = big_state; layer->has_big_state = TRUE; @@ -4666,7 +4656,7 @@ _cogl_material_init_default_layers (void) cogl_matrix_init_identity (&big_state->matrix); - ctx->default_layer_0 = _cogl_material_layer_object_new (layer); + ctx->default_layer_0 = _cogl_pipeline_layer_object_new (layer); /* TODO: we should make default_layer_n comprise of two * descendants of default_layer_0: @@ -4686,8 +4676,8 @@ _cogl_material_init_default_layers (void) * optimizations for flattening the ancestry when we make * the second descendant which reverts the state. */ - ctx->default_layer_n = _cogl_material_layer_copy (layer); - new = _cogl_material_set_layer_unit (NULL, ctx->default_layer_n, 1); + ctx->default_layer_n = _cogl_pipeline_layer_copy (layer); + new = _cogl_pipeline_set_layer_unit (NULL, ctx->default_layer_n, 1); g_assert (new == ctx->default_layer_n); /* Since we passed a newly allocated layer we don't expect that * _set_layer_unit() will have to allocate *another* layer. */ @@ -4697,7 +4687,7 @@ _cogl_material_init_default_layers (void) * remain immutable. */ ctx->dummy_layer_dependant = - _cogl_material_layer_copy (ctx->default_layer_n); + _cogl_pipeline_layer_copy (ctx->default_layer_n); } static void @@ -4781,14 +4771,14 @@ setup_texture_combine_state (CoglBlendStringStatement *statement, } gboolean -cogl_material_set_layer_combine (CoglMaterial *material, +cogl_pipeline_set_layer_combine (CoglPipeline *pipeline, int layer_index, const char *combine_description, GError **error) { - CoglMaterialLayerState state = COGL_MATERIAL_LAYER_STATE_COMBINE; - CoglMaterialLayer *authority; - CoglMaterialLayer *layer; + CoglPipelineLayerState state = COGL_PIPELINE_LAYER_STATE_COMBINE; + CoglPipelineLayer *authority; + CoglPipelineLayer *layer; CoglBlendStringStatement statements[2]; CoglBlendStringStatement split[2]; CoglBlendStringStatement *rgb; @@ -4796,19 +4786,19 @@ cogl_material_set_layer_combine (CoglMaterial *material, GError *internal_error = NULL; int count; - g_return_val_if_fail (cogl_is_material (material), FALSE); + g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. * * Note: If the layer already existed it's possibly owned by another - * material. If the layer is created then it will be owned by - * material. */ - layer = _cogl_material_get_layer (material, layer_index); + * pipeline. If the layer is created then it will be owned by + * pipeline. */ + layer = _cogl_pipeline_get_layer (pipeline, layer_index); /* Now find the ancestor of the layer that is the authority for the * state we want to change */ - authority = _cogl_material_layer_get_authority (layer, state); + authority = _cogl_pipeline_layer_get_authority (layer, state); count = _cogl_blend_string_compile (combine_description, @@ -4844,7 +4834,7 @@ cogl_material_set_layer_combine (CoglMaterial *material, /* FIXME: compare the new state with the current state! */ /* possibly flush primitives referencing the current state... */ - layer = _cogl_material_layer_pre_change_notify (material, layer, state); + layer = _cogl_pipeline_layer_pre_change_notify (pipeline, layer, state); setup_texture_combine_state (rgb, &layer->big_state->texture_combine_rgb_func, @@ -4860,20 +4850,20 @@ cogl_material_set_layer_combine (CoglMaterial *material, * the state we are changing see if we can revert to one of our * ancestors being the authority. */ if (layer == authority && - _cogl_material_layer_get_parent (authority) != NULL) + _cogl_pipeline_layer_get_parent (authority) != NULL) { - CoglMaterialLayer *parent = _cogl_material_layer_get_parent (authority); - CoglMaterialLayer *old_authority = - _cogl_material_layer_get_authority (parent, state); + CoglPipelineLayer *parent = _cogl_pipeline_layer_get_parent (authority); + CoglPipelineLayer *old_authority = + _cogl_pipeline_layer_get_authority (parent, state); - if (_cogl_material_layer_combine_state_equal (authority, + if (_cogl_pipeline_layer_combine_state_equal (authority, old_authority)) { layer->differences &= ~state; - g_assert (layer->owner == material); + g_assert (layer->owner == pipeline); if (layer->differences == 0) - _cogl_material_prune_empty_layer_difference (material, + _cogl_pipeline_prune_empty_layer_difference (pipeline, layer); goto changed; } @@ -4886,44 +4876,44 @@ cogl_material_set_layer_combine (CoglMaterial *material, if (layer != authority) { layer->differences |= state; - _cogl_material_layer_prune_redundant_ancestry (layer); + _cogl_pipeline_layer_prune_redundant_ancestry (layer); } changed: - handle_automatic_blend_enable (material, COGL_MATERIAL_STATE_LAYERS); + handle_automatic_blend_enable (pipeline, COGL_PIPELINE_STATE_LAYERS); return TRUE; } void -cogl_material_set_layer_combine_constant (CoglMaterial *material, +cogl_pipeline_set_layer_combine_constant (CoglPipeline *pipeline, int layer_index, const CoglColor *constant_color) { - CoglMaterialLayerState state = COGL_MATERIAL_LAYER_STATE_COMBINE_CONSTANT; - CoglMaterialLayer *layer; - CoglMaterialLayer *authority; - CoglMaterialLayer *new; + CoglPipelineLayerState state = COGL_PIPELINE_LAYER_STATE_COMBINE_CONSTANT; + CoglPipelineLayer *layer; + CoglPipelineLayer *authority; + CoglPipelineLayer *new; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. * * Note: If the layer already existed it's possibly owned by another - * material. If the layer is created then it will be owned by - * material. */ - layer = _cogl_material_get_layer (material, layer_index); + * pipeline. If the layer is created then it will be owned by + * pipeline. */ + layer = _cogl_pipeline_get_layer (pipeline, layer_index); /* Now find the ancestor of the layer that is the authority for the * state we want to change */ - authority = _cogl_material_layer_get_authority (layer, state); + authority = _cogl_pipeline_layer_get_authority (layer, state); if (memcmp (authority->big_state->texture_combine_constant, constant_color, sizeof (float) * 4) == 0) return; - new = _cogl_material_layer_pre_change_notify (material, layer, state); + new = _cogl_pipeline_layer_pre_change_notify (pipeline, layer, state); if (new != layer) layer = new; else @@ -4932,22 +4922,22 @@ cogl_material_set_layer_combine_constant (CoglMaterial *material, * the state we are changing see if we can revert to one of our * ancestors being the authority. */ if (layer == authority && - _cogl_material_layer_get_parent (authority) != NULL) + _cogl_pipeline_layer_get_parent (authority) != NULL) { - CoglMaterialLayer *parent = - _cogl_material_layer_get_parent (authority); - CoglMaterialLayer *old_authority = - _cogl_material_layer_get_authority (parent, state); - CoglMaterialLayerBigState *old_big_state = old_authority->big_state; + CoglPipelineLayer *parent = + _cogl_pipeline_layer_get_parent (authority); + CoglPipelineLayer *old_authority = + _cogl_pipeline_layer_get_authority (parent, state); + CoglPipelineLayerBigState *old_big_state = old_authority->big_state; if (memcmp (old_big_state->texture_combine_constant, constant_color, sizeof (float) * 4) == 0) { layer->differences &= ~state; - g_assert (layer->owner == material); + g_assert (layer->owner == pipeline); if (layer->differences == 0) - _cogl_material_prune_empty_layer_difference (material, + _cogl_pipeline_prune_empty_layer_difference (pipeline, layer); goto changed; } @@ -4970,68 +4960,68 @@ cogl_material_set_layer_combine_constant (CoglMaterial *material, if (layer != authority) { layer->differences |= state; - _cogl_material_layer_prune_redundant_ancestry (layer); + _cogl_pipeline_layer_prune_redundant_ancestry (layer); } changed: - handle_automatic_blend_enable (material, COGL_MATERIAL_STATE_LAYERS); + handle_automatic_blend_enable (pipeline, COGL_PIPELINE_STATE_LAYERS); } void -_cogl_material_get_layer_combine_constant (CoglMaterial *material, +_cogl_pipeline_get_layer_combine_constant (CoglPipeline *pipeline, int layer_index, float *constant) { - CoglMaterialLayerState change = - COGL_MATERIAL_LAYER_STATE_COMBINE_CONSTANT; - CoglMaterialLayer *layer; - CoglMaterialLayer *authority; + CoglPipelineLayerState change = + COGL_PIPELINE_LAYER_STATE_COMBINE_CONSTANT; + CoglPipelineLayer *layer; + CoglPipelineLayer *authority; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. * * Note: If the layer already existed it's possibly owned by another - * material. If the layer is created then it will be owned by - * material. */ - layer = _cogl_material_get_layer (material, layer_index); + * pipeline. If the layer is created then it will be owned by + * pipeline. */ + layer = _cogl_pipeline_get_layer (pipeline, layer_index); /* FIXME: we shouldn't ever construct a layer in a getter function */ - authority = _cogl_material_layer_get_authority (layer, change); + authority = _cogl_pipeline_layer_get_authority (layer, change); memcpy (constant, authority->big_state->texture_combine_constant, sizeof (float) * 4); } void -cogl_material_set_layer_matrix (CoglMaterial *material, +cogl_pipeline_set_layer_matrix (CoglPipeline *pipeline, int layer_index, const CoglMatrix *matrix) { - CoglMaterialLayerState state = COGL_MATERIAL_LAYER_STATE_USER_MATRIX; - CoglMaterialLayer *layer; - CoglMaterialLayer *authority; - CoglMaterialLayer *new; + CoglPipelineLayerState state = COGL_PIPELINE_LAYER_STATE_USER_MATRIX; + CoglPipelineLayer *layer; + CoglPipelineLayer *authority; + CoglPipelineLayer *new; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. * * Note: If the layer already existed it's possibly owned by another - * material. If the layer is created then it will be owned by - * material. */ - layer = _cogl_material_get_layer (material, layer_index); + * pipeline. If the layer is created then it will be owned by + * pipeline. */ + layer = _cogl_pipeline_get_layer (pipeline, layer_index); /* Now find the ancestor of the layer that is the authority for the * state we want to change */ - authority = _cogl_material_layer_get_authority (layer, state); + authority = _cogl_pipeline_layer_get_authority (layer, state); if (cogl_matrix_equal (matrix, &authority->big_state->matrix)) return; - new = _cogl_material_layer_pre_change_notify (material, layer, state); + new = _cogl_pipeline_layer_pre_change_notify (pipeline, layer, state); if (new != layer) layer = new; else @@ -5040,20 +5030,20 @@ cogl_material_set_layer_matrix (CoglMaterial *material, * the state we are changing see if we can revert to one of our * ancestors being the authority. */ if (layer == authority && - _cogl_material_layer_get_parent (authority) != NULL) + _cogl_pipeline_layer_get_parent (authority) != NULL) { - CoglMaterialLayer *parent = - _cogl_material_layer_get_parent (authority); - CoglMaterialLayer *old_authority = - _cogl_material_layer_get_authority (parent, state); + CoglPipelineLayer *parent = + _cogl_pipeline_layer_get_parent (authority); + CoglPipelineLayer *old_authority = + _cogl_pipeline_layer_get_authority (parent, state); if (cogl_matrix_equal (matrix, &old_authority->big_state->matrix)) { layer->differences &= ~state; - g_assert (layer->owner == material); + g_assert (layer->owner == pipeline); if (layer->differences == 0) - _cogl_material_prune_empty_layer_difference (material, + _cogl_pipeline_prune_empty_layer_difference (pipeline, layer); return; } @@ -5069,21 +5059,21 @@ cogl_material_set_layer_matrix (CoglMaterial *material, if (layer != authority) { layer->differences |= state; - _cogl_material_layer_prune_redundant_ancestry (layer); + _cogl_pipeline_layer_prune_redundant_ancestry (layer); } } void -cogl_material_remove_layer (CoglMaterial *material, int layer_index) +cogl_pipeline_remove_layer (CoglPipeline *pipeline, int layer_index) { - CoglMaterial *authority; - CoglMaterialLayerInfo layer_info; + CoglPipeline *authority; + CoglPipelineLayerInfo layer_info; int i; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_LAYERS); + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LAYERS); /* The layer index of the layer we want info about */ layer_info.layer_index = layer_index; @@ -5096,37 +5086,37 @@ cogl_material_remove_layer (CoglMaterial *material, int layer_index) * dropped down to a lower texture unit to fill the gap of the * removed layer. */ layer_info.layers_to_shift = - g_alloca (sizeof (CoglMaterialLayer *) * authority->n_layers); + g_alloca (sizeof (CoglPipelineLayer *) * authority->n_layers); layer_info.n_layers_to_shift = 0; /* Unlike when we query layer info when adding a layer we must * always have a complete layers_to_shift list... */ layer_info.ignore_shift_layers_if_found = FALSE; - _cogl_material_get_layer_info (authority, &layer_info); + _cogl_pipeline_get_layer_info (authority, &layer_info); if (layer_info.layer == NULL) return; for (i = 0; i < layer_info.n_layers_to_shift; i++) { - CoglMaterialLayer *shift_layer = layer_info.layers_to_shift[i]; - int unit_index = _cogl_material_layer_get_unit_index (shift_layer); - _cogl_material_set_layer_unit (material, shift_layer, unit_index - 1); + CoglPipelineLayer *shift_layer = layer_info.layers_to_shift[i]; + int unit_index = _cogl_pipeline_layer_get_unit_index (shift_layer); + _cogl_pipeline_set_layer_unit (pipeline, shift_layer, unit_index - 1); /* NB: shift_layer may not be writeable so _set_layer_unit() * will allocate a derived layer internally which will become - * owned by material. Check the return value if we need to do + * owned by pipeline. Check the return value if we need to do * anything else with this layer. */ } - _cogl_material_remove_layer_difference (material, layer_info.layer, TRUE); - _cogl_material_try_reverting_layers_authority (material, NULL); + _cogl_pipeline_remove_layer_difference (pipeline, layer_info.layer, TRUE); + _cogl_pipeline_try_reverting_layers_authority (pipeline, NULL); - handle_automatic_blend_enable (material, COGL_MATERIAL_STATE_LAYERS); + handle_automatic_blend_enable (pipeline, COGL_PIPELINE_STATE_LAYERS); } static gboolean -prepend_layer_to_list_cb (CoglMaterialLayer *layer, +prepend_layer_to_list_cb (CoglPipelineLayer *layer, void *user_data) { GList **layers = user_data; @@ -5136,157 +5126,149 @@ prepend_layer_to_list_cb (CoglMaterialLayer *layer, } /* TODO: deprecate this API and replace it with - * cogl_material_foreach_layer + * cogl_pipeline_foreach_layer * TODO: update the docs to note that if the user modifies any layers * then the list may become invalid. */ const GList * -cogl_material_get_layers (CoglMaterial *material) +_cogl_pipeline_get_layers (CoglPipeline *pipeline) { - g_return_val_if_fail (cogl_is_material (material), NULL); + g_return_val_if_fail (cogl_is_pipeline (pipeline), NULL); - if (!material->deprecated_get_layers_list_dirty) - g_list_free (material->deprecated_get_layers_list); + if (!pipeline->deprecated_get_layers_list_dirty) + g_list_free (pipeline->deprecated_get_layers_list); - material->deprecated_get_layers_list = NULL; + pipeline->deprecated_get_layers_list = NULL; - _cogl_material_foreach_layer_internal (material, + _cogl_pipeline_foreach_layer_internal (pipeline, prepend_layer_to_list_cb, - &material->deprecated_get_layers_list); - material->deprecated_get_layers_list = - g_list_reverse (material->deprecated_get_layers_list); + &pipeline->deprecated_get_layers_list); + pipeline->deprecated_get_layers_list = + g_list_reverse (pipeline->deprecated_get_layers_list); - material->deprecated_get_layers_list_dirty = 0; + pipeline->deprecated_get_layers_list_dirty = 0; - return material->deprecated_get_layers_list; + return pipeline->deprecated_get_layers_list; } int -cogl_material_get_n_layers (CoglMaterial *material) +cogl_pipeline_get_n_layers (CoglPipeline *pipeline) { - CoglMaterial *authority; + CoglPipeline *authority; - g_return_val_if_fail (cogl_is_material (material), 0); + g_return_val_if_fail (cogl_is_pipeline (pipeline), 0); authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_LAYERS); + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LAYERS); return authority->n_layers; } /* FIXME: deprecate and replace with - * cogl_material_get_layer_type() instead. */ -CoglMaterialLayerType -cogl_material_layer_get_type (CoglMaterialLayer *layer) -{ - return COGL_MATERIAL_LAYER_TYPE_TEXTURE; -} - -/* FIXME: deprecate and replace with - * cogl_material_get_layer_texture() instead. */ + * cogl_pipeline_get_layer_texture() instead. */ CoglHandle -cogl_material_layer_get_texture (CoglMaterialLayer *layer) +_cogl_pipeline_layer_get_texture (CoglPipelineLayer *layer) { - g_return_val_if_fail (_cogl_is_material_layer (layer), + g_return_val_if_fail (_cogl_is_pipeline_layer (layer), COGL_INVALID_HANDLE); - return _cogl_material_layer_get_texture (layer); + return _cogl_pipeline_layer_get_texture_real (layer); } gboolean -_cogl_material_layer_has_user_matrix (CoglMaterialLayer *layer) +_cogl_pipeline_layer_has_user_matrix (CoglPipelineLayer *layer) { - CoglMaterialLayer *authority; + CoglPipelineLayer *authority; - g_return_val_if_fail (_cogl_is_material_layer (layer), FALSE); + g_return_val_if_fail (_cogl_is_pipeline_layer (layer), FALSE); authority = - _cogl_material_layer_get_authority (layer, - COGL_MATERIAL_LAYER_STATE_USER_MATRIX); + _cogl_pipeline_layer_get_authority (layer, + COGL_PIPELINE_LAYER_STATE_USER_MATRIX); - /* If the authority is the default material then no, otherwise yes */ - return _cogl_material_layer_get_parent (authority) ? TRUE : FALSE; + /* If the authority is the default pipeline then no, otherwise yes */ + return _cogl_pipeline_layer_get_parent (authority) ? TRUE : FALSE; } void -_cogl_material_layer_get_filters (CoglMaterialLayer *layer, - CoglMaterialFilter *min_filter, - CoglMaterialFilter *mag_filter) +_cogl_pipeline_layer_get_filters (CoglPipelineLayer *layer, + CoglPipelineFilter *min_filter, + CoglPipelineFilter *mag_filter) { - CoglMaterialLayer *authority = - _cogl_material_layer_get_authority (layer, - COGL_MATERIAL_LAYER_STATE_FILTERS); + CoglPipelineLayer *authority = + _cogl_pipeline_layer_get_authority (layer, + COGL_PIPELINE_LAYER_STATE_FILTERS); *min_filter = authority->min_filter; *mag_filter = authority->mag_filter; } void -_cogl_material_get_layer_filters (CoglMaterial *material, +_cogl_pipeline_get_layer_filters (CoglPipeline *pipeline, int layer_index, - CoglMaterialFilter *min_filter, - CoglMaterialFilter *mag_filter) + CoglPipelineFilter *min_filter, + CoglPipelineFilter *mag_filter) { - CoglMaterialLayer *layer; - CoglMaterialLayer *authority; + CoglPipelineLayer *layer; + CoglPipelineLayer *authority; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); - layer = _cogl_material_get_layer (material, layer_index); + layer = _cogl_pipeline_get_layer (pipeline, layer_index); authority = - _cogl_material_layer_get_authority (layer, - COGL_MATERIAL_LAYER_STATE_FILTERS); + _cogl_pipeline_layer_get_authority (layer, + COGL_PIPELINE_LAYER_STATE_FILTERS); *min_filter = authority->min_filter; *mag_filter = authority->mag_filter; } -CoglMaterialFilter -_cogl_material_get_layer_min_filter (CoglMaterial *material, +CoglPipelineFilter +_cogl_pipeline_get_layer_min_filter (CoglPipeline *pipeline, int layer_index) { - CoglMaterialFilter min_filter; - CoglMaterialFilter mag_filter; + CoglPipelineFilter min_filter; + CoglPipelineFilter mag_filter; - _cogl_material_get_layer_filters (material, layer_index, + _cogl_pipeline_get_layer_filters (pipeline, layer_index, &min_filter, &mag_filter); return min_filter; } -CoglMaterialFilter -_cogl_material_get_layer_mag_filter (CoglMaterial *material, +CoglPipelineFilter +_cogl_pipeline_get_layer_mag_filter (CoglPipeline *pipeline, int layer_index) { - CoglMaterialFilter min_filter; - CoglMaterialFilter mag_filter; + CoglPipelineFilter min_filter; + CoglPipelineFilter mag_filter; - _cogl_material_get_layer_filters (material, layer_index, + _cogl_pipeline_get_layer_filters (pipeline, layer_index, &min_filter, &mag_filter); return mag_filter; } void -_cogl_material_layer_pre_paint (CoglMaterialLayer *layer) +_cogl_pipeline_layer_pre_paint (CoglPipelineLayer *layer) { - CoglMaterialLayer *texture_authority; + CoglPipelineLayer *texture_authority; texture_authority = - _cogl_material_layer_get_authority (layer, - COGL_MATERIAL_LAYER_STATE_TEXTURE); + _cogl_pipeline_layer_get_authority (layer, + COGL_PIPELINE_LAYER_STATE_TEXTURE); if (texture_authority->texture != COGL_INVALID_HANDLE) { CoglTexturePrePaintFlags flags = 0; - CoglMaterialFilter min_filter; - CoglMaterialFilter mag_filter; + CoglPipelineFilter min_filter; + CoglPipelineFilter mag_filter; - _cogl_material_layer_get_filters (layer, &min_filter, &mag_filter); + _cogl_pipeline_layer_get_filters (layer, &min_filter, &mag_filter); - if (min_filter == COGL_MATERIAL_FILTER_NEAREST_MIPMAP_NEAREST - || min_filter == COGL_MATERIAL_FILTER_LINEAR_MIPMAP_NEAREST - || min_filter == COGL_MATERIAL_FILTER_NEAREST_MIPMAP_LINEAR - || min_filter == COGL_MATERIAL_FILTER_LINEAR_MIPMAP_LINEAR) + if (min_filter == COGL_PIPELINE_FILTER_NEAREST_MIPMAP_NEAREST + || min_filter == COGL_PIPELINE_FILTER_LINEAR_MIPMAP_NEAREST + || min_filter == COGL_PIPELINE_FILTER_NEAREST_MIPMAP_LINEAR + || min_filter == COGL_PIPELINE_FILTER_LINEAR_MIPMAP_LINEAR) flags |= COGL_TEXTURE_NEEDS_MIPMAP; _cogl_texture_pre_paint (texture_authority->texture, flags); @@ -5294,71 +5276,71 @@ _cogl_material_layer_pre_paint (CoglMaterialLayer *layer) } void -_cogl_material_pre_paint_for_layer (CoglMaterial *material, +_cogl_pipeline_pre_paint_for_layer (CoglPipeline *pipeline, int layer_id) { - CoglMaterialLayer *layer = _cogl_material_get_layer (material, layer_id); - _cogl_material_layer_pre_paint (layer); + CoglPipelineLayer *layer = _cogl_pipeline_get_layer (pipeline, layer_id); + _cogl_pipeline_layer_pre_paint (layer); } -CoglMaterialFilter -cogl_material_layer_get_min_filter (CoglMaterialLayer *layer) +CoglPipelineFilter +_cogl_pipeline_layer_get_min_filter (CoglPipelineLayer *layer) { - CoglMaterialLayer *authority; + CoglPipelineLayer *authority; - g_return_val_if_fail (_cogl_is_material_layer (layer), 0); + g_return_val_if_fail (_cogl_is_pipeline_layer (layer), 0); authority = - _cogl_material_layer_get_authority (layer, - COGL_MATERIAL_LAYER_STATE_FILTERS); + _cogl_pipeline_layer_get_authority (layer, + COGL_PIPELINE_LAYER_STATE_FILTERS); return authority->min_filter; } -CoglMaterialFilter -cogl_material_layer_get_mag_filter (CoglMaterialLayer *layer) +CoglPipelineFilter +_cogl_pipeline_layer_get_mag_filter (CoglPipelineLayer *layer) { - CoglMaterialLayer *authority; + CoglPipelineLayer *authority; - g_return_val_if_fail (_cogl_is_material_layer (layer), 0); + g_return_val_if_fail (_cogl_is_pipeline_layer (layer), 0); authority = - _cogl_material_layer_get_authority (layer, - COGL_MATERIAL_LAYER_STATE_FILTERS); + _cogl_pipeline_layer_get_authority (layer, + COGL_PIPELINE_LAYER_STATE_FILTERS); return authority->mag_filter; } void -cogl_material_set_layer_filters (CoglMaterial *material, +cogl_pipeline_set_layer_filters (CoglPipeline *pipeline, int layer_index, - CoglMaterialFilter min_filter, - CoglMaterialFilter mag_filter) + CoglPipelineFilter min_filter, + CoglPipelineFilter mag_filter) { - CoglMaterialLayerState state = COGL_MATERIAL_LAYER_STATE_FILTERS; - CoglMaterialLayer *layer; - CoglMaterialLayer *authority; - CoglMaterialLayer *new; + CoglPipelineLayerState state = COGL_PIPELINE_LAYER_STATE_FILTERS; + CoglPipelineLayer *layer; + CoglPipelineLayer *authority; + CoglPipelineLayer *new; - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. * * Note: If the layer already existed it's possibly owned by another - * material. If the layer is created then it will be owned by - * material. */ - layer = _cogl_material_get_layer (material, layer_index); + * pipeline. If the layer is created then it will be owned by + * pipeline. */ + layer = _cogl_pipeline_get_layer (pipeline, layer_index); /* Now find the ancestor of the layer that is the authority for the * state we want to change */ - authority = _cogl_material_layer_get_authority (layer, state); + authority = _cogl_pipeline_layer_get_authority (layer, state); if (authority->min_filter == min_filter && authority->mag_filter == mag_filter) return; - new = _cogl_material_layer_pre_change_notify (material, layer, state); + new = _cogl_pipeline_layer_pre_change_notify (pipeline, layer, state); if (new != layer) layer = new; else @@ -5367,21 +5349,21 @@ cogl_material_set_layer_filters (CoglMaterial *material, * the state we are changing see if we can revert to one of our * ancestors being the authority. */ if (layer == authority && - _cogl_material_layer_get_parent (authority) != NULL) + _cogl_pipeline_layer_get_parent (authority) != NULL) { - CoglMaterialLayer *parent = - _cogl_material_layer_get_parent (authority); - CoglMaterialLayer *old_authority = - _cogl_material_layer_get_authority (parent, state); + CoglPipelineLayer *parent = + _cogl_pipeline_layer_get_parent (authority); + CoglPipelineLayer *old_authority = + _cogl_pipeline_layer_get_authority (parent, state); if (old_authority->min_filter == min_filter && old_authority->mag_filter == mag_filter) { layer->differences &= ~state; - g_assert (layer->owner == material); + g_assert (layer->owner == pipeline); if (layer->differences == 0) - _cogl_material_prune_empty_layer_difference (material, + _cogl_pipeline_prune_empty_layer_difference (pipeline, layer); return; } @@ -5398,71 +5380,71 @@ cogl_material_set_layer_filters (CoglMaterial *material, if (layer != authority) { layer->differences |= state; - _cogl_material_layer_prune_redundant_ancestry (layer); + _cogl_pipeline_layer_prune_redundant_ancestry (layer); } } float -cogl_material_get_point_size (CoglHandle handle) +cogl_pipeline_get_point_size (CoglHandle handle) { - CoglMaterial *material = COGL_MATERIAL (handle); - CoglMaterial *authority; + CoglPipeline *pipeline = COGL_PIPELINE (handle); + CoglPipeline *authority; - g_return_val_if_fail (cogl_is_material (handle), FALSE); + g_return_val_if_fail (cogl_is_pipeline (handle), FALSE); authority = - _cogl_material_get_authority (material, COGL_MATERIAL_STATE_POINT_SIZE); + _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_POINT_SIZE); return authority->big_state->point_size; } void -cogl_material_set_point_size (CoglHandle handle, +cogl_pipeline_set_point_size (CoglHandle handle, float point_size) { - CoglMaterial *material = COGL_MATERIAL (handle); - CoglMaterialState state = COGL_MATERIAL_STATE_POINT_SIZE; - CoglMaterial *authority; + CoglPipeline *pipeline = COGL_PIPELINE (handle); + CoglPipelineState state = COGL_PIPELINE_STATE_POINT_SIZE; + CoglPipeline *authority; - g_return_if_fail (cogl_is_material (handle)); + g_return_if_fail (cogl_is_pipeline (handle)); - authority = _cogl_material_get_authority (material, state); + authority = _cogl_pipeline_get_authority (pipeline, state); if (authority->big_state->point_size == point_size) return; /* - Flush journal primitives referencing the current state. - * - Make sure the material has no dependants so it may be modified. - * - If the material isn't currently an authority for the state being + * - Make sure the pipeline has no dependants so it may be modified. + * - If the pipeline isn't currently an authority for the state being * changed, then initialize that state from the current authority. */ - _cogl_material_pre_change_notify (material, state, NULL, FALSE); + _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); - material->big_state->point_size = point_size; + pipeline->big_state->point_size = point_size; - _cogl_material_update_authority (material, authority, state, - _cogl_material_point_size_equal); + _cogl_pipeline_update_authority (pipeline, authority, state, + _cogl_pipeline_point_size_equal); } -/* While a material is referenced by the Cogl journal we can not allow +/* While a pipeline is referenced by the Cogl journal we can not allow * modifications, so this gives us a mechanism to track journal * references separately */ -CoglMaterial * -_cogl_material_journal_ref (CoglMaterial *material) +CoglPipeline * +_cogl_pipeline_journal_ref (CoglPipeline *pipeline) { - material->journal_ref_count++; - return cogl_object_ref (material); + pipeline->journal_ref_count++; + return cogl_object_ref (pipeline); } void -_cogl_material_journal_unref (CoglMaterial *material) +_cogl_pipeline_journal_unref (CoglPipeline *pipeline) { - material->journal_ref_count--; - cogl_object_unref (material); + pipeline->journal_ref_count--; + cogl_object_unref (pipeline); } void -_cogl_material_apply_legacy_state (CoglMaterial *material) +_cogl_pipeline_apply_legacy_state (CoglPipeline *pipeline) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -5470,28 +5452,28 @@ _cogl_material_apply_legacy_state (CoglMaterial *material) * associating these things directly with the context when we * originally wrote Cogl. Until the corresponding deprecated APIs * can be removed though we now shoehorn the state changes through - * the cogl_material API instead. + * the cogl_pipeline API instead. */ - /* A program explicitly set on the material has higher precedence than + /* A program explicitly set on the pipeline has higher precedence than * one associated with the context using cogl_program_use() */ if (ctx->current_program && - cogl_material_get_user_program (material) == COGL_INVALID_HANDLE) - cogl_material_set_user_program (material, ctx->current_program); + cogl_pipeline_get_user_program (pipeline) == COGL_INVALID_HANDLE) + cogl_pipeline_set_user_program (pipeline, ctx->current_program); if (ctx->legacy_depth_test_enabled) - cogl_material_set_depth_test_enabled (material, TRUE); + cogl_pipeline_set_depth_test_enabled (pipeline, TRUE); if (ctx->legacy_fog_state.enabled) - _cogl_material_set_fog_state (material, &ctx->legacy_fog_state); + _cogl_pipeline_set_fog_state (pipeline, &ctx->legacy_fog_state); } void -_cogl_material_set_static_breadcrumb (CoglMaterial *material, +_cogl_pipeline_set_static_breadcrumb (CoglPipeline *pipeline, const char *breadcrumb) { - material->has_static_breadcrumb = TRUE; - material->static_breadcrumb = breadcrumb; + pipeline->has_static_breadcrumb = TRUE; + pipeline->static_breadcrumb = breadcrumb; } typedef struct @@ -5503,9 +5485,9 @@ typedef struct } PrintDebugState; static gboolean -dump_layer_cb (CoglMaterialNode *node, void *user_data) +dump_layer_cb (CoglPipelineNode *node, void *user_data) { - CoglMaterialLayer *layer = COGL_MATERIAL_LAYER (node); + CoglPipelineLayer *layer = COGL_PIPELINE_LAYER (node); PrintDebugState *state = user_data; int layer_id = *state->node_id_ptr; PrintDebugState state_out; @@ -5537,7 +5519,7 @@ dump_layer_cb (CoglMaterialNode *node, void *user_data) state->indent, "", layer_id); - if (layer->differences & COGL_MATERIAL_LAYER_STATE_UNIT) + if (layer->differences & COGL_PIPELINE_LAYER_STATE_UNIT) { changes = TRUE; g_string_append_printf (changes_label, @@ -5545,7 +5527,7 @@ dump_layer_cb (CoglMaterialNode *node, void *user_data) layer->unit_index); } - if (layer->differences & COGL_MATERIAL_LAYER_STATE_TEXTURE) + if (layer->differences & COGL_PIPELINE_LAYER_STATE_TEXTURE) { changes = TRUE; g_string_append_printf (changes_label, @@ -5568,7 +5550,7 @@ dump_layer_cb (CoglMaterialNode *node, void *user_data) state_out.graph = state->graph; state_out.indent = state->indent + 2; - _cogl_material_node_foreach_child (COGL_MATERIAL_NODE (layer), + _cogl_pipeline_node_foreach_child (COGL_PIPELINE_NODE (layer), dump_layer_cb, &state_out); @@ -5576,85 +5558,85 @@ dump_layer_cb (CoglMaterialNode *node, void *user_data) } static gboolean -dump_layer_ref_cb (CoglMaterialLayer *layer, void *data) +dump_layer_ref_cb (CoglPipelineLayer *layer, void *data) { PrintDebugState *state = data; - int material_id = *state->node_id_ptr; + int pipeline_id = *state->node_id_ptr; g_string_append_printf (state->graph, - "%*smaterial_state%d -> layer%p;\n", + "%*spipeline_state%d -> layer%p;\n", state->indent, "", - material_id, + pipeline_id, layer); return TRUE; } static gboolean -dump_material_cb (CoglMaterialNode *node, void *user_data) +dump_pipeline_cb (CoglPipelineNode *node, void *user_data) { - CoglMaterial *material = COGL_MATERIAL (node); + CoglPipeline *pipeline = COGL_PIPELINE (node); PrintDebugState *state = user_data; - int material_id = *state->node_id_ptr; + int pipeline_id = *state->node_id_ptr; PrintDebugState state_out; GString *changes_label; gboolean changes = FALSE; gboolean layers = FALSE; if (state->parent_id >= 0) - g_string_append_printf (state->graph, "%*smaterial%d -> material%d;\n", + g_string_append_printf (state->graph, "%*spipeline%d -> pipeline%d;\n", state->indent, "", state->parent_id, - material_id); + pipeline_id); g_string_append_printf (state->graph, - "%*smaterial%d [label=\"material=0x%p\\n" + "%*spipeline%d [label=\"pipeline=0x%p\\n" "ref count=%d\\n" "breadcrumb=\\\"%s\\\"\" color=\"red\"];\n", state->indent, "", - material_id, - material, - COGL_OBJECT (material)->ref_count, - material->has_static_breadcrumb ? - material->static_breadcrumb : "NULL"); + pipeline_id, + pipeline, + COGL_OBJECT (pipeline)->ref_count, + pipeline->has_static_breadcrumb ? + pipeline->static_breadcrumb : "NULL"); changes_label = g_string_new (""); g_string_append_printf (changes_label, - "%*smaterial%d -> material_state%d [weight=100];\n" - "%*smaterial_state%d [shape=box label=\"", + "%*spipeline%d -> pipeline_state%d [weight=100];\n" + "%*spipeline_state%d [shape=box label=\"", state->indent, "", - material_id, - material_id, + pipeline_id, + pipeline_id, state->indent, "", - material_id); + pipeline_id); - if (material->differences & COGL_MATERIAL_STATE_COLOR) + if (pipeline->differences & COGL_PIPELINE_STATE_COLOR) { changes = TRUE; g_string_append_printf (changes_label, "\\lcolor=0x%02X%02X%02X%02X\\n", - cogl_color_get_red_byte (&material->color), - cogl_color_get_green_byte (&material->color), - cogl_color_get_blue_byte (&material->color), - cogl_color_get_alpha_byte (&material->color)); + cogl_color_get_red_byte (&pipeline->color), + cogl_color_get_green_byte (&pipeline->color), + cogl_color_get_blue_byte (&pipeline->color), + cogl_color_get_alpha_byte (&pipeline->color)); } - if (material->differences & COGL_MATERIAL_STATE_BLEND) + if (pipeline->differences & COGL_PIPELINE_STATE_BLEND) { const char *blend_enable_name; changes = TRUE; - switch (material->blend_enable) + switch (pipeline->blend_enable) { - case COGL_MATERIAL_BLEND_ENABLE_AUTOMATIC: + case COGL_PIPELINE_BLEND_ENABLE_AUTOMATIC: blend_enable_name = "AUTO"; break; - case COGL_MATERIAL_BLEND_ENABLE_ENABLED: + case COGL_PIPELINE_BLEND_ENABLE_ENABLED: blend_enable_name = "ENABLED"; break; - case COGL_MATERIAL_BLEND_ENABLE_DISABLED: + case COGL_PIPELINE_BLEND_ENABLE_DISABLED: blend_enable_name = "DISABLED"; break; default: @@ -5665,12 +5647,12 @@ dump_material_cb (CoglMaterialNode *node, void *user_data) blend_enable_name); } - if (material->differences & COGL_MATERIAL_STATE_LAYERS) + if (pipeline->differences & COGL_PIPELINE_STATE_LAYERS) { changes = TRUE; layers = TRUE; g_string_append_printf (changes_label, "\\ln_layers=%d\\n", - material->n_layers); + pipeline->n_layers); } if (changes) @@ -5682,12 +5664,12 @@ dump_material_cb (CoglMaterialNode *node, void *user_data) if (layers) { - g_list_foreach (material->layer_differences, + g_list_foreach (pipeline->layer_differences, (GFunc)dump_layer_ref_cb, state); } - state_out.parent_id = material_id; + state_out.parent_id = pipeline_id; state_out.node_id_ptr = state->node_id_ptr; (*state_out.node_id_ptr)++; @@ -5695,25 +5677,25 @@ dump_material_cb (CoglMaterialNode *node, void *user_data) state_out.graph = state->graph; state_out.indent = state->indent + 2; - _cogl_material_node_foreach_child (COGL_MATERIAL_NODE (material), - dump_material_cb, + _cogl_pipeline_node_foreach_child (COGL_PIPELINE_NODE (pipeline), + dump_pipeline_cb, &state_out); return TRUE; } void -_cogl_debug_dump_materials_dot_file (const char *filename) +_cogl_debug_dump_pipelines_dot_file (const char *filename) { GString *graph; PrintDebugState layer_state; - PrintDebugState material_state; + PrintDebugState pipeline_state; int layer_id = 0; - int material_id = 0; + int pipeline_id = 0; _COGL_GET_CONTEXT (ctx, NO_RETVAL); - if (!ctx->default_material) + if (!ctx->default_pipeline) return; graph = g_string_new (""); @@ -5725,11 +5707,11 @@ _cogl_debug_dump_materials_dot_file (const char *filename) layer_state.indent = 0; dump_layer_cb (ctx->default_layer_0, &layer_state); - material_state.graph = graph; - material_state.parent_id = -1; - material_state.node_id_ptr = &material_id; - material_state.indent = 0; - dump_material_cb (ctx->default_material, &material_state); + pipeline_state.graph = graph; + pipeline_state.parent_id = -1; + pipeline_state.node_id_ptr = &pipeline_id; + pipeline_state.indent = 0; + dump_pipeline_cb (ctx->default_pipeline, &pipeline_state); g_string_append_printf (graph, "}\n"); diff --git a/clutter/cogl/cogl/cogl-pipeline.h b/clutter/cogl/cogl/cogl-pipeline.h new file mode 100644 index 000000000..57ce83ec0 --- /dev/null +++ b/clutter/cogl/cogl/cogl-pipeline.h @@ -0,0 +1,1234 @@ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2007,2008,2009 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * + */ + +#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __COGL_PIPELINE_H__ +#define __COGL_PIPELINE_H__ + +G_BEGIN_DECLS + +#include +#include + +/** + * SECTION:cogl-pipeline + * @short_description: Functions for creating and manipulating the GPU + * pipeline + * + * Cogl allows creating and manipulating objects representing the full + * configuration of the GPU pipeline. In simplified terms the GPU + * pipeline takes primitive geometry as the input, it first performs + * vertex processing, allowing you to deform your geometry, then + * rasterizes that (turning it from pure geometry into fragments) then + * 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) + +/** + * CoglPipelineFilter: + * @COGL_PIPELINE_FILTER_NEAREST: Measuring in manhatten distance from the, + * current pixel center, use the nearest texture texel + * @COGL_PIPELINE_FILTER_LINEAR: Use the weighted average of the 4 texels + * nearest the current pixel center + * @COGL_PIPELINE_FILTER_NEAREST_MIPMAP_NEAREST: Select the mimap level whose + * texel size most closely matches the current pixel, and use the + * %COGL_PIPELINE_FILTER_NEAREST criterion + * @COGL_PIPELINE_FILTER_LINEAR_MIPMAP_NEAREST: Select the mimap level whose + * texel size most closely matches the current pixel, and use the + * %COGL_PIPELINE_FILTER_LINEAR criterion + * @COGL_PIPELINE_FILTER_NEAREST_MIPMAP_LINEAR: Select the two mimap levels + * whose texel size most closely matches the current pixel, use + * the %COGL_PIPELINE_FILTER_NEAREST criterion on each one and take + * their weighted average + * @COGL_PIPELINE_FILTER_LINEAR_MIPMAP_LINEAR: Select the two mimap levels + * whose texel size most closely matches the current pixel, use + * the %COGL_PIPELINE_FILTER_LINEAR criterion on each one and take + * their weighted average + * + * Texture filtering is used whenever the current pixel maps either to more + * than one texture element (texel) or less than one. These filter enums + * correspond to different strategies used to come up with a pixel color, by + * possibly referring to multiple neighbouring texels and taking a weighted + * average or simply using the nearest texel. + */ +typedef enum { + COGL_PIPELINE_FILTER_NEAREST = 0x2600, + COGL_PIPELINE_FILTER_LINEAR = 0x2601, + COGL_PIPELINE_FILTER_NEAREST_MIPMAP_NEAREST = 0x2700, + COGL_PIPELINE_FILTER_LINEAR_MIPMAP_NEAREST = 0x2701, + COGL_PIPELINE_FILTER_NEAREST_MIPMAP_LINEAR = 0x2702, + COGL_PIPELINE_FILTER_LINEAR_MIPMAP_LINEAR = 0x2703 +} CoglPipelineFilter; +/* NB: these values come from the equivalents in gl.h */ + +/** + * CoglPipelineWrapMode: + * @COGL_PIPELINE_WRAP_MODE_REPEAT: The texture will be repeated. This + * is useful for example to draw a tiled background. + * @COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE: The coordinates outside the + * range 0→1 will sample copies of the edge pixels of the + * texture. This is useful to avoid artifacts if only one copy of + * the texture is being rendered. + * @COGL_PIPELINE_WRAP_MODE_AUTOMATIC: Cogl will try to automatically + * decide which of the above two to use. For cogl_rectangle(), it + * will use repeat mode if any of the texture coordinates are + * outside the range 0→1, otherwise it will use clamp to edge. For + * cogl_polygon() it will always use repeat mode. For + * cogl_vertex_buffer_draw() it will use repeat mode except for + * layers that have point sprite coordinate generation enabled. This + * is the default value. + * + * The wrap mode specifies what happens when texture coordinates + * outside the range 0→1 are used. Note that if the filter mode is + * anything but %COGL_PIPELINE_FILTER_NEAREST then texels outside the + * range 0→1 might be used even when the coordinate is exactly 0 or 1 + * because OpenGL will try to sample neighbouring pixels. For example + * if you are trying to render the full texture then you may get + * artifacts around the edges when the pixels from the other side are + * merged in if the wrap mode is set to repeat. + * + * Since: 2.0 + */ +/* GL_ALWAYS is just used here as a value that is known not to clash + * with any valid GL wrap modes + * + * XXX: keep the values in sync with the CoglPipelineWrapModeInternal + * enum so no conversion is actually needed. + */ +typedef enum { + COGL_PIPELINE_WRAP_MODE_REPEAT = 0x2901, + COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE = 0x812F, + COGL_PIPELINE_WRAP_MODE_AUTOMATIC = 0x0207 +} CoglPipelineWrapMode; +/* NB: these values come from the equivalents in gl.h */ + +/** + * cogl_pipeline_new: + * + * Allocates and initializes a default simple pipeline that will color + * a primitive white. + * + * Return value: a pointer to a new #CoglPipeline + */ +CoglPipeline * +cogl_pipeline_new (void); + +/** + * cogl_pipeline_copy: + * @source: a #CoglPipeline object to copy + * + * Creates a new pipeline with the configuration copied from the + * source pipeline. + * + * We would strongly advise developers to always aim to use + * cogl_pipeline_copy() instead of cogl_pipeline_new() whenever there will + * be any similarity between two pipelines. Copying a pipeline helps Cogl + * keep track of a pipelines ancestry which we may use to help minimize GPU + * state changes. + * + * Returns: a pointer to the newly allocated #CoglPipeline + * + * Since: 2.0 + */ +CoglPipeline * +cogl_pipeline_copy (CoglPipeline *source); + +/** + * cogl_is_pipeline: + * @handle: A CoglHandle + * + * Gets whether the given handle references an existing pipeline object. + * + * Return value: %TRUE if the handle references a #CoglPipeline, + * %FALSE otherwise + */ +gboolean +cogl_is_pipeline (CoglHandle handle); + +/** + * cogl_pipeline_set_color: + * @pipeline: A #CoglPipeline object + * @color: The components of the color + * + * Sets the basic color of the pipeline, used when no lighting is enabled. + * + * Note that if you don't add any layers to the pipeline then the color + * will be blended unmodified with the destination; the default blend + * expects premultiplied colors: for example, use (0.5, 0.0, 0.0, 0.5) for + * semi-transparent red. See cogl_color_premultiply(). + * + * The default value is (1.0, 1.0, 1.0, 1.0) + * + * Since: 2.0 + */ +void +cogl_pipeline_set_color (CoglPipeline *pipeline, + const CoglColor *color); + +/** + * cogl_pipeline_set_color4ub: + * @pipeline: A #CoglPipeline object + * @red: The red component + * @green: The green component + * @blue: The blue component + * @alpha: The alpha component + * + * Sets the basic color of the pipeline, used when no lighting is enabled. + * + * The default value is (0xff, 0xff, 0xff, 0xff) + * + * Since: 2.0 + */ +void +cogl_pipeline_set_color4ub (CoglPipeline *pipeline, + guint8 red, + guint8 green, + guint8 blue, + guint8 alpha); + +/** + * cogl_pipeline_set_color4f: + * @pipeline: A #CoglPipeline object + * @red: The red component + * @green: The green component + * @blue: The blue component + * @alpha: The alpha component + * + * Sets the basic color of the pipeline, used when no lighting is enabled. + * + * The default value is (1.0, 1.0, 1.0, 1.0) + * + * Since: 2.0 + */ +void +cogl_pipeline_set_color4f (CoglPipeline *pipeline, + float red, + float green, + float blue, + float alpha); + +/** + * cogl_pipeline_get_color: + * @pipeline: A #CoglPipeline object + * @color: (out): The location to store the color + * + * Retrieves the current pipeline color. + * + * Since: 2.0 + */ +void +cogl_pipeline_get_color (CoglPipeline *pipeline, + CoglColor *color); + +/** + * cogl_pipeline_set_ambient: + * @pipeline: A #CoglPipeline object + * @ambient: The components of the desired ambient color + * + * Sets the pipeline's ambient color, in the standard OpenGL lighting + * model. The ambient color affects the overall color of the object. + * + * Since the diffuse color will be intense when the light hits the surface + * directly, the ambient will be most apparent where the light hits at a + * slant. + * + * The default value is (0.2, 0.2, 0.2, 1.0) + * + * Since: 2.0 + */ +void +cogl_pipeline_set_ambient (CoglPipeline *pipeline, + const CoglColor *ambient); + +/** + * cogl_pipeline_get_ambient: + * @pipeline: A #CoglPipeline object + * @ambient: The location to store the ambient color + * + * Retrieves the current ambient color for @pipeline + * + * Since: 2.0 + */ +void +cogl_pipeline_get_ambient (CoglPipeline *pipeline, + CoglColor *ambient); + +/** + * cogl_pipeline_set_diffuse: + * @pipeline: A #CoglPipeline object + * @diffuse: The components of the desired diffuse color + * + * Sets the pipeline's diffuse color, in the standard OpenGL lighting + * model. The diffuse color is most intense where the light hits the + * surface directly - perpendicular to the surface. + * + * The default value is (0.8, 0.8, 0.8, 1.0) + * + * Since: 2.0 + */ +void +cogl_pipeline_set_diffuse (CoglPipeline *pipeline, + const CoglColor *diffuse); + +/** + * cogl_pipeline_get_diffuse: + * @pipeline: A #CoglPipeline object + * @diffuse: The location to store the diffuse color + * + * Retrieves the current diffuse color for @pipeline + * + * Since: 2.0 + */ +void +cogl_pipeline_get_diffuse (CoglPipeline *pipeline, + CoglColor *diffuse); + +/** + * cogl_pipeline_set_ambient_and_diffuse: + * @pipeline: A #CoglPipeline object + * @color: The components of the desired ambient and diffuse colors + * + * Conveniently sets the diffuse and ambient color of @pipeline at the same + * time. See cogl_pipeline_set_ambient() and cogl_pipeline_set_diffuse(). + * + * The default ambient color is (0.2, 0.2, 0.2, 1.0) + * + * The default diffuse color is (0.8, 0.8, 0.8, 1.0) + * + * Since: 2.0 + */ +void +cogl_pipeline_set_ambient_and_diffuse (CoglPipeline *pipeline, + const CoglColor *color); + +/** + * cogl_pipeline_set_specular: + * @pipeline: A #CoglPipeline object + * @specular: The components of the desired specular color + * + * Sets the pipeline's specular color, in the standard OpenGL lighting + * model. The intensity of the specular color depends on the viewport + * position, and is brightest along the lines of reflection. + * + * The default value is (0.0, 0.0, 0.0, 1.0) + * + * Since: 2.0 + */ +void +cogl_pipeline_set_specular (CoglPipeline *pipeline, + const CoglColor *specular); + +/** + * cogl_pipeline_get_specular: + * @pipeline: A #CoglPipeline object + * @specular: The location to store the specular color + * + * Retrieves the pipelines current specular color. + * + * Since: 2.0 + */ +void +cogl_pipeline_get_specular (CoglPipeline *pipeline, + CoglColor *specular); + +/** + * cogl_pipeline_set_shininess: + * @pipeline: A #CoglPipeline object + * @shininess: The desired shininess; must be >= 0.0 + * + * Sets the shininess of the pipeline, in the standard OpenGL lighting + * model, which determines the size of the specular highlights. A + * higher @shininess will produce smaller highlights which makes the + * object appear more shiny. + * + * The default value is 0.0 + * + * Since: 2.0 + */ +void +cogl_pipeline_set_shininess (CoglPipeline *pipeline, + float shininess); + +/** + * cogl_pipeline_get_shininess: + * @pipeline: A #CoglPipeline object + * + * Retrieves the pipelines current emission color. + * + * Return value: The pipelines current shininess value + * + * Since: 2.0 + */ +float +cogl_pipeline_get_shininess (CoglPipeline *pipeline); + +/** + * cogl_pipeline_set_emission: + * @pipeline: A #CoglPipeline object + * @emission: The components of the desired emissive color + * + * Sets the pipeline's emissive color, in the standard OpenGL lighting + * model. It will look like the surface is a light source emitting this + * color. + * + * The default value is (0.0, 0.0, 0.0, 1.0) + * + * Since: 2.0 + */ +void +cogl_pipeline_set_emission (CoglPipeline *pipeline, + const CoglColor *emission); + +/** + * cogl_pipeline_get_emission: + * @pipeline: A #CoglPipeline object + * @emission: The location to store the emission color + * + * Retrieves the pipelines current emission color. + * + * Since: 2.0 + */ +void +cogl_pipeline_get_emission (CoglPipeline *pipeline, + CoglColor *emission); + +/** + * CoglPipelineAlphaFunc: + * @COGL_PIPELINE_ALPHA_FUNC_NEVER: Never let the fragment through. + * @COGL_PIPELINE_ALPHA_FUNC_LESS: Let the fragment through if the incoming + * alpha value is less than the reference alpha value + * @COGL_PIPELINE_ALPHA_FUNC_EQUAL: Let the fragment through if the incoming + * alpha value equals the reference alpha value + * @COGL_PIPELINE_ALPHA_FUNC_LEQUAL: Let the fragment through if the incoming + * alpha value is less than or equal to the reference alpha value + * @COGL_PIPELINE_ALPHA_FUNC_GREATER: Let the fragment through if the incoming + * alpha value is greater than the reference alpha value + * @COGL_PIPELINE_ALPHA_FUNC_NOTEQUAL: Let the fragment through if the incoming + * alpha value does not equal the reference alpha value + * @COGL_PIPELINE_ALPHA_FUNC_GEQUAL: Let the fragment through if the incoming + * alpha value is greater than or equal to the reference alpha value. + * @COGL_PIPELINE_ALPHA_FUNC_ALWAYS: Always let the fragment through. + * + * Alpha testing happens before blending primitives with the framebuffer and + * gives an opportunity to discard fragments based on a comparison with the + * incoming alpha value and a reference alpha value. The #CoglPipelineAlphaFunc + * determines how the comparison is done. + */ +typedef enum { + COGL_PIPELINE_ALPHA_FUNC_NEVER = 0x0200, + COGL_PIPELINE_ALPHA_FUNC_LESS = 0x0201, + COGL_PIPELINE_ALPHA_FUNC_EQUAL = 0x0202, + COGL_PIPELINE_ALPHA_FUNC_LEQUAL = 0x0203, + COGL_PIPELINE_ALPHA_FUNC_GREATER = 0x0204, + COGL_PIPELINE_ALPHA_FUNC_NOTEQUAL = 0x0205, + COGL_PIPELINE_ALPHA_FUNC_GEQUAL = 0x0206, + COGL_PIPELINE_ALPHA_FUNC_ALWAYS = 0x0207 +} CoglPipelineAlphaFunc; +/* NB: these values come from the equivalents in gl.h */ + +/** + * cogl_pipeline_set_alpha_test_function: + * @pipeline: A #CoglPipeline object + * @alpha_func: A @CoglPipelineAlphaFunc constant + * @alpha_reference: A reference point that the chosen alpha function uses + * to compare incoming fragments to. + * + * Before a primitive is blended with the framebuffer, it goes through an + * alpha test stage which lets you discard fragments based on the current + * alpha value. This function lets you change the function used to evaluate + * the alpha channel, and thus determine which fragments are discarded + * and which continue on to the blending stage. + * + * The default is %COGL_PIPELINE_ALPHA_FUNC_ALWAYS + * + * Since: 2.0 + */ +void +cogl_pipeline_set_alpha_test_function (CoglPipeline *pipeline, + CoglPipelineAlphaFunc alpha_func, + float alpha_reference); + +/** + * cogl_pipeline_set_blend: + * @pipeline: A #CoglPipeline object + * @blend_string: A Cogl blend string + * describing the desired blend function. + * @error: return location for a #GError that may report lack of driver + * support if you give separate blend string statements for the alpha + * channel and RGB channels since some drivers, or backends such as + * GLES 1.1, don't support this feature. May be %NULL, in which case a + * warning will be printed out using GLib's logging facilities if an + * error is encountered. + * + * If not already familiar; please refer here + * for an overview of what blend strings are, and their syntax. + * + * Blending occurs after the alpha test function, and combines fragments with + * the framebuffer. + + * Currently the only blend function Cogl exposes is ADD(). So any valid + * blend statements will be of the form: + * + * |[ + * <channel-mask>=ADD(SRC_COLOR*(<factor>), DST_COLOR*(<factor>)) + * ]| + * + * The brackets around blend factors are currently not + * optional! + * + * This is the list of source-names usable as blend factors: + * + * SRC_COLOR: The color of the in comming fragment + * DST_COLOR: The color of the framebuffer + * CONSTANT: The constant set via cogl_pipeline_set_blend_constant() + * + * + * The source names can be used according to the + * color-source and factor syntax, + * so for example "(1-SRC_COLOR[A])" would be a valid factor, as would + * "(CONSTANT[RGB])" + * + * These can also be used as factors: + * + * 0: (0, 0, 0, 0) + * 1: (1, 1, 1, 1) + * SRC_ALPHA_SATURATE_FACTOR: (f,f,f,1) where f = MIN(SRC_COLOR[A],1-DST_COLOR[A]) + * + * + * Remember; all color components are normalized to the range [0, 1] + * before computing the result of blending. + * + * + * Blend Strings/1 + * Blend a non-premultiplied source over a destination with + * premultiplied alpha: + * + * "RGB = ADD(SRC_COLOR*(SRC_COLOR[A]), DST_COLOR*(1-SRC_COLOR[A]))" + * "A = ADD(SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))" + * + * + * + * + * Blend Strings/2 + * Blend a premultiplied source over a destination with + * premultiplied alpha + * + * "RGBA = ADD(SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))" + * + * + * + * The default blend string is: + * |[ + * RGBA = ADD (SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A])) + * ]| + * + * That gives normal alpha-blending when the calculated color for the pipeline + * is in premultiplied form. + * + * Return value: %TRUE if the blend string was successfully parsed, and the + * described blending is supported by the underlying driver/hardware. If + * there was an error, %FALSE is returned and @error is set accordingly (if + * present). + * + * Since: 2.0 + */ +gboolean +cogl_pipeline_set_blend (CoglPipeline *pipeline, + const char *blend_string, + GError **error); + +/** + * cogl_pipeline_set_blend_constant: + * @pipeline: A #CoglPipeline object + * @constant_color: The constant color you want + * + * When blending is setup to reference a CONSTANT blend factor then + * blending will depend on the constant set with this function. + * + * Since: 2.0 + */ +void +cogl_pipeline_set_blend_constant (CoglPipeline *pipeline, + const CoglColor *constant_color); + +/** + * cogl_pipeline_set_point_size: + * @pipeline: a #CoglHandle to a pipeline. + * @size: the new point size. + * + * Changes the size of points drawn when %COGL_VERTICES_MODE_POINTS is + * used with the vertex buffer API. Note that typically the GPU will + * only support a limited minimum and maximum range of point sizes. If + * the chosen point size is outside that range then the nearest value + * within that range will be used instead. The size of a point is in + * screen space so it will be the same regardless of any + * transformations. The default point size is 1.0. + * + * Since: 2.0 + */ +void +cogl_pipeline_set_point_size (CoglHandle pipeline, + float point_size); + +/** + * cogl_pipeline_get_point_size: + * @pipeline: a #CoglHandle to a pipeline. + * + * Get the size of points drawn when %COGL_VERTICES_MODE_POINTS is + * used with the vertex buffer API. + * + * Return value: the point size of the pipeline. + * + * Since: 2.0 + */ +float +cogl_pipeline_get_point_size (CoglHandle pipeline); + +/** + * cogl_pipeline_get_user_program: + * @pipeline: a #CoglPipeline object. + * + * Queries what user program has been associated with the given + * @pipeline using cogl_pipeline_set_user_program(). + * + * Return value: The current user program or %COGL_INVALID_HANDLE. + * + * Since: 2.0 + */ +CoglHandle +cogl_pipeline_get_user_program (CoglPipeline *pipeline); + +/** + * cogl_pipeline_set_user_program: + * @pipeline: a #CoglPipeline object. + * @program: A #CoglHandle to a linked CoglProgram + * + * Associates a linked CoglProgram with the given pipeline so that the + * program can take full control of vertex and/or fragment processing. + * + * This is an example of how it can be used to associate an ARBfp + * program with a #CoglPipeline: + * |[ + * CoglHandle shader; + * CoglHandle program; + * CoglPipeline *pipeline; + * + * shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT); + * cogl_shader_source (shader, + * "!!ARBfp1.0\n" + * "MOV result.color,fragment.color;\n" + * "END\n"); + * cogl_shader_compile (shader); + * + * program = cogl_create_program (); + * cogl_program_attach_shader (program, shader); + * cogl_program_link (program); + * + * pipeline = cogl_pipeline_new (); + * cogl_pipeline_set_user_program (pipeline, program); + * + * cogl_set_source_color4ub (0xff, 0x00, 0x00, 0xff); + * cogl_rectangle (0, 0, 100, 100); + * ]| + * + * It is possibly worth keeping in mind that this API is not part of + * the long term design for how we want to expose shaders to Cogl + * developers (We are planning on deprecating the cogl_program and + * cogl_shader APIs in favour of a "snippet" framework) but in the + * meantime we hope this will handle most practical GLSL and ARBfp + * requirements. + * + * Also remember you need to check for either the + * %COGL_FEATURE_SHADERS_GLSL or %COGL_FEATURE_SHADERS_ARBFP before + * using the cogl_program or cogl_shader API. + * + * Since: 2.0 + */ +void +cogl_pipeline_set_user_program (CoglPipeline *pipeline, + CoglHandle program); + +/** + * cogl_pipeline_set_layer: + * @pipeline: A #CoglPipeline object + * @layer_index: the index of the layer + * @texture: a #CoglHandle for the layer object + * + * In addition to the standard OpenGL lighting model a Cogl pipeline may have + * one or more layers comprised of textures that can be blended together in + * order, with a number of different texture combine modes. This function + * defines a new texture layer. + * + * The index values of multiple layers do not have to be consecutive; it is + * only their relative order that is important. + * + * In the future, we may define other types of pipeline layers, such + * as purely GLSL based layers. + * + * Since: 2.0 + */ +void +cogl_pipeline_set_layer_texture (CoglPipeline *pipeline, + int layer_index, + CoglHandle texture); + +/** + * cogl_pipeline_remove_layer: + * @pipeline: A #CoglPipeline object + * @layer_index: Specifies the layer you want to remove + * + * This function removes a layer from your pipeline + */ +void +cogl_pipeline_remove_layer (CoglPipeline *pipeline, + int layer_index); + +/** + * cogl_pipeline_set_layer_combine: + * @pipeline: A #CoglPipeline object + * @layer_index: Specifies the layer you want define a combine function for + * @blend_string: A Cogl blend string + * describing the desired texture combine function. + * @error: A #GError that may report parse errors or lack of GPU/driver + * support. May be %NULL, in which case a warning will be printed out if an + * error is encountered. + * + * If not already familiar; you can refer + * here for an overview of what blend + * strings are and there syntax. + * + * These are all the functions available for texture combining: + * + * REPLACE(arg0) = arg0 + * MODULATE(arg0, arg1) = arg0 x arg1 + * ADD(arg0, arg1) = arg0 + arg1 + * ADD_SIGNED(arg0, arg1) = arg0 + arg1 - 0.5 + * INTERPOLATE(arg0, arg1, arg2) = arg0 x arg2 + arg1 x (1 - arg2) + * SUBTRACT(arg0, arg1) = arg0 - arg1 + * + * + * DOT3_RGB(arg0, arg1) = 4 x ((arg0[R] - 0.5)) * (arg1[R] - 0.5) + + * (arg0[G] - 0.5)) * (arg1[G] - 0.5) + + * (arg0[B] - 0.5)) * (arg1[B] - 0.5)) + * + * + * + * + * DOT3_RGBA(arg0, arg1) = 4 x ((arg0[R] - 0.5)) * (arg1[R] - 0.5) + + * (arg0[G] - 0.5)) * (arg1[G] - 0.5) + + * (arg0[B] - 0.5)) * (arg1[B] - 0.5)) + * + * + * + * + * Refer to the + * color-source syntax for + * describing the arguments. The valid source names for texture combining + * are: + * + * + * TEXTURE + * Use the color from the current texture layer + * + * + * TEXTURE_0, TEXTURE_1, etc + * Use the color from the specified texture layer + * + * + * CONSTANT + * Use the color from the constant given with + * cogl_pipeline_set_layer_constant() + * + * + * PRIMARY + * Use the color of the pipeline as set with + * cogl_pipeline_set_color() + * + * + * PREVIOUS + * Either use the texture color from the previous layer, or + * if this is layer 0, use the color of the pipeline as set with + * cogl_pipeline_set_color() + * + * + * + * + * Layer Combine Examples + * This is effectively what the default blending is: + * + * RGBA = MODULATE (PREVIOUS, TEXTURE) + * + * This could be used to cross-fade between two images, using + * the alpha component of a constant as the interpolator. The constant + * color is given by calling cogl_pipeline_set_layer_constant. + * + * RGBA = INTERPOLATE (PREVIOUS, TEXTURE, CONSTANT[A]) + * + * + * + * You can't give a multiplication factor for arguments as you can + * with blending. + * + * Return value: %TRUE if the blend string was successfully parsed, and the + * described texture combining is supported by the underlying driver and + * or hardware. On failure, %FALSE is returned and @error is set + * + * Since: 2.0 + */ +gboolean +cogl_pipeline_set_layer_combine (CoglPipeline *pipeline, + int layer_index, + const char *blend_string, + GError **error); + +/** + * cogl_pipeline_set_layer_combine_constant: + * @pipeline: A #CoglPipeline object + * @layer_index: Specifies the layer you want to specify a constant used + * for texture combining + * @constant: The constant color you want + * + * When you are using the 'CONSTANT' color source in a layer combine + * description then you can use this function to define its value. + * + * Since: 2.0 + */ +void +cogl_pipeline_set_layer_combine_constant (CoglPipeline *pipeline, + int layer_index, + const CoglColor *constant); + +/** + * cogl_pipeline_set_layer_matrix: + * @pipeline: A #CoglPipeline object + * @layer_index: the index for the layer inside @pipeline + * @matrix: the transformation matrix for the layer + * + * This function lets you set a matrix that can be used to e.g. translate + * and rotate a single layer of a pipeline used to fill your geometry. + */ +void +cogl_pipeline_set_layer_matrix (CoglPipeline *pipeline, + int layer_index, + const CoglMatrix *matrix); + +/** + * cogl_pipeline_get_n_layers: + * @pipeline: A #CoglPipeline object + * + * Retrieves the number of layers defined for the given @pipeline + * + * Return value: the number of layers + * + * Since: 2.0 + */ +int +cogl_pipeline_get_n_layers (CoglPipeline *pipeline); + +/** + * cogl_pipeline_set_layer_filters: + * @pipeline: A #CoglPipeline object + * @layer_index: the layer number to change. + * @min_filter: the filter used when scaling a texture down. + * @mag_filter: the filter used when magnifying a texture. + * + * Changes the decimation and interpolation filters used when a texture is + * drawn at other scales than 100%. + */ +void +cogl_pipeline_set_layer_filters (CoglPipeline *pipeline, + int layer_index, + CoglPipelineFilter min_filter, + CoglPipelineFilter mag_filter); + +/** + * cogl_pipeline_set_layer_point_sprite_coords_enabled: + * @pipeline: a #CoglHandle to a pipeline. + * @layer_index: the layer number to change. + * @enable: whether to enable point sprite coord generation. + * @error: A return location for a GError, or NULL to ignore errors. + * + * When rendering points, if @enable is %TRUE then the texture + * coordinates for this layer will be replaced with coordinates that + * vary from 0.0 to 1.0 across the primitive. The top left of the + * point will have the coordinates 0.0,0.0 and the bottom right will + * have 1.0,1.0. If @enable is %FALSE then the coordinates will be + * fixed for the entire point. + * + * This function will only work if %COGL_FEATURE_POINT_SPRITE is + * available. If the feature is not available then the function will + * return %FALSE and set @error. + * + * Return value: %TRUE if the function succeeds, %FALSE otherwise. + * Since: 2.0 + */ +gboolean +cogl_pipeline_set_layer_point_sprite_coords_enabled (CoglPipeline *pipeline, + int layer_index, + gboolean enable, + GError **error); + +/** + * cogl_pipeline_get_layer_point_sprite_coords_enabled: + * @pipeline: a #CoglHandle to a pipeline. + * @layer_index: the layer number to check. + * + * Gets whether point sprite coordinate generation is enabled for this + * texture layer. + * + * Return value: whether the texture coordinates will be replaced with + * point sprite coordinates. + * + * Since: 2.0 + */ +gboolean +cogl_pipeline_get_layer_point_sprite_coords_enabled (CoglPipeline *pipeline, + int layer_index); + +/** + * cogl_pipeline_get_layer_wrap_mode_s: + * @pipeline: A #CoglPipeline object + * @layer_index: the layer number to change. + * + * Returns the wrap mode for the 's' coordinate of texture lookups on this + * layer. + * + * Return value: the wrap mode for the 's' coordinate of texture lookups on + * this layer. + * + * Since: 1.6 + */ +CoglPipelineWrapMode +cogl_pipeline_get_layer_wrap_mode_s (CoglPipeline *pipeline, + int layer_index); + +/** + * cogl_pipeline_set_layer_wrap_mode_s: + * @pipeline: A #CoglPipeline object + * @layer_index: the layer number to change. + * @mode: the new wrap mode + * + * Sets the wrap mode for the 's' coordinate of texture lookups on this layer. + * + * Since: 2.0 + */ +void +cogl_pipeline_set_layer_wrap_mode_s (CoglPipeline *pipeline, + int layer_index, + CoglPipelineWrapMode mode); + +/** + * cogl_pipeline_get_layer_wrap_mode_t: + * @pipeline: A #CoglPipeline object + * @layer_index: the layer number to change. + * + * Returns the wrap mode for the 't' coordinate of texture lookups on this + * layer. + * + * Return value: the wrap mode for the 't' coordinate of texture lookups on + * this layer. + * + * Since: 1.6 + */ +CoglPipelineWrapMode +cogl_pipeline_get_layer_wrap_mode_t (CoglPipeline *pipeline, + int layer_index); + + +/** + * cogl_pipeline_set_layer_wrap_mode_t: + * @pipeline: A #CoglPipeline object + * @layer_index: the layer number to change. + * @mode: the new wrap mode + * + * Sets the wrap mode for the 't' coordinate of texture lookups on this layer. + * + * Since: 2.0 + */ +void +cogl_pipeline_set_layer_wrap_mode_t (CoglPipeline *pipeline, + int layer_index, + CoglPipelineWrapMode mode); + +/** + * cogl_pipeline_get_layer_wrap_mode_p: + * @pipeline: A #CoglPipeline object + * @layer_index: the layer number to change. + * + * Returns the wrap mode for the 'p' coordinate of texture lookups on this + * layer. + * + * Return value: the wrap mode for the 'p' coordinate of texture lookups on + * this layer. + * + * Since: 1.6 + */ +CoglPipelineWrapMode +cogl_pipeline_get_layer_wrap_mode_p (CoglPipeline *pipeline, + int layer_index); + +/** + * cogl_pipeline_set_layer_wrap_mode_p: + * @pipeline: A #CoglPipeline object + * @layer_index: the layer number to change. + * @mode: the new wrap mode + * + * Sets the wrap mode for the 'p' coordinate of texture lookups on + * this layer. 'p' is the third coordinate. + * + * Since: 2.0 + */ +void +cogl_pipeline_set_layer_wrap_mode_p (CoglPipeline *pipeline, + int layer_index, + CoglPipelineWrapMode mode); + +/** + * cogl_pipeline_set_layer_wrap_mode: + * @pipeline: A #CoglPipeline object + * @layer_index: the layer number to change. + * @mode: the new wrap mode + * + * Sets the wrap mode for all three coordinates of texture lookups on + * this layer. This is equivalent to calling + * cogl_pipeline_set_layer_wrap_mode_s(), + * cogl_pipeline_set_layer_wrap_mode_t() and + * cogl_pipeline_set_layer_wrap_mode_p() separately. + * + * Since: 2.0 + */ +void +cogl_pipeline_set_layer_wrap_mode (CoglPipeline *pipeline, + int layer_index, + CoglPipelineWrapMode mode); + +#ifdef COGL_ENABLE_EXPERIMENTAL_API + +/** + * cogl_pipeline_set_depth_test_enabled: + * @pipeline: A #CoglPipeline object + * @enable: The enable state you want + * + * Enables or disables depth testing according to the value of + * @enable. + * + * If depth testing is enable then the #CoglDepthTestFunction set + * using cogl_pipeline_set_depth_test_function() us used to evaluate + * the depth value of incoming fragments against the corresponding + * value stored in the current depth buffer, and if the test passes + * then the fragments depth value is used to update the depth buffer. + * (unless you have disabled depth writing via + * cogl_pipeline_set_depth_writing_enabled ()) + * + * By default depth testing is disabled. + * + * Since: 2.0 + * Stability: Unstable + */ +void +cogl_pipeline_set_depth_test_enabled (CoglPipeline *pipeline, + gboolean enable); + +/** + * cogl_pipeline_get_depth_test_enabled: + * @pipeline: A #CoglPipeline object + * + * Gets the current depth test enabled state as previously set by + * cogl_pipeline_set_depth_test_enabled(). + * + * Returns: The pipeline's current depth test enabled state. + * Since: 2.0 + * Stability: Unstable + */ +gboolean +cogl_pipeline_get_depth_test_enabled (CoglPipeline *pipeline); + +/** + * cogl_pipeline_set_depth_writing_enabled: + * @pipeline: A #CoglPipeline object + * @enable: The enable state you want + * + * Enables or disables depth buffer writing according to the value of + * @enable. Normally when depth testing is enabled and the comparison + * between a fragment's depth value and the corresponding depth buffer + * value passes then the fragment's depth is written to the depth + * buffer unless writing is disabled here. + * + * By default depth writing is enabled + * + * Since: 2.0 + * Stability: Unstable + */ +void +cogl_pipeline_set_depth_writing_enabled (CoglPipeline *pipeline, + gboolean enable); + +/** + * cogl_pipeline_get_depth_writing_enabled: + * @pipeline: A #CoglPipeline object + * + * Gets the depth writing enable state as set by the corresponding + * cogl_pipeline_set_depth_writing_enabled. + * + * Returns: The current depth writing enable state + * Since: 2.0 + * Stability: Unstable + */ +gboolean +cogl_pipeline_get_depth_writing_enabled (CoglPipeline *pipeline); + +/** + * cogl_pipeline_set_depth_test_function: + * @pipeline: A #CoglPipeline object + * @function: The #CoglDepthTestFunction to set + * + * Sets the #CoglDepthTestFunction used to compare the depth value of + * an incoming fragment against the corresponding value in the current + * depth buffer. + * + * Since: 2.0 + * Stability: Unstable + */ +void +cogl_pipeline_set_depth_test_function (CoglPipeline *pipeline, + CoglDepthTestFunction function); + +/** + * cogl_pipeline_get_depth_test_function: + * @pipeline: A #CoglPipeline object + * + * Gets the current depth test enable state as previously set via + * cogl_pipeline_set_depth_test_enabled(). + * + * Returns: The current depth test enable state. + * Since: 2.0 + * Stability: Unstable + */ +CoglDepthTestFunction +cogl_pipeline_get_depth_test_function (CoglPipeline *pipeline); + +/** + * cogl_pipeline_set_depth_range: + * @pipeline: A #CoglPipeline object + * @near_val: The near component of the desired depth range which will be + * clamped to the range [0, 1] + * @far_val: The far component of the desired depth range which will be + * clamped to the range [0, 1] + * @error: location to store an error of type #CoglError + * + * Sets the range to map depth values in normalized device coordinates + * to before writing out to a depth buffer. + * + * After your geometry has be transformed, clipped and had perspective + * division applied placing it in normalized device + * coordinates all depth values between the near and far z clipping + * planes are in the range -1 to 1. Before writing any depth value to + * the depth buffer though the value is mapped into the range [0, 1]. + * + * With this function you can change the range which depth values are + * mapped too although the range must still lye within the range [0, + * 1]. + * + * If your driver does not support this feature (for example you are + * using GLES 1 drivers) then this will return %FALSE and set an error + * if @error isn't NULL. You can check ahead of time for the + * %COGL_FEATURE_DEPTH_RANGE feature with cogl_features_available() to + * know if this function will succeed. + * + * By default normalized device coordinate depth values are mapped to + * the full range of depth buffer values, [0, 1]. + * + * Returns: %TRUE if driver support is available else %FALSE. + * + * Since: 2.0 + * Stability: Unstable + */ +gboolean +cogl_pipeline_set_depth_range (CoglPipeline *pipeline, + float near_val, + float far_val, + GError **error); + +/** + * cogl_pipeline_get_depth_range_mapping: + * @pipeline: A #CoglPipeline object + * @near_val: A pointer to store the near component of the depth range + * @far_val: A pointer to store the far component of the depth range + * + * Gets the current range to which normalized depth values are mapped + * before writing to the depth buffer. This corresponds to the range + * set with cogl_pipeline_set_depth_range(). + * + * Since: 2.0 + * Stability: Unstable + */ +void +cogl_pipeline_get_depth_range (CoglPipeline *pipeline, + float *near_val, + float *far_val); + +/** + * CoglPipelineLayerCallback: + * @pipeline: The #CoglPipeline whos layers are being iterated + * @layer_index: The current layer index + * @user_data: The private data passed to cogl_pipeline_foreach_layer() + * + * The callback prototype used with cogl_pipeline_foreach_layer() for + * iterating all the layers of a @pipeline. + * + * Since: 2.0 + * Stability: Unstable + */ +typedef gboolean (*CoglPipelineLayerCallback) (CoglPipeline *pipeline, + int layer_index, + void *user_data); + +/** + * cogl_pipeline_foreach_layer: + * @pipeline: A #CoglPipeline object + * @callback: A #CoglPipelineLayerCallback to be called for each layer + * index + * @user_data: Private data that will be passed to the callback + * + * Iterates all the layer indices of the given @pipeline. + * + * Since: 2.0 + * Stability: Unstable + */ +void +cogl_pipeline_foreach_layer (CoglPipeline *pipeline, + CoglPipelineLayerCallback callback, + void *user_data); + +#endif /* COGL_ENABLE_EXPERIMENTAL_API */ + +G_END_DECLS + +#endif /* __COGL_PIPELINE_H__ */ diff --git a/clutter/cogl/cogl/cogl-primitives.c b/clutter/cogl/cogl/cogl-primitives.c index 946f306f4..466402a92 100644 --- a/clutter/cogl/cogl/cogl-primitives.c +++ b/clutter/cogl/cogl/cogl-primitives.c @@ -31,8 +31,8 @@ #include "cogl-context.h" #include "cogl-journal-private.h" #include "cogl-texture-private.h" -#include "cogl-material-private.h" -#include "cogl-material-opengl-private.h" +#include "cogl-pipeline-private.h" +#include "cogl-pipeline-opengl-private.h" #include "cogl-vertex-buffer-private.h" #include "cogl-framebuffer-private.h" #include "cogl-vertex-attribute-private.h" @@ -49,7 +49,7 @@ typedef struct _TextureSlicedQuadState { - CoglHandle material; + CoglPipeline *pipeline; float tex_virtual_origin_x; float tex_virtual_origin_y; float quad_origin_x; @@ -60,7 +60,7 @@ typedef struct _TextureSlicedQuadState float quad_len_y; gboolean flipped_x; gboolean flipped_y; - CoglMaterialWrapModeOverrides *wrap_mode_overrides; + CoglPipelineWrapModeOverrides *wrap_mode_overrides; } TextureSlicedQuadState; typedef struct _TextureSlicedPolygonState @@ -114,10 +114,10 @@ log_quad_sub_textures_cb (CoglHandle texture_handle, subtexture_coords[0], subtexture_coords[1], subtexture_coords[2], subtexture_coords[3]); - /* FIXME: when the wrap mode becomes part of the material we need to + /* FIXME: when the wrap mode becomes part of the pipeline we need to * be able to override the wrap mode when logging a quad. */ _cogl_journal_log_quad (quad_coords, - state->material, + state->pipeline, 1, /* one layer */ 0, /* don't need to use fallbacks */ gl_handle, /* replace the layer0 texture */ @@ -141,18 +141,18 @@ log_quad_sub_textures_cb (CoglHandle texture_handle, */ /* TODO: support multitexturing */ static void -_cogl_texture_quad_multiple_primitives (CoglHandle tex_handle, - CoglHandle material, - gboolean clamp_s, - gboolean clamp_t, - const float *position, - float tx_1, - float ty_1, - float tx_2, - float ty_2) +_cogl_texture_quad_multiple_primitives (CoglHandle tex_handle, + CoglPipeline *pipeline, + gboolean clamp_s, + gboolean clamp_t, + const float *position, + float tx_1, + float ty_1, + float tx_2, + float ty_2) { TextureSlicedQuadState state; - CoglMaterialWrapModeOverrides wrap_mode_overrides; + CoglPipelineWrapModeOverrides wrap_mode_overrides; gboolean tex_virtual_flipped_x; gboolean tex_virtual_flipped_y; gboolean quad_flipped_x; @@ -182,7 +182,7 @@ _cogl_texture_quad_multiple_primitives (CoglHandle tex_handle, (position[2] - position[0]) * (tx_1 - old_tx_1) / (old_tx_2 - old_tx_1)), position[3] }; - _cogl_texture_quad_multiple_primitives (tex_handle, material, + _cogl_texture_quad_multiple_primitives (tex_handle, pipeline, FALSE, clamp_t, tmp_position, tx_1, ty_1, tx_1, ty_2); @@ -197,7 +197,7 @@ _cogl_texture_quad_multiple_primitives (CoglHandle tex_handle, (position[2] - position[0]) * (tx_2 - old_tx_1) / (old_tx_2 - old_tx_1)), position[1], position[2], position[3] }; - _cogl_texture_quad_multiple_primitives (tex_handle, material, + _cogl_texture_quad_multiple_primitives (tex_handle, pipeline, FALSE, clamp_t, tmp_position, tx_2, ty_1, tx_2, ty_2); @@ -229,7 +229,7 @@ _cogl_texture_quad_multiple_primitives (CoglHandle tex_handle, (position[1] + (position[3] - position[1]) * (ty_1 - old_ty_1) / (old_ty_2 - old_ty_1)) }; - _cogl_texture_quad_multiple_primitives (tex_handle, material, + _cogl_texture_quad_multiple_primitives (tex_handle, pipeline, clamp_s, FALSE, tmp_position, tx_1, ty_1, tx_2, ty_1); @@ -245,7 +245,7 @@ _cogl_texture_quad_multiple_primitives (CoglHandle tex_handle, (position[3] - position[1]) * (ty_2 - old_ty_1) / (old_ty_2 - old_ty_1)), position[2], position[3] }; - _cogl_texture_quad_multiple_primitives (tex_handle, material, + _cogl_texture_quad_multiple_primitives (tex_handle, pipeline, clamp_s, FALSE, tmp_position, tx_1, ty_2, tx_2, ty_2); @@ -266,23 +266,23 @@ _cogl_texture_quad_multiple_primitives (CoglHandle tex_handle, otherwise it might pull in edge pixels from the other side. By default WRAP_MODE_AUTOMATIC becomes CLAMP_TO_EDGE so we only need to override if the wrap mode is repeat */ - first_layer = cogl_material_get_layers (material)->data; - if (cogl_material_layer_get_wrap_mode_s (first_layer) == - COGL_MATERIAL_WRAP_MODE_REPEAT) + first_layer = _cogl_pipeline_get_layers (pipeline)->data; + if (_cogl_pipeline_layer_get_wrap_mode_s (first_layer) == + COGL_PIPELINE_WRAP_MODE_REPEAT) { state.wrap_mode_overrides = &wrap_mode_overrides; wrap_mode_overrides.values[0].s = - COGL_MATERIAL_WRAP_MODE_OVERRIDE_CLAMP_TO_EDGE; + COGL_PIPELINE_WRAP_MODE_OVERRIDE_CLAMP_TO_EDGE; } - if (cogl_material_layer_get_wrap_mode_t (first_layer) == - COGL_MATERIAL_WRAP_MODE_REPEAT) + if (_cogl_pipeline_layer_get_wrap_mode_t (first_layer) == + COGL_PIPELINE_WRAP_MODE_REPEAT) { state.wrap_mode_overrides = &wrap_mode_overrides; wrap_mode_overrides.values[0].t = - COGL_MATERIAL_WRAP_MODE_OVERRIDE_CLAMP_TO_EDGE; + COGL_PIPELINE_WRAP_MODE_OVERRIDE_CLAMP_TO_EDGE; } - state.material = material; + state.pipeline = pipeline; /* Get together the data we need to transform the virtual texture * coordinates of each slice into quad coordinates... @@ -348,21 +348,21 @@ _cogl_texture_quad_multiple_primitives (CoglHandle tex_handle, * require repeating. */ static gboolean -_cogl_multitexture_quad_single_primitive (const float *position, - CoglHandle material, - guint32 fallback_layers, - const float *user_tex_coords, - int user_tex_coords_len) +_cogl_multitexture_quad_single_primitive (const float *position, + CoglPipeline *pipeline, + guint32 fallback_layers, + const float *user_tex_coords, + int user_tex_coords_len) { - int n_layers = cogl_material_get_n_layers (material); + int n_layers = cogl_pipeline_get_n_layers (pipeline); float *final_tex_coords = alloca (sizeof (float) * 4 * n_layers); const GList *layers; GList *tmp; int i; - CoglMaterialWrapModeOverrides wrap_mode_overrides; + CoglPipelineWrapModeOverrides wrap_mode_overrides; /* This will be set to point to wrap_mode_overrides when an override is needed */ - CoglMaterialWrapModeOverrides *wrap_mode_overrides_p = NULL; + CoglPipelineWrapModeOverrides *wrap_mode_overrides_p = NULL; _COGL_GET_CONTEXT (ctx, FALSE); @@ -371,7 +371,7 @@ _cogl_multitexture_quad_single_primitive (const float *position, /* * Validate the texture coordinates for this rectangle. */ - layers = cogl_material_get_layers (material); + layers = _cogl_pipeline_get_layers (pipeline); for (tmp = (GList *)layers, i = 0; tmp != NULL; tmp = tmp->next, i++) { CoglHandle layer = (CoglHandle)tmp->data; @@ -381,10 +381,10 @@ _cogl_multitexture_quad_single_primitive (const float *position, float default_tex_coords[4] = {0.0, 0.0, 1.0, 1.0}; CoglTransformResult transform_result; - tex_handle = cogl_material_layer_get_texture (layer); + tex_handle = _cogl_pipeline_layer_get_texture (layer); /* COGL_INVALID_HANDLE textures are handled by - * _cogl_material_flush_gl_state */ + * _cogl_pipeline_flush_gl_state */ if (tex_handle == COGL_INVALID_HANDLE) continue; @@ -456,25 +456,25 @@ _cogl_multitexture_quad_single_primitive (const float *position, the full texture is drawn with GL_LINEAR filter mode */ if (transform_result == COGL_TRANSFORM_HARDWARE_REPEAT) { - if (cogl_material_layer_get_wrap_mode_s (layer) == - COGL_MATERIAL_WRAP_MODE_AUTOMATIC) + if (_cogl_pipeline_layer_get_wrap_mode_s (layer) == + COGL_PIPELINE_WRAP_MODE_AUTOMATIC) { wrap_mode_overrides.values[i].s - = COGL_MATERIAL_WRAP_MODE_OVERRIDE_REPEAT; + = COGL_PIPELINE_WRAP_MODE_OVERRIDE_REPEAT; wrap_mode_overrides_p = &wrap_mode_overrides; } - if (cogl_material_layer_get_wrap_mode_t (layer) == - COGL_MATERIAL_WRAP_MODE_AUTOMATIC) + if (_cogl_pipeline_layer_get_wrap_mode_t (layer) == + COGL_PIPELINE_WRAP_MODE_AUTOMATIC) { wrap_mode_overrides.values[i].t - = COGL_MATERIAL_WRAP_MODE_OVERRIDE_REPEAT; + = COGL_PIPELINE_WRAP_MODE_OVERRIDE_REPEAT; wrap_mode_overrides_p = &wrap_mode_overrides; } } } _cogl_journal_log_quad (position, - material, + pipeline, n_layers, fallback_layers, 0, /* don't replace the layer0 texture */ @@ -497,7 +497,7 @@ _cogl_rectangles_with_multitexture_coords ( struct _CoglMutiTexturedRect *rects, int n_rects) { - CoglMaterial *material; + CoglPipeline *pipeline; const GList *layers; int n_layers; const GList *tmp; @@ -507,13 +507,13 @@ _cogl_rectangles_with_multitexture_coords ( _COGL_GET_CONTEXT (ctx, NO_RETVAL); - material = cogl_get_source (); + pipeline = cogl_get_source (); - layers = cogl_material_get_layers (material); - n_layers = cogl_material_get_n_layers (material); + layers = _cogl_pipeline_get_layers (pipeline); + n_layers = cogl_pipeline_get_n_layers (pipeline); /* - * Validate all the layers of the current source material... + * Validate all the layers of the current source pipeline... */ for (tmp = layers, i = 0; tmp != NULL; tmp = tmp->next, i++) @@ -521,10 +521,6 @@ _cogl_rectangles_with_multitexture_coords ( CoglHandle layer = tmp->data; CoglHandle tex_handle; - if (cogl_material_layer_get_type (layer) - != COGL_MATERIAL_LAYER_TYPE_TEXTURE) - continue; - /* We need to ensure the mipmaps are ready before deciding * anything else about the texture because the texture storage * could completely change if it needs to be migrated out of the @@ -535,42 +531,42 @@ _cogl_rectangles_with_multitexture_coords ( * underlying texture storage. We could add two mechanisms to * generalize this a bit... * - * 1) add a _cogl_material_layer_update_storage() function that + * 1) add a _cogl_pipeline_layer_update_storage() function that * would for instance consider if mipmapping is necessary and * potentially migrate the texture from an atlas. * - * 2) allow setting of transient primitive-flags on a material + * 2) allow setting of transient primitive-flags on a pipeline * that may affect the outcome of _update_storage(). One flag * could indicate that we expect to sample beyond the bounds of * the texture border. * - * flags = COGL_MATERIAL_PRIMITIVE_FLAG_VALID_BORDERS; - * _cogl_material_layer_assert_primitive_flags (layer, flags) - * _cogl_material_layer_update_storage (layer) + * flags = COGL_PIPELINE_PRIMITIVE_FLAG_VALID_BORDERS; + * _cogl_pipeline_layer_assert_primitive_flags (layer, flags) + * _cogl_pipeline_layer_update_storage (layer) * enqueue primitive in journal * * when the primitive is dequeued and drawn we should: - * _cogl_material_flush_gl_state (material) + * _cogl_pipeline_flush_gl_state (pipeline) * draw primitive - * _cogl_material_unassert_primitive_flags (layer, flags); + * _cogl_pipeline_unassert_primitive_flags (layer, flags); * - * _cogl_material_layer_update_storage should take into + * _cogl_pipeline_layer_update_storage should take into * consideration all the asserted primitive requirements. (E.g. * there could be multiple primitives in the journal - or in a * renderlist in the future - that need mipmaps or that need * valid contents beyond their borders (for cogl_polygon) * meaning they can't work with textures in an atas, so - * _cogl_material_layer_update_storage would pass on these + * _cogl_pipeline_layer_update_storage would pass on these * requirements to the texture atlas backend which would make * sure the referenced texture is migrated out of the atlas and * mipmaps are generated.) */ - _cogl_material_layer_pre_paint (layer); + _cogl_pipeline_layer_pre_paint (layer); - tex_handle = cogl_material_layer_get_texture (layer); + tex_handle = _cogl_pipeline_layer_get_texture (layer); /* COGL_INVALID_HANDLE textures are handled by - * _cogl_material_flush_gl_state */ + * _cogl_pipeline_flush_gl_state */ if (tex_handle == COGL_INVALID_HANDLE) continue; @@ -593,7 +589,7 @@ _cogl_rectangles_with_multitexture_coords ( { static gboolean warning_seen = FALSE; if (!warning_seen) - g_warning ("Skipping layers 1..n of your material since " + g_warning ("Skipping layers 1..n of your pipeline since " "the first layer is sliced. We don't currently " "support any multi-texturing with sliced " "textures but assume layer 0 is the most " @@ -606,7 +602,7 @@ _cogl_rectangles_with_multitexture_coords ( { static gboolean warning_seen = FALSE; if (!warning_seen) - g_warning ("Skipping layer %d of your material consisting of " + g_warning ("Skipping layer %d of your pipeline consisting of " "a sliced texture (unsuported for multi texturing)", i); warning_seen = TRUE; @@ -622,12 +618,12 @@ _cogl_rectangles_with_multitexture_coords ( * waste or if using GL_TEXTURE_RECTANGLE_ARB) then we don't support * multi texturing since we don't know if the result will end up trying * to texture from the waste area. */ - if (_cogl_material_layer_has_user_matrix (layer) + if (_cogl_pipeline_layer_has_user_matrix (layer) && !_cogl_texture_can_hardware_repeat (tex_handle)) { static gboolean warning_seen = FALSE; if (!warning_seen) - g_warning ("Skipping layer %d of your material since a custom " + g_warning ("Skipping layer %d of your pipeline since a custom " "texture matrix was given for a texture that can't be " "repeated using the GPU and the result may try to " "sample beyond the bounds of the texture ", @@ -656,7 +652,7 @@ _cogl_rectangles_with_multitexture_coords ( { gboolean success = _cogl_multitexture_quad_single_primitive (rects[i].position, - material, + pipeline, fallback_layers, rects[i].tex_coords, rects[i].tex_coords_len); @@ -671,25 +667,25 @@ _cogl_rectangles_with_multitexture_coords ( /* If multitexturing failed or we are drawing with a sliced texture * then we only support a single layer so we pluck out the texture - * from the first material layer... */ - layers = cogl_material_get_layers (material); + * from the first pipeline layer... */ + layers = _cogl_pipeline_get_layers (pipeline); first_layer = layers->data; - tex_handle = cogl_material_layer_get_texture (first_layer); + tex_handle = _cogl_pipeline_layer_get_texture (first_layer); if (rects[i].tex_coords) tex_coords = rects[i].tex_coords; else tex_coords = default_tex_coords; - clamp_s = (cogl_material_layer_get_wrap_mode_s (first_layer) == - COGL_MATERIAL_WRAP_MODE_CLAMP_TO_EDGE); - clamp_t = (cogl_material_layer_get_wrap_mode_t (first_layer) == - COGL_MATERIAL_WRAP_MODE_CLAMP_TO_EDGE); + clamp_s = (_cogl_pipeline_layer_get_wrap_mode_s (first_layer) == + COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE); + clamp_t = (_cogl_pipeline_layer_get_wrap_mode_t (first_layer) == + COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE); COGL_NOTE (DRAW, "Drawing Tex Quad (Multi-Prim Mode)"); _cogl_texture_quad_multiple_primitives (tex_handle, - material, + pipeline, clamp_s, clamp_t, rects[i].position, tex_coords[0], @@ -832,7 +828,7 @@ typedef struct _AppendTexCoordsState } AppendTexCoordsState; gboolean -append_tex_coord_attributes_cb (CoglMaterial *material, +append_tex_coord_attributes_cb (CoglPipeline *pipeline, int layer_index, void *user_data) { @@ -845,9 +841,9 @@ append_tex_coord_attributes_cb (CoglMaterial *material, ty = state->vertices_in[state->vertex].ty; /* COGL_INVALID_HANDLE textures will be handled in - * _cogl_material_flush_layers_gl_state but there is no need to worry + * _cogl_pipeline_flush_layers_gl_state but there is no need to worry * about scaling texture coordinates in this case */ - tex_handle = _cogl_material_get_layer_texture (material, layer_index); + tex_handle = _cogl_pipeline_get_layer_texture (pipeline, layer_index); if (tex_handle != COGL_INVALID_HANDLE) _cogl_texture_transform_coords_to_gl (tex_handle, &tx, &ty); @@ -863,40 +859,40 @@ append_tex_coord_attributes_cb (CoglMaterial *material, typedef struct _ValidateState { - CoglMaterial *original_material; - CoglMaterial *material; + CoglPipeline *original_pipeline; + CoglPipeline *pipeline; } ValidateState; gboolean -validate_layer_cb (CoglMaterial *material, +validate_layer_cb (CoglPipeline *pipeline, int layer_index, void *user_data) { ValidateState *state = user_data; - /* By default COGL_MATERIAL_WRAP_MODE_AUTOMATIC becomes + /* By default COGL_PIPELINE_WRAP_MODE_AUTOMATIC becomes * GL_CLAMP_TO_EDGE but we want the polygon API to use GL_REPEAT to * maintain compatibility with previous releases */ - if (cogl_material_get_layer_wrap_mode_s (material, layer_index) == - COGL_MATERIAL_WRAP_MODE_AUTOMATIC) + if (cogl_pipeline_get_layer_wrap_mode_s (pipeline, layer_index) == + COGL_PIPELINE_WRAP_MODE_AUTOMATIC) { - if (state->original_material == state->material) - state->material = cogl_material_copy (material); + if (state->original_pipeline == state->pipeline) + state->pipeline = cogl_pipeline_copy (pipeline); - cogl_material_set_layer_wrap_mode_s (state->material, layer_index, - COGL_MATERIAL_WRAP_MODE_REPEAT); + cogl_pipeline_set_layer_wrap_mode_s (state->pipeline, layer_index, + COGL_PIPELINE_WRAP_MODE_REPEAT); } - if (cogl_material_get_layer_wrap_mode_t (material, layer_index) == - COGL_MATERIAL_WRAP_MODE_AUTOMATIC) + if (cogl_pipeline_get_layer_wrap_mode_t (pipeline, layer_index) == + COGL_PIPELINE_WRAP_MODE_AUTOMATIC) { - if (state->original_material == state->material) - state->material = cogl_material_copy (material); + if (state->original_pipeline == state->pipeline) + state->pipeline = cogl_pipeline_copy (pipeline); - cogl_material_set_layer_wrap_mode_t (state->material, layer_index, - COGL_MATERIAL_WRAP_MODE_REPEAT); + cogl_pipeline_set_layer_wrap_mode_t (state->pipeline, layer_index, + COGL_PIPELINE_WRAP_MODE_REPEAT); } return TRUE; @@ -907,7 +903,7 @@ cogl_polygon (const CoglTextureVertex *vertices, unsigned int n_vertices, gboolean use_color) { - CoglMaterial *material; + CoglPipeline *pipeline; ValidateState validate_state; int n_layers; int n_attributes; @@ -920,16 +916,16 @@ cogl_polygon (const CoglTextureVertex *vertices, _COGL_GET_CONTEXT (ctx, NO_RETVAL); - material = cogl_get_source (); + pipeline = cogl_get_source (); - validate_state.original_material = material; - validate_state.material = material; - cogl_material_foreach_layer (material, + validate_state.original_pipeline = pipeline; + validate_state.pipeline = pipeline; + cogl_pipeline_foreach_layer (pipeline, validate_layer_cb, &validate_state); - material = validate_state.material; + pipeline = validate_state.pipeline; - n_layers = cogl_material_get_n_layers (material); + n_layers = cogl_pipeline_get_n_layers (pipeline); n_attributes = 1 + n_layers + (use_color ? 1 : 0); attributes = g_alloca (sizeof (CoglVertexAttribute *) * (n_attributes + 1)); @@ -1008,7 +1004,7 @@ cogl_polygon (const CoglTextureVertex *vertices, append_tex_coords_state.vertex = i; append_tex_coords_state.layer = 0; append_tex_coords_state.vertices_out = v; - cogl_material_foreach_layer (material, + cogl_pipeline_foreach_layer (pipeline, append_tex_coord_attributes_cb, &append_tex_coords_state); @@ -1031,7 +1027,7 @@ cogl_polygon (const CoglTextureVertex *vertices, (const guint8 *)v, ctx->polygon_vertices->len * sizeof (float)); - cogl_push_source (material); + cogl_push_source (pipeline); cogl_draw_vertex_attributes_array (COGL_VERTICES_MODE_TRIANGLE_FAN, 0, n_vertices, diff --git a/clutter/cogl/cogl/cogl-texture-2d-private.h b/clutter/cogl/cogl/cogl-texture-2d-private.h index a61267f55..bd36e8ffa 100644 --- a/clutter/cogl/cogl/cogl-texture-2d-private.h +++ b/clutter/cogl/cogl/cogl-texture-2d-private.h @@ -25,7 +25,7 @@ #define __COGL_TEXTURE_2D_H #include "cogl-handle.h" -#include "cogl-material-private.h" +#include "cogl-pipeline-private.h" #include "cogl-texture-private.h" #define COGL_TEXTURE_2D(tex) ((CoglTexture2D *) tex) diff --git a/clutter/cogl/cogl/cogl-texture-2d-sliced-private.h b/clutter/cogl/cogl/cogl-texture-2d-sliced-private.h index 039f77e0b..67a8ce9a9 100644 --- a/clutter/cogl/cogl/cogl-texture-2d-sliced-private.h +++ b/clutter/cogl/cogl/cogl-texture-2d-sliced-private.h @@ -26,7 +26,7 @@ #include "cogl-bitmap-private.h" #include "cogl-handle.h" -#include "cogl-material-private.h" +#include "cogl-pipeline-private.h" #include "cogl-texture-private.h" #define COGL_TEXTURE_2D_SLICED(tex) ((CoglTexture2DSliced *)tex) diff --git a/clutter/cogl/cogl/cogl-texture-2d-sliced.c b/clutter/cogl/cogl/cogl-texture-2d-sliced.c index 4e8958871..5f566b6c2 100644 --- a/clutter/cogl/cogl/cogl-texture-2d-sliced.c +++ b/clutter/cogl/cogl/cogl-texture-2d-sliced.c @@ -44,7 +44,7 @@ #include "cogl-handle.h" #include "cogl-spans.h" #include "cogl-journal-private.h" -#include "cogl-material-opengl-private.h" +#include "cogl-pipeline-opengl-private.h" #include #include diff --git a/clutter/cogl/cogl/cogl-texture-2d.c b/clutter/cogl/cogl/cogl-texture-2d.c index 61edb3bba..e29291805 100644 --- a/clutter/cogl/cogl/cogl-texture-2d.c +++ b/clutter/cogl/cogl/cogl-texture-2d.c @@ -37,7 +37,7 @@ #include "cogl-context.h" #include "cogl-handle.h" #include "cogl-journal-private.h" -#include "cogl-material-opengl-private.h" +#include "cogl-pipeline-opengl-private.h" #include #include diff --git a/clutter/cogl/cogl/cogl-texture-3d-private.h b/clutter/cogl/cogl/cogl-texture-3d-private.h index e3a080834..7fa29ae89 100644 --- a/clutter/cogl/cogl/cogl-texture-3d-private.h +++ b/clutter/cogl/cogl/cogl-texture-3d-private.h @@ -26,7 +26,7 @@ #define __COGL_TEXTURE_3D_PRIVATE_H #include "cogl-handle.h" -#include "cogl-material-private.h" +#include "cogl-pipeline-private.h" #include "cogl-texture-private.h" #define COGL_TEXTURE_3D(tex) ((CoglTexture3D *) tex) @@ -73,7 +73,7 @@ _cogl_handle_texture_3d_get_type (void); * be used. The default blending equations of Cogl expect premultiplied * color data; the main use of passing a non-premultiplied format here * is if you have non-premultiplied source data and are going to adjust - * the blend mode (see cogl_material_set_blend()) or use the data for + * the blend mode (see cogl_pipeline_set_blend()) or use the data for * something other than straight blending. * @error: A GError return location. * diff --git a/clutter/cogl/cogl/cogl-texture-3d.c b/clutter/cogl/cogl/cogl-texture-3d.c index d6d705020..9bbdfe170 100644 --- a/clutter/cogl/cogl/cogl-texture-3d.c +++ b/clutter/cogl/cogl/cogl-texture-3d.c @@ -35,8 +35,8 @@ #include "cogl-context.h" #include "cogl-handle.h" #include "cogl-journal-private.h" -#include "cogl-material-private.h" -#include "cogl-material-opengl-private.h" +#include "cogl-pipeline-private.h" +#include "cogl-pipeline-opengl-private.h" #include #include diff --git a/clutter/cogl/cogl/cogl-texture-private.h b/clutter/cogl/cogl/cogl-texture-private.h index 80b4aded2..f0c666133 100644 --- a/clutter/cogl/cogl/cogl-texture-private.h +++ b/clutter/cogl/cogl/cogl-texture-private.h @@ -26,7 +26,7 @@ #include "cogl-bitmap-private.h" #include "cogl-handle.h" -#include "cogl-material-private.h" +#include "cogl-pipeline-private.h" #define COGL_TEXTURE(tex) ((CoglTexture *)(tex)) @@ -145,7 +145,7 @@ typedef enum _CoglTextureChangeFlags /* Whenever the internals of a texture are changed such that the * underlying GL textures that represent the CoglTexture change then * we notify cogl-material.c via - * _cogl_material_texture_pre_change_notify + * _cogl_pipeline_texture_pre_change_notify */ COGL_TEXTURE_CHANGE_GL_TEXTURES diff --git a/clutter/cogl/cogl/cogl-texture-rectangle-private.h b/clutter/cogl/cogl/cogl-texture-rectangle-private.h index 48f3455e1..9a0dca225 100644 --- a/clutter/cogl/cogl/cogl-texture-rectangle-private.h +++ b/clutter/cogl/cogl/cogl-texture-rectangle-private.h @@ -25,7 +25,7 @@ #define __COGL_TEXTURE_RECTANGLE_H #include "cogl-handle.h" -#include "cogl-material-private.h" +#include "cogl-pipeline-private.h" #include "cogl-texture-private.h" #define COGL_TEXTURE_RECTANGLE(tex) ((CoglTextureRectangle *) tex) diff --git a/clutter/cogl/cogl/cogl-texture-rectangle.c b/clutter/cogl/cogl/cogl-texture-rectangle.c index 88236b77f..cf6365f5b 100644 --- a/clutter/cogl/cogl/cogl-texture-rectangle.c +++ b/clutter/cogl/cogl/cogl-texture-rectangle.c @@ -37,7 +37,7 @@ #include "cogl-context.h" #include "cogl-handle.h" #include "cogl-journal-private.h" -#include "cogl-material-opengl-private.h" +#include "cogl-pipeline-opengl-private.h" #include #include diff --git a/clutter/cogl/cogl/cogl-texture.c b/clutter/cogl/cogl/cogl-texture.c index 22b0a1fdf..c4f40a1b9 100644 --- a/clutter/cogl/cogl/cogl-texture.c +++ b/clutter/cogl/cogl/cogl-texture.c @@ -44,7 +44,7 @@ #include "cogl-texture-rectangle-private.h" #include "cogl-sub-texture-private.h" #include "cogl-atlas-texture-private.h" -#include "cogl-material.h" +#include "cogl-pipeline.h" #include "cogl-context.h" #include "cogl-handle.h" #include "cogl-primitives.h" @@ -276,7 +276,7 @@ _cogl_texture_prep_gl_alignment_for_pixels_download (int pixels_rowstride) GE( glPixelStorei (GL_PACK_ALIGNMENT, 1) ); } -/* FIXME: wrap modes should be set on materials not textures */ +/* FIXME: wrap modes should be set on pipelines not textures */ void _cogl_texture_set_wrap_mode_parameters (CoglHandle handle, GLenum wrap_mode_s, @@ -1084,26 +1084,26 @@ _cogl_texture_draw_and_read (CoglHandle handle, /* Direct copy operation */ - if (ctx->texture_download_material == COGL_INVALID_HANDLE) + if (ctx->texture_download_pipeline == COGL_INVALID_HANDLE) { - ctx->texture_download_material = cogl_material_new (); - cogl_material_set_blend (ctx->texture_download_material, + ctx->texture_download_pipeline = cogl_pipeline_new (); + cogl_pipeline_set_blend (ctx->texture_download_pipeline, "RGBA = ADD (SRC_COLOR, 0)", NULL); } - cogl_push_source (ctx->texture_download_material); + cogl_push_source (ctx->texture_download_pipeline); - cogl_material_set_layer (ctx->texture_download_material, 0, handle); + cogl_pipeline_set_layer_texture (ctx->texture_download_pipeline, 0, handle); - cogl_material_set_layer_combine (ctx->texture_download_material, + cogl_pipeline_set_layer_combine (ctx->texture_download_pipeline, 0, /* layer */ "RGBA = REPLACE (TEXTURE)", NULL); - cogl_material_set_layer_filters (ctx->texture_download_material, 0, - COGL_MATERIAL_FILTER_NEAREST, - COGL_MATERIAL_FILTER_NEAREST); + cogl_pipeline_set_layer_filters (ctx->texture_download_pipeline, 0, + COGL_PIPELINE_FILTER_NEAREST, + COGL_PIPELINE_FILTER_NEAREST); do_texture_draw_and_read (handle, target_bmp, viewport); @@ -1145,7 +1145,7 @@ _cogl_texture_draw_and_read (CoglHandle handle, NULL); /* Draw alpha values into RGB channels */ - cogl_material_set_layer_combine (ctx->texture_download_material, + cogl_pipeline_set_layer_combine (ctx->texture_download_pipeline, 0, /* layer */ "RGBA = REPLACE (TEXTURE[A])", NULL); @@ -1175,7 +1175,7 @@ _cogl_texture_draw_and_read (CoglHandle handle, _cogl_matrix_stack_pop (modelview_stack); _cogl_matrix_stack_pop (projection_stack); - /* restore the original material */ + /* restore the original pipeline */ cogl_pop_source (); return TRUE; diff --git a/clutter/cogl/cogl/cogl-types.h b/clutter/cogl/cogl/cogl-types.h index a2b5fc929..e2b100714 100644 --- a/clutter/cogl/cogl/cogl-types.h +++ b/clutter/cogl/cogl/cogl-types.h @@ -243,11 +243,11 @@ typedef enum { /*< prefix=COGL_PIXEL_FORMAT >*/ * %COGL_FEATURE_TEXTURE_NPOT_MIPMAP and %COGL_FEATURE_TEXTURE_NPOT_REPEAT * features to know if the hardware supports npot texture mipmaps * or repeat modes other than - * %COGL_MATERIAL_WRAP_MODE_CLAMP_TO_EDGE respectively. + * %COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE respectively. * @COGL_FEATURE_TEXTURE_NPOT_MIPMAP: Mipmapping is supported in * conjuntion with non power of two textures. * @COGL_FEATURE_TEXTURE_NPOT_REPEAT: Repeat modes other than - * %COGL_MATERIAL_WRAP_MODE_CLAMP_TO_EDGE are supported by the + * %COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE are supported by the * hardware. * @COGL_FEATURE_POINT_SPRITE: Whether * cogl_material_set_layer_point_sprite_coords_enabled() is supported. @@ -448,7 +448,7 @@ cogl_blend_string_error_quark (void); * %COGL_FEATURE_TEXTURE_NPOT is not advertised. * The GPU can not handle the configuration you have * requested. An example might be if you try to use too many texture - * layers in a single #CoglMaterial + * layers in a single #CoglPipeline * The driver does not support some * configuration. * @@ -513,6 +513,52 @@ typedef enum { /* NB: The above definitions are taken from gl.h equivalents */ + +/* XXX: should this be CoglMaterialDepthTestFunction? + * It makes it very verbose but would be consistent with + * CoglMaterialWrapMode */ + +/** + * CoglDepthTestFunction: + * @COGL_DEPTH_TEST_FUNCTION_NEVER: Never passes. + * @COGL_DEPTH_TEST_FUNCTION_LESS: Passes if the fragment's depth + * value is less than the value currently in the depth buffer. + * @COGL_DEPTH_TEST_FUNCTION_EQUAL: Passes if the fragment's depth + * value is equal to the value currently in the depth buffer. + * @COGL_DEPTH_TEST_FUNCTION_LEQUAL: Passes if the fragment's depth + * value is less or equal to the value currently in the depth buffer. + * @COGL_DEPTH_TEST_FUNCTION_GREATER: Passes if the fragment's depth + * value is greater than the value currently in the depth buffer. + * @COGL_DEPTH_TEST_FUNCTION_NOTEQUAL: Passes if the fragment's depth + * value is not equal to the value currently in the depth buffer. + * @COGL_DEPTH_TEST_FUNCTION_GEQUAL: Passes if the fragment's depth + * value greater than or equal to the value currently in the depth buffer. + * @COGL_DEPTH_TEST_FUNCTION_ALWAYS: Always passes. + * + * When using depth testing one of these functions is used to compare + * the depth of an incoming fragment against the depth value currently + * stored in the depth buffer. The function is changed using + * cogl_material_set_depth_test_function(). + * + * The test is only done when depth testing is explicitly enabled. (See + * cogl_material_set_depth_test_enabled()) + */ +typedef enum +{ + COGL_DEPTH_TEST_FUNCTION_NEVER = 0x0200, + COGL_DEPTH_TEST_FUNCTION_LESS = 0x0201, + COGL_DEPTH_TEST_FUNCTION_EQUAL = 0x0202, + COGL_DEPTH_TEST_FUNCTION_LEQUAL = 0x0203, + COGL_DEPTH_TEST_FUNCTION_GREATER = 0x0204, + COGL_DEPTH_TEST_FUNCTION_NOTEQUAL = 0x0205, + COGL_DEPTH_TEST_FUNCTION_GEQUAL = 0x0206, + COGL_DEPTH_TEST_FUNCTION_ALWAYS = 0x0207 +} CoglDepthTestFunction; +/* XXX: Note these types are only referenced by experimental API so + * although they aren't explicitly guarded they are implicitly + * experimental too. */ +/* NB: The above definitions are taken from gl.h equivalents */ + G_END_DECLS #endif /* __COGL_TYPES_H__ */ diff --git a/clutter/cogl/cogl/cogl-util.c b/clutter/cogl/cogl/cogl-util.c index f6d3709f2..7c8c5479c 100644 --- a/clutter/cogl/cogl/cogl-util.c +++ b/clutter/cogl/cogl/cogl-util.c @@ -32,7 +32,7 @@ #include "cogl-fixed.h" #include "cogl-internal.h" -#include "cogl-material.h" +#include "cogl-pipeline.h" #include "cogl-offscreen.h" #include "cogl-shader.h" #include "cogl-texture.h" diff --git a/clutter/cogl/cogl/cogl-vertex-attribute.c b/clutter/cogl/cogl/cogl-vertex-attribute.c index 875a7ad79..2a6d5e116 100644 --- a/clutter/cogl/cogl/cogl-vertex-attribute.c +++ b/clutter/cogl/cogl/cogl-vertex-attribute.c @@ -34,9 +34,9 @@ #include "cogl-journal-private.h" #include "cogl-vertex-attribute.h" #include "cogl-vertex-attribute-private.h" -#include "cogl-material.h" -#include "cogl-material-private.h" -#include "cogl-material-opengl-private.h" +#include "cogl-pipeline.h" +#include "cogl-pipeline-private.h" +#include "cogl-pipeline-opengl-private.h" #include "cogl-texture-private.h" #include "cogl-framebuffer-private.h" #include "cogl-indices-private.h" @@ -365,22 +365,22 @@ _cogl_vertex_attribute_free (CoglVertexAttribute *attribute) typedef struct { int unit; - CoglMaterialFlushOptions options; + CoglPipelineFlushOptions options; guint32 fallback_layers; } ValidateLayerState; static gboolean -validate_layer_cb (CoglMaterial *material, +validate_layer_cb (CoglPipeline *pipeline, int layer_index, void *user_data) { CoglHandle texture = - _cogl_material_get_layer_texture (material, layer_index); + _cogl_pipeline_get_layer_texture (pipeline, layer_index); ValidateLayerState *state = user_data; gboolean status = TRUE; /* invalid textures will be handled correctly in - * _cogl_material_flush_layers_gl_state */ + * _cogl_pipeline_flush_layers_gl_state */ if (texture == COGL_INVALID_HANDLE) goto validated; @@ -394,7 +394,7 @@ validate_layer_cb (CoglMaterial *material, * could completely change if it needs to be migrated out of the * atlas and will affect how we validate the layer. */ - _cogl_material_pre_paint_for_layer (material, layer_index); + _cogl_pipeline_pre_paint_for_layer (pipeline, layer_index); if (!_cogl_texture_can_hardware_repeat (texture)) { @@ -415,7 +415,7 @@ validate_layer_cb (CoglMaterial *material, * matrix. */ state->fallback_layers |= (1 << state->unit); - state->options.flags |= COGL_MATERIAL_FLUSH_FALLBACK_MASK; + state->options.flags |= COGL_PIPELINE_FLUSH_FALLBACK_MASK; } validated: @@ -433,13 +433,13 @@ enable_gl_state (CoglVertexAttribute **attributes, #endif unsigned long enable_flags = 0; gboolean skip_gl_color = FALSE; - CoglMaterial *source; - CoglMaterial *copy = NULL; + CoglPipeline *source; + CoglPipeline *copy = NULL; _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE); /* NB: _cogl_framebuffer_flush_state may disrupt various state (such - * as the material state) when flushing the clip stack, so should + * as the pipeline state) when flushing the clip stack, so should * always be done first when preparing to draw. We need to do this * before setting up the array pointers because setting up the clip * stack can cause some drawing which would change the array @@ -471,12 +471,12 @@ enable_gl_state (CoglVertexAttribute **attributes, attribute->stride, base + attribute->offset)); - if (!_cogl_material_get_real_blend_enabled (source)) + if (!_cogl_pipeline_get_real_blend_enabled (source)) { - CoglMaterialBlendEnable blend_enable = - COGL_MATERIAL_BLEND_ENABLE_ENABLED; - copy = cogl_material_copy (source); - _cogl_material_set_blend_enabled (copy, blend_enable); + CoglPipelineBlendEnable blend_enable = + COGL_PIPELINE_BLEND_ENABLE_ENABLED; + copy = cogl_pipeline_copy (source); + _cogl_pipeline_set_blend_enabled (copy, blend_enable); source = copy; } skip_gl_color = TRUE; @@ -533,27 +533,27 @@ enable_gl_state (CoglVertexAttribute **attributes, if (G_UNLIKELY (state->options.flags)) { - /* If we haven't already created a derived material... */ + /* If we haven't already created a derived pipeline... */ if (!copy) { - copy = cogl_material_copy (source); + copy = cogl_pipeline_copy (source); source = copy; } - _cogl_material_apply_overrides (source, &state->options); + _cogl_pipeline_apply_overrides (source, &state->options); /* TODO: - * overrides = cogl_material_get_data (material, + * overrides = cogl_pipeline_get_data (pipeline, * last_overrides_key); * if (overrides) * { - * age = cogl_material_get_age (material); + * age = cogl_pipeline_get_age (pipeline); * XXX: actually we also need to check for legacy_state * and blending overrides for use of glColorPointer... * if (overrides->ags != age || * memcmp (&overrides->options, &options, * sizeof (options) != 0) * { - * cogl_object_unref (overrides->weak_material); + * cogl_object_unref (overrides->weak_pipeline); * g_slice_free (Overrides, overrides); * overrides = NULL; * } @@ -561,32 +561,32 @@ enable_gl_state (CoglVertexAttribute **attributes, * if (!overrides) * { * overrides = g_slice_new (Overrides); - * overrides->weak_material = - * cogl_material_weak_copy (cogl_get_source ()); - * _cogl_material_apply_overrides (overrides->weak_material, + * overrides->weak_pipeline = + * cogl_pipeline_weak_copy (cogl_get_source ()); + * _cogl_pipeline_apply_overrides (overrides->weak_pipeline, * &options); * - * cogl_material_set_data (material, last_overrides_key, + * cogl_pipeline_set_data (pipeline, last_overrides_key, * weak_overrides, * free_overrides_cb, * NULL); * } - * source = overrides->weak_material; + * source = overrides->weak_pipeline; */ } if (G_UNLIKELY (ctx->legacy_state_set)) { - /* If we haven't already created a derived material... */ + /* If we haven't already created a derived pipeline... */ if (!copy) { - copy = cogl_material_copy (source); + copy = cogl_pipeline_copy (source); source = copy; } - _cogl_material_apply_legacy_state (source); + _cogl_pipeline_apply_legacy_state (source); } - _cogl_material_flush_gl_state (source, skip_gl_color); + _cogl_pipeline_flush_gl_state (source, skip_gl_color); if (ctx->enable_backface_culling) enable_flags |= COGL_ENABLE_BACKFACE_CULLING; @@ -601,7 +601,7 @@ enable_gl_state (CoglVertexAttribute **attributes, * just disable the things not needed after enabling state. */ static void disable_gl_state (CoglVertexAttribute **attributes, - CoglMaterial *source) + CoglPipeline *source) { #ifdef MAY_HAVE_PROGRAMABLE_GL GLuint generic_index = 0; @@ -655,7 +655,7 @@ _cogl_draw_vertex_attributes_array_real (CoglVerticesMode mode, CoglVertexAttribute **attributes, ValidateLayerState *state) { - CoglMaterial *source = enable_gl_state (attributes, state); + CoglPipeline *source = enable_gl_state (attributes, state); GE (glDrawArrays ((GLenum)mode, first_vertex, n_vertices)); @@ -665,7 +665,7 @@ _cogl_draw_vertex_attributes_array_real (CoglVerticesMode mode, } /* This can be used by the CoglJournal to draw attributes skiping - * the implicit journal flush and material validation. */ + * the implicit journal flush and pipeline validation. */ void _cogl_draw_vertex_attributes_array (CoglVerticesMode mode, int first_vertex, @@ -698,7 +698,7 @@ cogl_draw_vertex_attributes_array (CoglVerticesMode mode, state.options.flags = 0; state.fallback_layers = 0; - cogl_material_foreach_layer (cogl_get_source (), + cogl_pipeline_foreach_layer (cogl_get_source (), validate_layer_cb, &state); @@ -758,7 +758,7 @@ _cogl_draw_indexed_vertex_attributes_array_real (CoglVerticesMode mode, CoglVertexAttribute **attributes, ValidateLayerState *state) { - CoglMaterial *source = enable_gl_state (attributes, state); + CoglPipeline *source = enable_gl_state (attributes, state); CoglBuffer *buffer; void *base; size_t array_offset; @@ -834,7 +834,7 @@ cogl_draw_indexed_vertex_attributes_array (CoglVerticesMode mode, state.options.flags = 0; state.fallback_layers = 0; - cogl_material_foreach_layer (cogl_get_source (), + cogl_pipeline_foreach_layer (cogl_get_source (), validate_layer_cb, &state); diff --git a/clutter/cogl/cogl/cogl-vertex-buffer.c b/clutter/cogl/cogl/cogl-vertex-buffer.c index 479d900a4..192d4d561 100644 --- a/clutter/cogl/cogl/cogl-vertex-buffer.c +++ b/clutter/cogl/cogl/cogl-vertex-buffer.c @@ -103,8 +103,8 @@ #include "cogl-handle.h" #include "cogl-vertex-buffer-private.h" #include "cogl-texture-private.h" -#include "cogl-material.h" -#include "cogl-material-private.h" +#include "cogl-pipeline.h" +#include "cogl-pipeline-private.h" #include "cogl-primitives.h" #include "cogl-framebuffer-private.h" #include "cogl-journal-private.h" @@ -114,7 +114,7 @@ static void _cogl_vertex_buffer_free (CoglVertexBuffer *buffer); static void _cogl_vertex_buffer_indices_free (CoglVertexBufferIndices *buffer_indices); -static CoglUserDataKey _cogl_vertex_buffer_material_priv_key; +static CoglUserDataKey _cogl_vertex_buffer_pipeline_priv_key; COGL_HANDLE_DEFINE (VertexBuffer, vertex_buffer); COGL_OBJECT_DEFINE_DEPRECATED_REF_COUNTING (vertex_buffer); @@ -1392,70 +1392,70 @@ cogl_vertex_buffer_submit (CoglHandle handle) typedef struct { - CoglMaterial *real_source; + CoglPipeline *real_source; } VertexBufferMaterialPrivate; static void -weak_override_source_destroyed_cb (CoglMaterial *material, +weak_override_source_destroyed_cb (CoglPipeline *pipeline, void *user_data) { - VertexBufferMaterialPrivate *material_priv = user_data; - material_priv->real_source = NULL; + VertexBufferMaterialPrivate *pipeline_priv = user_data; + pipeline_priv->real_source = NULL; } static gboolean -validate_layer_cb (CoglMaterial *material, +validate_layer_cb (CoglPipeline *pipeline, int layer_index, void *user_data) { - VertexBufferMaterialPrivate *material_priv = user_data; - CoglMaterial *source = material_priv->real_source; + VertexBufferMaterialPrivate *pipeline_priv = user_data; + CoglPipeline *source = pipeline_priv->real_source; - if (!cogl_material_get_layer_point_sprite_coords_enabled (source, + if (!cogl_pipeline_get_layer_point_sprite_coords_enabled (source, layer_index)) { - CoglMaterialWrapMode wrap_s; - CoglMaterialWrapMode wrap_t; - CoglMaterialWrapMode wrap_p; + CoglPipelineWrapMode wrap_s; + CoglPipelineWrapMode wrap_t; + CoglPipelineWrapMode wrap_p; gboolean need_override_source = FALSE; - /* By default COGL_MATERIAL_WRAP_MODE_AUTOMATIC becomes + /* By default COGL_PIPELINE_WRAP_MODE_AUTOMATIC becomes * GL_CLAMP_TO_EDGE but we want GL_REPEAT to maintain * compatibility with older versions of Cogl so we'll override * it. We don't want to do this for point sprites because in * that case the whole texture is drawn so you would usually * want clamp-to-edge. */ - wrap_s = cogl_material_get_layer_wrap_mode_s (source, layer_index); - if (wrap_s == COGL_MATERIAL_WRAP_MODE_AUTOMATIC) + wrap_s = cogl_pipeline_get_layer_wrap_mode_s (source, layer_index); + if (wrap_s == COGL_PIPELINE_WRAP_MODE_AUTOMATIC) { need_override_source = TRUE; - wrap_s = COGL_MATERIAL_WRAP_MODE_REPEAT; + wrap_s = COGL_PIPELINE_WRAP_MODE_REPEAT; } - wrap_t = cogl_material_get_layer_wrap_mode_t (source, layer_index); - if (wrap_t == COGL_MATERIAL_WRAP_MODE_AUTOMATIC) + wrap_t = cogl_pipeline_get_layer_wrap_mode_t (source, layer_index); + if (wrap_t == COGL_PIPELINE_WRAP_MODE_AUTOMATIC) { need_override_source = TRUE; - wrap_t = COGL_MATERIAL_WRAP_MODE_REPEAT; + wrap_t = COGL_PIPELINE_WRAP_MODE_REPEAT; } - wrap_p = cogl_material_get_layer_wrap_mode_p (source, layer_index); - if (wrap_p == COGL_MATERIAL_WRAP_MODE_AUTOMATIC) + wrap_p = cogl_pipeline_get_layer_wrap_mode_p (source, layer_index); + if (wrap_p == COGL_PIPELINE_WRAP_MODE_AUTOMATIC) { need_override_source = TRUE; - wrap_p = COGL_MATERIAL_WRAP_MODE_REPEAT; + wrap_p = COGL_PIPELINE_WRAP_MODE_REPEAT; } if (need_override_source) { - if (material_priv->real_source == material) - material_priv->real_source = source = - _cogl_material_weak_copy (material, + if (pipeline_priv->real_source == pipeline) + pipeline_priv->real_source = source = + _cogl_pipeline_weak_copy (pipeline, weak_override_source_destroyed_cb, - material_priv); + pipeline_priv); - cogl_material_set_layer_wrap_mode_s (source, layer_index, wrap_s); - cogl_material_set_layer_wrap_mode_t (source, layer_index, wrap_t); - cogl_material_set_layer_wrap_mode_p (source, layer_index, wrap_p); + cogl_pipeline_set_layer_wrap_mode_s (source, layer_index, wrap_s); + cogl_pipeline_set_layer_wrap_mode_t (source, layer_index, wrap_t); + cogl_pipeline_set_layer_wrap_mode_p (source, layer_index, wrap_p); } } @@ -1463,7 +1463,7 @@ validate_layer_cb (CoglMaterial *material, } static void -destroy_material_priv_cb (void *user_data) +destroy_pipeline_priv_cb (void *user_data) { g_slice_free (VertexBufferMaterialPrivate, user_data); } @@ -1475,8 +1475,8 @@ update_primitive_and_draw (CoglVertexBuffer *buffer, int count, CoglVertexBufferIndices *buffer_indices) { - VertexBufferMaterialPrivate *material_priv; - CoglMaterial *users_source; + VertexBufferMaterialPrivate *pipeline_priv; + CoglPipeline *users_source; _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -1492,27 +1492,27 @@ update_primitive_and_draw (CoglVertexBuffer *buffer, cogl_vertex_buffer_submit_real (buffer); users_source = cogl_get_source (); - material_priv = + pipeline_priv = cogl_object_get_user_data (COGL_OBJECT (users_source), - &_cogl_vertex_buffer_material_priv_key); - if (G_UNLIKELY (!material_priv)) + &_cogl_vertex_buffer_pipeline_priv_key); + if (G_UNLIKELY (!pipeline_priv)) { - material_priv = g_slice_new0 (VertexBufferMaterialPrivate); + pipeline_priv = g_slice_new0 (VertexBufferMaterialPrivate); cogl_object_set_user_data (COGL_OBJECT (users_source), - &_cogl_vertex_buffer_material_priv_key, - material_priv, - destroy_material_priv_cb); + &_cogl_vertex_buffer_pipeline_priv_key, + pipeline_priv, + destroy_pipeline_priv_cb); } - if (G_UNLIKELY (!material_priv->real_source)) + if (G_UNLIKELY (!pipeline_priv->real_source)) { - material_priv->real_source = users_source; - cogl_material_foreach_layer (material_priv->real_source, + pipeline_priv->real_source = users_source; + cogl_pipeline_foreach_layer (pipeline_priv->real_source, validate_layer_cb, - material_priv); + pipeline_priv); } - cogl_push_source (material_priv->real_source); + cogl_push_source (pipeline_priv->real_source); cogl_primitive_draw (buffer->primitive); diff --git a/clutter/cogl/cogl/cogl.c b/clutter/cogl/cogl/cogl.c index f740173ca..af3a3d57b 100644 --- a/clutter/cogl/cogl/cogl.c +++ b/clutter/cogl/cogl/cogl.c @@ -36,8 +36,8 @@ #include "cogl-internal.h" #include "cogl-util.h" #include "cogl-context.h" -#include "cogl-material-private.h" -#include "cogl-material-opengl-private.h" +#include "cogl-pipeline-private.h" +#include "cogl-pipeline-opengl-private.h" #include "cogl-winsys.h" #include "cogl-framebuffer-private.h" #include "cogl-matrix-private.h" @@ -158,7 +158,7 @@ cogl_clear (const CoglColor *color, unsigned long buffers) _cogl_journal_flush (); /* NB: _cogl_framebuffer_flush_state may disrupt various state (such - * as the material state) when flushing the clip stack, so should + * as the pipeline state) when flushing the clip stack, so should * always be done first when preparing to draw. */ _cogl_framebuffer_flush_state (_cogl_get_framebuffer (), 0); @@ -375,9 +375,9 @@ cogl_set_source_color (const CoglColor *color) premultiplied = *color; cogl_color_premultiply (&premultiplied); - cogl_material_set_color (ctx->simple_material, &premultiplied); + cogl_pipeline_set_color (ctx->simple_pipeline, &premultiplied); - cogl_set_source (ctx->simple_material); + cogl_set_source (ctx->simple_pipeline); } void @@ -585,7 +585,7 @@ cogl_read_pixels (int x, result of the default blending operations for Cogl ends up with premultiplied data in the framebuffer. However it is possible for the framebuffer to be in whatever format - depending on what CoglMaterial is used to render to + depending on what CoglPipeline is used to render to it. Eventually we may want to add a way for an application to inform Cogl that the framebuffer is not premultiplied in case it is being used for some special purpose. */ @@ -740,20 +740,20 @@ cogl_begin_gl (void) * projection matrix state * * NB: _cogl_framebuffer_flush_state may disrupt various state (such - * as the material state) when flushing the clip stack, so should + * as the pipeline state) when flushing the clip stack, so should * always be done first when preparing to draw. */ _cogl_framebuffer_flush_state (_cogl_get_framebuffer (), 0); - /* Setup the state for the current material */ + /* Setup the state for the current pipeline */ - /* We considered flushing a specific, minimal material here to try and + /* We considered flushing a specific, minimal pipeline here to try and * simplify the GL state, but decided to avoid special cases and second * guessing what would be actually helpful. * * A user should instead call cogl_set_source_color4ub() before * cogl_begin_gl() to simplify the state flushed. */ - _cogl_material_flush_gl_state (cogl_get_source (), FALSE); + _cogl_pipeline_flush_gl_state (cogl_get_source (), FALSE); if (ctx->enable_backface_culling) enable_flags |= COGL_ENABLE_BACKFACE_CULLING; @@ -945,17 +945,17 @@ _cogl_driver_error_quark (void) typedef struct _CoglSourceState { - CoglMaterial *material; + CoglPipeline *pipeline; int push_count; } CoglSourceState; static void -_push_source_real (CoglMaterial *material) +_push_source_real (CoglPipeline *pipeline) { CoglSourceState *top = g_slice_new (CoglSourceState); _COGL_GET_CONTEXT (ctx, NO_RETVAL); - top->material = cogl_object_ref (material); + top->pipeline = cogl_object_ref (pipeline); top->push_count = 1; ctx->source_stack = g_list_prepend (ctx->source_stack, top); @@ -963,29 +963,30 @@ _push_source_real (CoglMaterial *material) /* FIXME: This should take a context pointer for Cogl 2.0 Technically * we could make it so we can retrieve a context reference from the - * material, but this would not by symmetric with cogl_pop_source. */ + * pipeline, but this would not by symmetric with cogl_pop_source. */ void -cogl_push_source (CoglMaterial *material) +cogl_push_source (void *material_or_pipeline) { CoglSourceState *top; + CoglPipeline *pipeline = COGL_PIPELINE (material_or_pipeline); _COGL_GET_CONTEXT (ctx, NO_RETVAL); - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); if (ctx->source_stack) { top = ctx->source_stack->data; - if (top->material == material) + if (top->pipeline == pipeline) { top->push_count++; return; } else - _push_source_real (material); + _push_source_real (pipeline); } else - _push_source_real (material); + _push_source_real (pipeline); } /* FIXME: This needs to take a context pointer for Cogl 2.0 */ @@ -1002,7 +1003,7 @@ cogl_pop_source (void) top->push_count--; if (top->push_count == 0) { - cogl_object_unref (top->material); + cogl_object_unref (top->pipeline); g_slice_free (CoglSourceState, top); ctx->source_stack = g_list_delete_link (ctx->source_stack, ctx->source_stack); @@ -1010,7 +1011,7 @@ cogl_pop_source (void) } /* FIXME: This needs to take a context pointer for Cogl 2.0 */ -CoglMaterial * +void * cogl_get_source (void) { CoglSourceState *top; @@ -1020,35 +1021,36 @@ cogl_get_source (void) g_return_val_if_fail (ctx->source_stack, NULL); top = ctx->source_stack->data; - return top->material; + return top->pipeline; } void -cogl_set_source (CoglMaterial *material) +cogl_set_source (void *material_or_pipeline) { CoglSourceState *top; + CoglPipeline *pipeline = COGL_PIPELINE (material_or_pipeline); _COGL_GET_CONTEXT (ctx, NO_RETVAL); - g_return_if_fail (cogl_is_material (material)); + g_return_if_fail (cogl_is_pipeline (pipeline)); g_return_if_fail (ctx->source_stack); top = ctx->source_stack->data; - if (top->material == material) + if (top->pipeline == pipeline) return; if (top->push_count == 1) { - /* NB: top->material may be only thing keeping material - * alive currently so ref material first... */ - cogl_object_ref (material); - cogl_object_unref (top->material); - top->material = material; + /* NB: top->pipeline may be only thing keeping pipeline + * alive currently so ref pipeline first... */ + cogl_object_ref (pipeline); + cogl_object_unref (top->pipeline); + top->pipeline = pipeline; } else { top->push_count--; - cogl_push_source (material); + cogl_push_source (pipeline); } } @@ -1059,8 +1061,8 @@ cogl_set_source_texture (CoglHandle texture_handle) g_return_if_fail (texture_handle != NULL); - cogl_material_set_layer (ctx->texture_material, 0, texture_handle); - cogl_set_source (ctx->texture_material); + cogl_pipeline_set_layer_texture (ctx->texture_pipeline, 0, texture_handle); + cogl_set_source (ctx->texture_pipeline); } void diff --git a/clutter/cogl/cogl/cogl.h b/clutter/cogl/cogl/cogl.h index 864806916..9f2cabe84 100644 --- a/clutter/cogl/cogl/cogl.h +++ b/clutter/cogl/cogl/cogl.h @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include @@ -59,6 +59,7 @@ #include #include #include +#include #endif G_BEGIN_DECLS @@ -589,7 +590,7 @@ cogl_clear (const CoglColor *color, * Since: 1.0 */ void -cogl_set_source (CoglMaterial *material); +cogl_set_source (void *material); /** * cogl_get_source: @@ -607,7 +608,7 @@ cogl_set_source (CoglMaterial *material); * * Since: 1.6 */ -CoglMaterial * +void * cogl_get_source (void); /** @@ -621,7 +622,7 @@ cogl_get_source (void); * Since: 1.6 */ void -cogl_push_source (CoglMaterial *material); +cogl_push_source (void *material); /** * cogl_pop_source: diff --git a/clutter/cogl/cogl/driver/gl/cogl-texture-driver-gl.c b/clutter/cogl/cogl/driver/gl/cogl-texture-driver-gl.c index bf742d7c8..bda0b0c20 100644 --- a/clutter/cogl/cogl/driver/gl/cogl-texture-driver-gl.c +++ b/clutter/cogl/cogl/driver/gl/cogl-texture-driver-gl.c @@ -36,11 +36,11 @@ #include "cogl-bitmap.h" #include "cogl-bitmap-private.h" #include "cogl-texture-private.h" -#include "cogl-material.h" +#include "cogl-pipeline.h" #include "cogl-context.h" #include "cogl-handle.h" #include "cogl-primitives.h" -#include "cogl-material-opengl-private.h" +#include "cogl-pipeline-opengl-private.h" #include #include diff --git a/clutter/cogl/cogl/driver/gles/cogl-texture-driver-gles.c b/clutter/cogl/cogl/driver/gles/cogl-texture-driver-gles.c index 503090c27..f33f05199 100644 --- a/clutter/cogl/cogl/driver/gles/cogl-texture-driver-gles.c +++ b/clutter/cogl/cogl/driver/gles/cogl-texture-driver-gles.c @@ -36,8 +36,8 @@ #include "cogl-bitmap.h" #include "cogl-bitmap-private.h" #include "cogl-texture-private.h" -#include "cogl-material.h" -#include "cogl-material-opengl-private.h" +#include "cogl-pipeline.h" +#include "cogl-pipeline-opengl-private.h" #include "cogl-context.h" #include "cogl-handle.h" #include "cogl-primitives.h" diff --git a/clutter/cogl/cogl/winsys/cogl-texture-pixmap-x11.c b/clutter/cogl/cogl/winsys/cogl-texture-pixmap-x11.c index be0c30229..54697f8e7 100644 --- a/clutter/cogl/cogl/winsys/cogl-texture-pixmap-x11.c +++ b/clutter/cogl/cogl/winsys/cogl-texture-pixmap-x11.c @@ -43,7 +43,7 @@ #include "cogl-context.h" #include "cogl-handle.h" #include "cogl-xlib.h" -#include "cogl-material-opengl-private.h" +#include "cogl-pipeline-opengl-private.h" #include #include @@ -1066,10 +1066,10 @@ _cogl_texture_pixmap_x11_set_use_glx_texture (CoglTexturePixmapX11 *tex_pixmap, { if (tex_pixmap->use_glx_texture != new_value) { - /* Notify cogl-material.c that the texture's underlying GL texture + /* Notify cogl-pipeline.c that the texture's underlying GL texture * storage is changing so it knows it may need to bind a new texture * if the CoglTexture is reused with the same texture unit. */ - _cogl_material_texture_storage_change_notify (tex_pixmap); + _cogl_pipeline_texture_storage_change_notify (tex_pixmap); tex_pixmap->use_glx_texture = new_value; }