summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2010-10-28 12:18:28 +0100
committerNeil Roberts <neil@linux.intel.com>2010-10-28 12:18:28 +0100
commit8556ca8dc6b7eeb7be36c9ee95b0bd26da99f8e9 (patch)
treeeb42d3d2ef4b31afb63abb19ed316f6ef58713b8
parentd617b11bf289a1bf652493d9bc2d48b74184a8da (diff)
downloadclutter-8556ca8dc6b7eeb7be36c9ee95b0bd26da99f8e9.tar.gz
cogl: Use separate materials for set_source_color and texture
Previously cogl_set_source_color and cogl_set_source_texture modified a single global material. If an application then mixes using cogl_set_source_color and texture then the material will constantly need a new ARBfp program because the numbers of layers alternates between 0 and 1. This patch just adds a second global material that is only used for cogl_set_source_texture. I think it would still end up flushing the journal if cogl_set_source_texture is used with multiple different textures but at least it should avoid a recompile unless the texture target also changes. It might be nice to somehow attach a material to the CoglTexture for use with cogl_set_source_texture but it would be difficult to implement this without creating a circular reference. (cherry picked from commit 65d7a113eeb0de08ccb402fe4ade14fe82fcaff1) Conflicts: clutter/cogl/cogl/cogl-context.c clutter/cogl/cogl/cogl-context.h
-rw-r--r--clutter/cogl/cogl/cogl-context.c3
-rw-r--r--clutter/cogl/cogl/cogl-context.h3
-rw-r--r--clutter/cogl/cogl/cogl.c11
3 files changed, 7 insertions, 10 deletions
diff --git a/clutter/cogl/cogl/cogl-context.c b/clutter/cogl/cogl/cogl-context.c
index 5b3418a5a..86f5c7e68 100644
--- a/clutter/cogl/cogl/cogl-context.c
+++ b/clutter/cogl/cogl/cogl-context.c
@@ -130,6 +130,7 @@ cogl_create_context (void)
_context->legacy_fog_state.enabled = FALSE;
_context->simple_material = cogl_material_new ();
+ _context->texture_material = cogl_material_new ();
_context->source_material = NULL;
_context->arbfp_source_buffer = g_string_new ("");
@@ -268,6 +269,8 @@ _cogl_destroy_context (void)
if (_context->simple_material)
cogl_handle_unref (_context->simple_material);
+ if (_context->texture_material)
+ cogl_handle_unref (_context->texture_material);
if (_context->journal)
g_array_free (_context->journal, TRUE);
diff --git a/clutter/cogl/cogl/cogl-context.h b/clutter/cogl/cogl/cogl-context.h
index 54815349a..70bcddd88 100644
--- a/clutter/cogl/cogl/cogl-context.h
+++ b/clutter/cogl/cogl/cogl-context.h
@@ -75,7 +75,8 @@ typedef struct
CoglMaterialFogState legacy_fog_state;
/* Materials */
- CoglMaterial *simple_material;
+ CoglMaterial *simple_material; /* used for set_source_color */
+ CoglMaterial *texture_material; /* used for set_source_texture */
CoglMaterial *source_material;
GString *arbfp_source_buffer;
diff --git a/clutter/cogl/cogl/cogl.c b/clutter/cogl/cogl/cogl.c
index 600572511..7e33cc408 100644
--- a/clutter/cogl/cogl/cogl.c
+++ b/clutter/cogl/cogl/cogl.c
@@ -373,9 +373,6 @@ cogl_set_source_color (const CoglColor *color)
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
- /* In case cogl_set_source_texture was previously used... */
- cogl_material_remove_layer (ctx->simple_material, 0);
-
premultiplied = *color;
cogl_color_premultiply (&premultiplied);
cogl_material_set_color (ctx->simple_material, &premultiplied);
@@ -1041,16 +1038,12 @@ cogl_set_source (CoglHandle material_handle)
void
cogl_set_source_texture (CoglHandle texture_handle)
{
- CoglColor white;
-
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
g_return_if_fail (texture_handle != NULL);
- cogl_material_set_layer (ctx->simple_material, 0, texture_handle);
- cogl_color_init_from_4ub (&white, 0xff, 0xff, 0xff, 0xff);
- cogl_material_set_color (ctx->simple_material, &white);
- cogl_set_source (ctx->simple_material);
+ cogl_material_set_layer (ctx->texture_material, 0, texture_handle);
+ cogl_set_source (ctx->texture_material);
}
void