mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 19:42:05 +00:00
[cogl] Ensure well defined semantics for COGL_INVALID_HANDLE material layers
Fixes and adds a unit test for creating and drawing using materials with COGL_INVALID_HANDLE texture layers. This may be valid if for example the user has set a texture combine string that only references a constant color. _cogl_material_flush_layers_gl_state will bind the fallback texture for any COGL_INVALID_HANDLE layer, later though we could explicitly check when the current blend mode does't actually reference a texture source in which case binding the fallback texture is redundant. This tests drawing using cogl_rectangle, cogl_polygon and cogl_vertex_buffer_draw.
This commit is contained in:
parent
4d55d146b3
commit
fdc048ddd0
@ -1336,7 +1336,13 @@ _cogl_material_flush_layers_gl_state (CoglMaterial *material,
|
||||
(disable_mask & (1<<i)) ? TRUE : FALSE;
|
||||
|
||||
tex_handle = layer->texture;
|
||||
cogl_texture_get_gl_texture (tex_handle, &gl_texture, &gl_target);
|
||||
if (tex_handle != COGL_INVALID_HANDLE)
|
||||
cogl_texture_get_gl_texture (tex_handle, &gl_texture, &gl_target);
|
||||
else
|
||||
{
|
||||
new_gl_layer_info.fallback = TRUE;
|
||||
gl_target = GL_TEXTURE_2D;
|
||||
}
|
||||
|
||||
if (new_gl_layer_info.layer0_overridden)
|
||||
gl_texture = layer0_override_texture;
|
||||
|
@ -942,7 +942,6 @@ _cogl_multitexture_unsliced_quad (float x_1,
|
||||
for (tmp = (GList *)layers, i = 0; tmp != NULL; tmp = tmp->next, i++)
|
||||
{
|
||||
CoglHandle layer = (CoglHandle)tmp->data;
|
||||
/* CoglLayerInfo *layer_info; */
|
||||
CoglHandle tex_handle;
|
||||
CoglTexture *tex;
|
||||
const float *in_tex_coords;
|
||||
@ -950,12 +949,13 @@ _cogl_multitexture_unsliced_quad (float x_1,
|
||||
CoglTexSliceSpan *x_span;
|
||||
CoglTexSliceSpan *y_span;
|
||||
|
||||
/* layer_info = &layers[i]; */
|
||||
|
||||
/* FIXME - we shouldn't be checking this stuff if layer_info->gl_texture
|
||||
* already == 0 */
|
||||
|
||||
tex_handle = cogl_material_layer_get_texture (layer);
|
||||
|
||||
/* COGL_INVALID_HANDLE textures are handled by
|
||||
* _cogl_material_flush_gl_state */
|
||||
if (tex_handle == COGL_INVALID_HANDLE)
|
||||
continue;
|
||||
|
||||
tex = _cogl_texture_pointer_from_handle (tex_handle);
|
||||
|
||||
in_tex_coords = &user_tex_coords[i * 4];
|
||||
@ -1131,14 +1131,23 @@ _cogl_rectangles_with_multitexture_coords (
|
||||
for (tmp = layers, i = 0; tmp != NULL; tmp = tmp->next, i++)
|
||||
{
|
||||
CoglHandle layer = tmp->data;
|
||||
CoglHandle tex_handle = cogl_material_layer_get_texture (layer);
|
||||
CoglTexture *texture = _cogl_texture_pointer_from_handle (tex_handle);
|
||||
CoglHandle tex_handle;
|
||||
CoglTexture *texture = NULL;
|
||||
gulong flags;
|
||||
|
||||
if (cogl_material_layer_get_type (layer)
|
||||
!= COGL_MATERIAL_LAYER_TYPE_TEXTURE)
|
||||
continue;
|
||||
|
||||
tex_handle = cogl_material_layer_get_texture (layer);
|
||||
|
||||
/* COGL_INVALID_HANDLE textures are handled by
|
||||
* _cogl_material_flush_gl_state */
|
||||
if (tex_handle == COGL_INVALID_HANDLE)
|
||||
continue;
|
||||
|
||||
texture = _cogl_texture_pointer_from_handle (tex_handle);
|
||||
|
||||
/* XXX:
|
||||
* For now, if the first layer is sliced then all other layers are
|
||||
* ignored since we currently don't support multi-texturing with
|
||||
@ -1503,6 +1512,13 @@ _cogl_multitexture_unsliced_polygon (CoglTextureVertex *vertices,
|
||||
float tx, ty;
|
||||
|
||||
tex_handle = cogl_material_layer_get_texture (layer);
|
||||
|
||||
/* COGL_INVALID_HANDLE textures will be handled in
|
||||
* _cogl_material_flush_layers_gl_state but there is no need to worry
|
||||
* about scaling texture coordinates in this case */
|
||||
if (tex_handle == COGL_INVALID_HANDLE)
|
||||
continue;
|
||||
|
||||
tex = _cogl_texture_pointer_from_handle (tex_handle);
|
||||
|
||||
y_span = &g_array_index (tex->slice_y_spans, CoglTexSliceSpan, 0);
|
||||
@ -1585,6 +1601,11 @@ cogl_polygon (CoglTextureVertex *vertices,
|
||||
CoglHandle layer = (CoglHandle)tmp->data;
|
||||
CoglHandle tex_handle = cogl_material_layer_get_texture (layer);
|
||||
|
||||
/* COGL_INVALID_HANDLE textures will be handled in
|
||||
* _cogl_material_flush_layers_gl_state */
|
||||
if (tex_handle == COGL_INVALID_HANDLE)
|
||||
continue;
|
||||
|
||||
if (i == 0 && cogl_texture_is_sliced (tex_handle))
|
||||
{
|
||||
#if defined (HAVE_COGL_GLES) || defined (HAVE_COGL_GLES2)
|
||||
|
@ -1618,8 +1618,14 @@ enable_state_for_drawing_buffer (CoglVertexBuffer *buffer)
|
||||
{
|
||||
CoglHandle layer = (CoglHandle)tmp->data;
|
||||
CoglHandle tex_handle = cogl_material_layer_get_texture (layer);
|
||||
CoglTexture *texture =
|
||||
_cogl_texture_pointer_from_handle (tex_handle);
|
||||
CoglTexture *texture;
|
||||
|
||||
/* invalid textures will be handled correctly in
|
||||
* _cogl_material_flush_layers_gl_state */
|
||||
if (tex_handle == COGL_INVALID_HANDLE)
|
||||
continue;
|
||||
|
||||
texture = _cogl_texture_pointer_from_handle (tex_handle);
|
||||
|
||||
if (cogl_texture_is_sliced (tex_handle)
|
||||
|| _cogl_texture_span_has_waste (texture, 0, 0))
|
||||
|
Loading…
Reference in New Issue
Block a user