summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2012-01-23 10:41:46 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-01-27 17:49:08 (GMT)
commitbd85d2bbb3ab9bff189ef70f86df8c2ad12e3c36 (patch)
treed6e50289ef57a262e8808ad3e187640e548d3c09 /src/gui
parent14656e150217cc972540a131d3ebdea39907716d (diff)
downloadQt-bd85d2bbb3ab9bff189ef70f86df8c2ad12e3c36.zip
Qt-bd85d2bbb3ab9bff189ef70f86df8c2ad12e3c36.tar.gz
Qt-bd85d2bbb3ab9bff189ef70f86df8c2ad12e3c36.tar.bz2
blitter: Use CapabilitiesToStateMask as a class member
Move the bit helper functions into CapabilitiesToStateMask as they are only used in this class, allocate the class as part of the QBlitterPaintEnginePrivate, shorten the name as well. Change-Id: Ifab7905d7e240b7c9f08ac5e3421a632b6fe2249 Based-On: If22ddd117a9789cd98edb08f23fd0ffabb17d5a5 Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/painting/qpaintengine_blitter.cpp59
1 files changed, 29 insertions, 30 deletions
diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp
index ff7b175..1b7030f 100644
--- a/src/gui/painting/qpaintengine_blitter.cpp
+++ b/src/gui/painting/qpaintengine_blitter.cpp
@@ -66,16 +66,6 @@ QT_BEGIN_NAMESPACE
#define STATE_CLIP_COMPLEX 0x00020000
-static inline void updateStateBits(uint *state, uint mask, bool on)
-{
- *state = on ? (*state | mask) : (*state & ~mask);
-}
-
-static inline bool checkStateAgainstMask(uint state, uint mask)
-{
- return !state || (state & mask && !(state & ~mask));
-}
-
class CapabilitiesToStateMask
{
public:
@@ -128,7 +118,17 @@ public:
updateStateBits(&capabillitiesState, mask, on);
}
-public:
+private:
+
+ static inline void updateStateBits(uint *state, uint mask, bool on)
+ {
+ *state = on ? (*state | mask) : (*state & ~mask);
+ }
+
+ static inline bool checkStateAgainstMask(uint state, uint mask)
+ {
+ return !state || (state & mask && !(state & ~mask));
+ }
void setFillRectMask() {
updateStateBits(&fillRectMask, STATE_XFORM_SCALE, false);
@@ -188,12 +188,12 @@ public:
QBlitterPaintEnginePrivate(QBlittablePixmapData *p)
: QPaintEngineExPrivate()
, pmData(p)
+ , caps(pmData->blittable()->capabilities())
, isBlitterLocked(false)
, hasXForm(false)
{
raster.reset(new QRasterPaintEngine(p->buffer()));
- capabillities.reset(new CapabilitiesToStateMask(pmData->blittable()->capabilities()));
}
inline void lock() {
@@ -265,7 +265,7 @@ public:
Q_Q(QBlitterPaintEngine);
const QClipData *clip = q->clip();
bool complex = clip && !(clip->hasRectClip || clip->hasRegionClip);
- capabillities->updateState(STATE_CLIP_COMPLEX, complex);
+ caps.updateState(STATE_CLIP_COMPLEX, complex);
}
void systemStateChanged() {
@@ -275,10 +275,9 @@ public:
QScopedPointer<QRasterPaintEngine> raster;
QBlittablePixmapData *pmData;
+ CapabilitiesToStateMask caps;
bool isBlitterLocked;
- QScopedPointer<CapabilitiesToStateMask> capabillities;
-
uint hasXForm;
};
@@ -336,7 +335,7 @@ void QBlitterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
void QBlitterPaintEngine::fillRect(const QRectF &rect, const QColor &color)
{
Q_D(QBlitterPaintEngine);
- if (d->capabillities->canBlitterFillRect() && color.alpha() == 0xff) {
+ if (d->caps.canBlitterFillRect() && color.alpha() == 0xff) {
d->fillRect(rect, color);
} else {
d->lock();
@@ -354,10 +353,10 @@ void QBlitterPaintEngine::fillRect(const QRectF &rect, const QBrush &brush)
if (qbrush_style(brush) == Qt::SolidPattern
&& qbrush_color(brush).alpha() == 0xff
- && d->capabillities->canBlitterFillRect()) {
+ && d->caps.canBlitterFillRect()) {
d->fillRect(rect, qbrush_color(brush));
} else if (brush.style() == Qt::TexturePattern
- && d->capabillities->canBlitterDrawPixmap(rect, brush.texture(), rect)) {
+ && d->caps.canBlitterDrawPixmap(rect, brush.texture(), rect)) {
bool rectIsFilled = false;
QRectF transformedRect = state()->matrix.mapRect(rect);
qreal x = transformedRect.x();
@@ -464,7 +463,7 @@ void QBlitterPaintEngine::penChanged()
Q_D(QBlitterPaintEngine);
d->lock();
d->raster->penChanged();
- d->capabillities->updateState(STATE_PEN_ENABLED, qpen_style(state()->pen) != Qt::NoPen);
+ d->caps.updateState(STATE_PEN_ENABLED, qpen_style(state()->pen) != Qt::NoPen);
}
void QBlitterPaintEngine::brushChanged()
@@ -474,9 +473,9 @@ void QBlitterPaintEngine::brushChanged()
bool solid = qbrush_style(state()->brush) == Qt::SolidPattern;
- d->capabillities->updateState(STATE_BRUSH_PATTERN, !solid);
- d->capabillities->updateState(STATE_BRUSH_ALPHA,
- qbrush_color(state()->brush).alpha() < 255);
+ d->caps.updateState(STATE_BRUSH_PATTERN, !solid);
+ d->caps.updateState(STATE_BRUSH_ALPHA,
+ qbrush_color(state()->brush).alpha() < 255);
}
void QBlitterPaintEngine::brushOriginChanged()
@@ -491,7 +490,7 @@ void QBlitterPaintEngine::opacityChanged()
d->raster->opacityChanged();
bool translucent = state()->opacity < 1;
- d->capabillities->updateState(STATE_ALPHA, translucent);
+ d->caps.updateState(STATE_ALPHA, translucent);
}
void QBlitterPaintEngine::compositionModeChanged()
@@ -502,7 +501,7 @@ void QBlitterPaintEngine::compositionModeChanged()
bool nonTrivial = state()->composition_mode != QPainter::CompositionMode_SourceOver
&& state()->composition_mode != QPainter::CompositionMode_Source;
- d->capabillities->updateState(STATE_BLENDING_COMPLEX, nonTrivial);
+ d->caps.updateState(STATE_BLENDING_COMPLEX, nonTrivial);
}
void QBlitterPaintEngine::renderHintsChanged()
@@ -511,7 +510,7 @@ void QBlitterPaintEngine::renderHintsChanged()
d->raster->renderHintsChanged();
bool aa = state()->renderHints & QPainter::Antialiasing;
- d->capabillities->updateState(STATE_ANTIALIASING, aa);
+ d->caps.updateState(STATE_ANTIALIASING, aa);
}
@@ -522,8 +521,8 @@ void QBlitterPaintEngine::transformChanged()
QTransform::TransformationType type = state()->matrix.type();
- d->capabillities->updateState(STATE_XFORM_COMPLEX, type > QTransform::TxScale);
- d->capabillities->updateState(STATE_XFORM_SCALE, type > QTransform::TxTranslate);
+ d->caps.updateState(STATE_XFORM_COMPLEX, type > QTransform::TxScale);
+ d->caps.updateState(STATE_XFORM_SCALE, type > QTransform::TxTranslate);
d->hasXForm = type >= QTransform::TxTranslate;
@@ -532,7 +531,7 @@ void QBlitterPaintEngine::transformChanged()
void QBlitterPaintEngine::drawRects(const QRect *rects, int rectCount)
{
Q_D(QBlitterPaintEngine);
- if (d->capabillities->canBlitterDrawRectMask()) {
+ if (d->caps.canBlitterDrawRectMask()) {
for (int i=0; i<rectCount; ++i)
d->fillRect(rects[i], qbrush_color(state()->brush));
} else {
@@ -544,7 +543,7 @@ void QBlitterPaintEngine::drawRects(const QRect *rects, int rectCount)
void QBlitterPaintEngine::drawRects(const QRectF *rects, int rectCount)
{
Q_D(QBlitterPaintEngine);
- if (d->capabillities->canBlitterDrawRectMask()) {
+ if (d->caps.canBlitterDrawRectMask()) {
for (int i = 0; i < rectCount; ++i)
d->fillRect(rects[i], qbrush_color(state()->brush));
} else {
@@ -556,7 +555,7 @@ void QBlitterPaintEngine::drawRects(const QRectF *rects, int rectCount)
void QBlitterPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)
{
Q_D(QBlitterPaintEngine);
- if (d->capabillities->canBlitterDrawPixmap(r, pm, sr)) {
+ if (d->caps.canBlitterDrawPixmap(r, pm, sr)) {
d->unlock();
QRectF targetRect = r;