diff options
author | Andrew Knight <andrew.knight@digia.com> | 2014-08-27 16:23:28 +0300 |
---|---|---|
committer | Andrew Knight <andrew.knight@digia.com> | 2014-09-01 18:08:43 +0200 |
commit | 1cdcf64ad5c0f42d23ad1a53c965df5c69a6bb4b (patch) | |
tree | 1aba794e7125cea85e14376b1c078221fe283204 /src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.cpp | |
parent | fc3acdd9d2766637e0410f7de83b63116df7e053 (diff) |
direct2d: Fix translucent/frameless window rendering
When using WA_TranslucentBackground/FramelessWindowHint, the backing
store must paint to an offscreen texture instead of the swap chain in
order to achieve the desired results. This texture is then presented to
the screen using UpdateLayeredWindowIndirect().
As the swap chain is not needed in this mode, its construction is skipped
if indirect rendering is active.
Furthermore, the layering options were updated to fix an issue with
transparent layers overpainting the background. The layer options were
switched to D2D1_LAYER_OPTIONS1_NONE, which appears to work for both
translucent and non-translucent rendering modes.
Task-number: QTBUG-40601
Change-Id: I656f7cdfb424d1eda6f82c2c69500e78d8c1726a
Reviewed-by: Louai Al-Khanji <louai.al-khanji@digia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.cpp')
-rw-r--r-- | src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.cpp index be013f027b..59b543e6d5 100644 --- a/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.cpp +++ b/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.cpp @@ -49,6 +49,7 @@ #include "qwindowscontext.h" +#include <QtGui/QPainter> #include <QtGui/QWindow> #include <QtCore/QDebug> @@ -85,9 +86,18 @@ QWindowsDirect2DBackingStore::~QWindowsDirect2DBackingStore() { } -void QWindowsDirect2DBackingStore::beginPaint(const QRegion &) +void QWindowsDirect2DBackingStore::beginPaint(const QRegion ®ion) { - bitmap(nativeWindow(window())->pixmap())->deviceContext()->begin(); + QPixmap *pixmap = nativeWindow(window())->pixmap(); + bitmap(pixmap)->deviceContext()->begin(); + + QPainter painter(pixmap); + QColor clear(Qt::transparent); + + painter.setCompositionMode(QPainter::CompositionMode_Source); + + foreach (const QRect &r, region.rects()) + painter.fillRect(r, clear); } void QWindowsDirect2DBackingStore::endPaint() @@ -107,7 +117,7 @@ void QWindowsDirect2DBackingStore::flush(QWindow *targetWindow, const QRegion &r nativeWindow(targetWindow)->flush(copy.data(), region, offset); } - nativeWindow(targetWindow)->present(); + nativeWindow(targetWindow)->present(region); } void QWindowsDirect2DBackingStore::resize(const QSize &size, const QRegion ®ion) |