From ce0b1507c3f2aaaa0d1919b7b1fa69c30fe12692 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sun, 19 Mar 2023 01:24:33 -0700 Subject: [PATCH] OpenGL: Fix layers not recentering properly when scale is reduced --- src/platform/opengl/gles2.c | 24 ++++++++++++------------ src/platform/qt/DisplayGL.cpp | 2 ++ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/platform/opengl/gles2.c b/src/platform/opengl/gles2.c index 653b863a9..43d9a772b 100644 --- a/src/platform/opengl/gles2.c +++ b/src/platform/opengl/gles2.c @@ -185,26 +185,26 @@ static void mGLES2ContextSetLayerDimensions(struct VideoBackend* v, enum VideoLa if (layer >= VIDEO_LAYER_MAX) { return; } - context->layerDims[layer].x = dims->x; - context->layerDims[layer].y = dims->y; - if (dims->width == context->layerDims[layer].width && dims->height == context->layerDims[layer].height) { - return; - } - context->layerDims[layer].width = dims->width; - context->layerDims[layer].height = dims->height; + if (dims->width != context->layerDims[layer].width && dims->height != context->layerDims[layer].height) { + context->layerDims[layer].width = dims->width; + context->layerDims[layer].height = dims->height; - glBindTexture(GL_TEXTURE_2D, context->tex[layer]); + glBindTexture(GL_TEXTURE_2D, context->tex[layer]); #ifdef COLOR_16_BIT #ifdef COLOR_5_6_5 - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dims->width, dims->height, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 0); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dims->width, dims->height, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 0); #else - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dims->width, dims->height, 0, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 0); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dims->width, dims->height, 0, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 0); #endif #elif defined(__BIG_ENDIAN__) - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dims->width, dims->height, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, 0); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dims->width, dims->height, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, 0); #else - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dims->width, dims->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dims->width, dims->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); #endif + } + + context->layerDims[layer].x = dims->x; + context->layerDims[layer].y = dims->y; unsigned newW; unsigned newH; diff --git a/src/platform/qt/DisplayGL.cpp b/src/platform/qt/DisplayGL.cpp index dc7ad9a86..162160121 100644 --- a/src/platform/qt/DisplayGL.cpp +++ b/src/platform/qt/DisplayGL.cpp @@ -653,6 +653,8 @@ void PainterGL::recenterLayers() { for (VideoLayer l : centeredLayers) { Rectangle dims; m_backend->layerDimensions(m_backend, l, &dims); + dims.x = 0; + dims.y = 0; RectangleUnion(&frame, &dims); } for (VideoLayer l : centeredLayers) {