cogl: Generalize maybe_update_max_level()
into set_max_level()
This way the caller can choose their own precondition. https://gitlab.gnome.org/GNOME/mutter/merge_requests/1003
This commit is contained in:
parent
a3f27dfd89
commit
f4301b77fa
@ -204,7 +204,7 @@ struct _CoglTexture
|
|||||||
CoglContext *context;
|
CoglContext *context;
|
||||||
CoglTextureLoader *loader;
|
CoglTextureLoader *loader;
|
||||||
GList *framebuffers;
|
GList *framebuffers;
|
||||||
int max_level;
|
int max_level_set;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
gboolean allocated;
|
gboolean allocated;
|
||||||
|
@ -115,7 +115,7 @@ _cogl_texture_init (CoglTexture *texture,
|
|||||||
const CoglTextureVtable *vtable)
|
const CoglTextureVtable *vtable)
|
||||||
{
|
{
|
||||||
texture->context = context;
|
texture->context = context;
|
||||||
texture->max_level = 0;
|
texture->max_level_set = 0;
|
||||||
texture->width = width;
|
texture->width = width;
|
||||||
texture->height = height;
|
texture->height = height;
|
||||||
texture->allocated = FALSE;
|
texture->allocated = FALSE;
|
||||||
|
@ -567,7 +567,8 @@ _cogl_texture_2d_gl_copy_from_bitmap (CoglTexture2D *tex_2d,
|
|||||||
&gl_format,
|
&gl_format,
|
||||||
&gl_type);
|
&gl_type);
|
||||||
|
|
||||||
_cogl_texture_gl_maybe_update_max_level (tex, level);
|
if (tex->max_level_set < level)
|
||||||
|
cogl_texture_gl_set_max_level (tex, level);
|
||||||
|
|
||||||
status = ctx->texture_driver->upload_subregion_to_gl (ctx,
|
status = ctx->texture_driver->upload_subregion_to_gl (ctx,
|
||||||
tex,
|
tex,
|
||||||
|
@ -53,8 +53,8 @@ _cogl_texture_gl_flush_legacy_texobj_filters (CoglTexture *texture,
|
|||||||
unsigned int mag_filter);
|
unsigned int mag_filter);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_texture_gl_maybe_update_max_level (CoglTexture *texture,
|
cogl_texture_gl_set_max_level (CoglTexture *texture,
|
||||||
int max_level);
|
int max_level);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_texture_gl_generate_mipmaps (CoglTexture *texture);
|
_cogl_texture_gl_generate_mipmaps (CoglTexture *texture);
|
||||||
|
@ -107,26 +107,25 @@ _cogl_texture_gl_flush_legacy_texobj_filters (CoglTexture *texture,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_texture_gl_maybe_update_max_level (CoglTexture *texture,
|
cogl_texture_gl_set_max_level (CoglTexture *texture,
|
||||||
int max_level)
|
int max_level)
|
||||||
{
|
{
|
||||||
CoglContext *ctx = texture->context;
|
CoglContext *ctx = texture->context;
|
||||||
|
|
||||||
if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_TEXTURE_MAX_LEVEL) &&
|
if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_TEXTURE_MAX_LEVEL))
|
||||||
texture->max_level < max_level)
|
|
||||||
{
|
{
|
||||||
GLuint gl_handle;
|
GLuint gl_handle;
|
||||||
GLenum gl_target;
|
GLenum gl_target;
|
||||||
|
|
||||||
cogl_texture_get_gl_texture (texture, &gl_handle, &gl_target);
|
cogl_texture_get_gl_texture (texture, &gl_handle, &gl_target);
|
||||||
|
|
||||||
texture->max_level = max_level;
|
texture->max_level_set = max_level;
|
||||||
|
|
||||||
_cogl_bind_gl_texture_transient (gl_target,
|
_cogl_bind_gl_texture_transient (gl_target,
|
||||||
gl_handle);
|
gl_handle);
|
||||||
|
|
||||||
GE( ctx, glTexParameteri (gl_target,
|
GE( ctx, glTexParameteri (gl_target,
|
||||||
GL_TEXTURE_MAX_LEVEL, texture->max_level));
|
GL_TEXTURE_MAX_LEVEL, texture->max_level_set));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +137,8 @@ _cogl_texture_gl_generate_mipmaps (CoglTexture *texture)
|
|||||||
GLuint gl_handle;
|
GLuint gl_handle;
|
||||||
GLenum gl_target;
|
GLenum gl_target;
|
||||||
|
|
||||||
_cogl_texture_gl_maybe_update_max_level (texture, n_levels - 1);
|
if (texture->max_level_set < n_levels - 1)
|
||||||
|
cogl_texture_gl_set_max_level (texture, n_levels - 1);
|
||||||
|
|
||||||
cogl_texture_get_gl_texture (texture, &gl_handle, &gl_target);
|
cogl_texture_get_gl_texture (texture, &gl_handle, &gl_target);
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
|
|||||||
* glTexImage2D first to assert that the storage for this
|
* glTexImage2D first to assert that the storage for this
|
||||||
* level exists.
|
* level exists.
|
||||||
*/
|
*/
|
||||||
if (texture->max_level < level)
|
if (texture->max_level_set < level)
|
||||||
{
|
{
|
||||||
ctx->glTexImage2D (gl_target,
|
ctx->glTexImage2D (gl_target,
|
||||||
level,
|
level,
|
||||||
|
@ -303,7 +303,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
|
|||||||
* glTexImage2D first to assert that the storage for this
|
* glTexImage2D first to assert that the storage for this
|
||||||
* level exists.
|
* level exists.
|
||||||
*/
|
*/
|
||||||
if (texture->max_level < level)
|
if (texture->max_level_set < level)
|
||||||
{
|
{
|
||||||
ctx->glTexImage2D (gl_target,
|
ctx->glTexImage2D (gl_target,
|
||||||
level,
|
level,
|
||||||
|
Loading…
Reference in New Issue
Block a user