diff options
author | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2013-03-20 13:46:57 +0100 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2013-03-20 13:49:28 +0100 |
commit | 76c0be34cd4ff4564693162fa7528463e23ce9d8 (patch) | |
tree | f165b7bc319548fb0082365411a871028f92e89e /src/gui/painting | |
parent | 27b4fe96b59e9e63d1e570e802c072e9afdfb2d4 (diff) | |
parent | 36cb3f3f655a9090c82de609010cbfb88651a0f3 (diff) |
Merge branch 'dev' into stable
This starts Qt 5.1 release cycle
Conflicts:
src/gui/text/qfontdatabase.cpp
src/gui/text/qharfbuzz_copy_p.h
src/widgets/kernel/qapplication.cpp
src/widgets/kernel/qcoreapplication.cpp
Change-Id: I72fbf83ab3c2206aeea1b089428b0fc2a89bd62b
Diffstat (limited to 'src/gui/painting')
35 files changed, 119 insertions, 193 deletions
diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index 1bf0b33047..fb47e62d11 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -45,6 +45,7 @@ #include <qpa/qplatformbackingstore.h> #include <qpa/qplatformintegration.h> #include <qscreen.h> +#include <qdebug.h> #include <private/qguiapplication_p.h> #include <private/qwindow_p.h> @@ -97,8 +98,10 @@ void QBackingStore::flush(const QRegion ®ion, QWindow *win, const QPoint &off if (!win) win = window(); - if (win && !qt_window_private(win)->receivedExpose) - qWarning("QBackingStore::flush() called with non-exposed window, behavior is undefined"); + if (win && !qt_window_private(win)->receivedExpose) { + qWarning().nospace() << "QBackingStore::flush() called with non-exposed window " + << win << ", behavior is undefined"; + } d_ptr->platformBackingStore->flush(win, region, offset); } diff --git a/src/gui/painting/qbackingstore.h b/src/gui/painting/qbackingstore.h index 2a3f91246b..65efab2f48 100644 --- a/src/gui/painting/qbackingstore.h +++ b/src/gui/painting/qbackingstore.h @@ -47,8 +47,6 @@ #include <QtGui/qwindow.h> #include <QtGui/qregion.h> -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -93,6 +91,4 @@ private: QT_END_NAMESPACE -QT_END_HEADER - #endif // QBACKINGSTORE_H diff --git a/src/gui/painting/qbrush.h b/src/gui/painting/qbrush.h index 294e0b7931..4d8c97e255 100644 --- a/src/gui/painting/qbrush.h +++ b/src/gui/painting/qbrush.h @@ -52,17 +52,6 @@ #include <QtGui/qimage.h> #include <QtGui/qpixmap.h> -#if defined(Q_OS_VXWORKS) -# if defined(m_data) -# undef m_data -# endif -# if defined(m_type) -# undef m_type -# endif -#endif - -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -326,6 +315,4 @@ public: QT_END_NAMESPACE -QT_END_HEADER - #endif // QBRUSH_H diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 7eec60ed12..12ca84d8d1 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -1572,7 +1572,7 @@ QColor QColor::toRgb() const // achromatic case color.ct.argb.red = color.ct.argb.green = color.ct.argb.blue = ct.ahsl.lightness; } else if (ct.ahsl.lightness == 0) { - // lightness 0 + // lightness 0 color.ct.argb.red = color.ct.argb.green = color.ct.argb.blue = 0; } else { // chromatic case diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h index cd65984f4e..ef3503e8d8 100644 --- a/src/gui/painting/qcolor.h +++ b/src/gui/painting/qcolor.h @@ -46,8 +46,6 @@ #include <QtCore/qnamespace.h> #include <QtCore/qstringlist.h> -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -268,14 +266,12 @@ inline QColor::QColor(const QColor &acolor) inline bool QColor::isValid() const { return cspec != Invalid; } -inline QColor QColor::lighter(int f) const +inline QColor QColor::lighter(int f) const { return light(f); } -inline QColor QColor::darker(int f) const +inline QColor QColor::darker(int f) const { return dark(f); } QT_END_NAMESPACE -QT_END_HEADER - #endif // QCOLOR_H diff --git a/src/gui/painting/qcosmeticstroker_p.h b/src/gui/painting/qcosmeticstroker_p.h index f4fb5fab30..05c8a2b0cf 100644 --- a/src/gui/painting/qcosmeticstroker_p.h +++ b/src/gui/painting/qcosmeticstroker_p.h @@ -47,8 +47,6 @@ #include <private/qpaintengine_raster_p.h> #include <qpen.h> -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -157,6 +155,4 @@ public: QT_END_NAMESPACE -QT_END_HEADER - #endif // QCOSMETICLINE_H diff --git a/src/gui/painting/qcssutil_p.h b/src/gui/painting/qcssutil_p.h index 38e45ae7c9..7888b9edf1 100644 --- a/src/gui/painting/qcssutil_p.h +++ b/src/gui/painting/qcssutil_p.h @@ -78,7 +78,7 @@ extern void Q_GUI_EXPORT qNormalizeRadii(const QRect &br, const QSize *radii, QSize *tlr, QSize *trr, QSize *blr, QSize *brr); QT_END_NAMESPACE - + #endif //QT_NO_CSSPARSER #endif // QCSSUTIL_P_H diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 0f77ae6d86..906ef128fa 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -5368,7 +5368,7 @@ void qBlendTexture(int count, const QSpan *spans, void *userData) proc(count, spans, userData); } -template <class DST> +template <class DST> Q_STATIC_TEMPLATE_FUNCTION inline void qt_bitmapblit_template(QRasterBuffer *rasterBuffer, int x, int y, DST color, const uchar *map, diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index 258f130efc..5d9867012f 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -70,15 +70,19 @@ QT_BEGIN_NAMESPACE #if defined(Q_CC_RVCT) // RVCT doesn't like static template functions # define Q_STATIC_TEMPLATE_FUNCTION -# define Q_STATIC_INLINE_FUNCTION static __forceinline +# define Q_ALWAYS_INLINE __forceinline # define Q_DECL_RESTRICT #elif defined(Q_CC_GNU) -# define Q_STATIC_TEMPLATE_FUNCTION static __attribute__((always_inline)) -# define Q_STATIC_INLINE_FUNCTION static inline __attribute__((always_inline)) +# define Q_STATIC_TEMPLATE_FUNCTION static +# define Q_ALWAYS_INLINE inline __attribute__((always_inline)) # define Q_DECL_RESTRICT __restrict__ +#elif defined(Q_CC_MSVC) +# define Q_STATIC_TEMPLATE_FUNCTION static +# define Q_ALWAYS_INLINE __forceinline +# define Q_DECL_RESTRICT __restrict #else # define Q_STATIC_TEMPLATE_FUNCTION static -# define Q_STATIC_INLINE_FUNCTION static inline +# define Q_ALWAYS_INLINE inline # define Q_DECL_RESTRICT #endif @@ -382,13 +386,14 @@ static inline qreal qRadialDeterminant(qreal a, qreal b, qreal c) return (b * b) - (4 * a * c); } -template <class RadialFetchFunc> +extern void (*qt_memfill32)(quint32 *dest, quint32 value, int count); + +template <class RadialFetchFunc> Q_STATIC_TEMPLATE_FUNCTION const uint * QT_FASTCALL qt_fetch_radial_gradient_template(uint *buffer, const Operator *op, const QSpanData *data, int y, int x, int length) { // avoid division by zero if (qFuzzyIsNull(op->radial.a)) { - extern void (*qt_memfill32)(quint32 *dest, quint32 value, int count); qt_memfill32(buffer, 0, length); return buffer; } @@ -562,7 +567,7 @@ public: # pragma push # pragma arm #endif -Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_255(uint x, uint a, uint y, uint b) { +static Q_ALWAYS_INLINE uint INTERPOLATE_PIXEL_255(uint x, uint a, uint y, uint b) { uint t = (x & 0xff00ff) * a + (y & 0xff00ff) * b; t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8; t &= 0xff00ff; @@ -579,7 +584,7 @@ Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_255(uint x, uint a, uint y, uint #if QT_POINTER_SIZE == 8 // 64-bit versions -Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b) { +static Q_ALWAYS_INLINE uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b) { quint64 t = (((quint64(x)) | ((quint64(x)) << 24)) & 0x00ff00ff00ff00ff) * a; t += (((quint64(y)) | ((quint64(y)) << 24)) & 0x00ff00ff00ff00ff) * b; t >>= 8; @@ -587,14 +592,14 @@ Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint return (uint(t)) | (uint(t >> 24)); } -Q_STATIC_INLINE_FUNCTION uint BYTE_MUL(uint x, uint a) { +static Q_ALWAYS_INLINE uint BYTE_MUL(uint x, uint a) { quint64 t = (((quint64(x)) | ((quint64(x)) << 24)) & 0x00ff00ff00ff00ff) * a; t = (t + ((t >> 8) & 0xff00ff00ff00ff) + 0x80008000800080) >> 8; t &= 0x00ff00ff00ff00ff; return (uint(t)) | (uint(t >> 24)); } -Q_STATIC_INLINE_FUNCTION uint PREMUL(uint x) { +static Q_ALWAYS_INLINE uint PREMUL(uint x) { uint a = x >> 24; quint64 t = (((quint64(x)) | ((quint64(x)) << 24)) & 0x00ff00ff00ff00ff) * a; t = (t + ((t >> 8) & 0xff00ff00ff00ff) + 0x80008000800080) >> 8; @@ -604,7 +609,7 @@ Q_STATIC_INLINE_FUNCTION uint PREMUL(uint x) { #else // 32-bit versions -Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b) { +static Q_ALWAYS_INLINE uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b) { uint t = (x & 0xff00ff) * a + (y & 0xff00ff) * b; t >>= 8; t &= 0xff00ff; @@ -619,7 +624,7 @@ Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint # pragma push # pragma arm #endif -Q_STATIC_INLINE_FUNCTION uint BYTE_MUL(uint x, uint a) { +static Q_ALWAYS_INLINE uint BYTE_MUL(uint x, uint a) { uint t = (x & 0xff00ff) * a; t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8; t &= 0xff00ff; @@ -634,7 +639,7 @@ Q_STATIC_INLINE_FUNCTION uint BYTE_MUL(uint x, uint a) { # pragma pop #endif -Q_STATIC_INLINE_FUNCTION uint PREMUL(uint x) { +static Q_ALWAYS_INLINE uint PREMUL(uint x) { uint a = x >> 24; uint t = (x & 0xff00ff) * a; t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8; @@ -649,14 +654,14 @@ Q_STATIC_INLINE_FUNCTION uint PREMUL(uint x) { #endif -Q_STATIC_INLINE_FUNCTION uint BYTE_MUL_RGB16(uint x, uint a) { +static Q_ALWAYS_INLINE uint BYTE_MUL_RGB16(uint x, uint a) { a += 1; uint t = (((x & 0x07e0)*a) >> 8) & 0x07e0; t |= (((x & 0xf81f)*(a>>2)) >> 6) & 0xf81f; return t; } -Q_STATIC_INLINE_FUNCTION uint BYTE_MUL_RGB16_32(uint x, uint a) { +static Q_ALWAYS_INLINE uint BYTE_MUL_RGB16_32(uint x, uint a) { uint t = (((x & 0xf81f07e0) >> 5)*a) & 0xf81f07e0; t |= (((x & 0x07e0f81f)*a) >> 5) & 0x07e0f81f; return t; @@ -687,12 +692,11 @@ inline quint24::operator uint() const return data[2] | (data[1] << 8) | (data[0] << 16); } -template <class T> +template <class T> Q_STATIC_TEMPLATE_FUNCTION void qt_memfill(T *dest, T value, int count); template<> inline void qt_memfill(quint32 *dest, quint32 color, int count) { - extern void (*qt_memfill32)(quint32 *dest, quint32 value, int count); qt_memfill32(dest, color, count); } @@ -728,7 +732,7 @@ inline void qt_memfill(T *dest, T value, int count) } } -template <class T> +template <class T> Q_STATIC_TEMPLATE_FUNCTION inline void qt_rectfill(T *dest, T value, int x, int y, int width, int height, int stride) { @@ -794,7 +798,7 @@ do { \ # pragma push # pragma arm #endif -Q_STATIC_INLINE_FUNCTION int qt_div_255(int x) { return (x + (x>>8) + 0x80) >> 8; } +static Q_ALWAYS_INLINE int qt_div_255(int x) { return (x + (x>>8) + 0x80) >> 8; } #if defined(Q_CC_RVCT) # pragma pop #endif diff --git a/src/gui/painting/qemulationpaintengine_p.h b/src/gui/painting/qemulationpaintengine_p.h index f706ef3705..db2d51e53a 100644 --- a/src/gui/painting/qemulationpaintengine_p.h +++ b/src/gui/painting/qemulationpaintengine_p.h @@ -55,8 +55,6 @@ #include <private/qpaintengineex_p.h> -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -64,10 +62,10 @@ class QEmulationPaintEngine : public QPaintEngineEx { public: QEmulationPaintEngine(QPaintEngineEx *engine); - + virtual bool begin(QPaintDevice *pdev); virtual bool end(); - + virtual Type type() const; virtual QPainterState *createState(QPainterState *orig) const; @@ -80,7 +78,7 @@ public: virtual void drawStaticTextItem(QStaticTextItem *item); virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s); virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags); - + virtual void clipEnabledChanged(); virtual void penChanged(); virtual void brushChanged(); @@ -107,6 +105,4 @@ private: QT_END_NAMESPACE -QT_END_HEADER - #endif diff --git a/src/gui/painting/qgrayraster.c b/src/gui/painting/qgrayraster.c index 8be462517c..7dfb743ae2 100644 --- a/src/gui/painting/qgrayraster.c +++ b/src/gui/painting/qgrayraster.c @@ -1736,9 +1736,9 @@ if ( raster->worker ) raster->worker->skip_spans = params->skip_spans; - // If raster object and raster buffer are allocated, but - // raster size isn't of the minimum size, indicate out of - // memory. + /* If raster object and raster buffer are allocated, but */ + /* raster size isn't of the minimum size, indicate out of */ + /* memory. */ if (raster->buffer_allocated_size < MINIMUM_POOL_SIZE ) return ErrRaster_OutOfMemory; @@ -1866,8 +1866,8 @@ ( sizeof ( TCell ) * 8 ) ); } else if ( pool_base) - { // Case when there is a raster pool allocated, but it - // doesn't have the minimum size (and so memory will be reallocated) + { /* Case when there is a raster pool allocated, but it */ + /* doesn't have the minimum size (and so memory will be reallocated) */ rast->buffer = pool_base; rast->worker = NULL; rast->buffer_size = pool_size; diff --git a/src/gui/painting/qmatrix.h b/src/gui/painting/qmatrix.h index 672bbdcfd1..d2c1ae3a3c 100644 --- a/src/gui/painting/qmatrix.h +++ b/src/gui/painting/qmatrix.h @@ -49,8 +49,6 @@ #include <QtCore/qpoint.h> #include <QtCore/qrect.h> -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -185,6 +183,4 @@ Q_GUI_EXPORT QDebug operator<<(QDebug, const QMatrix &); QT_END_NAMESPACE -QT_END_HEADER - #endif // QMATRIX_H diff --git a/src/gui/painting/qoutlinemapper.cpp b/src/gui/painting/qoutlinemapper.cpp index 2f2fe44209..8b47dae5ff 100644 --- a/src/gui/painting/qoutlinemapper.cpp +++ b/src/gui/painting/qoutlinemapper.cpp @@ -48,8 +48,6 @@ QT_BEGIN_NAMESPACE -static const qreal aliasedCoordinateDelta = 0.5 - 0.015625; - #define qreal_to_fixed_26_6(f) (int(f * 64)) diff --git a/src/gui/painting/qpagedpaintdevice.h b/src/gui/painting/qpagedpaintdevice.h index b2b53d8038..d44a401184 100644 --- a/src/gui/painting/qpagedpaintdevice.h +++ b/src/gui/painting/qpagedpaintdevice.h @@ -44,8 +44,6 @@ #include <QtGui/qpaintdevice.h> -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE #if defined(B0) @@ -90,6 +88,4 @@ protected: QT_END_NAMESPACE -QT_END_HEADER - #endif diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp index 1a5a19a366..bb0c441b40 100644 --- a/src/gui/painting/qpaintbuffer.cpp +++ b/src/gui/painting/qpaintbuffer.cpp @@ -74,11 +74,11 @@ QTextItemIntCopy::QTextItemIntCopy(const QTextItem &item) char *glyphLayoutData = new char[size]; QGlyphLayout glyphs(glyphLayoutData, m_item.glyphs.numGlyphs); memcpy(glyphs.offsets, m_item.glyphs.offsets, m_item.glyphs.numGlyphs * sizeof(QFixedPoint)); - memcpy(glyphs.glyphs, m_item.glyphs.glyphs, m_item.glyphs.numGlyphs * sizeof(HB_Glyph)); + memcpy(glyphs.glyphs, m_item.glyphs.glyphs, m_item.glyphs.numGlyphs * sizeof(glyph_t)); memcpy(glyphs.advances_x, m_item.glyphs.advances_x, m_item.glyphs.numGlyphs * sizeof(QFixed)); memcpy(glyphs.advances_y, m_item.glyphs.advances_y, m_item.glyphs.numGlyphs * sizeof(QFixed)); memcpy(glyphs.justifications, m_item.glyphs.justifications, m_item.glyphs.numGlyphs * sizeof(QGlyphJustification)); - memcpy(glyphs.attributes, m_item.glyphs.attributes, m_item.glyphs.numGlyphs * sizeof(HB_GlyphAttributes)); + memcpy(glyphs.attributes, m_item.glyphs.attributes, m_item.glyphs.numGlyphs * sizeof(QGlyphAttributes)); m_item.glyphs = glyphs; m_font = *m_item.f; @@ -1731,12 +1731,12 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd) #endif painter->setClipRegion(region, Qt::ClipOperation(cmd.extra)); break; } - + #if !defined(QT_NO_RAWFONT) case QPaintBufferPrivate::Cmd_DrawStaticText: { - + QVariantList variants(d->variants.at(cmd.offset).value<QVariantList>()); - + QFont font = variants.at(0).value<QFont>(); QVector<quint32> glyphIndexes; @@ -1752,7 +1752,7 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd) QRawFont rawFont; QRawFontPrivate *rawFontD = QRawFontPrivate::get(rawFont); QFontPrivate *fontD = QFontPrivate::get(font); - rawFontD->fontEngine = fontD->engineForScript(QUnicodeTables::Common); + rawFontD->fontEngine = fontD->engineForScript(QChar::Script_Common); rawFontD->fontEngine->ref.ref(); QGlyphRun glyphs; diff --git a/src/gui/painting/qpaintdevice.h b/src/gui/painting/qpaintdevice.h index 1a638ffeba..1529b701cf 100644 --- a/src/gui/painting/qpaintdevice.h +++ b/src/gui/painting/qpaintdevice.h @@ -45,8 +45,6 @@ #include <QtGui/qwindowdefs.h> #include <QtCore/qrect.h> -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -120,6 +118,4 @@ inline bool QPaintDevice::paintingActive() const QT_END_NAMESPACE -QT_END_HEADER - #endif // QPAINTDEVICE_H diff --git a/src/gui/painting/qpaintengine.h b/src/gui/painting/qpaintengine.h index 85f4d2159e..b3e3762cc8 100644 --- a/src/gui/painting/qpaintengine.h +++ b/src/gui/painting/qpaintengine.h @@ -47,8 +47,6 @@ #include <QtCore/qscopedpointer.h> #include <QtGui/qpainter.h> -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -348,6 +346,4 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QPaintEngine::DirtyFlags) QT_END_NAMESPACE -QT_END_HEADER - #endif // QPAINTENGINE_H diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 941e3ea71a..a123c147a2 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -2858,7 +2858,19 @@ bool QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, // x, y, // positions[i].x.toInt(), positions[i].y.toInt()); - alphaPenBlt(bits + ((c.x << leftShift) >> rightShift) + c.y * bpl, bpl, depth, x, y, c.w, c.h); + const uchar *glyphBits = bits + ((c.x << leftShift) >> rightShift) + c.y * bpl; + + if (glyphType == QFontEngineGlyphCache::Raster_ARGB) { + // The current state transform has already been applied to the positions, + // so we prevent drawImage() from re-applying the transform by clearing + // the state for the duration of the call. + QTransform originalTransform = s->matrix; + s->matrix = QTransform(); + drawImage(QPoint(x, y), QImage(glyphBits, c.w, c.h, bpl, image.format())); + s->matrix = originalTransform; + } else { + alphaPenBlt(glyphBits, bpl, depth, x, y, c.w, c.h); + } } } return true; @@ -3011,13 +3023,15 @@ void QRasterPaintEngine::drawStaticTextItem(QStaticTextItem *textItem) ensurePen(); ensureRasterState(); + QTransform matrix = state()->matrix; + QFontEngine *fontEngine = textItem->fontEngine(); - if (!supportsTransformations(fontEngine)) { + if (shouldDrawCachedGlyphs(fontEngine, matrix)) { drawCachedGlyphs(textItem->numGlyphs, textItem->glyphs, textItem->glyphPositions, fontEngine); - } else if (state()->matrix.type() < QTransform::TxProject) { + } else if (matrix.type() < QTransform::TxProject) { bool invertible; - QTransform invMat = state()->matrix.inverted(&invertible); + QTransform invMat = matrix.inverted(&invertible); if (!invertible) return; @@ -3056,7 +3070,7 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte QRasterPaintEngineState *s = state(); QTransform matrix = s->matrix; - if (!supportsTransformations(ti.fontEngine)) { + if (shouldDrawCachedGlyphs(ti.fontEngine, matrix)) { QVarLengthArray<QFixedPoint> positions; QVarLengthArray<glyph_t> glyphs; @@ -3300,21 +3314,25 @@ void QRasterPaintEngine::releaseDC(HDC) const /*! \internal */ -bool QRasterPaintEngine::supportsTransformations(QFontEngine *fontEngine) const +bool QRasterPaintEngine::requiresPretransformedGlyphPositions(QFontEngine *fontEngine, const QTransform &m) const { - const QTransform &m = state()->matrix; - return supportsTransformations(fontEngine, m); + // Cached glyphs always require pretransformed positions + if (shouldDrawCachedGlyphs(fontEngine, m)) + return true; + + // Otherwise let the base-class decide based on the transform + return QPaintEngineEx::requiresPretransformedGlyphPositions(fontEngine, m); } -/*! - \internal -*/ -bool QRasterPaintEngine::supportsTransformations(QFontEngine *fontEngine, const QTransform &m) const +bool QRasterPaintEngine::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &m) const { - if (fontEngine->supportsTransformations(m)) - return true; + // The font engine might not support filling the glyph cache + // with the given transform applied, in which case we need to + // fall back to the QPainterPath code-path. + if (!fontEngine->supportsTransformation(m)) + return false; - return !shouldDrawCachedGlyphs(fontEngine, m); + return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, m); } /*! diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h index d9e4a4b505..00a9ae750c 100644 --- a/src/gui/painting/qpaintengine_raster_p.h +++ b/src/gui/painting/qpaintengine_raster_p.h @@ -231,8 +231,8 @@ public: QPoint coordinateOffset() const; - bool supportsTransformations(QFontEngine *fontEngine) const; - bool supportsTransformations(QFontEngine *fontEngine, const QTransform &m) const; + bool requiresPretransformedGlyphPositions(QFontEngine *fontEngine, const QTransform &m) const; + bool shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &m) const; protected: QRasterPaintEngine(QRasterPaintEnginePrivate &d, QPaintDevice *); diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index 83b684da1e..6e72b5db7f 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -1081,18 +1081,16 @@ void QPaintEngineEx::drawStaticTextItem(QStaticTextItem *staticTextItem) } } -bool QPaintEngineEx::supportsTransformations(QFontEngine *fontEngine, const QTransform &m) const +bool QPaintEngineEx::requiresPretransformedGlyphPositions(QFontEngine *, const QTransform &t) const { - Q_UNUSED(fontEngine); - - if (!m.isAffine()) - return true; - - return false; + return t.type() >= QTransform::TxProject; } bool QPaintEngineEx::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &m) const { + if (fontEngine->glyphFormat == QFontEngineGlyphCache::Raster_ARGB) + return true; + qreal pixelSize = fontEngine->fontDef.pixelSize; return (pixelSize * pixelSize * qAbs(m.determinant())) < QT_MAX_CACHED_GLYPH_SIZE * QT_MAX_CACHED_GLYPH_SIZE; diff --git a/src/gui/painting/qpaintengineex_p.h b/src/gui/painting/qpaintengineex_p.h index 399a6f63b0..5a9df72c76 100644 --- a/src/gui/painting/qpaintengineex_p.h +++ b/src/gui/painting/qpaintengineex_p.h @@ -61,8 +61,6 @@ #include <private/qvectorpath_p.h> -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -164,7 +162,7 @@ public: IsEmulationEngine = 0x02 // If set, this object is a QEmulationEngine. }; virtual uint flags() const {return 0;} - virtual bool supportsTransformations(QFontEngine *fontEngine, const QTransform &m) const; + virtual bool requiresPretransformedGlyphPositions(QFontEngine *fontEngine, const QTransform &m) const; virtual bool shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &m) const; protected: @@ -192,6 +190,4 @@ public: QT_END_NAMESPACE -QT_END_HEADER - #endif diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 786136d203..be77fffc7c 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -1155,9 +1155,6 @@ void QPainterPrivate::updateState(QPainterState *newState) should antialias text if possible, and the \l {RenderHint}{QPainter::SmoothPixmapTransform} indicates that the engine should use a smooth pixmap transformation algorithm. - \l {RenderHint}{HighQualityAntialiasing} is an OpenGL-specific rendering hint - indicating that the engine should use fragment programs and offscreen - rendering for antialiasing. The renderHints() function returns a flag that specifies the rendering hints that are set for this painter. Use the @@ -1409,9 +1406,8 @@ void QPainterPrivate::updateState(QPainterState *newState) a smooth pixmap transformation algorithm (such as bilinear) rather than nearest neighbor. - \value HighQualityAntialiasing An OpenGL-specific rendering hint - indicating that the engine should use fragment programs and offscreen - rendering for antialiasing. + \value HighQualityAntialiasing This value is obsolete and will be ignored, + use the Antialiasing render hint instead. \value NonCosmeticDefaultPen This value is obsolete, the default for QPen is now non-cosmetic. @@ -5552,13 +5548,13 @@ void QPainter::drawGlyphRun(const QPointF &position, const QGlyphRun &glyphRun) QVarLengthArray<QFixedPoint, 128> fixedPointPositions(count); QRawFontPrivate *fontD = QRawFontPrivate::get(font); - bool supportsTransformations = d->extended - ? d->extended->supportsTransformations(fontD->fontEngine, d->state->matrix) - : d->engine->type() == QPaintEngine::CoreGraphics || d->state->matrix.isAffine(); + bool engineRequiresPretransformedGlyphPositions = d->extended + ? d->extended->requiresPretransformedGlyphPositions(fontD->fontEngine, d->state->matrix) + : d->engine->type() != QPaintEngine::CoreGraphics && !d->state->matrix.isAffine(); for (int i=0; i<count; ++i) { QPointF processedPosition = position + glyphPositions[i]; - if (!supportsTransformations) + if (engineRequiresPretransformedGlyphPositions) processedPosition = d->state->transform().map(processedPosition); fixedPointPositions[i] = QFixedPoint::fromPointF(processedPosition); } @@ -5616,13 +5612,13 @@ void QPainterPrivate::drawGlyphs(const quint32 *glyphArray, QFixedPoint *positio QVarLengthArray<QFixed, 128> advances(glyphCount); QVarLengthArray<QGlyphJustification, 128> glyphJustifications(glyphCount); - QVarLengthArray<HB_GlyphAttributes, 128> glyphAttributes(glyphCount); - memset(glyphAttributes.data(), 0, glyphAttributes.size() * sizeof(HB_GlyphAttributes)); + QVarLengthArray<QGlyphAttributes, 128> glyphAttributes(glyphCount); + memset(glyphAttributes.data(), 0, glyphAttributes.size() * sizeof(QGlyphAttributes)); memset(advances.data(), 0, advances.size() * sizeof(QFixed)); memset(glyphJustifications.data(), 0, glyphJustifications.size() * sizeof(QGlyphJustification)); textItem.glyphs.numGlyphs = glyphCount; - textItem.glyphs.glyphs = reinterpret_cast<HB_Glyph *>(const_cast<quint32 *>(glyphArray)); + textItem.glyphs.glyphs = const_cast<glyph_t *>(glyphArray); textItem.glyphs.offsets = positions; textItem.glyphs.advances_x = advances.data(); textItem.glyphs.advances_y = advances.data(); @@ -5738,17 +5734,21 @@ void QPainter::drawStaticText(const QPointF &topLeftPosition, const QStaticText return; } - QFontEngine *fe = staticText_d->font.d->engineForScript(QUnicodeTables::Common); + QFontEngine *fe = staticText_d->font.d->engineForScript(QChar::Script_Common); if (fe->type() == QFontEngine::Multi) fe = static_cast<QFontEngineMulti *>(fe)->engine(0); - bool supportsTransformations = d->extended->supportsTransformations(fe, - d->state->matrix); - if (supportsTransformations && !staticText_d->untransformedCoordinates) { - staticText_d->untransformedCoordinates = true; - staticText_d->needsRelayout = true; - } else if (!supportsTransformations && staticText_d->untransformedCoordinates) { + + bool engineRequiresPretransform = d->extended->requiresPretransformedGlyphPositions(fe, d->state->matrix); + if (staticText_d->untransformedCoordinates && engineRequiresPretransform) { + // The coordinates are untransformed, and the engine can't deal with that + // nativly, so we have to pre-transform the static text. staticText_d->untransformedCoordinates = false; staticText_d->needsRelayout = true; + } else if (!staticText_d->untransformedCoordinates && !engineRequiresPretransform) { + // The coordinates are already transformed, but the engine can handle that + // nativly, so undo the transform of the static text. + staticText_d->untransformedCoordinates = true; + staticText_d->needsRelayout = true; } // Don't recalculate entire layout because of translation, rather add the dx and dy @@ -5841,11 +5841,11 @@ void QPainter::drawText(const QPointF &p, const QString &str, int tf, int justif return; if (tf & Qt::TextBypassShaping) { - // Skip harfbuzz complex shaping, shape using glyph advances only + // Skip complex shaping, shape using glyph advances only int len = str.length(); int numGlyphs = len; QVarLengthGlyphLayoutArray glyphs(len); - QFontEngine *fontEngine = d->state->font.d->engineForScript(QUnicodeTables::Common); + QFontEngine *fontEngine = d->state->font.d->engineForScript(QChar::Script_Common); if (!fontEngine->stringToCMap(str.data(), len, &glyphs, &numGlyphs, 0)) { glyphs.resize(numGlyphs); if (!fontEngine->stringToCMap(str.data(), len, &glyphs, &numGlyphs, 0)) diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h index 9f390b9865..874b244bd6 100644 --- a/src/gui/painting/qpainter.h +++ b/src/gui/painting/qpainter.h @@ -60,8 +60,6 @@ #include <QtGui/qfontmetrics.h> #endif -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -932,6 +930,4 @@ inline void QPainter::drawPicture(const QPoint &pt, const QPicture &p) QT_END_NAMESPACE -QT_END_HEADER - #endif // QPAINTER_H diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h index 7c3365875e..e22c1729f3 100644 --- a/src/gui/painting/qpainterpath.h +++ b/src/gui/painting/qpainterpath.h @@ -49,8 +49,6 @@ #include <QtCore/qvector.h> #include <QtCore/qscopedpointer.h> -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -375,6 +373,4 @@ Q_GUI_EXPORT QDebug operator<<(QDebug, const QPainterPath &); QT_END_NAMESPACE -QT_END_HEADER - #endif // QPAINTERPATH_H diff --git a/src/gui/painting/qpathclipper_p.h b/src/gui/painting/qpathclipper_p.h index 4ab2b9d88a..45cce640c5 100644 --- a/src/gui/painting/qpathclipper_p.h +++ b/src/gui/painting/qpathclipper_p.h @@ -60,8 +60,6 @@ #include <private/qdatabuffer_p.h> #include <stdio.h> -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -488,6 +486,4 @@ inline QPathEdge::Direction QWingedEdge::flip(QPathEdge::Direction direction) QT_END_NAMESPACE -QT_END_HEADER - #endif // QPATHCLIPPER_P_H diff --git a/src/gui/painting/qpdfwriter.h b/src/gui/painting/qpdfwriter.h index 792aeefad1..45bb5ad4b4 100644 --- a/src/gui/painting/qpdfwriter.h +++ b/src/gui/painting/qpdfwriter.h @@ -45,8 +45,6 @@ #include <QtCore/qobject.h> #include <QtGui/qpagedpaintdevice.h> -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -85,6 +83,4 @@ private: QT_END_NAMESPACE -QT_END_HEADER - #endif diff --git a/src/gui/painting/qpen.h b/src/gui/painting/qpen.h index 3e5e258123..c5144f784f 100644 --- a/src/gui/painting/qpen.h +++ b/src/gui/painting/qpen.h @@ -45,8 +45,6 @@ #include <QtGui/qcolor.h> #include <QtGui/qbrush.h> -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -139,6 +137,4 @@ Q_GUI_EXPORT QDebug operator<<(QDebug, const QPen &); QT_END_NAMESPACE -QT_END_HEADER - #endif // QPEN_H diff --git a/src/gui/painting/qplatformbackingstore.h b/src/gui/painting/qplatformbackingstore.h index 0429ec7e89..1b19b2c379 100644 --- a/src/gui/painting/qplatformbackingstore.h +++ b/src/gui/painting/qplatformbackingstore.h @@ -56,8 +56,6 @@ #include <QtGui/qwindow.h> #include <QtGui/qregion.h> -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -95,6 +93,4 @@ private: QT_END_NAMESPACE -QT_END_HEADER - #endif // QPLATFORMBACKINGSTORE_H diff --git a/src/gui/painting/qpolygon.h b/src/gui/painting/qpolygon.h index 32de4ddd65..1039e842ab 100644 --- a/src/gui/painting/qpolygon.h +++ b/src/gui/painting/qpolygon.h @@ -46,8 +46,6 @@ #include <QtCore/qpoint.h> #include <QtCore/qrect.h> -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -185,6 +183,4 @@ inline QPolygonF QPolygonF::translated(qreal dx, qreal dy) const QT_END_NAMESPACE -QT_END_HEADER - #endif // QPOLYGON_H diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h index dee996c523..0e436e3fb4 100644 --- a/src/gui/painting/qregion.h +++ b/src/gui/painting/qregion.h @@ -50,8 +50,6 @@ #include <QtCore/qdatastream.h> #endif -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -173,6 +171,4 @@ Q_GUI_EXPORT QDebug operator<<(QDebug, const QRegion &); QT_END_NAMESPACE -QT_END_HEADER - #endif // QREGION_H diff --git a/src/gui/painting/qrgb.h b/src/gui/painting/qrgb.h index 06c479e5cd..d7a01840e8 100644 --- a/src/gui/painting/qrgb.h +++ b/src/gui/painting/qrgb.h @@ -44,14 +44,13 @@ #include <QtCore/qglobal.h> -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE typedef unsigned int QRgb; // RGB triplet -const QRgb RGB_MASK = 0x00ffffff; // masks RGB values +// non-namespaced Qt global variable +const Q_DECL_UNUSED QRgb RGB_MASK = 0x00ffffff; // masks RGB values inline int qRed(QRgb rgb) // get red part of RGB { return ((rgb >> 16) & 0xff); } @@ -82,6 +81,4 @@ inline bool qIsGray(QRgb rgb) QT_END_NAMESPACE -QT_END_HEADER - #endif // QRGB_H diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index ed0473749e..6676d3daa6 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -135,6 +135,7 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const switch (m_type) { case Raster_A8: format = QFontEngine::Format_A8; break; case Raster_RGBMask: format = QFontEngine::Format_A32; break; + case Raster_ARGB: format = QFontEngine::Format_ARGB; break; default: format = QFontEngine::Format_Mono; break; } @@ -163,7 +164,7 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const metrics.yoff.toReal(), metrics.x.toReal(), metrics.y.toReal()); -#endif +#endif GlyphAndSubPixelPosition key(glyph, subPixelPosition); int glyph_width = metrics.width.ceil().toInt(); int glyph_height = metrics.height.ceil().toInt(); @@ -281,6 +282,8 @@ QImage QTextureGlyphCache::textureMapForGlyph(glyph_t g, QFixed subPixelPosition { if (m_type == QFontEngineGlyphCache::Raster_RGBMask) return m_current_fontengine->alphaRGBMapForGlyph(g, subPixelPosition, m_transform); + else if (m_type == QFontEngineGlyphCache::Raster_ARGB) + return m_current_fontengine->bitmapForGlyph(g, subPixelPosition, m_transform); return m_current_fontengine->alphaMapForGlyph(g, subPixelPosition, m_transform); } @@ -312,6 +315,7 @@ void QImageTextureGlyphCache::createTextureData(int width, int height) m_image = QImage(width, height, QImage::Format_RGB32); break; case QFontEngineGlyphCache::Raster_ARGB: + m_image = QImage(width, height, QImage::Format_ARGB32_Premultiplied); break; } } @@ -328,7 +332,8 @@ void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g, QFixed subP } #endif - if (m_type == QFontEngineGlyphCache::Raster_RGBMask) { + if (m_type == QFontEngineGlyphCache::Raster_RGBMask + || m_type == QFontEngineGlyphCache::Raster_ARGB) { QImage ref(m_image.bits() + (c.x * 4 + c.y * m_image.bytesPerLine()), qMax(mask.width(), c.w), qMax(mask.height(), c.h), m_image.bytesPerLine(), m_image.format()); diff --git a/src/gui/painting/qtextureglyphcache_p.h b/src/gui/painting/qtextureglyphcache_p.h index d0fe7ab8cb..d93f57ad80 100644 --- a/src/gui/painting/qtextureglyphcache_p.h +++ b/src/gui/painting/qtextureglyphcache_p.h @@ -60,10 +60,6 @@ #include <private/qfontengineglyphcache_p.h> -#if defined(Q_OS_VXWORKS) && defined(m_type) -# undef m_type -#endif - #ifndef QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH #define QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH 256 #endif diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h index f98642cd98..060362f63e 100644 --- a/src/gui/painting/qtransform.h +++ b/src/gui/painting/qtransform.h @@ -50,12 +50,6 @@ #include <QtCore/qpoint.h> #include <QtCore/qrect.h> -#if defined(Q_OS_VXWORKS) && defined(m_type) -# undef m_type -#endif - -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -389,6 +383,4 @@ inline QTransform operator -(const QTransform &a, qreal n) QT_END_NAMESPACE -QT_END_HEADER - #endif // QTRANSFORM_H diff --git a/src/gui/painting/qvectorpath_p.h b/src/gui/painting/qvectorpath_p.h index f8ba02dc79..e97d6e1dce 100644 --- a/src/gui/painting/qvectorpath_p.h +++ b/src/gui/painting/qvectorpath_p.h @@ -60,8 +60,6 @@ #include <private/qpainter_p.h> -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -187,6 +185,4 @@ Q_GUI_EXPORT const QVectorPath &qtVectorPathForPath(const QPainterPath &path); QT_END_NAMESPACE -QT_END_HEADER - #endif |