From 9eeec42f67e3e5c344d024eb28ac4f09d7c96c41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 10 Jun 2009 12:13:06 +0200 Subject: Make QVectorPath::controlPointRect() return a QRectF. This makes debugging etc much easier, plus most of the places controlPointRect() was called the caller had to convert the rect to a QRectF manually. --- src/gui/painting/qemulationpaintengine.cpp | 12 ++++++------ src/gui/painting/qpaintengine_raster.cpp | 3 +-- src/gui/painting/qpaintengineex.cpp | 12 +++++------- src/gui/painting/qvectorpath_p.h | 2 +- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/gui/painting/qemulationpaintengine.cpp b/src/gui/painting/qemulationpaintengine.cpp index 175f1ab..5ce1136 100644 --- a/src/gui/painting/qemulationpaintengine.cpp +++ b/src/gui/painting/qemulationpaintengine.cpp @@ -99,9 +99,9 @@ void QEmulationPaintEngine::fill(const QVectorPath &path, const QBrush &brush) } else if (g->coordinateMode() == QGradient::ObjectBoundingMode) { QBrush copy = brush; QTransform mat = copy.transform(); - QRealRect r = path.controlPointRect(); - mat.translate(r.x1, r.y1); - mat.scale(r.x2 - r.x1, r.y2 - r.y1); + QRectF r = path.controlPointRect(); + mat.translate(r.x(), r.y()); + mat.scale(r.width(), r.height()); copy.setTransform(mat); real_engine->fill(path, copy); return; @@ -139,9 +139,9 @@ void QEmulationPaintEngine::stroke(const QVectorPath &path, const QPen &pen) return; } else if (g->coordinateMode() == QGradient::ObjectBoundingMode) { QTransform mat = brush.transform(); - QRealRect r = path.controlPointRect(); - mat.translate(r.x1, r.y1); - mat.scale(r.x2 - r.x1, r.y2 - r.y1); + QRectF r = path.controlPointRect(); + mat.translate(r.x(), r.y()); + mat.scale(r.width(), r.height()); brush.setTransform(mat); copy.setBrush(brush); real_engine->stroke(path, copy); diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 7ed2dfd..2ce1d09 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1852,8 +1852,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush) } // ### Optimize for non transformed ellipses and rectangles... - QRealRect r = path.controlPointRect(); - QRectF cpRect(r.x1, r.y1, r.x2 - r.x1, r.y2 - r.y1); + QRectF cpRect = path.controlPointRect(); const QRect deviceRect = s->matrix.mapRect(cpRect).toRect(); ProcessSpans blend = d->getBrushFunc(deviceRect, &s->brushData); diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index d2671c8..67a3fa9 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -56,15 +56,15 @@ QT_BEGIN_NAMESPACE * */ -const QRealRect &QVectorPath::controlPointRect() const +QRectF QVectorPath::controlPointRect() const { if (m_hints & ControlPointRect) - return m_cp_rect; + return QRectF(QPointF(m_cp_rect.x1, m_cp_rect.y1), QPointF(m_cp_rect.x2, m_cp_rect.y2)); if (m_count == 0) { m_cp_rect.x1 = m_cp_rect.x2 = m_cp_rect.y1 = m_cp_rect.y2 = 0; m_hints |= ControlPointRect; - return m_cp_rect; + return QRectF(QPointF(m_cp_rect.x1, m_cp_rect.y1), QPointF(m_cp_rect.x2, m_cp_rect.y2)); } Q_ASSERT(m_points && m_count > 0); @@ -88,7 +88,7 @@ const QRealRect &QVectorPath::controlPointRect() const } m_hints |= ControlPointRect; - return m_cp_rect; + return QRectF(QPointF(m_cp_rect.x1, m_cp_rect.y1), QPointF(m_cp_rect.x2, m_cp_rect.y2)); } const QVectorPath &qtVectorPathForPath(const QPainterPath &path) @@ -100,9 +100,7 @@ const QVectorPath &qtVectorPathForPath(const QPainterPath &path) #ifndef QT_NO_DEBUG_STREAM QDebug Q_GUI_EXPORT &operator<<(QDebug &s, const QVectorPath &path) { - QRealRect vectorPathBounds = path.controlPointRect(); - QRectF rf(vectorPathBounds.x1, vectorPathBounds.y1, - vectorPathBounds.x2 - vectorPathBounds.x1, vectorPathBounds.y2 - vectorPathBounds.y1); + QRectF rf = path.controlPointRect(); s << "QVectorPath(size:" << path.elementCount() << " hints:" << hex << path.hints() << rf << ')'; diff --git a/src/gui/painting/qvectorpath_p.h b/src/gui/painting/qvectorpath_p.h index 2602a3d..b073f8c 100644 --- a/src/gui/painting/qvectorpath_p.h +++ b/src/gui/painting/qvectorpath_p.h @@ -112,7 +112,7 @@ public: { } - const QRealRect &controlPointRect() const; + QRectF controlPointRect() const; inline Hint shape() const { return (Hint) (m_hints & ShapeHintMask); } -- cgit v0.12