mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 00:20:42 -05:00
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.
This commit is contained in:
parent
89cedc7800
commit
65d7a113ee
@ -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->arbfp_source_buffer = g_string_new ("");
|
||||
_context->source_stack = NULL;
|
||||
|
||||
@ -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);
|
||||
|
@ -83,7 +83,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 */
|
||||
GString *arbfp_source_buffer;
|
||||
GList *source_stack;
|
||||
|
||||
|
@ -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);
|
||||
@ -1058,16 +1055,12 @@ cogl_set_source (CoglMaterial *material)
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user