Commit d797a04a authored by Jan Arve Saether's avatar Jan Arve Saether Committed by Jan Arve Sæther
Browse files

Speed up printing when drawing opaque primitives.

We only need to merge the rectangles into a region if we are painting
a non-opaque a primitive with alpha.

Performance measurements
Excluding patch: 244686 ms
Including patch:   5070 ms

This is an improvement of 48x (for debug build)

Task-number: QTBUG-48334
Change-Id: I03684c6e7d8a5fb039ea6477ed1a860f09e1b08c
Reviewed-by: default avatarAndy Shaw <>
parent 68ea2f7e
......@@ -376,6 +376,7 @@ QAlphaPaintEnginePrivate::QAlphaPaintEnginePrivate()
......@@ -426,7 +427,14 @@ void QAlphaPaintEnginePrivate::addAlphaRect(const QRectF &rect)
bool QAlphaPaintEnginePrivate::canSeeTroughBackground(bool somethingInRectHasAlpha, const QRectF &rect) const
return somethingInRectHasAlpha && m_dirtyrgn.intersects(rect.toAlignedRect());
if (somethingInRectHasAlpha) {
if (m_dirtyRects.count() != m_numberOfCachedRects) {
m_cachedDirtyRgn.setRects(m_dirtyRects.constData(), m_dirtyRects.count());
m_numberOfCachedRects = m_dirtyRects.count();
return m_cachedDirtyRgn.intersects(rect.toAlignedRect());
return false;
void QAlphaPaintEnginePrivate::drawAlphaImage(const QRectF &rect)
......@@ -99,7 +99,9 @@ public:
QRegion m_alphargn;
QRegion m_cliprgn;
QRegion m_dirtyrgn;
mutable QRegion m_cachedDirtyRgn;
mutable int m_numberOfCachedRects;
QVector<QRect> m_dirtyRects;
bool m_hasalpha;
bool m_alphaPen;
......@@ -115,7 +117,7 @@ public:
QPen m_pen;
void addAlphaRect(const QRectF &rect);
void addDirtyRect(const QRectF &rect) { m_dirtyrgn |= rect.toAlignedRect(); }
void addDirtyRect(const QRectF &rect) { m_dirtyRects.append(rect.toAlignedRect()); }
bool canSeeTroughBackground(bool somethingInRectHasAlpha, const QRectF &rect) const;
QRectF addPenWidth(const QPainterPath &path);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment