Making cached glyphs drawing check clearer
Putting the logic inside supportsTransformation() is a bit confusing and that name is misleading. Also move the same check in GL2 paint engine to the same place. Change-Id: I182500a0ff375122e6be966b7ce2495c84d113d0 Reviewed-on: http://codereview.qt.nokia.com/2096 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
This commit is contained in:
parent
a150880ae6
commit
8d762c9cae
@ -3011,7 +3011,7 @@ void QRasterPaintEngine::drawStaticTextItem(QStaticTextItem *textItem)
|
||||
ensureState();
|
||||
|
||||
QFontEngine *fontEngine = textItem->fontEngine();
|
||||
if (!supportsTransformations(fontEngine)) {
|
||||
if (shouldDrawCachedGlyphs(fontEngine->fontDef.pixelSize, state()->matrix)) {
|
||||
drawCachedGlyphs(textItem->numGlyphs, textItem->glyphs, textItem->glyphPositions,
|
||||
fontEngine);
|
||||
} else {
|
||||
@ -3385,10 +3385,7 @@ bool QRasterPaintEngine::supportsTransformations(qreal pixelSize, const QTransfo
|
||||
#endif
|
||||
return true;
|
||||
|
||||
if (pixelSize * pixelSize * qAbs(m.determinant()) >= 64 * 64)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return !shouldDrawCachedGlyphs(pixelSize, m);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -53,6 +53,10 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#if !defined(QT_MAX_CACHED_GLYPH_SIZE)
|
||||
# define QT_MAX_CACHED_GLYPH_SIZE 64
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* class QVectorPath
|
||||
@ -1096,4 +1100,10 @@ bool QPaintEngineEx::supportsTransformations(qreal pixelSize, const QTransform &
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QPaintEngineEx::shouldDrawCachedGlyphs(qreal pixelSize, const QTransform &m) const
|
||||
{
|
||||
return (pixelSize * pixelSize * qAbs(m.determinant())) <
|
||||
QT_MAX_CACHED_GLYPH_SIZE * QT_MAX_CACHED_GLYPH_SIZE;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -228,6 +228,7 @@ public:
|
||||
};
|
||||
virtual uint flags() const {return 0;}
|
||||
virtual bool supportsTransformations(qreal pixelSize, const QTransform &m) const;
|
||||
virtual bool shouldDrawCachedGlyphs(qreal pixelSize, const QTransform &m) const;
|
||||
|
||||
protected:
|
||||
QPaintEngineEx(QPaintEngineExPrivate &data);
|
||||
|
@ -98,10 +98,6 @@ extern Q_GUI_EXPORT bool qt_cleartype_enabled;
|
||||
extern bool qt_applefontsmoothing_enabled;
|
||||
#endif
|
||||
|
||||
#if !defined(QT_MAX_CACHED_GLYPH_SIZE)
|
||||
# define QT_MAX_CACHED_GLYPH_SIZE 64
|
||||
#endif
|
||||
|
||||
Q_GUI_EXPORT QImage qt_imageForBrush(int brushStyle, bool invert);
|
||||
|
||||
////////////////////////////////// Private Methods //////////////////////////////////////////
|
||||
@ -1442,8 +1438,7 @@ void QGL2PaintEngineEx::drawStaticTextItem(QStaticTextItem *textItem)
|
||||
// don't try to cache huge fonts or vastly transformed fonts
|
||||
QFontEngine *fontEngine = textItem->fontEngine();
|
||||
const qreal pixelSize = fontEngine->fontDef.pixelSize;
|
||||
if (pixelSize * pixelSize * qAbs(det) < QT_MAX_CACHED_GLYPH_SIZE * QT_MAX_CACHED_GLYPH_SIZE ||
|
||||
det < 0.25f || det > 4.f) {
|
||||
if (shouldDrawCachedGlyphs(pixelSize, s->matrix) || det < 0.25f || det > 4.f) {
|
||||
QFontEngineGlyphCache::Type glyphType = fontEngine->glyphFormat >= 0
|
||||
? QFontEngineGlyphCache::Type(textItem->fontEngine()->glyphFormat)
|
||||
: d->glyphCacheType;
|
||||
@ -1501,8 +1496,7 @@ void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem
|
||||
|
||||
// don't try to cache huge fonts or vastly transformed fonts
|
||||
const qreal pixelSize = ti.fontEngine->fontDef.pixelSize;
|
||||
if (pixelSize * pixelSize * qAbs(det) >= QT_MAX_CACHED_GLYPH_SIZE * QT_MAX_CACHED_GLYPH_SIZE ||
|
||||
det < 0.25f || det > 4.f)
|
||||
if (shouldDrawCachedGlyphs(pixelSize, s->matrix) || det < 0.25f || det > 4.f)
|
||||
drawCached = false;
|
||||
|
||||
QFontEngineGlyphCache::Type glyphType = ti.fontEngine->glyphFormat >= 0
|
||||
|
Loading…
Reference in New Issue
Block a user