From aa6731e338a88d03e718980604ac8f2393391a9f Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Mon, 1 Feb 2010 13:25:19 +0000 Subject: [PATCH] cogl-material: Compare GL texture numbers for material layer textures When deciding if a material layer is equal it now compares the GL target and texture number if the textures are not sliced. This is needed to get batching across atlased textures. --- clutter/cogl/cogl/cogl-material.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/clutter/cogl/cogl/cogl-material.c b/clutter/cogl/cogl/cogl-material.c index 35e898f..589a753 100644 --- a/clutter/cogl/cogl/cogl-material.c +++ b/clutter/cogl/cogl/cogl-material.c @@ -1713,12 +1713,35 @@ _cogl_material_flush_gl_state (CoglHandle handle, } static gboolean +_cogl_material_texture_equal (CoglHandle texture0, CoglHandle texture1) +{ + GLenum gl_handle0, gl_handle1, gl_target0, gl_target1; + + /* If the texture handles are the same then the textures are + definitely equal */ + if (texture0 == texture1) + return TRUE; + + /* If neither texture is sliced then they could still be the same if + the are referring to the same GL texture */ + if (cogl_texture_is_sliced (texture0) || + cogl_texture_is_sliced (texture1)) + return FALSE; + + cogl_texture_get_gl_texture (texture0, &gl_handle0, &gl_target0); + cogl_texture_get_gl_texture (texture1, &gl_handle1, &gl_target1); + + return gl_handle0 == gl_handle1 && gl_target0 == gl_target1; +} + +static gboolean _cogl_material_layer_equal (CoglMaterialLayer *material0_layer, CoglHandle material0_layer_texture, CoglMaterialLayer *material1_layer, CoglHandle material1_layer_texture) { - if (material0_layer_texture != material1_layer_texture) + if (!_cogl_material_texture_equal (material0_layer_texture, + material1_layer_texture)) return FALSE; if ((material0_layer->flags & COGL_MATERIAL_LAYER_FLAG_DEFAULT_COMBINE) != -- 2.7.4