From e2e2c86f374008fb29a10654ec1f47a6b93da421 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Mon, 21 Nov 2016 12:33:09 +0000 Subject: [PATCH] Scale surface damage events Damage events come in global compositor space, not relative to the surface. For a glTex2D we need the events relatvie to the surface, so they need scaling up Reviewers: #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D3501 --- abstract_egl_backend.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/abstract_egl_backend.cpp b/abstract_egl_backend.cpp index 7ddcb782d5..0d637e757f 100644 --- a/abstract_egl_backend.cpp +++ b/abstract_egl_backend.cpp @@ -356,27 +356,31 @@ void AbstractEglTexture::updateTexture(WindowPixmap *pixmap) q->bind(); const QRegion damage = s->trackedDamage(); s->resetTrackedDamage(); + auto scale = s->scale(); //damage is normalised, so needs converting up to match texture // TODO: this should be shared with GLTexture::update if (GLPlatform::instance()->isGLES()) { if (s_supportsARGB32 && (image.format() == QImage::Format_ARGB32 || image.format() == QImage::Format_ARGB32_Premultiplied)) { const QImage im = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); for (const QRect &rect : damage.rects()) { - glTexSubImage2D(m_target, 0, rect.x(), rect.y(), rect.width(), rect.height(), - GL_BGRA_EXT, GL_UNSIGNED_BYTE, im.copy(rect).bits()); + auto scaledRect = QRect(rect.x() * scale, rect.y() * scale, rect.width() * scale, rect.height() * scale); + glTexSubImage2D(m_target, 0, scaledRect.x(), scaledRect.y(), scaledRect.width(), scaledRect.height(), + GL_BGRA_EXT, GL_UNSIGNED_BYTE, im.copy(scaledRect).bits()); } } else { const QImage im = image.convertToFormat(QImage::Format_RGBA8888_Premultiplied); for (const QRect &rect : damage.rects()) { - glTexSubImage2D(m_target, 0, rect.x(), rect.y(), rect.width(), rect.height(), - GL_RGBA, GL_UNSIGNED_BYTE, im.copy(rect).bits()); + auto scaledRect = QRect(rect.x() * scale, rect.y() * scale, rect.width() * scale, rect.height() * scale); + glTexSubImage2D(m_target, 0, scaledRect.x(), scaledRect.y(), scaledRect.width(), scaledRect.height(), + GL_RGBA, GL_UNSIGNED_BYTE, im.copy(scaledRect).bits()); } } } else { const QImage im = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); for (const QRect &rect : damage.rects()) { - glTexSubImage2D(m_target, 0, rect.x(), rect.y(), rect.width(), rect.height(), - GL_BGRA, GL_UNSIGNED_BYTE, im.copy(rect).bits()); + auto scaledRect = QRect(rect.x() * scale, rect.y() * scale, rect.width() * scale, rect.height() * scale); + glTexSubImage2D(m_target, 0, scaledRect.x(), scaledRect.y(), scaledRect.width(), scaledRect.height(), + GL_BGRA, GL_UNSIGNED_BYTE, im.copy(scaledRect).bits()); } } q->unbind();