Direct2D QPA: Speed up widget painting

By only starting/ending drawing once in the backing store, we can avoid
multiple start/ends and thus flushes of the direct2d device context. This
can potentially be much faster with some drivers when many widgets that
draw to the same backing store need to redraw. Because starts/ends of
QWindowsDirect2DDeviceContext are already refcounted this works out of the
box.

Change-Id: Ib48edceef6a1041ae0509587c77ac0caa8b29fc6
Reviewed-by: Risto Avila <risto.avila@digia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
Louai Al-Khanji 2014-04-28 08:32:17 +03:00 committed by The Qt Project
parent 774082e2ee
commit 81fde3a976
2 changed files with 13 additions and 0 deletions

View File

@ -75,6 +75,16 @@ QWindowsDirect2DBackingStore::~QWindowsDirect2DBackingStore()
{
}
void QWindowsDirect2DBackingStore::beginPaint(const QRegion &)
{
platformPixmap(m_pixmap.data())->bitmap()->deviceContext()->begin();
}
void QWindowsDirect2DBackingStore::endPaint()
{
platformPixmap(m_pixmap.data())->bitmap()->deviceContext()->end();
}
QPaintDevice *QWindowsDirect2DBackingStore::paintDevice()
{
return m_pixmap.data();

View File

@ -58,6 +58,9 @@ public:
QWindowsDirect2DBackingStore(QWindow *window);
~QWindowsDirect2DBackingStore();
void beginPaint(const QRegion &);
void endPaint();
QPaintDevice *paintDevice() Q_DECL_OVERRIDE;
void flush(QWindow *window, const QRegion &region, const QPoint &offset) Q_DECL_OVERRIDE;
void resize(const QSize &size, const QRegion &staticContents) Q_DECL_OVERRIDE;