summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@nokia.com>2009-06-11 09:30:37 (GMT)
committerErik Verbruggen <erik.verbruggen@nokia.com>2009-06-11 09:30:37 (GMT)
commitf10791eb1c45b090f60a2c2ecca3cc5fd237278e (patch)
tree9cca3ca900bb12b79a8b8b304b1eb8da07143186 /src
parent7d7c1da715474cefa5404df684d680c36e4b6b20 (diff)
downloadQt-f10791eb1c45b090f60a2c2ecca3cc5fd237278e.zip
Qt-f10791eb1c45b090f60a2c2ecca3cc5fd237278e.tar.gz
Qt-f10791eb1c45b090f60a2c2ecca3cc5fd237278e.tar.bz2
Getting kinetic compiling again on MacOS.
Diffstat (limited to 'src')
-rw-r--r--src/gui/painting/qpaintengineex.cpp83
-rw-r--r--src/gui/painting/qpaintengineex_p.h34
-rw-r--r--src/gui/painting/qpainter.cpp71
-rw-r--r--src/gui/painting/qpainter.h1
-rw-r--r--src/gui/painting/qpainter_p.h6
5 files changed, 61 insertions, 134 deletions
diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp
index d2671c8..8eaad60 100644
--- a/src/gui/painting/qpaintengineex.cpp
+++ b/src/gui/painting/qpaintengineex.cpp
@@ -105,7 +105,7 @@ QDebug Q_GUI_EXPORT &operator<<(QDebug &s, const QVectorPath &path)
vectorPathBounds.x2 - vectorPathBounds.x1, vectorPathBounds.y2 - vectorPathBounds.y1);
s << "QVectorPath(size:" << path.elementCount()
<< " hints:" << hex << path.hints()
- << rf << ')';
+ << rf << ")";
return s;
}
#endif
@@ -138,75 +138,6 @@ QPaintEngineExPrivate::~QPaintEngineExPrivate()
}
-void QPaintEngineExPrivate::replayClipOperations()
-{
- Q_Q(QPaintEngineEx);
-
- QPainter *p = q->painter();
- if (!p || !p->d_ptr)
- return;
-
- QPainterPrivate *pp = p->d_ptr;
- QList<QPainterClipInfo> clipInfo = pp->state->clipInfo;
-
- QTransform transform = q->state()->matrix;
-
- const QTransform &redirection = q->state()->redirectionMatrix;
-
- for (int i = 0; i < clipInfo.size(); ++i) {
- const QPainterClipInfo &info = clipInfo.at(i);
-
- QTransform combined = info.matrix * redirection;
-
- if (combined != q->state()->matrix) {
- q->state()->matrix = combined;
- q->transformChanged();
- }
-
- switch (info.clipType) {
- case QPainterClipInfo::RegionClip:
- q->clip(info.region, info.operation);
- break;
- case QPainterClipInfo::PathClip:
- q->clip(info.path, info.operation);
- break;
- case QPainterClipInfo::RectClip:
- q->clip(info.rect, info.operation);
- break;
- case QPainterClipInfo::RectFClip: {
- qreal right = info.rectf.x() + info.rectf.width();
- qreal bottom = info.rectf.y() + info.rectf.height();
- qreal pts[] = { info.rectf.x(), info.rectf.y(),
- right, info.rectf.y(),
- right, bottom,
- info.rectf.x(), bottom };
- QVectorPath vp(pts, 4, 0, QVectorPath::RectangleHint);
- q->clip(vp, info.operation);
- break;
- }
- }
- }
-
- if (transform != q->state()->matrix) {
- q->state()->matrix = transform;
- q->transformChanged();
- }
-}
-
-
-bool QPaintEngineExPrivate::hasClipOperations() const
-{
- Q_Q(const QPaintEngineEx);
-
- QPainter *p = q->painter();
- if (!p || !p->d_ptr)
- return false;
-
- QPainterPrivate *pp = p->d_ptr;
- QList<QPainterClipInfo> clipInfo = pp->state->clipInfo;
-
- return !clipInfo.isEmpty();
-}
/*******************************************************************************
*
@@ -313,18 +244,13 @@ static void qpaintengineex_cubicTo(qreal c1x, qreal c1y, qreal c2x, qreal c2y, q
((StrokeHandler *) data)->types.add(QPainterPath::CurveToDataElement);
}
-QPaintEngineEx::QPaintEngineEx()
- : QPaintEngine(*new QPaintEngineExPrivate, AllFeatures)
-{
- extended = true;
-}
-
QPaintEngineEx::QPaintEngineEx(QPaintEngineExPrivate &data)
: QPaintEngine(data, AllFeatures)
{
extended = true;
}
+
QPainterState *QPaintEngineEx::createState(QPainterState *orig) const
{
if (!orig)
@@ -557,9 +483,6 @@ void QPaintEngineEx::clip(const QRect &r, Qt::ClipOperation op)
void QPaintEngineEx::clip(const QRegion &region, Qt::ClipOperation op)
{
- if (region.numRects() == 1)
- clip(region.boundingRect(), op);
-
QVector<QRect> rects = region.rects();
if (rects.size() <= 32) {
qreal pts[2*32*4];
@@ -855,7 +778,7 @@ void QPaintEngineEx::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, con
{
QBrush brush(state()->pen.color(), pixmap);
QTransform xform;
- xform.translate(r.x() - s.x(), r.y() - s.y());
+ xform.translate(-s.x(), -s.y());
brush.setTransform(xform);
qreal pts[] = { r.x(), r.y(),
diff --git a/src/gui/painting/qpaintengineex_p.h b/src/gui/painting/qpaintengineex_p.h
index 3f64260..593726c 100644
--- a/src/gui/painting/qpaintengineex_p.h
+++ b/src/gui/painting/qpaintengineex_p.h
@@ -139,13 +139,27 @@ public:
QDebug Q_GUI_EXPORT &operator<<(QDebug &, const QVectorPath &path);
#endif
+class Q_GUI_EXPORT QPaintEngineExPrivate : public QPaintEnginePrivate
+{
+public:
+ QPaintEngineExPrivate();
+ ~QPaintEngineExPrivate();
+
+ QStroker stroker;
+ QDashStroker dasher;
+ StrokeHandler *strokeHandler;
+ QStrokerOps *activeStroker;
+ QPen strokerPen;
+};
+
class QPixmapFilter;
class Q_GUI_EXPORT QPaintEngineEx : public QPaintEngine
{
Q_DECLARE_PRIVATE(QPaintEngineEx)
public:
- QPaintEngineEx();
+ inline QPaintEngineEx()
+ : QPaintEngine(*new QPaintEngineExPrivate, AllFeatures) { extended = true; }
virtual QPainterState *createState(QPainterState *orig) const;
@@ -202,30 +216,12 @@ public:
inline QPainterState *state() { return static_cast<QPainterState *>(QPaintEngine::state); }
inline const QPainterState *state() const { return static_cast<const QPainterState *>(QPaintEngine::state); }
- virtual void sync() {}
-
virtual QPixmapFilter *createPixmapFilter(int /*type*/) const { return 0; }
protected:
QPaintEngineEx(QPaintEngineExPrivate &data);
};
-class Q_GUI_EXPORT QPaintEngineExPrivate : public QPaintEnginePrivate
-{
- Q_DECLARE_PUBLIC(QPaintEngineEx)
-public:
- QPaintEngineExPrivate();
- ~QPaintEngineExPrivate();
-
- void replayClipOperations();
- bool hasClipOperations() const;
-
- QStroker stroker;
- QDashStroker dasher;
- StrokeHandler *strokeHandler;
- QStrokerOps *activeStroker;
- QPen strokerPen;
-};
inline uint QVectorPath::polygonFlags(QPaintEngine::PolygonDrawMode mode) {
switch (mode) {
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 0ece498..cc48d24 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -281,14 +281,10 @@ bool QPainterPrivate::attachPainterPrivate(QPainter *q, QPaintDevice *pdev)
q->d_ptr->state->wh = q->d_ptr->state->vh = widget->height();
// Update matrix.
- if (q->d_ptr->state->WxF) {
- q->d_ptr->state->redirectionMatrix *= q->d_ptr->state->worldMatrix;
- q->d_ptr->state->redirectionMatrix.translate(-offset.x(), -offset.y());
- q->d_ptr->state->worldMatrix = QTransform();
- q->d_ptr->state->WxF = false;
- } else {
- q->d_ptr->state->redirectionMatrix = QTransform::fromTranslate(-offset.x(), -offset.y());
- }
+ if (q->d_ptr->state->WxF)
+ q->d_ptr->state->worldMatrix.translate(-offset.x(), -offset.y());
+ else
+ q->d_ptr->state->redirection_offset = offset;
q->d_ptr->updateMatrix();
QPaintEnginePrivate *enginePrivate = q->d_ptr->engine->d_func();
@@ -414,7 +410,7 @@ void QPainterPrivate::draw_helper(const QPainterPath &originalPath, DrawOperatio
bool old_txinv = txinv;
QTransform old_invMatrix = invMatrix;
txinv = true;
- invMatrix = state->redirectionMatrix;
+ invMatrix = QTransform().translate(-state->redirection_offset.x(), -state->redirection_offset.y());
QPainterPath clipPath = q->clipPath();
QRectF r = clipPath.boundingRect().intersected(absPathRect);
absPathRect = r.toAlignedRect();
@@ -638,7 +634,20 @@ void QPainterPrivate::updateMatrix()
state->matrix *= viewTransform();
txinv = false; // no inverted matrix
- state->matrix *= state->redirectionMatrix;
+ if (!state->redirection_offset.isNull()) {
+ // We want to translate in dev space so we do the adding of the redirection
+ // offset manually.
+ if (state->matrix.isAffine()) {
+ state->matrix = QTransform(state->matrix.m11(), state->matrix.m12(),
+ state->matrix.m21(), state->matrix.m22(),
+ state->matrix.dx()-state->redirection_offset.x(),
+ state->matrix.dy()-state->redirection_offset.y());
+ } else {
+ QTransform temp;
+ temp.translate(-state->redirection_offset.x(), -state->redirection_offset.y());
+ state->matrix *= temp;
+ }
+ }
if (extended)
extended->transformChanged();
else
@@ -1563,8 +1572,10 @@ void QPainter::restore()
// replay the list of clip states,
for (int i=0; i<d->state->clipInfo.size(); ++i) {
const QPainterClipInfo &info = d->state->clipInfo.at(i);
- tmp->matrix = info.matrix;
- tmp->matrix *= d->state->redirectionMatrix;
+ tmp->matrix.setMatrix(info.matrix.m11(), info.matrix.m12(), info.matrix.m13(),
+ info.matrix.m21(), info.matrix.m22(), info.matrix.m23(),
+ info.matrix.dx() - d->state->redirection_offset.x(),
+ info.matrix.dy() - d->state->redirection_offset.y(), info.matrix.m33());
tmp->clipOperation = info.operation;
if (info.clipType == QPainterClipInfo::RectClip) {
tmp->dirtyFlags = QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyTransform;
@@ -1678,7 +1689,7 @@ bool QPainter::begin(QPaintDevice *pd)
d->state->painter = this;
d->states.push_back(d->state);
- d->state->redirectionMatrix.translate(-redirectionOffset.x(), -redirectionOffset.y());
+ d->state->redirection_offset = redirectionOffset;
d->state->brushOrigin = QPointF();
if (!d->engine) {
@@ -1712,8 +1723,7 @@ bool QPainter::begin(QPaintDevice *pd)
// Adjust offset for alien widgets painting outside the paint event.
if (!inPaintEvent && paintOutsidePaintEvent && !widget->internalWinId()
&& widget->testAttribute(Qt::WA_WState_Created)) {
- const QPoint offset = widget->mapTo(widget->nativeParentWidget(), QPoint());
- d->state->redirectionMatrix.translate(offset.x(), offset.y());
+ d->state->redirection_offset -= widget->mapTo(widget->nativeParentWidget(), QPoint());
}
break;
}
@@ -1795,12 +1805,11 @@ bool QPainter::begin(QPaintDevice *pd)
d->state->wh = d->state->vh = pd->metric(QPaintDevice::PdmHeight);
}
- const QPoint coordinateOffset = d->engine->coordinateOffset();
- d->state->redirectionMatrix.translate(-coordinateOffset.x(), -coordinateOffset.y());
+ d->state->redirection_offset += d->engine->coordinateOffset();
Q_ASSERT(d->engine->isActive());
- if (!d->state->redirectionMatrix.isIdentity())
+ if (!d->state->redirection_offset.isNull())
d->updateMatrix();
Q_ASSERT(d->engine->isActive());
@@ -6073,22 +6082,22 @@ void QPainter::drawTextItem(const QPointF &p, const QTextItem &_ti)
const QTransform &m = d->state->matrix;
if (d->state->matrix.type() < QTransform::TxShear) {
bool isPlain90DegreeRotation =
- (qFuzzyIsNull(m.m11())
- && qFuzzyIsNull(m.m12() - qreal(1))
- && qFuzzyIsNull(m.m21() + qreal(1))
- && qFuzzyIsNull(m.m22())
+ (qFuzzyCompare(m.m11() + 1, qreal(1))
+ && qFuzzyCompare(m.m12(), qreal(1))
+ && qFuzzyCompare(m.m21(), qreal(-1))
+ && qFuzzyCompare(m.m22() + 1, qreal(1))
)
||
- (qFuzzyIsNull(m.m11() + qreal(1))
- && qFuzzyIsNull(m.m12())
- && qFuzzyIsNull(m.m21())
- && qFuzzyIsNull(m.m22() + qreal(1))
+ (qFuzzyCompare(m.m11(), qreal(-1))
+ && qFuzzyCompare(m.m12() + 1, qreal(1))
+ && qFuzzyCompare(m.m21() + 1, qreal(1))
+ && qFuzzyCompare(m.m22(), qreal(-1))
)
||
- (qFuzzyIsNull(m.m11())
- && qFuzzyIsNull(m.m12() + qreal(1))
- && qFuzzyIsNull(m.m21() - qreal(1))
- && qFuzzyIsNull(m.m22())
+ (qFuzzyCompare(m.m11() + 1, qreal(1))
+ && qFuzzyCompare(m.m12(), qreal(-1))
+ && qFuzzyCompare(m.m21(), qreal(1))
+ && qFuzzyCompare(m.m22() + 1, qreal(1))
)
;
aa = !isPlain90DegreeRotation;
@@ -7695,7 +7704,7 @@ QPainterState::QPainterState(const QPainterState *s)
clipRegion(s->clipRegion), clipPath(s->clipPath),
clipOperation(s->clipOperation),
renderHints(s->renderHints), clipInfo(s->clipInfo),
- worldMatrix(s->worldMatrix), matrix(s->matrix), redirectionMatrix(s->redirectionMatrix),
+ worldMatrix(s->worldMatrix), matrix(s->matrix), redirection_offset(s->redirection_offset),
wx(s->wx), wy(s->wy), ww(s->ww), wh(s->wh),
vx(s->vx), vy(s->vy), vw(s->vw), vh(s->vh),
opacity(s->opacity), WxF(s->WxF), VxF(s->VxF),
diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h
index 78cd713..f3df7a3 100644
--- a/src/gui/painting/qpainter.h
+++ b/src/gui/painting/qpainter.h
@@ -507,7 +507,6 @@ private:
friend class QFontEngineXLFD;
friend class QWSManager;
friend class QPaintEngine;
- friend class QPaintEngineExPrivate;
friend class QOpenGLPaintEngine;
friend class QX11PaintEngine;
friend class QX11PaintEnginePrivate;
diff --git a/src/gui/painting/qpainter_p.h b/src/gui/painting/qpainter_p.h
index 8d4e6c5..258b25a 100644
--- a/src/gui/painting/qpainter_p.h
+++ b/src/gui/painting/qpainter_p.h
@@ -92,8 +92,8 @@ inline Qt::PenJoinStyle qpen_joinStyle(const QPen &p) { return data_ptr(p)->join
// QBrush inline functions...
inline QBrush::DataPtr &data_ptr(const QBrush &p) { return const_cast<QBrush &>(p).data_ptr(); }
inline bool qbrush_fast_equals(const QBrush &a, const QBrush &b) { return data_ptr(a) == data_ptr(b); }
-inline Qt::BrushStyle qbrush_style(const QBrush &b) { return data_ptr(b)->style; }
-inline const QColor &qbrush_color(const QBrush &b) { return data_ptr(b)->color; }
+inline Qt::BrushStyle qbrush_style(const QBrush &b) { return data_ptr(b)->style; };
+inline const QColor &qbrush_color(const QBrush &b) { return data_ptr(b)->color; };
inline bool qbrush_has_transform(const QBrush &b) { return data_ptr(b)->transform.type() > QTransform::TxNone; }
class QPainterClipInfo
@@ -158,7 +158,7 @@ public:
QList<QPainterClipInfo> clipInfo; // ### Make me smaller and faster to copy around...
QTransform worldMatrix; // World transformation matrix, not window and viewport
QTransform matrix; // Complete transformation matrix,
- QTransform redirectionMatrix;
+ QPoint redirection_offset;
int wx, wy, ww, wh; // window rectangle
int vx, vy, vw, vh; // viewport rectangle
qreal opacity;