OpenGL: Fix layers not recentering properly when scale is reduced

This commit is contained in:
Vicki Pfau 2023-03-19 01:24:33 -07:00
parent 44fb887737
commit ce0b1507c3
2 changed files with 14 additions and 12 deletions

View File

@ -185,26 +185,26 @@ static void mGLES2ContextSetLayerDimensions(struct VideoBackend* v, enum VideoLa
if (layer >= VIDEO_LAYER_MAX) { if (layer >= VIDEO_LAYER_MAX) {
return; return;
} }
context->layerDims[layer].x = dims->x; if (dims->width != context->layerDims[layer].width && dims->height != context->layerDims[layer].height) {
context->layerDims[layer].y = dims->y; context->layerDims[layer].width = dims->width;
if (dims->width == context->layerDims[layer].width && dims->height == context->layerDims[layer].height) { context->layerDims[layer].height = dims->height;
return;
}
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_16_BIT
#ifdef COLOR_5_6_5 #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 #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 #endif
#elif defined(__BIG_ENDIAN__) #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 #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 #endif
}
context->layerDims[layer].x = dims->x;
context->layerDims[layer].y = dims->y;
unsigned newW; unsigned newW;
unsigned newH; unsigned newH;

View File

@ -653,6 +653,8 @@ void PainterGL::recenterLayers() {
for (VideoLayer l : centeredLayers) { for (VideoLayer l : centeredLayers) {
Rectangle dims; Rectangle dims;
m_backend->layerDimensions(m_backend, l, &dims); m_backend->layerDimensions(m_backend, l, &dims);
dims.x = 0;
dims.y = 0;
RectangleUnion(&frame, &dims); RectangleUnion(&frame, &dims);
} }
for (VideoLayer l : centeredLayers) { for (VideoLayer l : centeredLayers) {