diff --git a/src/printsupport/kernel/qpaintengine_alpha.cpp b/src/printsupport/kernel/qpaintengine_alpha.cpp index 710691453a..0ae9464b69 100644 --- a/src/printsupport/kernel/qpaintengine_alpha.cpp +++ b/src/printsupport/kernel/qpaintengine_alpha.cpp @@ -376,6 +376,7 @@ QAlphaPaintEnginePrivate::QAlphaPaintEnginePrivate() m_pic(0), m_picengine(0), m_picpainter(0), + m_numberOfCachedRects(0), m_hasalpha(false), m_alphaPen(false), m_alphaBrush(false), @@ -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) diff --git a/src/printsupport/kernel/qpaintengine_alpha_p.h b/src/printsupport/kernel/qpaintengine_alpha_p.h index 2becad7379..49a9938e56 100644 --- a/src/printsupport/kernel/qpaintengine_alpha_p.h +++ b/src/printsupport/kernel/qpaintengine_alpha_p.h @@ -99,7 +99,9 @@ public: QRegion m_alphargn; QRegion m_cliprgn; - QRegion m_dirtyrgn; + mutable QRegion m_cachedDirtyRgn; + mutable int m_numberOfCachedRects; + QVector 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);