snippet: Add a hook for the layer texture coordinate transformation

This adds a hook called COGL_SNIPPET_HOOK_TEXTURE_COORD_TRANSFORM.
This can be used to alter the application of the layer user matrix to
a texture coordinate or it can bypass it altogether.

This is the first per-layer hook that affects the vertex shader state
so the patch includes the boilerplate needed to get that to work.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
Neil Roberts
2011-11-28 19:58:15 +00:00
committed by Robert Bragg
parent b7e15929b6
commit 68b3643b25
11 changed files with 268 additions and 12 deletions

View File

@ -114,6 +114,10 @@ _cogl_pipeline_layer_has_alpha (CoglPipelineLayer *layer)
}
/* All bets are off if the layer contains any snippets */
snippets_authority = _cogl_pipeline_layer_get_authority
(layer, COGL_PIPELINE_LAYER_STATE_VERTEX_SNIPPETS);
if (!COGL_LIST_EMPTY (&snippets_authority->big_state->vertex_snippets))
return TRUE;
snippets_authority = _cogl_pipeline_layer_get_authority
(layer, COGL_PIPELINE_LAYER_STATE_FRAGMENT_SNIPPETS);
if (!COGL_LIST_EMPTY (&snippets_authority->big_state->fragment_snippets))
@ -211,6 +215,11 @@ _cogl_pipeline_layer_init_multi_property_sparse_state (
}
break;
}
case COGL_PIPELINE_LAYER_STATE_VERTEX_SNIPPETS:
_cogl_pipeline_snippet_list_copy (&layer->big_state->vertex_snippets,
&authority->big_state->
vertex_snippets);
break;
case COGL_PIPELINE_LAYER_STATE_FRAGMENT_SNIPPETS:
_cogl_pipeline_snippet_list_copy (&layer->big_state->fragment_snippets,
&authority->big_state->
@ -591,6 +600,12 @@ _cogl_pipeline_layer_equal (CoglPipelineLayer *layer0,
_cogl_pipeline_layer_point_sprite_coords_equal))
return FALSE;
if (layers_difference & COGL_PIPELINE_LAYER_STATE_VERTEX_SNIPPETS &&
!layer_state_equal (COGL_PIPELINE_LAYER_STATE_VERTEX_SNIPPETS_INDEX,
authorities0, authorities1,
_cogl_pipeline_layer_vertex_snippets_equal))
return FALSE;
if (layers_difference & COGL_PIPELINE_LAYER_STATE_FRAGMENT_SNIPPETS &&
!layer_state_equal (COGL_PIPELINE_LAYER_STATE_FRAGMENT_SNIPPETS_INDEX,
authorities0, authorities1,
@ -609,6 +624,9 @@ _cogl_pipeline_layer_free (CoglPipelineLayer *layer)
layer->texture != NULL)
cogl_object_unref (layer->texture);
if (layer->differences & COGL_PIPELINE_LAYER_STATE_VERTEX_SNIPPETS)
_cogl_pipeline_snippet_list_free (&layer->big_state->vertex_snippets);
if (layer->differences & COGL_PIPELINE_LAYER_STATE_FRAGMENT_SNIPPETS)
_cogl_pipeline_snippet_list_free (&layer->big_state->fragment_snippets);