aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Edmundson <[email protected]>2016-11-21 12:33:09 +0000
committerDavid Edmundson <[email protected]>2017-03-29 20:53:22 +0100
commite2e2c86f374008fb29a10654ec1f47a6b93da421 (patch)
treeb5bf7cb1a148d54d27f5be38d0386a04ac34b5ad
parentbd1d88359f39e8fcf46e082668c44b4f579d05cf (diff)
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
-rw-r--r--abstract_egl_backend.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/abstract_egl_backend.cpp b/abstract_egl_backend.cpp
index 7ddcb78..0d637e7 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();