From dc09fca2649d11d7c080b3c859b2996e1911f9f5 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Wed, 9 Jun 2010 13:53:34 +0100 Subject: [PATCH] cogl-material: Fix the function which sets the enable blend flag This function had two problems. Firstly it would clear the enable blend flag before calling pre_change_notify so that if blending was previously enabled the journal would end up being flushed while the flag was still cleared. Secondly it would call the pre change notify whenever blending is needed regardless of whether it was already needed previously. This was causing problems in test-depth. --- clutter/cogl/cogl/cogl-material.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/clutter/cogl/cogl/cogl-material.c b/clutter/cogl/cogl/cogl-material.c index fce85439f..c4715ba9c 100644 --- a/clutter/cogl/cogl/cogl-material.c +++ b/clutter/cogl/cogl/cogl-material.c @@ -359,14 +359,19 @@ _cogl_material_pre_change_notify (CoglMaterial *material, static void handle_automatic_blend_enable (CoglMaterial *material) { - material->flags &= ~COGL_MATERIAL_FLAG_ENABLE_BLEND; + gboolean needs_blending_enabled = + _cogl_material_needs_blending_enabled (material, NULL); - if (_cogl_material_needs_blending_enabled (material, NULL)) + if (needs_blending_enabled != + !!(material->flags & COGL_MATERIAL_FLAG_ENABLE_BLEND)) { _cogl_material_pre_change_notify (material, COGL_MATERIAL_CHANGE_ENABLE_BLEND, NULL); - material->flags |= COGL_MATERIAL_FLAG_ENABLE_BLEND; + if (needs_blending_enabled) + material->flags |= COGL_MATERIAL_FLAG_ENABLE_BLEND; + else + material->flags &= ~COGL_MATERIAL_FLAG_ENABLE_BLEND; } }