diff options
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qoutlinemapper.cpp | 2 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 20 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_raster_p.h | 2 | ||||
-rw-r--r-- | src/gui/painting/qpaintengineex.cpp | 2 | ||||
-rw-r--r-- | src/gui/painting/qpainter.cpp | 6 | ||||
-rw-r--r-- | src/gui/painting/qpainterpath.h | 2 | ||||
-rw-r--r-- | src/gui/painting/qtextureglyphcache.cpp | 43 | ||||
-rw-r--r-- | src/gui/painting/qtextureglyphcache_p.h | 8 |
8 files changed, 41 insertions, 44 deletions
diff --git a/src/gui/painting/qoutlinemapper.cpp b/src/gui/painting/qoutlinemapper.cpp index 8b47dae5ff..6a38ed6c70 100644 --- a/src/gui/painting/qoutlinemapper.cpp +++ b/src/gui/painting/qoutlinemapper.cpp @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE -#define qreal_to_fixed_26_6(f) (int(f * 64)) +#define qreal_to_fixed_26_6(f) (qRound(f * 64)) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 9a2e49618c..67896f786d 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -523,7 +523,7 @@ bool QRasterPaintEngine::begin(QPaintDevice *device) #endif if (d->mono_surface) - d->glyphCacheType = QFontEngineGlyphCache::Raster_Mono; + d->glyphCacheFormat = QFontEngine::Format_Mono; #if defined(Q_OS_WIN) else if (clearTypeFontsEnabled()) #else @@ -532,11 +532,11 @@ bool QRasterPaintEngine::begin(QPaintDevice *device) { QImage::Format format = static_cast<QImage *>(d->device)->format(); if (format == QImage::Format_ARGB32_Premultiplied || format == QImage::Format_RGB32) - d->glyphCacheType = QFontEngineGlyphCache::Raster_RGBMask; + d->glyphCacheFormat = QFontEngine::Format_A32; else - d->glyphCacheType = QFontEngineGlyphCache::Raster_A8; + d->glyphCacheFormat = QFontEngine::Format_A8; } else - d->glyphCacheType = QFontEngineGlyphCache::Raster_A8; + d->glyphCacheFormat = QFontEngine::Format_A8; setActive(true); return true; @@ -2819,12 +2819,12 @@ bool QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, } } else { - QFontEngineGlyphCache::Type glyphType = fontEngine->glyphFormat >= 0 ? QFontEngineGlyphCache::Type(fontEngine->glyphFormat) : d->glyphCacheType; + QFontEngine::GlyphFormat glyphFormat = fontEngine->glyphFormat != QFontEngine::Format_None ? fontEngine->glyphFormat : d->glyphCacheFormat; QImageTextureGlyphCache *cache = - static_cast<QImageTextureGlyphCache *>(fontEngine->glyphCache(0, glyphType, s->matrix)); + static_cast<QImageTextureGlyphCache *>(fontEngine->glyphCache(0, glyphFormat, s->matrix)); if (!cache) { - cache = new QImageTextureGlyphCache(glyphType, s->matrix); + cache = new QImageTextureGlyphCache(glyphFormat, s->matrix); fontEngine->setGlyphCache(0, cache); } @@ -2842,7 +2842,7 @@ bool QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, else if (depth == 1) rightShift = 3; // divide by 8 - int margin = fontEngine->glyphMargin(glyphType); + int margin = fontEngine->glyphMargin(glyphFormat); const uchar *bits = image.bits(); for (int i=0; i<numGlyphs; ++i) { @@ -2865,7 +2865,7 @@ bool QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, const uchar *glyphBits = bits + ((c.x << leftShift) >> rightShift) + c.y * bpl; - if (glyphType == QFontEngineGlyphCache::Raster_ARGB) { + if (glyphFormat == QFontEngine::Format_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. @@ -3064,7 +3064,7 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte Q_D(QRasterPaintEngine); fprintf(stderr," - QRasterPaintEngine::drawTextItem(), (%.2f,%.2f), string=%s ct=%d\n", p.x(), p.y(), QString::fromRawData(ti.chars, ti.num_chars).toLatin1().data(), - d->glyphCacheType); + d->glyphCacheFormat); #endif if (ti.glyphs.numGlyphs == 0) diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h index 00a9ae750c..4bfdbd91e0 100644 --- a/src/gui/painting/qpaintengine_raster_p.h +++ b/src/gui/painting/qpaintengine_raster_p.h @@ -336,7 +336,7 @@ public: QSpanData solid_color_filler; - QFontEngineGlyphCache::Type glyphCacheType; + QFontEngine::GlyphFormat glyphCacheFormat; QScopedPointer<QClipData> baseClip; diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index 6e72b5db7f..e75a59cc91 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -1088,7 +1088,7 @@ bool QPaintEngineEx::requiresPretransformedGlyphPositions(QFontEngine *, const Q bool QPaintEngineEx::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &m) const { - if (fontEngine->glyphFormat == QFontEngineGlyphCache::Raster_ARGB) + if (fontEngine->glyphFormat == QFontEngine::Format_ARGB) return true; qreal pixelSize = fontEngine->fontDef.pixelSize; diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 1fc044aa44..e35cdd370e 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -171,9 +171,6 @@ static bool qt_painter_thread_test(int devType, const char *what) void QPainterPrivate::checkEmulation() { Q_ASSERT(extended); - if (extended->flags() & QPaintEngineEx::DoNotEmulate) - return; - bool doEmulation = false; if (state->bgMode == Qt::OpaqueMode) doEmulation = true; @@ -186,6 +183,9 @@ void QPainterPrivate::checkEmulation() if (pg && pg->coordinateMode() > QGradient::LogicalMode) doEmulation = true; + if (doEmulation && extended->flags() & QPaintEngineEx::DoNotEmulate) + return; + if (doEmulation) { if (extended != emulationEngine) { if (!emulationEngine) diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h index c922867eb9..db65e14af9 100644 --- a/src/gui/painting/qpainterpath.h +++ b/src/gui/painting/qpainterpath.h @@ -244,7 +244,7 @@ class Q_GUI_EXPORT QPainterPathStroker Q_DECLARE_PRIVATE(QPainterPathStroker) public: QPainterPathStroker(); - QPainterPathStroker(const QPen &pen); + explicit QPainterPathStroker(const QPen &pen); ~QPainterPathStroker(); void setWidth(qreal width); diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index e340c1e613..83edeb41a6 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -130,14 +130,6 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const QHash<GlyphAndSubPixelPosition, Coord> listItemCoordinates; int rowHeight = 0; - QFontEngine::GlyphFormat format; - 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; - } - // check each glyph for its metrics and get the required rowHeight. for (int i=0; i < numGlyphs; ++i) { const glyph_t glyph = glyphs[i]; @@ -159,12 +151,12 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const // we ask for the alphaMapBoundingBox(), the glyph will be loaded, rasterized and its // proper metrics will be cached and used later. if (fontEngine->hasInternalCaching()) { - QImage *locked = fontEngine->lockedAlphaMapForGlyph(glyph, subPixelPosition, format); + QImage *locked = fontEngine->lockedAlphaMapForGlyph(glyph, subPixelPosition, m_format); if (locked && !locked->isNull()) fontEngine->unlockAlphaMapForGlyph(); } - glyph_metrics_t metrics = fontEngine->alphaMapBoundingBox(glyph, subPixelPosition, m_transform, format); + glyph_metrics_t metrics = fontEngine->alphaMapBoundingBox(glyph, subPixelPosition, m_transform, m_format); #ifdef CACHE_DEBUG printf("(%4x): w=%.2f, h=%.2f, xoff=%.2f, yoff=%.2f, x=%.2f, y=%.2f\n", @@ -186,7 +178,7 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const continue; } // align to 8-bit boundary - if (m_type == QFontEngineGlyphCache::Raster_Mono) + if (m_format == QFontEngine::Format_Mono) glyph_width = (glyph_width+7)&~7; Coord c = { 0, 0, // will be filled in later @@ -289,11 +281,14 @@ void QTextureGlyphCache::fillInPendingGlyphs() QImage QTextureGlyphCache::textureMapForGlyph(glyph_t g, QFixed subPixelPosition) const { - if (m_type == QFontEngineGlyphCache::Raster_RGBMask) + switch (m_format) { + case QFontEngine::Format_A32: return m_current_fontengine->alphaRGBMapForGlyph(g, subPixelPosition, m_transform); - else if (m_type == QFontEngineGlyphCache::Raster_ARGB) + case QFontEngine::Format_ARGB: return m_current_fontengine->bitmapForGlyph(g, subPixelPosition, m_transform); - return m_current_fontengine->alphaMapForGlyph(g, subPixelPosition, m_transform); + default: + return m_current_fontengine->alphaMapForGlyph(g, subPixelPosition, m_transform); + } } /************************************************************************ @@ -307,11 +302,11 @@ void QImageTextureGlyphCache::resizeTextureData(int width, int height) void QImageTextureGlyphCache::createTextureData(int width, int height) { - switch (m_type) { - case QFontEngineGlyphCache::Raster_Mono: + switch (m_format) { + case QFontEngine::Format_Mono: m_image = QImage(width, height, QImage::Format_Mono); break; - case QFontEngineGlyphCache::Raster_A8: { + case QFontEngine::Format_A8: { m_image = QImage(width, height, QImage::Format_Indexed8); m_image.fill(0); QVector<QRgb> colors(256); @@ -320,12 +315,14 @@ void QImageTextureGlyphCache::createTextureData(int width, int height) *it = 0xff000000 | i | (i<<8) | (i<<16); m_image.setColorTable(colors); break; } - case QFontEngineGlyphCache::Raster_RGBMask: + case QFontEngine::Format_A32: m_image = QImage(width, height, QImage::Format_RGB32); break; - case QFontEngineGlyphCache::Raster_ARGB: + case QFontEngine::Format_ARGB: m_image = QImage(width, height, QImage::Format_ARGB32_Premultiplied); break; + default: + Q_UNREACHABLE(); } } @@ -341,8 +338,8 @@ void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g, QFixed subP } #endif - if (m_type == QFontEngineGlyphCache::Raster_RGBMask - || m_type == QFontEngineGlyphCache::Raster_ARGB) { + if (m_format == QFontEngine::Format_A32 + || m_format == QFontEngine::Format_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()); @@ -351,7 +348,7 @@ void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g, QFixed subP p.fillRect(0, 0, c.w, c.h, QColor(0,0,0,0)); // TODO optimize this p.drawImage(0, 0, mask); p.end(); - } else if (m_type == QFontEngineGlyphCache::Raster_Mono) { + } else if (m_format == QFontEngine::Format_Mono) { if (mask.depth() > 1) { // TODO optimize this mask = mask.alphaChannel(); @@ -414,7 +411,7 @@ void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g, QFixed subP #ifdef CACHE_DEBUG // QPainter p(&m_image); // p.drawLine( - int margin = m_current_fontengine ? m_current_fontengine->glyphMargin(m_type) : 0; + int margin = m_current_fontengine ? m_current_fontengine->glyphMargin(m_format) : 0; QPoint base(c.x + margin, c.y + margin + c.baseLineY-1); if (m_image.rect().contains(base)) m_image.setPixel(base, 255); diff --git a/src/gui/painting/qtextureglyphcache_p.h b/src/gui/painting/qtextureglyphcache_p.h index d93f57ad80..84f62717f6 100644 --- a/src/gui/painting/qtextureglyphcache_p.h +++ b/src/gui/painting/qtextureglyphcache_p.h @@ -75,8 +75,8 @@ class QTextItemInt; class Q_GUI_EXPORT QTextureGlyphCache : public QFontEngineGlyphCache { public: - QTextureGlyphCache(QFontEngineGlyphCache::Type type, const QTransform &matrix) - : QFontEngineGlyphCache(matrix, type), m_current_fontengine(0), + QTextureGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix) + : QFontEngineGlyphCache(format, matrix), m_current_fontengine(0), m_w(0), m_h(0), m_cx(0), m_cy(0), m_currentRowHeight(0) { } @@ -163,8 +163,8 @@ inline uint qHash(const QTextureGlyphCache::GlyphAndSubPixelPosition &g) class Q_GUI_EXPORT QImageTextureGlyphCache : public QTextureGlyphCache { public: - QImageTextureGlyphCache(QFontEngineGlyphCache::Type type, const QTransform &matrix) - : QTextureGlyphCache(type, matrix) { } + QImageTextureGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix) + : QTextureGlyphCache(format, matrix) { } virtual void createTextureData(int width, int height); virtual void resizeTextureData(int width, int height); virtual void fillTexture(const Coord &c, glyph_t glyph, QFixed subPixelPosition); |