summaryrefslogtreecommitdiff
path: root/cogl/cogl-path.c
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2010-04-26 10:01:43 +0100
committerRobert Bragg <robert@linux.intel.com>2010-06-09 17:15:59 +0100
commitacc44161c108dafef63d730b585b4f68b935f6ad (patch)
tree23171e3b4972c746255c6dfdd0a6cca3def7c52b /cogl/cogl-path.c
parent8ebf76a9a91da0bbbe1208366c1740f0c77d6392 (diff)
downloadcogl-acc44161c108dafef63d730b585b4f68b935f6ad.tar.gz
material: Adds backend abstraction for fragment processing
As part of an effort to improve the architecture of CoglMaterial internally this overhauls how we flush layer state to OpenGL by adding a formal backend abstraction for fragment processing and further formalizing the CoglTextureUnit abstraction. There are three backends: "glsl", "arbfp" and "fixed". The fixed backend uses the OpenGL fixed function APIs to setup the fragment processing, the arbfp backend uses code generation to handle fragment processing using an ARBfp program, and the GLSL backend is currently only there as a formality to handle user programs associated with a material. (i.e. the glsl backend doesn't yet support code generation) The GLSL backend has highest precedence, then arbfp and finally the fixed. If a backend can't support some particular CoglMaterial feature then it will fallback to the next backend. This adds three new COGL_DEBUG options: * "disable-texturing" as expected should disable all texturing * "disable-arbfp" always make the arbfp backend fallback * "disable-glsl" always make the glsl backend fallback * "show-source" show code generated by the arbfp/glsl backends
Diffstat (limited to 'cogl/cogl-path.c')
-rw-r--r--cogl/cogl-path.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/cogl/cogl-path.c b/cogl/cogl-path.c
index 9c1475ad..606dfe5f 100644
--- a/cogl/cogl-path.c
+++ b/cogl/cogl-path.c
@@ -132,6 +132,7 @@ _cogl_path_stroke_nodes (void)
unsigned long enable_flags = COGL_ENABLE_VERTEX_ARRAY;
CoglPathData *data;
CoglMaterialFlushOptions options;
+ CoglHandle source;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
@@ -151,7 +152,15 @@ _cogl_path_stroke_nodes (void)
/* disable all texture layers */
options.disable_layers = (guint32)~0;
- _cogl_material_flush_gl_state (ctx->source_material, &options);
+ if (G_UNLIKELY (ctx->legacy_state_set))
+ {
+ source = cogl_material_copy (ctx->source_material);
+ _cogl_material_apply_legacy_state (source);
+ }
+ else
+ source = ctx->source_material;
+
+ _cogl_material_flush_gl_state (source, &options);
while (path_start < data->path_nodes->len)
{
@@ -163,6 +172,9 @@ _cogl_path_stroke_nodes (void)
path_start += node->path_size;
}
+
+ if (G_UNLIKELY (source != ctx->source_material))
+ cogl_handle_unref (source);
}
static void
@@ -332,6 +344,8 @@ _cogl_path_fill_nodes_scanlines (CoglPathNode *path,
unsigned int bounds_w,
unsigned int bounds_h)
{
+ CoglHandle source;
+
/* This is our edge list it stores intersections between our
* curve and scanlines, it should probably be implemented with a
* data structure that has smaller overhead for inserting the
@@ -359,6 +373,14 @@ _cogl_path_fill_nodes_scanlines (CoglPathNode *path,
* always be done first when preparing to draw. */
_cogl_framebuffer_flush_state (_cogl_get_framebuffer (), 0);
+ if (G_UNLIKELY (ctx->legacy_state_set))
+ {
+ source = cogl_material_copy (ctx->source_material);
+ _cogl_material_apply_legacy_state (source);
+ }
+ else
+ source = ctx->source_material;
+
_cogl_material_flush_gl_state (ctx->source_material, NULL);
_cogl_enable (COGL_ENABLE_VERTEX_ARRAY
@@ -502,6 +524,9 @@ _cogl_path_fill_nodes_scanlines (CoglPathNode *path,
GE (glDrawArrays (GL_TRIANGLES, 0, spans * 2 * 3));
g_free (coords);
}
+
+ if (G_UNLIKELY (source != ctx->source_material))
+ cogl_handle_unref (source);
}
static void