[mutter/gnome-3-36] cogl: Generalize `maybe_update_max_level()` into `set_max_level()`
- From: Robert Mader <rmader src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gnome-3-36] cogl: Generalize `maybe_update_max_level()` into `set_max_level()`
- Date: Mon, 31 Aug 2020 20:18:38 +0000 (UTC)
commit ed22b33968fc64ea46210cd72e678f05d1eb4ce8
Author: Daniel van Vugt <daniel van vugt canonical com>
Date: Thu Apr 16 17:18:46 2020 +0800
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
(cherry picked from commit f4301b77faf570252f65f9a77d2144ca222b8056)
cogl/cogl/cogl-texture-private.h | 2 +-
cogl/cogl/cogl-texture.c | 2 +-
cogl/cogl/driver/gl/cogl-texture-2d-gl.c | 3 ++-
cogl/cogl/driver/gl/cogl-texture-gl-private.h | 4 ++--
cogl/cogl/driver/gl/cogl-texture-gl.c | 14 +++++++-------
cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c | 2 +-
cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c | 2 +-
7 files changed, 15 insertions(+), 14 deletions(-)
---
diff --git a/cogl/cogl/cogl-texture-private.h b/cogl/cogl/cogl-texture-private.h
index 69d7ebd4a1..c6a00ca0ef 100644
--- a/cogl/cogl/cogl-texture-private.h
+++ b/cogl/cogl/cogl-texture-private.h
@@ -204,7 +204,7 @@ struct _CoglTexture
CoglContext *context;
CoglTextureLoader *loader;
GList *framebuffers;
- int max_level;
+ int max_level_set;
int width;
int height;
gboolean allocated;
diff --git a/cogl/cogl/cogl-texture.c b/cogl/cogl/cogl-texture.c
index 587088c971..5c9848d68d 100644
--- a/cogl/cogl/cogl-texture.c
+++ b/cogl/cogl/cogl-texture.c
@@ -115,7 +115,7 @@ _cogl_texture_init (CoglTexture *texture,
const CoglTextureVtable *vtable)
{
texture->context = context;
- texture->max_level = 0;
+ texture->max_level_set = 0;
texture->width = width;
texture->height = height;
texture->allocated = FALSE;
diff --git a/cogl/cogl/driver/gl/cogl-texture-2d-gl.c b/cogl/cogl/driver/gl/cogl-texture-2d-gl.c
index 749c9941fc..d602de2c87 100644
--- a/cogl/cogl/driver/gl/cogl-texture-2d-gl.c
+++ b/cogl/cogl/driver/gl/cogl-texture-2d-gl.c
@@ -567,7 +567,8 @@ _cogl_texture_2d_gl_copy_from_bitmap (CoglTexture2D *tex_2d,
&gl_format,
&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,
tex,
diff --git a/cogl/cogl/driver/gl/cogl-texture-gl-private.h b/cogl/cogl/driver/gl/cogl-texture-gl-private.h
index 70e79998d2..a8fbd28661 100644
--- a/cogl/cogl/driver/gl/cogl-texture-gl-private.h
+++ b/cogl/cogl/driver/gl/cogl-texture-gl-private.h
@@ -53,8 +53,8 @@ _cogl_texture_gl_flush_legacy_texobj_filters (CoglTexture *texture,
unsigned int mag_filter);
void
-_cogl_texture_gl_maybe_update_max_level (CoglTexture *texture,
- int max_level);
+cogl_texture_gl_set_max_level (CoglTexture *texture,
+ int max_level);
void
_cogl_texture_gl_generate_mipmaps (CoglTexture *texture);
diff --git a/cogl/cogl/driver/gl/cogl-texture-gl.c b/cogl/cogl/driver/gl/cogl-texture-gl.c
index f365fc90b7..25a8537c95 100644
--- a/cogl/cogl/driver/gl/cogl-texture-gl.c
+++ b/cogl/cogl/driver/gl/cogl-texture-gl.c
@@ -107,26 +107,25 @@ _cogl_texture_gl_flush_legacy_texobj_filters (CoglTexture *texture,
#endif
void
-_cogl_texture_gl_maybe_update_max_level (CoglTexture *texture,
- int max_level)
+cogl_texture_gl_set_max_level (CoglTexture *texture,
+ int max_level)
{
CoglContext *ctx = texture->context;
- if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_TEXTURE_MAX_LEVEL) &&
- texture->max_level < max_level)
+ if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_TEXTURE_MAX_LEVEL))
{
GLuint gl_handle;
GLenum 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,
gl_handle);
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;
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);
diff --git a/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c
index 5b33a0a259..35c10c2d6d 100644
--- a/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c
+++ b/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c
@@ -255,7 +255,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
* glTexImage2D first to assert that the storage for this
* level exists.
*/
- if (texture->max_level < level)
+ if (texture->max_level_set < level)
{
ctx->glTexImage2D (gl_target,
level,
diff --git a/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c
b/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c
index 01653bc87e..f3cf3831e6 100644
--- a/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c
+++ b/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c
@@ -303,7 +303,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
* glTexImage2D first to assert that the storage for this
* level exists.
*/
- if (texture->max_level < level)
+ if (texture->max_level_set < level)
{
ctx->glTexImage2D (gl_target,
level,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]