diff options
author | Simon Ser <contact@emersion.fr> | 2021-07-11 19:44:57 +0200 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2021-07-12 09:16:09 -0400 |
commit | 55449738142d41b8e0f7c21f086d85c6570e3dad (patch) | |
tree | 44973e014f747d64825840baca7d71ceac94a029 | |
parent | 9dba176e8d0ceee456de2aa9ac91908b740628e2 (diff) |
render/gles2: disable blending opportunistically
We don't always need to enable blending: when the texture doesn't
have alpha or when the color is opaque, we can disable it.
-rw-r--r-- | render/gles2/renderer.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index 0e6109ab..6317399f 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -204,8 +204,6 @@ static void gles2_begin(struct wlr_renderer *wlr_renderer, uint32_t width, wlr_matrix_projection(renderer->projection, width, height, WL_OUTPUT_TRANSFORM_NORMAL); - // enable transparency - glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); // XXX: maybe we should save output projection and remove some of the need @@ -294,6 +292,12 @@ static bool gles2_render_subtexture_with_matrix( push_gles2_debug(renderer); + if (!texture->has_alpha && alpha == 1.0) { + glDisable(GL_BLEND); + } else { + glEnable(GL_BLEND); + } + glActiveTexture(GL_TEXTURE0); glBindTexture(texture->target, texture->tex); @@ -348,6 +352,13 @@ static void gles2_render_quad_with_matrix(struct wlr_renderer *wlr_renderer, wlr_matrix_transpose(gl_matrix, gl_matrix); push_gles2_debug(renderer); + + if (color[3] == 1.0) { + glDisable(GL_BLEND); + } else { + glEnable(GL_BLEND); + } + glUseProgram(renderer->shaders.quad.program); glUniformMatrix3fv(renderer->shaders.quad.proj, 1, GL_FALSE, gl_matrix); |