summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/winrt/qwinrtbackingstore.cpp
diff options
context:
space:
mode:
authorAndrew Knight <andrew.knight@digia.com>2014-05-22 08:54:14 +0300
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-22 07:59:49 +0200
commiteea02ff10da0ff6bba665df560c5404477b9f550 (patch)
tree4222b91ae33f9ce1337ec276951d468d9cecf563 /src/plugins/platforms/winrt/qwinrtbackingstore.cpp
parentc32295eb8008c01b422fc04839b22e914786704f (diff)
WinRT: Support High-DPI
Previously, the backing store and default framebuffer were created with the logical screen resolution (in device-independent pixels), not the the physical screen resolution. This lead to blurry text on high-DPI devices. This change fixes this by creating those at full size, and setting the device pixel ratio appropriately. Windows are still reported in device-independent pixels, but text and images are now rendered sharply for Qt Quick applications. As QPainter does not support non-integer scaling, the backing store is still drawn in DIPs and scaled by OpenGL. Task-number: QTBUG-38464 Change-Id: I7377d4c734126825d670b8ebb65fd0dd1ef705f2 Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
Diffstat (limited to 'src/plugins/platforms/winrt/qwinrtbackingstore.cpp')
-rw-r--r--src/plugins/platforms/winrt/qwinrtbackingstore.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/plugins/platforms/winrt/qwinrtbackingstore.cpp b/src/plugins/platforms/winrt/qwinrtbackingstore.cpp
index 9b623048af..b8418eef6a 100644
--- a/src/plugins/platforms/winrt/qwinrtbackingstore.cpp
+++ b/src/plugins/platforms/winrt/qwinrtbackingstore.cpp
@@ -284,7 +284,7 @@ QWinRTBackingStore::~QWinRTBackingStore()
QPaintDevice *QWinRTBackingStore::paintDevice()
{
- return m_paintDevice.data();
+ return &m_paintDevice;
}
void QWinRTBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
@@ -293,8 +293,6 @@ void QWinRTBackingStore::flush(QWindow *window, const QRegion &region, const QPo
if (m_size.isEmpty())
return;
- const QImage *image = static_cast<QImage *>(m_paintDevice.data());
-
m_context->makeCurrent(window);
// Blitting the entire image width trades zero image copy/relayout for a larger texture upload.
@@ -307,7 +305,7 @@ void QWinRTBackingStore::flush(QWindow *window, const QRegion &region, const QPo
glBindTexture(GL_TEXTURE_2D, m_texture);
QRect bounds = region.boundingRect();
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, bounds.y(), m_size.width(), bounds.height(),
- GL_BGRA_EXT, GL_UNSIGNED_BYTE, image->scanLine(bounds.y()));
+ GL_BGRA_EXT, GL_UNSIGNED_BYTE, m_paintDevice.constScanLine(bounds.y()));
// TODO: Implement GL_EXT_unpack_subimage in ANGLE for more minimal uploads
//glPixelStorei(GL_UNPACK_ROW_LENGTH, image->bytesPerLine());
//glTexSubImage2D(GL_TEXTURE_2D, 0, bounds.x(), bounds.y(), bounds.width(), bounds.height(),
@@ -325,7 +323,8 @@ void QWinRTBackingStore::flush(QWindow *window, const QRegion &region, const QPo
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, quadCoords);
// Render
- glViewport(0, 0, m_size.width(), m_size.height());
+ const QSize blitSize = m_size * window->devicePixelRatio();
+ glViewport(0, 0, blitSize.width(), blitSize.height());
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
// Unbind
@@ -338,8 +337,8 @@ void QWinRTBackingStore::flush(QWindow *window, const QRegion &region, const QPo
// fast blit - TODO: perform the blit inside swap buffers instead
glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, m_fbo);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, 0);
- glBlitFramebufferANGLE(0, 0, m_size.width(), m_size.height(), // TODO: blit only the changed rectangle
- 0, 0, m_size.width(), m_size.height(),
+ glBlitFramebufferANGLE(0, 0, blitSize.width(), blitSize.height(), // TODO: blit only the changed rectangle
+ 0, 0, blitSize.width(), blitSize.height(),
GL_COLOR_BUFFER_BIT, GL_NEAREST);
m_context->swapBuffers(window);
@@ -359,21 +358,22 @@ void QWinRTBackingStore::resize(const QSize &size, const QRegion &staticContents
if (m_size.isEmpty())
return;
- m_paintDevice.reset(new QImage(m_size, QImage::Format_ARGB32_Premultiplied));
+ m_paintDevice = QImage(m_size, QImage::Format_ARGB32_Premultiplied);
m_context->makeCurrent(window());
// Input texture
glBindTexture(GL_TEXTURE_2D, m_texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, m_size.width(), m_size.height(),
0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, NULL);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glBindTexture(GL_TEXTURE_2D, 0);
// Render buffer
glBindRenderbuffer(GL_RENDERBUFFER, m_rbo);
- glRenderbufferStorage(GL_RENDERBUFFER, GL_BGRA8_EXT, m_size.width(), m_size.height());
+ const QSize blitSize = m_size * window()->devicePixelRatio();
+ glRenderbufferStorage(GL_RENDERBUFFER, GL_BGRA8_EXT, blitSize.width(), blitSize.height());
glBindRenderbuffer(GL_RENDERBUFFER, 0);
m_context->doneCurrent();
}