[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:
parent
c20886c5e3
commit
26f07abc65
@ -671,7 +671,8 @@ cogl_material_set_layer (CoglHandle material_handle,
|
|||||||
int n_layers;
|
int n_layers;
|
||||||
|
|
||||||
g_return_if_fail (cogl_is_material (material_handle));
|
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);
|
material = _cogl_material_pointer_from_handle (material_handle);
|
||||||
layer = _cogl_material_get_layer (material_handle, layer_index, TRUE);
|
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. */
|
* MAX_COMBINED_TEXTURE_IMAGE_UNITS layers. */
|
||||||
}
|
}
|
||||||
|
|
||||||
cogl_handle_ref (texture_handle);
|
if (texture_handle)
|
||||||
|
cogl_handle_ref (texture_handle);
|
||||||
|
|
||||||
if (layer->texture)
|
if (layer->texture)
|
||||||
cogl_handle_unref (layer->texture);
|
cogl_handle_unref (layer->texture);
|
||||||
|
Loading…
Reference in New Issue
Block a user