[cogl-material] Allow setting a layer with an invalid texture handle

It was previously possible to create a material layer with no texture
by setting some property on it such as the matrix. However it was not
possible to get back to that state without removing the layer and
recreating it. It is useful to be able to remove the texture to free
resources without forgetting the state of the layer so we can put a
different texture in later.
This commit is contained in:
Neil Roberts 2009-06-03 15:22:42 +01:00
parent 8909d6a129
commit b7c8f8111e

View File

@ -671,7 +671,8 @@ cogl_material_set_layer (CoglHandle material_handle,
int n_layers;
g_return_if_fail (cogl_is_material (material_handle));
g_return_if_fail (cogl_is_texture (texture_handle));
g_return_if_fail (texture_handle == COGL_INVALID_HANDLE
|| cogl_is_texture (texture_handle));
material = _cogl_material_pointer_from_handle (material_handle);
layer = _cogl_material_get_layer (material_handle, layer_index, TRUE);
@ -692,7 +693,8 @@ cogl_material_set_layer (CoglHandle material_handle,
* MAX_COMBINED_TEXTURE_IMAGE_UNITS layers. */
}
cogl_handle_ref (texture_handle);
if (texture_handle)
cogl_handle_ref (texture_handle);
if (layer->texture)
cogl_handle_unref (layer->texture);