summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2012-01-23 10:42:08 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-01-27 17:49:21 (GMT)
commit342fb21a7f6ffdade7dca5871f44a8874a462789 (patch)
treef3e9544e4bc27e7b09426a9050e6339513ae63a0 /src/gui
parentc9b18c882915b8f31c8c99bfc271a87800ba61ed (diff)
downloadQt-342fb21a7f6ffdade7dca5871f44a8874a462789.zip
Qt-342fb21a7f6ffdade7dca5871f44a8874a462789.tar.gz
Qt-342fb21a7f6ffdade7dca5871f44a8874a462789.tar.bz2
blitter: Move state updates into new methods
Create updateCompleteState(QPainterState*) so we don't need to call into the paintengine, move all state methods into the QBlitterPaintEnginePrivate class. Change-Id: Ia621aeb9dba98152503f14d8900cf57b5bf2d4f9 Based-On: If30fdcc3f63755e0443bced7d9d9fb993d4ec2b7 Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/painting/qpaintengine_blitter.cpp131
1 files changed, 86 insertions, 45 deletions
diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp
index 635b568..f3a021f 100644
--- a/src/gui/painting/qpaintengine_blitter.cpp
+++ b/src/gui/painting/qpaintengine_blitter.cpp
@@ -200,12 +200,15 @@ public:
void fillRect(const QRectF& rect, const QColor&);
void clipAndDrawPixmap(const QRectF &clip, const QRectF &target, const QPixmap &pm, const QRectF &sr);
- void updateClip() {
- Q_Q(QBlitterPaintEngine);
- const QClipData *clip = q->clip();
- bool complex = clip && !(clip->hasRectClip || clip->hasRegionClip);
- caps.updateState(STATE_CLIP_COMPLEX, complex);
- }
+
+ void updateCompleteState(QPainterState *s);
+ void updatePenState(QPainterState *s);
+ void updateBrushState(QPainterState *s);
+ void updateOpacityState(QPainterState *s);
+ void updateCompositionModeState(QPainterState *s);
+ void updateRenderHintsState(QPainterState *s);
+ void updateTransformState(QPainterState *s);
+ void updateClipState(QPainterState *s);
void systemStateChanged() {
raster->d_func()->systemStateChanged();
@@ -229,6 +232,71 @@ inline void QBlitterPaintEnginePrivate::unlock()
pmData->blittable()->unlock();
}
+// State tracking to make decisions
+void QBlitterPaintEnginePrivate::updateCompleteState(QPainterState *s)
+{
+ updatePenState(s);
+ updateBrushState(s);
+ updateOpacityState(s);
+ updateCompositionModeState(s);
+ updateRenderHintsState(s);
+ updateTransformState(s);
+ updateClipState(s);
+}
+
+void QBlitterPaintEnginePrivate::updatePenState(QPainterState *s)
+{
+ caps.updateState(STATE_PEN_ENABLED, qpen_style(s->pen) != Qt::NoPen);
+}
+
+void QBlitterPaintEnginePrivate::updateBrushState(QPainterState *s)
+{
+ bool solid = qbrush_style(s->brush) == Qt::SolidPattern;
+
+ caps.updateState(STATE_BRUSH_PATTERN, !solid);
+ caps.updateState(STATE_BRUSH_ALPHA,
+ qbrush_color(s->brush).alpha() < 255);
+}
+
+void QBlitterPaintEnginePrivate::updateOpacityState(QPainterState *s)
+{
+ bool translucent = s->opacity < 1;
+ caps.updateState(STATE_ALPHA, translucent);
+}
+
+void QBlitterPaintEnginePrivate::updateCompositionModeState(QPainterState *s)
+{
+ bool nonTrivial = s->composition_mode != QPainter::CompositionMode_SourceOver
+ && s->composition_mode != QPainter::CompositionMode_Source;
+
+ caps.updateState(STATE_BLENDING_COMPLEX, nonTrivial);
+}
+
+void QBlitterPaintEnginePrivate::updateRenderHintsState(QPainterState *s)
+{
+ bool aa = s->renderHints & QPainter::Antialiasing;
+ caps.updateState(STATE_ANTIALIASING, aa);
+}
+
+void QBlitterPaintEnginePrivate::updateTransformState(QPainterState *s)
+{
+ QTransform::TransformationType type = s->matrix.type();
+
+ caps.updateState(STATE_XFORM_COMPLEX, type > QTransform::TxScale);
+ caps.updateState(STATE_XFORM_SCALE, type > QTransform::TxTranslate);
+
+ hasXForm = type >= QTransform::TxTranslate;
+}
+
+void QBlitterPaintEnginePrivate::updateClipState(QPainterState *)
+{
+ Q_Q(QBlitterPaintEngine);
+
+ const QClipData *clip = q->clip();
+ bool complexClip = clip && !(clip->hasRectClip || clip->hasRegionClip);
+ caps.updateState(STATE_CLIP_COMPLEX, complexClip);
+}
+
void QBlitterPaintEnginePrivate::fillRect(const QRectF &rect, const QColor &color)
{
Q_Q(QBlitterPaintEngine);
@@ -434,14 +502,14 @@ void QBlitterPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op)
Q_D(QBlitterPaintEngine);
d->lock();
d->raster->clip(path, op);
- d->updateClip();
+ d->updateClipState(state());
}
void QBlitterPaintEngine::clip(const QRect &rect, Qt::ClipOperation op){
Q_D(QBlitterPaintEngine);
d->lock();
d->raster->clip(rect, op);
- d->updateClip();
+ d->updateClipState(state());
}
void QBlitterPaintEngine::clip(const QRegion &region, Qt::ClipOperation op)
@@ -449,7 +517,7 @@ void QBlitterPaintEngine::clip(const QRegion &region, Qt::ClipOperation op)
Q_D(QBlitterPaintEngine);
d->lock();
d->raster->clip(region, op);
- d->updateClip();
+ d->updateClipState(state());
}
void QBlitterPaintEngine::clipEnabledChanged()
@@ -457,6 +525,7 @@ void QBlitterPaintEngine::clipEnabledChanged()
Q_D(QBlitterPaintEngine);
d->lock();
d->raster->clipEnabledChanged();
+ d->updateClipState(state());
}
void QBlitterPaintEngine::penChanged()
@@ -464,7 +533,8 @@ void QBlitterPaintEngine::penChanged()
Q_D(QBlitterPaintEngine);
d->lock();
d->raster->penChanged();
- d->caps.updateState(STATE_PEN_ENABLED, qpen_style(state()->pen) != Qt::NoPen);
+
+ d->updatePenState(state());
}
void QBlitterPaintEngine::brushChanged()
@@ -472,11 +542,7 @@ void QBlitterPaintEngine::brushChanged()
Q_D(QBlitterPaintEngine);
d->raster->brushChanged();
- bool solid = qbrush_style(state()->brush) == Qt::SolidPattern;
-
- d->caps.updateState(STATE_BRUSH_PATTERN, !solid);
- d->caps.updateState(STATE_BRUSH_ALPHA,
- qbrush_color(state()->brush).alpha() < 255);
+ d->updateBrushState(state());
}
void QBlitterPaintEngine::brushOriginChanged()
@@ -489,44 +555,28 @@ void QBlitterPaintEngine::opacityChanged()
{
Q_D(QBlitterPaintEngine);
d->raster->opacityChanged();
-
- bool translucent = state()->opacity < 1;
- d->caps.updateState(STATE_ALPHA, translucent);
+ d->updateOpacityState(state());
}
void QBlitterPaintEngine::compositionModeChanged()
{
Q_D(QBlitterPaintEngine);
d->raster->compositionModeChanged();
-
- bool nonTrivial = state()->composition_mode != QPainter::CompositionMode_SourceOver
- && state()->composition_mode != QPainter::CompositionMode_Source;
-
- d->caps.updateState(STATE_BLENDING_COMPLEX, nonTrivial);
+ d->updateCompositionModeState(state());
}
void QBlitterPaintEngine::renderHintsChanged()
{
Q_D(QBlitterPaintEngine);
d->raster->renderHintsChanged();
-
- bool aa = state()->renderHints & QPainter::Antialiasing;
- d->caps.updateState(STATE_ANTIALIASING, aa);
-
+ d->updateRenderHintsState(state());
}
void QBlitterPaintEngine::transformChanged()
{
Q_D(QBlitterPaintEngine);
d->raster->transformChanged();
-
- QTransform::TransformationType type = state()->matrix.type();
-
- d->caps.updateState(STATE_XFORM_COMPLEX, type > QTransform::TxScale);
- d->caps.updateState(STATE_XFORM_SCALE, type > QTransform::TxTranslate);
-
- d->hasXForm = type >= QTransform::TxTranslate;
-
+ d->updateTransformState(state());
}
void QBlitterPaintEngine::drawRects(const QRect *rects, int rectCount)
@@ -627,16 +677,7 @@ void QBlitterPaintEngine::setState(QPainterState *s)
QPaintEngineEx::setState(s);
d->raster->setState(s);
- clipEnabledChanged();
- penChanged();
- brushChanged();
- brushOriginChanged();
- opacityChanged();
- compositionModeChanged();
- renderHintsChanged();
- transformChanged();
-
- d->updateClip();
+ d->updateCompleteState(s);
}
inline QRasterPaintEngine *QBlitterPaintEngine::raster() const