diff options
author | Morten Johan Sørvig <morten.sorvig@nokia.com> | 2010-05-12 07:42:52 (GMT) |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@nokia.com> | 2010-05-12 07:42:52 (GMT) |
commit | 731a2f16578ead0f75f2752e757b138376b2f872 (patch) | |
tree | 2b6f9746771992f97cbdb5cf5af8f35ac6928b26 /src/gui/painting | |
parent | 37475bcc4aef3f08c5917f22c7f0f427e4214b91 (diff) | |
parent | b4c589868f278aa9a58ab9afa727dbf0a9442e22 (diff) | |
download | Qt-731a2f16578ead0f75f2752e757b138376b2f872.zip Qt-731a2f16578ead0f75f2752e757b138376b2f872.tar.gz Qt-731a2f16578ead0f75f2752e757b138376b2f872.tar.bz2 |
Merge remote branch 'mainline/4.7' into 4.7
Conflicts:
src/declarative/qml/qdeclarativeengine.cpp
tools/qdoc3/htmlgenerator.cpp
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qdatabuffer_p.h | 19 | ||||
-rw-r--r-- | src/gui/painting/qdrawutil.cpp | 14 | ||||
-rw-r--r-- | src/gui/painting/qoutlinemapper.cpp | 3 | ||||
-rw-r--r-- | src/gui/painting/qoutlinemapper_p.h | 11 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 52 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_raster_p.h | 3 | ||||
-rw-r--r-- | src/gui/painting/qpaintengineex.cpp | 3 | ||||
-rw-r--r-- | src/gui/painting/qpathclipper.cpp | 23 | ||||
-rw-r--r-- | src/gui/painting/qpathclipper_p.h | 7 | ||||
-rw-r--r-- | src/gui/painting/qpolygonclipper_p.h | 3 | ||||
-rw-r--r-- | src/gui/painting/qrasterizer.cpp | 8 | ||||
-rw-r--r-- | src/gui/painting/qstroker.cpp | 2 |
12 files changed, 104 insertions, 44 deletions
diff --git a/src/gui/painting/qdatabuffer_p.h b/src/gui/painting/qdatabuffer_p.h index bc5f1ef..8f8544f 100644 --- a/src/gui/painting/qdatabuffer_p.h +++ b/src/gui/painting/qdatabuffer_p.h @@ -60,16 +60,20 @@ QT_BEGIN_NAMESPACE template <typename Type> class QDataBuffer { public: - QDataBuffer(int res = 64) + QDataBuffer(int res) { capacity = res; - buffer = (Type*) qMalloc(capacity * sizeof(Type)); + if (res) + buffer = (Type*) qMalloc(capacity * sizeof(Type)); + else + buffer = 0; siz = 0; } ~QDataBuffer() { - qFree(buffer); + if (buffer) + qFree(buffer); } inline void reset() { siz = 0; } @@ -104,6 +108,8 @@ public: inline void reserve(int size) { if (size > capacity) { + if (capacity == 0) + capacity = 1; while (capacity < size) capacity *= 2; buffer = (Type*) qRealloc(buffer, capacity * sizeof(Type)); @@ -112,7 +118,12 @@ public: inline void shrink(int size) { capacity = size; - buffer = (Type*) qRealloc(buffer, capacity * sizeof(Type)); + if (size) + buffer = (Type*) qRealloc(buffer, capacity * sizeof(Type)); + else { + qFree(buffer); + buffer = 0; + } } inline void swap(QDataBuffer<Type> &other) { diff --git a/src/gui/painting/qdrawutil.cpp b/src/gui/painting/qdrawutil.cpp index a62f06b..ef9b18c 100644 --- a/src/gui/painting/qdrawutil.cpp +++ b/src/gui/painting/qdrawutil.cpp @@ -1137,6 +1137,15 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin xTarget.resize(columns + 1); yTarget.resize(rows + 1); + bool oldAA = painter->testRenderHint(QPainter::Antialiasing); + bool oldSmooth = painter->testRenderHint(QPainter::SmoothPixmapTransform); + if (painter->paintEngine()->type() != QPaintEngine::OpenGL + && painter->paintEngine()->type() != QPaintEngine::OpenGL2 + && (oldSmooth || oldAA) && painter->combinedTransform().type() != QTransform::TxNone) { + painter->setRenderHint(QPainter::Antialiasing, false); + painter->setRenderHint(QPainter::SmoothPixmapTransform, false); + } + xTarget[0] = targetRect.left(); xTarget[1] = targetCenterLeft; xTarget[columns - 1] = targetCenterRight; @@ -1342,6 +1351,11 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin painter->drawPixmapFragments(opaqueData.data(), opaqueData.size(), pixmap, QPainter::OpaqueHint); if (translucentData.size()) painter->drawPixmapFragments(translucentData.data(), translucentData.size(), pixmap); + + if (oldAA) + painter->setRenderHint(QPainter::Antialiasing, true); + if (oldSmooth) + painter->setRenderHint(QPainter::SmoothPixmapTransform, true); } QT_END_NAMESPACE diff --git a/src/gui/painting/qoutlinemapper.cpp b/src/gui/painting/qoutlinemapper.cpp index ad0c2eb..1b01960 100644 --- a/src/gui/painting/qoutlinemapper.cpp +++ b/src/gui/painting/qoutlinemapper.cpp @@ -154,7 +154,8 @@ QT_FT_Outline *QOutlineMapper::convertPath(const QVectorPath &path) // ### We can kill this copying and just use the buffer straight... m_elements.resize(count); - memcpy(m_elements.data(), path.points(), count* sizeof(QPointF)); + if (count) + memcpy(m_elements.data(), path.points(), count* sizeof(QPointF)); m_element_types.resize(0); } diff --git a/src/gui/painting/qoutlinemapper_p.h b/src/gui/painting/qoutlinemapper_p.h index d0ce1a9..39b7593 100644 --- a/src/gui/painting/qoutlinemapper_p.h +++ b/src/gui/painting/qoutlinemapper_p.h @@ -87,8 +87,15 @@ const int QT_RASTER_COORD_LIMIT = 32767; class QOutlineMapper { public: - QOutlineMapper() - : m_round_coords(false) + QOutlineMapper() : + m_element_types(0), + m_elements(0), + m_elements_dev(0), + m_points(0), + m_tags(0), + m_contours(0), + m_polygon_dev(0), + m_round_coords(false) { } diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 9148ac2..6f395f6 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -251,6 +251,11 @@ static void qt_debug_path(const QPainterPath &path) } #endif +QRasterPaintEnginePrivate::QRasterPaintEnginePrivate() : + QPaintEngineExPrivate(), + cachedLines(0) +{ +} /*! @@ -336,17 +341,6 @@ void QRasterPaintEngine::init() d->hdc = 0; #endif - d->rasterPoolSize = 8192; - d->rasterPoolBase = -#if defined(Q_WS_WIN64) - // We make use of setjmp and longjmp in qgrayraster.c which requires - // 16-byte alignment, hence we hardcode this requirement here.. - (unsigned char *) _aligned_malloc(d->rasterPoolSize, sizeof(void*) * 2); -#else - (unsigned char *) malloc(d->rasterPoolSize); -#endif - Q_CHECK_PTR(d->rasterPoolBase); - // The antialiasing raster. d->grayRaster.reset(new QT_FT_Raster); Q_CHECK_PTR(d->grayRaster.data()); @@ -354,8 +348,6 @@ void QRasterPaintEngine::init() QT_THROW(std::bad_alloc()); // an error creating the raster is caused by a bad malloc - qt_ft_grays_raster.raster_reset(*d->grayRaster.data(), d->rasterPoolBase, d->rasterPoolSize); - d->rasterizer.reset(new QRasterizer); d->rasterBuffer.reset(new QRasterBuffer()); d->outlineMapper.reset(new QOutlineMapper); @@ -437,12 +429,6 @@ QRasterPaintEngine::~QRasterPaintEngine() { Q_D(QRasterPaintEngine); -#if defined(Q_WS_WIN64) - _aligned_free(d->rasterPoolBase); -#else - free(d->rasterPoolBase); -#endif - qt_ft_grays_raster.raster_done(*d->grayRaster.data()); } @@ -4090,6 +4076,22 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, return; } + const int rasterPoolInitialSize = 8192; + int rasterPoolSize = rasterPoolInitialSize; + unsigned char *rasterPoolBase; +#if defined(Q_WS_WIN64) + rasterPoolBase = + // We make use of setjmp and longjmp in qgrayraster.c which requires + // 16-byte alignment, hence we hardcode this requirement here.. + (unsigned char *) _aligned_malloc(rasterPoolSize, sizeof(void*) * 2); +#else + unsigned char rasterPoolOnStack[rasterPoolInitialSize]; + rasterPoolBase = rasterPoolOnStack; +#endif + Q_CHECK_PTR(rasterPoolBase); + + qt_ft_grays_raster.raster_reset(*grayRaster.data(), rasterPoolBase, rasterPoolSize); + void *data = userData; QT_FT_BBox clip_box = { deviceRect.x(), @@ -4122,13 +4124,14 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, int new_size = rasterPoolSize * 2; if (new_size > 1024 * 1024) { qWarning("QPainter: Rasterization of primitive failed"); - return; + break; } #if defined(Q_WS_WIN64) _aligned_free(rasterPoolBase); #else - free(rasterPoolBase); + if (rasterPoolBase != rasterPoolOnStack) // initially on the stack + free(rasterPoolBase); #endif rasterPoolSize = new_size; @@ -4149,6 +4152,13 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, done = true; } } + +#if defined(Q_WS_WIN64) + _aligned_free(rasterPoolBase); +#else + if (rasterPoolBase != rasterPoolOnStack) // initially on the stack + free(rasterPoolBase); +#endif } void QRasterPaintEnginePrivate::recalculateFastImages() diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h index 55eb82e..1016f8d 100644 --- a/src/gui/painting/qpaintengine_raster_p.h +++ b/src/gui/painting/qpaintengine_raster_p.h @@ -300,6 +300,7 @@ QRasterPaintEnginePrivate : public QPaintEngineExPrivate { Q_DECLARE_PUBLIC(QRasterPaintEngine) public: + QRasterPaintEnginePrivate(); void rasterizeLine_dashed(QLineF line, qreal width, int *dashIndex, qreal *dashOffset, bool *inDash); @@ -354,8 +355,6 @@ public: QScopedPointer<QDashStroker> dashStroker; QScopedPointer<QT_FT_Raster> grayRaster; - unsigned long rasterPoolSize; - unsigned char *rasterPoolBase; QDataBuffer<QLineF> cachedLines; QSpanData image_filler; diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index a78cafb..fda937e 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -149,6 +149,7 @@ QDebug Q_GUI_EXPORT &operator<<(QDebug &s, const QVectorPath &path) struct StrokeHandler { + StrokeHandler(int reserve) : pts(reserve), types(reserve) {} QDataBuffer<qreal> pts; QDataBuffer<QPainterPath::ElementType> types; }; @@ -394,7 +395,7 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) return; if (!d->strokeHandler) { - d->strokeHandler = new StrokeHandler; + d->strokeHandler = new StrokeHandler(path.elementCount()+4); d->stroker.setMoveToHook(qpaintengineex_moveTo); d->stroker.setLineToHook(qpaintengineex_lineTo); d->stroker.setCubicToHook(qpaintengineex_cubicTo); diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp index c910024..78553c9 100644 --- a/src/gui/painting/qpathclipper.cpp +++ b/src/gui/painting/qpathclipper.cpp @@ -278,7 +278,8 @@ private: }; SegmentTree::SegmentTree(QPathSegments &segments) - : m_segments(segments) + : m_segments(segments), + m_intersections(0) { m_bounds.x1 = qt_inf(); m_bounds.y1 = qt_inf(); @@ -806,7 +807,7 @@ void QWingedEdge::intersectAndAdd() for (int i = 0; i < m_segments.points(); ++i) addVertex(m_segments.pointAt(i)); - QDataBuffer<QPathSegments::Intersection> intersections; + QDataBuffer<QPathSegments::Intersection> intersections(m_segments.segments()); for (int i = 0; i < m_segments.segments(); ++i) { intersections.reset(); @@ -857,11 +858,17 @@ void QWingedEdge::intersectAndAdd() } } -QWingedEdge::QWingedEdge() +QWingedEdge::QWingedEdge() : + m_edges(0), + m_vertices(0), + m_segments(0) { } -QWingedEdge::QWingedEdge(const QPainterPath &subject, const QPainterPath &clip) +QWingedEdge::QWingedEdge(const QPainterPath &subject, const QPainterPath &clip) : + m_edges(subject.length()), + m_vertices(subject.length()), + m_segments(subject.length()) { m_segments.setPath(subject); m_segments.addPath(clip); @@ -1414,9 +1421,9 @@ bool QPathClipper::intersect() else if (clipIsRect) return subjectPath.intersects(r2); - QPathSegments a; + QPathSegments a(subjectPath.length()); a.setPath(subjectPath); - QPathSegments b; + QPathSegments b(clipPath.length()); b.setPath(clipPath); QIntersectionFinder finder; @@ -1459,9 +1466,9 @@ bool QPathClipper::contains() if (clipIsRect) return subjectPath.contains(r2); - QPathSegments a; + QPathSegments a(subjectPath.length()); a.setPath(subjectPath); - QPathSegments b; + QPathSegments b(clipPath.length()); b.setPath(clipPath); QIntersectionFinder finder; diff --git a/src/gui/painting/qpathclipper_p.h b/src/gui/painting/qpathclipper_p.h index 7962400..fab618d 100644 --- a/src/gui/painting/qpathclipper_p.h +++ b/src/gui/painting/qpathclipper_p.h @@ -199,7 +199,7 @@ public: }; - QPathSegments(); + QPathSegments(int reserve); void setPath(const QPainterPath &path); void addPath(const QPainterPath &path); @@ -345,7 +345,10 @@ inline QPathVertex::operator QPointF() const return QPointF(x, y); } -inline QPathSegments::QPathSegments() +inline QPathSegments::QPathSegments(int reserve) : + m_points(reserve), + m_segments(reserve), + m_intersections(reserve) { } diff --git a/src/gui/painting/qpolygonclipper_p.h b/src/gui/painting/qpolygonclipper_p.h index 1b4cbb3..cdaac1c 100644 --- a/src/gui/painting/qpolygonclipper_p.h +++ b/src/gui/painting/qpolygonclipper_p.h @@ -62,7 +62,8 @@ QT_BEGIN_NAMESPACE template <typename InType, typename OutType, typename CastType> class QPolygonClipper { public: - QPolygonClipper() + QPolygonClipper() : + buffer1(0), buffer2(0) { x1 = y1 = x2 = y2 = 0; } diff --git a/src/gui/painting/qrasterizer.cpp b/src/gui/painting/qrasterizer.cpp index 51d01c9..f8f8afb 100644 --- a/src/gui/painting/qrasterizer.cpp +++ b/src/gui/painting/qrasterizer.cpp @@ -198,9 +198,11 @@ public: }; QScanConverter::QScanConverter() - : m_alloc(0) + : m_lines(0) + , m_alloc(0) , m_size(0) , m_intersections(0) + , m_active(0) { } @@ -310,6 +312,10 @@ struct QBoolToType template <typename T> void qScanConvert(QScanConverter &d, T allVertical) { + if (!d.m_lines.size()) { + d.m_active.reset(); + return; + } qSort(d.m_lines.data(), d.m_lines.data() + d.m_lines.size(), QT_PREPEND_NAMESPACE(topOrder)); int line = 0; for (int y = d.m_lines.first().top; y <= d.m_bottom; ++y) { diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp index e43544c..9b8e099 100644 --- a/src/gui/painting/qstroker.cpp +++ b/src/gui/painting/qstroker.cpp @@ -187,7 +187,7 @@ static inline qreal adapted_angle_on_x(const QLineF &line) } QStrokerOps::QStrokerOps() - : m_customData(0), m_moveTo(0), m_lineTo(0), m_cubicTo(0) + : m_elements(0), m_customData(0), m_moveTo(0), m_lineTo(0), m_cubicTo(0) { } |