The loop that generates code for a list of snippets now starts from
the first snippet that has a replace string. Any snippets before that
would be ignored so there's no point in generating code for them.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
The function for generating the GLSL for a list of snippets was trying
to detect the last snippet so that it could use a different function
name. However this wouldn't work if the last snippet has a different
hook. To fix this it now just counts the snippets that have the same
hook beforehand and detects the last one using the count.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Instead of specifying the hook point when adding to the pipeline using
a separate function for each hook, the hook is now a property of the
snippet. The hook is set on construction and is then read-only.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
This adds a per-layer snippet hook for the texure lookup. Here the
snippet can modify the texture coordinates used for the lookup or
modify the texel resulting from the lookup. This is the first
per-layer hook so this also adds the
COGL_PIPELINE_LAYER_STATE_FRAGMENT_SNIPPETS state and all of the
boilerplate needed to make that work.
Most of the functions used by the pipeline state to manage the snippet
list has been moved into cogl-pipeline-snippet.c so that it can be
shared with the layer state.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
The two loops that generate the functions for the snippets in the
fragend and vertend are very similar so to avoid code duplication this
patch moves the logic to its own function in a new
cogl-pipeline-snippet.c file.
Reviewed-by: Robert Bragg <robert@linux.intel.com>