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: If30fdcc3f63755e0443bced7d9d9fb993d4ec2b7 Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
This commit is contained in:
parent
e02749fe7e
commit
feb6211dfb
@ -199,12 +199,15 @@ public:
|
|||||||
void fillRect(const QRectF &rect, const QColor &color);
|
void fillRect(const QRectF &rect, const QColor &color);
|
||||||
void clipAndDrawPixmap(const QRectF &clip, const QRectF &target, const QPixmap &pm, const QRectF &sr);
|
void clipAndDrawPixmap(const QRectF &clip, const QRectF &target, const QPixmap &pm, const QRectF &sr);
|
||||||
|
|
||||||
void updateClip() {
|
|
||||||
Q_Q(QBlitterPaintEngine);
|
void updateCompleteState(QPainterState *s);
|
||||||
const QClipData *clip = q->clipData();
|
void updatePenState(QPainterState *s);
|
||||||
bool complex = clip && !(clip->hasRectClip || clip->hasRegionClip);
|
void updateBrushState(QPainterState *s);
|
||||||
caps.updateState(STATE_CLIP_COMPLEX, complex);
|
void updateOpacityState(QPainterState *s);
|
||||||
}
|
void updateCompositionModeState(QPainterState *s);
|
||||||
|
void updateRenderHintsState(QPainterState *s);
|
||||||
|
void updateTransformState(QPainterState *s);
|
||||||
|
void updateClipState(QPainterState *s);
|
||||||
|
|
||||||
void systemStateChanged() {
|
void systemStateChanged() {
|
||||||
raster->d_func()->systemStateChanged();
|
raster->d_func()->systemStateChanged();
|
||||||
@ -229,6 +232,71 @@ inline void QBlitterPaintEnginePrivate::unlock()
|
|||||||
pmData->blittable()->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->clipData();
|
||||||
|
bool complexClip = clip && !(clip->hasRectClip || clip->hasRegionClip);
|
||||||
|
caps.updateState(STATE_CLIP_COMPLEX, complexClip);
|
||||||
|
}
|
||||||
|
|
||||||
void QBlitterPaintEnginePrivate::fillRect(const QRectF &rect, const QColor &color)
|
void QBlitterPaintEnginePrivate::fillRect(const QRectF &rect, const QColor &color)
|
||||||
{
|
{
|
||||||
Q_Q(QBlitterPaintEngine);
|
Q_Q(QBlitterPaintEngine);
|
||||||
@ -437,14 +505,14 @@ void QBlitterPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op)
|
|||||||
Q_D(QBlitterPaintEngine);
|
Q_D(QBlitterPaintEngine);
|
||||||
d->lock();
|
d->lock();
|
||||||
d->raster->clip(path, op);
|
d->raster->clip(path, op);
|
||||||
d->updateClip();
|
d->updateClipState(state());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QBlitterPaintEngine::clip(const QRect &rect, Qt::ClipOperation op){
|
void QBlitterPaintEngine::clip(const QRect &rect, Qt::ClipOperation op){
|
||||||
Q_D(QBlitterPaintEngine);
|
Q_D(QBlitterPaintEngine);
|
||||||
d->lock();
|
d->lock();
|
||||||
d->raster->clip(rect, op);
|
d->raster->clip(rect, op);
|
||||||
d->updateClip();
|
d->updateClipState(state());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QBlitterPaintEngine::clip(const QRegion ®ion, Qt::ClipOperation op)
|
void QBlitterPaintEngine::clip(const QRegion ®ion, Qt::ClipOperation op)
|
||||||
@ -452,7 +520,7 @@ void QBlitterPaintEngine::clip(const QRegion ®ion, Qt::ClipOperation op)
|
|||||||
Q_D(QBlitterPaintEngine);
|
Q_D(QBlitterPaintEngine);
|
||||||
d->lock();
|
d->lock();
|
||||||
d->raster->clip(region, op);
|
d->raster->clip(region, op);
|
||||||
d->updateClip();
|
d->updateClipState(state());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QBlitterPaintEngine::clipEnabledChanged()
|
void QBlitterPaintEngine::clipEnabledChanged()
|
||||||
@ -460,6 +528,7 @@ void QBlitterPaintEngine::clipEnabledChanged()
|
|||||||
Q_D(QBlitterPaintEngine);
|
Q_D(QBlitterPaintEngine);
|
||||||
d->lock();
|
d->lock();
|
||||||
d->raster->clipEnabledChanged();
|
d->raster->clipEnabledChanged();
|
||||||
|
d->updateClipState(state());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QBlitterPaintEngine::penChanged()
|
void QBlitterPaintEngine::penChanged()
|
||||||
@ -467,7 +536,8 @@ void QBlitterPaintEngine::penChanged()
|
|||||||
Q_D(QBlitterPaintEngine);
|
Q_D(QBlitterPaintEngine);
|
||||||
d->lock();
|
d->lock();
|
||||||
d->raster->penChanged();
|
d->raster->penChanged();
|
||||||
d->caps.updateState(STATE_PEN_ENABLED, qpen_style(state()->pen) != Qt::NoPen);
|
|
||||||
|
d->updatePenState(state());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QBlitterPaintEngine::brushChanged()
|
void QBlitterPaintEngine::brushChanged()
|
||||||
@ -475,11 +545,7 @@ void QBlitterPaintEngine::brushChanged()
|
|||||||
Q_D(QBlitterPaintEngine);
|
Q_D(QBlitterPaintEngine);
|
||||||
d->raster->brushChanged();
|
d->raster->brushChanged();
|
||||||
|
|
||||||
bool solid = qbrush_style(state()->brush) == Qt::SolidPattern;
|
d->updateBrushState(state());
|
||||||
|
|
||||||
d->caps.updateState(STATE_BRUSH_PATTERN, !solid);
|
|
||||||
d->caps.updateState(STATE_BRUSH_ALPHA,
|
|
||||||
qbrush_color(state()->brush).alpha() < 255);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QBlitterPaintEngine::brushOriginChanged()
|
void QBlitterPaintEngine::brushOriginChanged()
|
||||||
@ -492,44 +558,28 @@ void QBlitterPaintEngine::opacityChanged()
|
|||||||
{
|
{
|
||||||
Q_D(QBlitterPaintEngine);
|
Q_D(QBlitterPaintEngine);
|
||||||
d->raster->opacityChanged();
|
d->raster->opacityChanged();
|
||||||
|
d->updateOpacityState(state());
|
||||||
bool translucent = state()->opacity < 1;
|
|
||||||
d->caps.updateState(STATE_ALPHA, translucent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QBlitterPaintEngine::compositionModeChanged()
|
void QBlitterPaintEngine::compositionModeChanged()
|
||||||
{
|
{
|
||||||
Q_D(QBlitterPaintEngine);
|
Q_D(QBlitterPaintEngine);
|
||||||
d->raster->compositionModeChanged();
|
d->raster->compositionModeChanged();
|
||||||
|
d->updateCompositionModeState(state());
|
||||||
bool nonTrivial = state()->composition_mode != QPainter::CompositionMode_SourceOver
|
|
||||||
&& state()->composition_mode != QPainter::CompositionMode_Source;
|
|
||||||
|
|
||||||
d->caps.updateState(STATE_BLENDING_COMPLEX, nonTrivial);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QBlitterPaintEngine::renderHintsChanged()
|
void QBlitterPaintEngine::renderHintsChanged()
|
||||||
{
|
{
|
||||||
Q_D(QBlitterPaintEngine);
|
Q_D(QBlitterPaintEngine);
|
||||||
d->raster->renderHintsChanged();
|
d->raster->renderHintsChanged();
|
||||||
|
d->updateRenderHintsState(state());
|
||||||
bool aa = state()->renderHints & QPainter::Antialiasing;
|
|
||||||
d->caps.updateState(STATE_ANTIALIASING, aa);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QBlitterPaintEngine::transformChanged()
|
void QBlitterPaintEngine::transformChanged()
|
||||||
{
|
{
|
||||||
Q_D(QBlitterPaintEngine);
|
Q_D(QBlitterPaintEngine);
|
||||||
d->raster->transformChanged();
|
d->raster->transformChanged();
|
||||||
|
d->updateTransformState(state());
|
||||||
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;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QBlitterPaintEngine::drawRects(const QRect *rects, int rectCount)
|
void QBlitterPaintEngine::drawRects(const QRect *rects, int rectCount)
|
||||||
@ -630,16 +680,7 @@ void QBlitterPaintEngine::setState(QPainterState *s)
|
|||||||
QPaintEngineEx::setState(s);
|
QPaintEngineEx::setState(s);
|
||||||
d->raster->setState(s);
|
d->raster->setState(s);
|
||||||
|
|
||||||
clipEnabledChanged();
|
d->updateCompleteState(s);
|
||||||
penChanged();
|
|
||||||
brushChanged();
|
|
||||||
brushOriginChanged();
|
|
||||||
opacityChanged();
|
|
||||||
compositionModeChanged();
|
|
||||||
renderHintsChanged();
|
|
||||||
transformChanged();
|
|
||||||
|
|
||||||
d->updateClip();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QRasterPaintEngine *QBlitterPaintEngine::raster() const
|
inline QRasterPaintEngine *QBlitterPaintEngine::raster() const
|
||||||
|
Loading…
Reference in New Issue
Block a user