cogl/texture: Add a is_allocated helper
Reduce the usage of direct access of Texture struct fields, so we can migrate to using macros in the future. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4100>
This commit is contained in:
parent
7d5f1b5898
commit
cc3bf059e6
@ -746,7 +746,7 @@ _cogl_texture_2d_sliced_is_sliced (CoglTexture *tex)
|
|||||||
|
|
||||||
/* It's only after allocating a sliced texture that we will know
|
/* It's only after allocating a sliced texture that we will know
|
||||||
* whether it really needed to be sliced... */
|
* whether it really needed to be sliced... */
|
||||||
if (!tex->allocated)
|
if (!cogl_texture_is_allocated (tex))
|
||||||
cogl_texture_allocate (tex, NULL);
|
cogl_texture_allocate (tex, NULL);
|
||||||
|
|
||||||
if (tex_2ds->slice_x_spans->len != 1 ||
|
if (tex_2ds->slice_x_spans->len != 1 ||
|
||||||
|
@ -337,3 +337,5 @@ cogl_texture_get_max_level_set (CoglTexture *texture);
|
|||||||
void
|
void
|
||||||
cogl_texture_set_max_level_set (CoglTexture *texture,
|
cogl_texture_set_max_level_set (CoglTexture *texture,
|
||||||
int max_level_set);
|
int max_level_set);
|
||||||
|
|
||||||
|
gboolean cogl_texture_is_allocated (CoglTexture *texture);
|
||||||
|
@ -258,7 +258,7 @@ cogl_texture_get_height (CoglTexture *texture)
|
|||||||
CoglPixelFormat
|
CoglPixelFormat
|
||||||
cogl_texture_get_format (CoglTexture *texture)
|
cogl_texture_get_format (CoglTexture *texture)
|
||||||
{
|
{
|
||||||
if (!texture->allocated)
|
if (!cogl_texture_is_allocated (texture))
|
||||||
cogl_texture_allocate (texture, NULL);
|
cogl_texture_allocate (texture, NULL);
|
||||||
|
|
||||||
return COGL_TEXTURE_GET_CLASS (texture)->get_format (texture);
|
return COGL_TEXTURE_GET_CLASS (texture)->get_format (texture);
|
||||||
@ -324,7 +324,7 @@ cogl_texture_is_sliced (CoglTexture *texture)
|
|||||||
{
|
{
|
||||||
g_return_val_if_fail (COGL_IS_TEXTURE (texture), FALSE);
|
g_return_val_if_fail (COGL_IS_TEXTURE (texture), FALSE);
|
||||||
|
|
||||||
if (!texture->allocated)
|
if (!cogl_texture_is_allocated (texture))
|
||||||
cogl_texture_allocate (texture, NULL);
|
cogl_texture_allocate (texture, NULL);
|
||||||
|
|
||||||
return COGL_TEXTURE_GET_CLASS (texture)->is_sliced (texture);
|
return COGL_TEXTURE_GET_CLASS (texture)->is_sliced (texture);
|
||||||
@ -337,7 +337,7 @@ cogl_texture_is_sliced (CoglTexture *texture)
|
|||||||
gboolean
|
gboolean
|
||||||
_cogl_texture_can_hardware_repeat (CoglTexture *texture)
|
_cogl_texture_can_hardware_repeat (CoglTexture *texture)
|
||||||
{
|
{
|
||||||
if (!texture->allocated)
|
if (!cogl_texture_is_allocated (texture))
|
||||||
cogl_texture_allocate (texture, NULL);
|
cogl_texture_allocate (texture, NULL);
|
||||||
return COGL_TEXTURE_GET_CLASS (texture)->can_hardware_repeat (texture);
|
return COGL_TEXTURE_GET_CLASS (texture)->can_hardware_repeat (texture);
|
||||||
}
|
}
|
||||||
@ -349,7 +349,7 @@ cogl_texture_get_gl_texture (CoglTexture *texture,
|
|||||||
{
|
{
|
||||||
g_return_val_if_fail (COGL_IS_TEXTURE (texture), FALSE);
|
g_return_val_if_fail (COGL_IS_TEXTURE (texture), FALSE);
|
||||||
|
|
||||||
if (!texture->allocated)
|
if (!cogl_texture_is_allocated (texture))
|
||||||
cogl_texture_allocate (texture, NULL);
|
cogl_texture_allocate (texture, NULL);
|
||||||
|
|
||||||
return COGL_TEXTURE_GET_CLASS (texture)->get_gl_texture (texture,
|
return COGL_TEXTURE_GET_CLASS (texture)->get_gl_texture (texture,
|
||||||
@ -1100,13 +1100,19 @@ _cogl_texture_set_allocated (CoglTexture *texture,
|
|||||||
_cogl_texture_free_loader (texture);
|
_cogl_texture_free_loader (texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
cogl_texture_is_allocated (CoglTexture *texture)
|
||||||
|
{
|
||||||
|
return texture->allocated;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
cogl_texture_allocate (CoglTexture *texture,
|
cogl_texture_allocate (CoglTexture *texture,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (COGL_IS_TEXTURE (texture), FALSE);
|
g_return_val_if_fail (COGL_IS_TEXTURE (texture), FALSE);
|
||||||
|
|
||||||
if (texture->allocated)
|
if (cogl_texture_is_allocated (texture))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if (texture->components == COGL_TEXTURE_COMPONENTS_RG &&
|
if (texture->components == COGL_TEXTURE_COMPONENTS_RG &&
|
||||||
@ -1220,7 +1226,7 @@ cogl_texture_set_components (CoglTexture *texture,
|
|||||||
CoglTextureComponents components)
|
CoglTextureComponents components)
|
||||||
{
|
{
|
||||||
g_return_if_fail (COGL_IS_TEXTURE (texture));
|
g_return_if_fail (COGL_IS_TEXTURE (texture));
|
||||||
g_return_if_fail (!texture->allocated);
|
g_return_if_fail (!cogl_texture_is_allocated (texture));
|
||||||
|
|
||||||
if (texture->components == components)
|
if (texture->components == components)
|
||||||
return;
|
return;
|
||||||
@ -1241,7 +1247,7 @@ cogl_texture_set_premultiplied (CoglTexture *texture,
|
|||||||
gboolean premultiplied)
|
gboolean premultiplied)
|
||||||
{
|
{
|
||||||
g_return_if_fail (COGL_IS_TEXTURE (texture));
|
g_return_if_fail (COGL_IS_TEXTURE (texture));
|
||||||
g_return_if_fail (!texture->allocated);
|
g_return_if_fail (!cogl_texture_is_allocated (texture));
|
||||||
|
|
||||||
premultiplied = !!premultiplied;
|
premultiplied = !!premultiplied;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user