Unify glyph format between QFontEngine and QFontEngineGlyphCache
Instead of the glyph cache having its own cache type that always mapped one to one to a font engine glyph format, causing confusion and needless conversions, the glyph caches now use QFontEngine's glyph format enum. This also removes the iffy use of an int for the glyphFormat in the font engines. Change-Id: I529bad5c179e004f63e152f7dcc311d298c3db98 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
This commit is contained in:
parent
30fd22b957
commit
4de3c5db23
@ -1434,19 +1434,18 @@ void QOpenGL2PaintEngineEx::drawStaticTextItem(QStaticTextItem *textItem)
|
|||||||
|
|
||||||
QFontEngine *fontEngine = textItem->fontEngine();
|
QFontEngine *fontEngine = textItem->fontEngine();
|
||||||
if (shouldDrawCachedGlyphs(fontEngine, s->matrix)) {
|
if (shouldDrawCachedGlyphs(fontEngine, s->matrix)) {
|
||||||
QFontEngineGlyphCache::Type glyphType = fontEngine->glyphFormat >= 0
|
QFontEngine::GlyphFormat glyphFormat = fontEngine->glyphFormat != QFontEngine::Format_None
|
||||||
? QFontEngineGlyphCache::Type(textItem->fontEngine()->glyphFormat)
|
? fontEngine->glyphFormat : d->glyphCacheFormat;
|
||||||
: d->glyphCacheType;
|
if (glyphFormat == QFontEngine::Format_A32) {
|
||||||
if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) {
|
|
||||||
if (d->device->context()->format().alphaBufferSize() > 0 || s->matrix.type() > QTransform::TxTranslate
|
if (d->device->context()->format().alphaBufferSize() > 0 || s->matrix.type() > QTransform::TxTranslate
|
||||||
|| (s->composition_mode != QPainter::CompositionMode_Source
|
|| (s->composition_mode != QPainter::CompositionMode_Source
|
||||||
&& s->composition_mode != QPainter::CompositionMode_SourceOver))
|
&& s->composition_mode != QPainter::CompositionMode_SourceOver))
|
||||||
{
|
{
|
||||||
glyphType = QFontEngineGlyphCache::Raster_A8;
|
glyphFormat = QFontEngine::Format_A8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
d->drawCachedGlyphs(glyphType, textItem);
|
d->drawCachedGlyphs(glyphFormat, textItem);
|
||||||
} else {
|
} else {
|
||||||
QPaintEngineEx::drawStaticTextItem(textItem);
|
QPaintEngineEx::drawStaticTextItem(textItem);
|
||||||
}
|
}
|
||||||
@ -1483,17 +1482,15 @@ void QOpenGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &text
|
|||||||
|
|
||||||
QTransform::TransformationType txtype = s->matrix.type();
|
QTransform::TransformationType txtype = s->matrix.type();
|
||||||
|
|
||||||
QFontEngineGlyphCache::Type glyphType = ti.fontEngine->glyphFormat >= 0
|
QFontEngine::GlyphFormat glyphFormat = ti.fontEngine->glyphFormat != QFontEngine::Format_None
|
||||||
? QFontEngineGlyphCache::Type(ti.fontEngine->glyphFormat)
|
? ti.fontEngine->glyphFormat : d->glyphCacheFormat;
|
||||||
: d->glyphCacheType;
|
|
||||||
|
|
||||||
|
if (glyphFormat == QFontEngine::Format_A32) {
|
||||||
if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) {
|
|
||||||
if (d->device->context()->format().alphaBufferSize() > 0 || txtype > QTransform::TxTranslate
|
if (d->device->context()->format().alphaBufferSize() > 0 || txtype > QTransform::TxTranslate
|
||||||
|| (state()->composition_mode != QPainter::CompositionMode_Source
|
|| (state()->composition_mode != QPainter::CompositionMode_Source
|
||||||
&& state()->composition_mode != QPainter::CompositionMode_SourceOver))
|
&& state()->composition_mode != QPainter::CompositionMode_SourceOver))
|
||||||
{
|
{
|
||||||
glyphType = QFontEngineGlyphCache::Raster_A8;
|
glyphFormat = QFontEngine::Format_A8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1512,7 +1509,7 @@ void QOpenGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &text
|
|||||||
staticTextItem.numGlyphs = glyphs.size();
|
staticTextItem.numGlyphs = glyphs.size();
|
||||||
staticTextItem.glyphPositions = positions.data();
|
staticTextItem.glyphPositions = positions.data();
|
||||||
|
|
||||||
d->drawCachedGlyphs(glyphType, &staticTextItem);
|
d->drawCachedGlyphs(glyphFormat, &staticTextItem);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1537,7 +1534,7 @@ namespace {
|
|||||||
QSize cacheSize;
|
QSize cacheSize;
|
||||||
QOpenGL2PEXVertexArray vertexCoordinateArray;
|
QOpenGL2PEXVertexArray vertexCoordinateArray;
|
||||||
QOpenGL2PEXVertexArray textureCoordinateArray;
|
QOpenGL2PEXVertexArray textureCoordinateArray;
|
||||||
QFontEngineGlyphCache::Type glyphType;
|
QFontEngine::GlyphFormat glyphFormat;
|
||||||
int cacheSerialNumber;
|
int cacheSerialNumber;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1572,7 +1569,7 @@ bool QOpenGL2PaintEngineEx::shouldDrawCachedGlyphs(QFontEngine *fontEngine, cons
|
|||||||
return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t);
|
return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyphType,
|
void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngine::GlyphFormat glyphFormat,
|
||||||
QStaticTextItem *staticTextItem)
|
QStaticTextItem *staticTextItem)
|
||||||
{
|
{
|
||||||
Q_Q(QOpenGL2PaintEngineEx);
|
Q_Q(QOpenGL2PaintEngineEx);
|
||||||
@ -1596,9 +1593,9 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type
|
|||||||
}
|
}
|
||||||
|
|
||||||
QOpenGLTextureGlyphCache *cache =
|
QOpenGLTextureGlyphCache *cache =
|
||||||
(QOpenGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphType, glyphCacheTransform);
|
(QOpenGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphFormat, glyphCacheTransform);
|
||||||
if (!cache || cache->cacheType() != glyphType || cache->contextGroup() == 0) {
|
if (!cache || cache->glyphFormat() != glyphFormat || cache->contextGroup() == 0) {
|
||||||
cache = new QOpenGLTextureGlyphCache(glyphType, glyphCacheTransform);
|
cache = new QOpenGLTextureGlyphCache(glyphFormat, glyphCacheTransform);
|
||||||
fe->setGlyphCache(cacheKey, cache);
|
fe->setGlyphCache(cacheKey, cache);
|
||||||
recreateVertexArrays = true;
|
recreateVertexArrays = true;
|
||||||
}
|
}
|
||||||
@ -1611,7 +1608,7 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type
|
|||||||
recreateVertexArrays = true;
|
recreateVertexArrays = true;
|
||||||
} else {
|
} else {
|
||||||
QOpenGLStaticTextUserData *userData = static_cast<QOpenGLStaticTextUserData *>(staticTextItem->userData());
|
QOpenGLStaticTextUserData *userData = static_cast<QOpenGLStaticTextUserData *>(staticTextItem->userData());
|
||||||
if (userData->glyphType != glyphType) {
|
if (userData->glyphFormat != glyphFormat) {
|
||||||
recreateVertexArrays = true;
|
recreateVertexArrays = true;
|
||||||
} else if (userData->cacheSerialNumber != cache->serialNumber()) {
|
} else if (userData->cacheSerialNumber != cache->serialNumber()) {
|
||||||
recreateVertexArrays = true;
|
recreateVertexArrays = true;
|
||||||
@ -1636,12 +1633,12 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type
|
|||||||
if (cache->width() == 0 || cache->height() == 0)
|
if (cache->width() == 0 || cache->height() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (glyphType == QFontEngineGlyphCache::Raster_ARGB)
|
if (glyphFormat == QFontEngine::Format_ARGB)
|
||||||
transferMode(ImageArrayDrawingMode);
|
transferMode(ImageArrayDrawingMode);
|
||||||
else
|
else
|
||||||
transferMode(TextDrawingMode);
|
transferMode(TextDrawingMode);
|
||||||
|
|
||||||
int margin = fe->glyphMargin(glyphType);
|
int margin = fe->glyphMargin(glyphFormat);
|
||||||
|
|
||||||
GLfloat dx = 1.0 / cache->width();
|
GLfloat dx = 1.0 / cache->width();
|
||||||
GLfloat dy = 1.0 / cache->height();
|
GLfloat dy = 1.0 / cache->height();
|
||||||
@ -1663,7 +1660,7 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type
|
|||||||
userData = static_cast<QOpenGLStaticTextUserData*>(staticTextItem->userData());
|
userData = static_cast<QOpenGLStaticTextUserData*>(staticTextItem->userData());
|
||||||
}
|
}
|
||||||
|
|
||||||
userData->glyphType = glyphType;
|
userData->glyphFormat = glyphFormat;
|
||||||
userData->cacheSerialNumber = cache->serialNumber();
|
userData->cacheSerialNumber = cache->serialNumber();
|
||||||
|
|
||||||
// Use cache if backend optimizations is turned on
|
// Use cache if backend optimizations is turned on
|
||||||
@ -1735,7 +1732,7 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (glyphType != QFontEngineGlyphCache::Raster_ARGB || recreateVertexArrays) {
|
if (glyphFormat != QFontEngine::Format_ARGB || recreateVertexArrays) {
|
||||||
setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, (GLfloat*)vertexCoordinates->data());
|
setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, (GLfloat*)vertexCoordinates->data());
|
||||||
setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, (GLfloat*)textureCoordinates->data());
|
setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, (GLfloat*)textureCoordinates->data());
|
||||||
}
|
}
|
||||||
@ -1748,7 +1745,7 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type
|
|||||||
QBrush pensBrush = q->state()->pen.brush();
|
QBrush pensBrush = q->state()->pen.brush();
|
||||||
setBrush(pensBrush);
|
setBrush(pensBrush);
|
||||||
|
|
||||||
if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) {
|
if (glyphFormat == QFontEngine::Format_A32) {
|
||||||
|
|
||||||
// Subpixel antialiasing without gamma correction
|
// Subpixel antialiasing without gamma correction
|
||||||
|
|
||||||
@ -1821,7 +1818,7 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type
|
|||||||
glBlendFunc(GL_ONE, GL_ONE);
|
glBlendFunc(GL_ONE, GL_ONE);
|
||||||
}
|
}
|
||||||
compositionModeDirty = true;
|
compositionModeDirty = true;
|
||||||
} else if (glyphType == QFontEngineGlyphCache::Raster_ARGB) {
|
} else if (glyphFormat == QFontEngine::Format_ARGB) {
|
||||||
currentBrush = noBrush;
|
currentBrush = noBrush;
|
||||||
shaderManager->setSrcPixelType(QOpenGLEngineShaderManager::ImageSrc);
|
shaderManager->setSrcPixelType(QOpenGLEngineShaderManager::ImageSrc);
|
||||||
if (prepareForCachedGlyphDraw(*cache))
|
if (prepareForCachedGlyphDraw(*cache))
|
||||||
@ -1836,7 +1833,7 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type
|
|||||||
QOpenGLTextureGlyphCache::FilterMode filterMode = (s->matrix.type() > QTransform::TxTranslate)?QOpenGLTextureGlyphCache::Linear:QOpenGLTextureGlyphCache::Nearest;
|
QOpenGLTextureGlyphCache::FilterMode filterMode = (s->matrix.type() > QTransform::TxTranslate)?QOpenGLTextureGlyphCache::Linear:QOpenGLTextureGlyphCache::Nearest;
|
||||||
if (lastMaskTextureUsed != cache->texture() || cache->filterMode() != filterMode) {
|
if (lastMaskTextureUsed != cache->texture() || cache->filterMode() != filterMode) {
|
||||||
|
|
||||||
if (glyphType == QFontEngineGlyphCache::Raster_ARGB)
|
if (glyphFormat == QFontEngine::Format_ARGB)
|
||||||
funcs.glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT);
|
funcs.glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT);
|
||||||
else
|
else
|
||||||
funcs.glActiveTexture(GL_TEXTURE0 + QT_MASK_TEXTURE_UNIT);
|
funcs.glActiveTexture(GL_TEXTURE0 + QT_MASK_TEXTURE_UNIT);
|
||||||
@ -2012,12 +2009,12 @@ bool QOpenGL2PaintEngineEx::begin(QPaintDevice *pdev)
|
|||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
d->glyphCacheType = QFontEngineGlyphCache::Raster_A8;
|
d->glyphCacheFormat = QFontEngine::Format_A8;
|
||||||
|
|
||||||
#ifndef QT_OPENGL_ES_2
|
#ifndef QT_OPENGL_ES_2
|
||||||
if (!QOpenGLFunctions::isES()) {
|
if (!QOpenGLFunctions::isES()) {
|
||||||
glDisable(GL_MULTISAMPLE);
|
glDisable(GL_MULTISAMPLE);
|
||||||
d->glyphCacheType = QFontEngineGlyphCache::Raster_RGBMask;
|
d->glyphCacheFormat = QFontEngine::Format_A32;
|
||||||
d->multisamplingAlwaysEnabled = false;
|
d->multisamplingAlwaysEnabled = false;
|
||||||
} else
|
} else
|
||||||
#endif // QT_OPENGL_ES_2
|
#endif // QT_OPENGL_ES_2
|
||||||
|
@ -212,7 +212,7 @@ public:
|
|||||||
void drawTexture(const QOpenGLRect& dest, const QOpenGLRect& src, const QSize &textureSize, bool opaque, bool pattern = false);
|
void drawTexture(const QOpenGLRect& dest, const QOpenGLRect& src, const QSize &textureSize, bool opaque, bool pattern = false);
|
||||||
void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap,
|
void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap,
|
||||||
QPainter::PixmapFragmentHints hints);
|
QPainter::PixmapFragmentHints hints);
|
||||||
void drawCachedGlyphs(QFontEngineGlyphCache::Type glyphType, QStaticTextItem *staticTextItem);
|
void drawCachedGlyphs(QFontEngine::GlyphFormat glyphFormat, QStaticTextItem *staticTextItem);
|
||||||
|
|
||||||
// Calls glVertexAttributePointer if the pointer has changed
|
// Calls glVertexAttributePointer if the pointer has changed
|
||||||
inline void setVertexAttributePointer(unsigned int arrayIndex, const GLfloat *pointer);
|
inline void setVertexAttributePointer(unsigned int arrayIndex, const GLfloat *pointer);
|
||||||
@ -267,7 +267,7 @@ public:
|
|||||||
int width, height;
|
int width, height;
|
||||||
QOpenGLContext *ctx;
|
QOpenGLContext *ctx;
|
||||||
EngineMode mode;
|
EngineMode mode;
|
||||||
QFontEngineGlyphCache::Type glyphCacheType;
|
QFontEngine::GlyphFormat glyphCacheFormat;
|
||||||
|
|
||||||
bool vertexAttributeArraysEnabledState[QT_GL_VERTEX_ARRAY_TRACKED_COUNT];
|
bool vertexAttributeArraysEnabledState[QT_GL_VERTEX_ARRAY_TRACKED_COUNT];
|
||||||
|
|
||||||
|
@ -51,8 +51,8 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
QBasicAtomicInt qopengltextureglyphcache_serial_number = Q_BASIC_ATOMIC_INITIALIZER(1);
|
QBasicAtomicInt qopengltextureglyphcache_serial_number = Q_BASIC_ATOMIC_INITIALIZER(1);
|
||||||
|
|
||||||
QOpenGLTextureGlyphCache::QOpenGLTextureGlyphCache(QFontEngineGlyphCache::Type type, const QTransform &matrix)
|
QOpenGLTextureGlyphCache::QOpenGLTextureGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix)
|
||||||
: QImageTextureGlyphCache(type, matrix)
|
: QImageTextureGlyphCache(format, matrix)
|
||||||
, m_textureResource(0)
|
, m_textureResource(0)
|
||||||
, pex(0)
|
, pex(0)
|
||||||
, m_blitProgram(0)
|
, m_blitProgram(0)
|
||||||
@ -122,7 +122,7 @@ void QOpenGLTextureGlyphCache::createTextureData(int width, int height)
|
|||||||
m_textureResource->m_width = width;
|
m_textureResource->m_width = width;
|
||||||
m_textureResource->m_height = height;
|
m_textureResource->m_height = height;
|
||||||
|
|
||||||
if (m_type == QFontEngineGlyphCache::Raster_RGBMask || m_type == QFontEngineGlyphCache::Raster_ARGB) {
|
if (m_format == QFontEngine::Format_A32 || m_format == QFontEngine::Format_ARGB) {
|
||||||
QVarLengthArray<uchar> data(width * height * 4);
|
QVarLengthArray<uchar> data(width * height * 4);
|
||||||
for (int i = 0; i < data.size(); ++i)
|
for (int i = 0; i < data.size(); ++i)
|
||||||
data[i] = 0;
|
data[i] = 0;
|
||||||
|
@ -109,7 +109,7 @@ public:
|
|||||||
class Q_GUI_EXPORT QOpenGLTextureGlyphCache : public QImageTextureGlyphCache
|
class Q_GUI_EXPORT QOpenGLTextureGlyphCache : public QImageTextureGlyphCache
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QOpenGLTextureGlyphCache(QFontEngineGlyphCache::Type type, const QTransform &matrix);
|
QOpenGLTextureGlyphCache(QFontEngine::GlyphFormat glyphFormat, const QTransform &matrix);
|
||||||
~QOpenGLTextureGlyphCache();
|
~QOpenGLTextureGlyphCache();
|
||||||
|
|
||||||
virtual void createTextureData(int width, int height);
|
virtual void createTextureData(int width, int height);
|
||||||
|
@ -523,7 +523,7 @@ bool QRasterPaintEngine::begin(QPaintDevice *device)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (d->mono_surface)
|
if (d->mono_surface)
|
||||||
d->glyphCacheType = QFontEngineGlyphCache::Raster_Mono;
|
d->glyphCacheFormat = QFontEngine::Format_Mono;
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
else if (clearTypeFontsEnabled())
|
else if (clearTypeFontsEnabled())
|
||||||
#else
|
#else
|
||||||
@ -532,11 +532,11 @@ bool QRasterPaintEngine::begin(QPaintDevice *device)
|
|||||||
{
|
{
|
||||||
QImage::Format format = static_cast<QImage *>(d->device)->format();
|
QImage::Format format = static_cast<QImage *>(d->device)->format();
|
||||||
if (format == QImage::Format_ARGB32_Premultiplied || format == QImage::Format_RGB32)
|
if (format == QImage::Format_ARGB32_Premultiplied || format == QImage::Format_RGB32)
|
||||||
d->glyphCacheType = QFontEngineGlyphCache::Raster_RGBMask;
|
d->glyphCacheFormat = QFontEngine::Format_A32;
|
||||||
else
|
else
|
||||||
d->glyphCacheType = QFontEngineGlyphCache::Raster_A8;
|
d->glyphCacheFormat = QFontEngine::Format_A8;
|
||||||
} else
|
} else
|
||||||
d->glyphCacheType = QFontEngineGlyphCache::Raster_A8;
|
d->glyphCacheFormat = QFontEngine::Format_A8;
|
||||||
|
|
||||||
setActive(true);
|
setActive(true);
|
||||||
return true;
|
return true;
|
||||||
@ -2819,12 +2819,12 @@ bool QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} 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 =
|
QImageTextureGlyphCache *cache =
|
||||||
static_cast<QImageTextureGlyphCache *>(fontEngine->glyphCache(0, glyphType, s->matrix));
|
static_cast<QImageTextureGlyphCache *>(fontEngine->glyphCache(0, glyphFormat, s->matrix));
|
||||||
if (!cache) {
|
if (!cache) {
|
||||||
cache = new QImageTextureGlyphCache(glyphType, s->matrix);
|
cache = new QImageTextureGlyphCache(glyphFormat, s->matrix);
|
||||||
fontEngine->setGlyphCache(0, cache);
|
fontEngine->setGlyphCache(0, cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2842,7 +2842,7 @@ bool QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs,
|
|||||||
else if (depth == 1)
|
else if (depth == 1)
|
||||||
rightShift = 3; // divide by 8
|
rightShift = 3; // divide by 8
|
||||||
|
|
||||||
int margin = fontEngine->glyphMargin(glyphType);
|
int margin = fontEngine->glyphMargin(glyphFormat);
|
||||||
const uchar *bits = image.bits();
|
const uchar *bits = image.bits();
|
||||||
for (int i=0; i<numGlyphs; ++i) {
|
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;
|
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,
|
// The current state transform has already been applied to the positions,
|
||||||
// so we prevent drawImage() from re-applying the transform by clearing
|
// so we prevent drawImage() from re-applying the transform by clearing
|
||||||
// the state for the duration of the call.
|
// the state for the duration of the call.
|
||||||
@ -3064,7 +3064,7 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte
|
|||||||
Q_D(QRasterPaintEngine);
|
Q_D(QRasterPaintEngine);
|
||||||
fprintf(stderr," - QRasterPaintEngine::drawTextItem(), (%.2f,%.2f), string=%s ct=%d\n",
|
fprintf(stderr," - QRasterPaintEngine::drawTextItem(), (%.2f,%.2f), string=%s ct=%d\n",
|
||||||
p.x(), p.y(), QString::fromRawData(ti.chars, ti.num_chars).toLatin1().data(),
|
p.x(), p.y(), QString::fromRawData(ti.chars, ti.num_chars).toLatin1().data(),
|
||||||
d->glyphCacheType);
|
d->glyphCacheFormat);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (ti.glyphs.numGlyphs == 0)
|
if (ti.glyphs.numGlyphs == 0)
|
||||||
|
@ -336,7 +336,7 @@ public:
|
|||||||
QSpanData solid_color_filler;
|
QSpanData solid_color_filler;
|
||||||
|
|
||||||
|
|
||||||
QFontEngineGlyphCache::Type glyphCacheType;
|
QFontEngine::GlyphFormat glyphCacheFormat;
|
||||||
|
|
||||||
QScopedPointer<QClipData> baseClip;
|
QScopedPointer<QClipData> baseClip;
|
||||||
|
|
||||||
|
@ -1088,7 +1088,7 @@ bool QPaintEngineEx::requiresPretransformedGlyphPositions(QFontEngine *, const Q
|
|||||||
|
|
||||||
bool QPaintEngineEx::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &m) const
|
bool QPaintEngineEx::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &m) const
|
||||||
{
|
{
|
||||||
if (fontEngine->glyphFormat == QFontEngineGlyphCache::Raster_ARGB)
|
if (fontEngine->glyphFormat == QFontEngine::Format_ARGB)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
qreal pixelSize = fontEngine->fontDef.pixelSize;
|
qreal pixelSize = fontEngine->fontDef.pixelSize;
|
||||||
|
@ -130,14 +130,6 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const
|
|||||||
QHash<GlyphAndSubPixelPosition, Coord> listItemCoordinates;
|
QHash<GlyphAndSubPixelPosition, Coord> listItemCoordinates;
|
||||||
int rowHeight = 0;
|
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.
|
// check each glyph for its metrics and get the required rowHeight.
|
||||||
for (int i=0; i < numGlyphs; ++i) {
|
for (int i=0; i < numGlyphs; ++i) {
|
||||||
const glyph_t glyph = glyphs[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
|
// we ask for the alphaMapBoundingBox(), the glyph will be loaded, rasterized and its
|
||||||
// proper metrics will be cached and used later.
|
// proper metrics will be cached and used later.
|
||||||
if (fontEngine->hasInternalCaching()) {
|
if (fontEngine->hasInternalCaching()) {
|
||||||
QImage *locked = fontEngine->lockedAlphaMapForGlyph(glyph, subPixelPosition, format);
|
QImage *locked = fontEngine->lockedAlphaMapForGlyph(glyph, subPixelPosition, m_format);
|
||||||
if (locked && !locked->isNull())
|
if (locked && !locked->isNull())
|
||||||
fontEngine->unlockAlphaMapForGlyph();
|
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
|
#ifdef CACHE_DEBUG
|
||||||
printf("(%4x): w=%.2f, h=%.2f, xoff=%.2f, yoff=%.2f, x=%.2f, y=%.2f\n",
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
// align to 8-bit boundary
|
// align to 8-bit boundary
|
||||||
if (m_type == QFontEngineGlyphCache::Raster_Mono)
|
if (m_format == QFontEngine::Format_Mono)
|
||||||
glyph_width = (glyph_width+7)&~7;
|
glyph_width = (glyph_width+7)&~7;
|
||||||
|
|
||||||
Coord c = { 0, 0, // will be filled in later
|
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
|
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);
|
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->bitmapForGlyph(g, subPixelPosition, m_transform);
|
||||||
|
default:
|
||||||
return m_current_fontengine->alphaMapForGlyph(g, subPixelPosition, m_transform);
|
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)
|
void QImageTextureGlyphCache::createTextureData(int width, int height)
|
||||||
{
|
{
|
||||||
switch (m_type) {
|
switch (m_format) {
|
||||||
case QFontEngineGlyphCache::Raster_Mono:
|
case QFontEngine::Format_Mono:
|
||||||
m_image = QImage(width, height, QImage::Format_Mono);
|
m_image = QImage(width, height, QImage::Format_Mono);
|
||||||
break;
|
break;
|
||||||
case QFontEngineGlyphCache::Raster_A8: {
|
case QFontEngine::Format_A8: {
|
||||||
m_image = QImage(width, height, QImage::Format_Indexed8);
|
m_image = QImage(width, height, QImage::Format_Indexed8);
|
||||||
m_image.fill(0);
|
m_image.fill(0);
|
||||||
QVector<QRgb> colors(256);
|
QVector<QRgb> colors(256);
|
||||||
@ -320,12 +315,14 @@ void QImageTextureGlyphCache::createTextureData(int width, int height)
|
|||||||
*it = 0xff000000 | i | (i<<8) | (i<<16);
|
*it = 0xff000000 | i | (i<<8) | (i<<16);
|
||||||
m_image.setColorTable(colors);
|
m_image.setColorTable(colors);
|
||||||
break; }
|
break; }
|
||||||
case QFontEngineGlyphCache::Raster_RGBMask:
|
case QFontEngine::Format_A32:
|
||||||
m_image = QImage(width, height, QImage::Format_RGB32);
|
m_image = QImage(width, height, QImage::Format_RGB32);
|
||||||
break;
|
break;
|
||||||
case QFontEngineGlyphCache::Raster_ARGB:
|
case QFontEngine::Format_ARGB:
|
||||||
m_image = QImage(width, height, QImage::Format_ARGB32_Premultiplied);
|
m_image = QImage(width, height, QImage::Format_ARGB32_Premultiplied);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
Q_UNREACHABLE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,8 +338,8 @@ void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g, QFixed subP
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (m_type == QFontEngineGlyphCache::Raster_RGBMask
|
if (m_format == QFontEngine::Format_A32
|
||||||
|| m_type == QFontEngineGlyphCache::Raster_ARGB) {
|
|| m_format == QFontEngine::Format_ARGB) {
|
||||||
QImage ref(m_image.bits() + (c.x * 4 + c.y * m_image.bytesPerLine()),
|
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(),
|
qMax(mask.width(), c.w), qMax(mask.height(), c.h), m_image.bytesPerLine(),
|
||||||
m_image.format());
|
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.fillRect(0, 0, c.w, c.h, QColor(0,0,0,0)); // TODO optimize this
|
||||||
p.drawImage(0, 0, mask);
|
p.drawImage(0, 0, mask);
|
||||||
p.end();
|
p.end();
|
||||||
} else if (m_type == QFontEngineGlyphCache::Raster_Mono) {
|
} else if (m_format == QFontEngine::Format_Mono) {
|
||||||
if (mask.depth() > 1) {
|
if (mask.depth() > 1) {
|
||||||
// TODO optimize this
|
// TODO optimize this
|
||||||
mask = mask.alphaChannel();
|
mask = mask.alphaChannel();
|
||||||
@ -414,7 +411,7 @@ void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g, QFixed subP
|
|||||||
#ifdef CACHE_DEBUG
|
#ifdef CACHE_DEBUG
|
||||||
// QPainter p(&m_image);
|
// QPainter p(&m_image);
|
||||||
// p.drawLine(
|
// 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);
|
QPoint base(c.x + margin, c.y + margin + c.baseLineY-1);
|
||||||
if (m_image.rect().contains(base))
|
if (m_image.rect().contains(base))
|
||||||
m_image.setPixel(base, 255);
|
m_image.setPixel(base, 255);
|
||||||
|
@ -75,8 +75,8 @@ class QTextItemInt;
|
|||||||
class Q_GUI_EXPORT QTextureGlyphCache : public QFontEngineGlyphCache
|
class Q_GUI_EXPORT QTextureGlyphCache : public QFontEngineGlyphCache
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QTextureGlyphCache(QFontEngineGlyphCache::Type type, const QTransform &matrix)
|
QTextureGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix)
|
||||||
: QFontEngineGlyphCache(matrix, type), m_current_fontengine(0),
|
: QFontEngineGlyphCache(format, matrix), m_current_fontengine(0),
|
||||||
m_w(0), m_h(0), m_cx(0), m_cy(0), m_currentRowHeight(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
|
class Q_GUI_EXPORT QImageTextureGlyphCache : public QTextureGlyphCache
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QImageTextureGlyphCache(QFontEngineGlyphCache::Type type, const QTransform &matrix)
|
QImageTextureGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix)
|
||||||
: QTextureGlyphCache(type, matrix) { }
|
: QTextureGlyphCache(format, matrix) { }
|
||||||
virtual void createTextureData(int width, int height);
|
virtual void createTextureData(int width, int height);
|
||||||
virtual void resizeTextureData(int width, int height);
|
virtual void resizeTextureData(int width, int height);
|
||||||
virtual void fillTexture(const Coord &c, glyph_t glyph, QFixed subPixelPosition);
|
virtual void fillTexture(const Coord &c, glyph_t glyph, QFixed subPixelPosition);
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
#include <qdebug.h>
|
#include <qdebug.h>
|
||||||
#include <private/qfontengine_p.h>
|
#include <private/qfontengine_p.h>
|
||||||
|
#include <private/qfontengineglyphcache_p.h>
|
||||||
|
|
||||||
#include "qbitmap.h"
|
#include "qbitmap.h"
|
||||||
#include "qpainter.h"
|
#include "qpainter.h"
|
||||||
@ -253,7 +254,7 @@ QFontEngine::QFontEngine()
|
|||||||
fsType = 0;
|
fsType = 0;
|
||||||
symbol = false;
|
symbol = false;
|
||||||
|
|
||||||
glyphFormat = -1;
|
glyphFormat = Format_None;
|
||||||
m_subPixelPositionCount = 0;
|
m_subPixelPositionCount = 0;
|
||||||
|
|
||||||
#ifdef QT_BUILD_INTERNAL
|
#ifdef QT_BUILD_INTERNAL
|
||||||
@ -979,12 +980,12 @@ void QFontEngine::setGlyphCache(const void *key, QFontEngineGlyphCache *data)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QFontEngineGlyphCache *QFontEngine::glyphCache(const void *key, QFontEngineGlyphCache::Type type, const QTransform &transform) const
|
QFontEngineGlyphCache *QFontEngine::glyphCache(const void *key, GlyphFormat format, const QTransform &transform) const
|
||||||
{
|
{
|
||||||
for (QLinkedList<GlyphCacheEntry>::const_iterator it = m_glyphCaches.constBegin(), end = m_glyphCaches.constEnd(); it != end; ++it) {
|
for (QLinkedList<GlyphCacheEntry>::const_iterator it = m_glyphCaches.constBegin(), end = m_glyphCaches.constEnd(); it != end; ++it) {
|
||||||
QFontEngineGlyphCache *c = it->cache.data();
|
QFontEngineGlyphCache *c = it->cache.data();
|
||||||
if (key == it->context
|
if (key == it->context
|
||||||
&& type == c->cacheType()
|
&& format == c->glyphFormat()
|
||||||
&& qtransform_equals_no_translate(c->m_transform, transform)) {
|
&& qtransform_equals_no_translate(c->m_transform, transform)) {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@ -1354,6 +1355,28 @@ QFixed QFontEngine::lastRightBearing(const QGlyphLayout &glyphs, bool round)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QFontEngine::GlyphCacheEntry::GlyphCacheEntry()
|
||||||
|
: context(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QFontEngine::GlyphCacheEntry::GlyphCacheEntry(const GlyphCacheEntry &o)
|
||||||
|
: context(o.context), cache(o.cache)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QFontEngine::GlyphCacheEntry::~GlyphCacheEntry()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QFontEngine::GlyphCacheEntry &QFontEngine::GlyphCacheEntry::operator=(const GlyphCacheEntry &o)
|
||||||
|
{
|
||||||
|
context = o.context;
|
||||||
|
cache = o.cache;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
// The box font engine
|
// The box font engine
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
@ -690,11 +690,9 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format,
|
|||||||
this->antialias = antialias;
|
this->antialias = antialias;
|
||||||
|
|
||||||
if (!antialias)
|
if (!antialias)
|
||||||
glyphFormat = QFontEngineGlyphCache::Raster_Mono;
|
glyphFormat = QFontEngine::Format_Mono;
|
||||||
else if (format == Format_A8)
|
else
|
||||||
glyphFormat = QFontEngineGlyphCache::Raster_A8;
|
glyphFormat = defaultFormat;
|
||||||
else if (format == Format_A32)
|
|
||||||
glyphFormat = QFontEngineGlyphCache::Raster_RGBMask;
|
|
||||||
|
|
||||||
face_id = faceId;
|
face_id = faceId;
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ private:
|
|||||||
virtual void unlockAlphaMapForGlyph();
|
virtual void unlockAlphaMapForGlyph();
|
||||||
|
|
||||||
virtual void removeGlyphFromCache(glyph_t glyph);
|
virtual void removeGlyphFromCache(glyph_t glyph);
|
||||||
virtual int glyphMargin(QFontEngineGlyphCache::Type /* type */) { return 0; }
|
virtual int glyphMargin(QFontEngine::GlyphFormat /* format */) { return 0; }
|
||||||
|
|
||||||
virtual int glyphCount() const;
|
virtual int glyphCount() const;
|
||||||
|
|
||||||
|
@ -60,11 +60,10 @@
|
|||||||
#include "private/qtextengine_p.h"
|
#include "private/qtextengine_p.h"
|
||||||
#include "private/qfont_p.h"
|
#include "private/qfont_p.h"
|
||||||
|
|
||||||
#include <private/qfontengineglyphcache_p.h>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class QPainterPath;
|
class QPainterPath;
|
||||||
|
class QFontEngineGlyphCache;
|
||||||
|
|
||||||
struct QGlyphLayout;
|
struct QGlyphLayout;
|
||||||
|
|
||||||
@ -246,7 +245,7 @@ public:
|
|||||||
virtual Type type() const = 0;
|
virtual Type type() const = 0;
|
||||||
|
|
||||||
virtual int glyphCount() const;
|
virtual int glyphCount() const;
|
||||||
virtual int glyphMargin(QFontEngineGlyphCache::Type type) { return type == QFontEngineGlyphCache::Raster_RGBMask ? 2 : 0; }
|
virtual int glyphMargin(GlyphFormat format) { return format == Format_A32 ? 2 : 0; }
|
||||||
|
|
||||||
virtual QFontEngine *cloneWithSize(qreal /*pixelSize*/) const { return 0; }
|
virtual QFontEngine *cloneWithSize(qreal /*pixelSize*/) const { return 0; }
|
||||||
|
|
||||||
@ -258,7 +257,7 @@ public:
|
|||||||
|
|
||||||
void clearGlyphCache(const void *key);
|
void clearGlyphCache(const void *key);
|
||||||
void setGlyphCache(const void *key, QFontEngineGlyphCache *data);
|
void setGlyphCache(const void *key, QFontEngineGlyphCache *data);
|
||||||
QFontEngineGlyphCache *glyphCache(const void *key, QFontEngineGlyphCache::Type type, const QTransform &transform) const;
|
QFontEngineGlyphCache *glyphCache(const void *key, GlyphFormat format, const QTransform &transform) const;
|
||||||
|
|
||||||
static const uchar *getCMap(const uchar *table, uint tableSize, bool *isSymbolFont, int *cmapSize);
|
static const uchar *getCMap(const uchar *table, uint tableSize, bool *isSymbolFont, int *cmapSize);
|
||||||
static quint32 getTrueTypeGlyphIndex(const uchar *cmap, uint unicode);
|
static quint32 getTrueTypeGlyphIndex(const uchar *cmap, uint unicode);
|
||||||
@ -300,7 +299,7 @@ public:
|
|||||||
QVector<KernPair> kerning_pairs;
|
QVector<KernPair> kerning_pairs;
|
||||||
void loadKerningPairs(QFixed scalingFactor);
|
void loadKerningPairs(QFixed scalingFactor);
|
||||||
|
|
||||||
int glyphFormat;
|
GlyphFormat glyphFormat;
|
||||||
QImage currentlyLockedAlphaMap;
|
QImage currentlyLockedAlphaMap;
|
||||||
int m_subPixelPositionCount; // Number of positions within a single pixel for this cache
|
int m_subPixelPositionCount; // Number of positions within a single pixel for this cache
|
||||||
|
|
||||||
@ -313,6 +312,12 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
struct GlyphCacheEntry {
|
struct GlyphCacheEntry {
|
||||||
|
GlyphCacheEntry();
|
||||||
|
GlyphCacheEntry(const GlyphCacheEntry &);
|
||||||
|
~GlyphCacheEntry();
|
||||||
|
|
||||||
|
GlyphCacheEntry &operator=(const GlyphCacheEntry &);
|
||||||
|
|
||||||
const void *context;
|
const void *context;
|
||||||
QExplicitlySharedDataPointer<QFontEngineGlyphCache> cache;
|
QExplicitlySharedDataPointer<QFontEngineGlyphCache> cache;
|
||||||
bool operator==(const GlyphCacheEntry &other) const { return context == other.context && cache == other.cache; }
|
bool operator==(const GlyphCacheEntry &other) const { return context == other.context && cache == other.cache; }
|
||||||
|
@ -58,6 +58,7 @@
|
|||||||
#include "QtCore/qatomic.h"
|
#include "QtCore/qatomic.h"
|
||||||
#include <QtCore/qvarlengtharray.h>
|
#include <QtCore/qvarlengtharray.h>
|
||||||
#include "private/qfont_p.h"
|
#include "private/qfont_p.h"
|
||||||
|
#include "private/qfontengine_p.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -66,22 +67,18 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QFontEngineGlyphCache: public QSharedData
|
class QFontEngineGlyphCache: public QSharedData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Type {
|
QFontEngineGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix) : m_format(format), m_transform(matrix)
|
||||||
Raster_RGBMask,
|
{
|
||||||
Raster_A8,
|
Q_ASSERT(m_format != QFontEngine::Format_None);
|
||||||
Raster_Mono,
|
}
|
||||||
Raster_ARGB
|
|
||||||
};
|
|
||||||
|
|
||||||
QFontEngineGlyphCache(const QTransform &matrix, Type type) : m_transform(matrix), m_type(type) { }
|
|
||||||
|
|
||||||
virtual ~QFontEngineGlyphCache() { }
|
virtual ~QFontEngineGlyphCache() { }
|
||||||
|
|
||||||
Type cacheType() const { return m_type; }
|
QFontEngine::GlyphFormat glyphFormat() const { return m_format; }
|
||||||
const QTransform &transform() const { return m_transform; }
|
const QTransform &transform() const { return m_transform; }
|
||||||
|
|
||||||
|
QFontEngine::GlyphFormat m_format;
|
||||||
QTransform m_transform;
|
QTransform m_transform;
|
||||||
QFontEngineGlyphCache::Type m_type;
|
|
||||||
};
|
};
|
||||||
typedef QHash<void *, QList<QFontEngineGlyphCache *> > GlyphPointerHash;
|
typedef QHash<void *, QList<QFontEngineGlyphCache *> > GlyphPointerHash;
|
||||||
typedef QHash<int, QList<QFontEngineGlyphCache *> > GlyphIntHash;
|
typedef QHash<int, QList<QFontEngineGlyphCache *> > GlyphIntHash;
|
||||||
|
@ -1482,20 +1482,20 @@ void QGL2PaintEngineEx::drawStaticTextItem(QStaticTextItem *textItem)
|
|||||||
// don't try to cache huge fonts or vastly transformed fonts
|
// don't try to cache huge fonts or vastly transformed fonts
|
||||||
QFontEngine *fontEngine = textItem->fontEngine();
|
QFontEngine *fontEngine = textItem->fontEngine();
|
||||||
if (shouldDrawCachedGlyphs(fontEngine, s->matrix)) {
|
if (shouldDrawCachedGlyphs(fontEngine, s->matrix)) {
|
||||||
QFontEngineGlyphCache::Type glyphType = fontEngine->glyphFormat >= 0
|
QFontEngine::GlyphFormat glyphFormat = fontEngine->glyphFormat >= 0
|
||||||
? QFontEngineGlyphCache::Type(textItem->fontEngine()->glyphFormat)
|
? QFontEngine::GlyphFormat(textItem->fontEngine()->glyphFormat)
|
||||||
: d->glyphCacheType;
|
: d->glyphCacheFormat;
|
||||||
if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) {
|
if (glyphFormat == QFontEngine::Format_A32) {
|
||||||
if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()
|
if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()
|
||||||
|| d->device->alphaRequested() || s->matrix.type() > QTransform::TxTranslate
|
|| d->device->alphaRequested() || s->matrix.type() > QTransform::TxTranslate
|
||||||
|| (s->composition_mode != QPainter::CompositionMode_Source
|
|| (s->composition_mode != QPainter::CompositionMode_Source
|
||||||
&& s->composition_mode != QPainter::CompositionMode_SourceOver))
|
&& s->composition_mode != QPainter::CompositionMode_SourceOver))
|
||||||
{
|
{
|
||||||
glyphType = QFontEngineGlyphCache::Raster_A8;
|
glyphFormat = QFontEngine::Format_A8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
d->drawCachedGlyphs(glyphType, textItem);
|
d->drawCachedGlyphs(glyphFormat, textItem);
|
||||||
} else {
|
} else {
|
||||||
QPaintEngineEx::drawStaticTextItem(textItem);
|
QPaintEngineEx::drawStaticTextItem(textItem);
|
||||||
}
|
}
|
||||||
@ -1532,18 +1532,18 @@ void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem
|
|||||||
|
|
||||||
QTransform::TransformationType txtype = s->matrix.type();
|
QTransform::TransformationType txtype = s->matrix.type();
|
||||||
|
|
||||||
QFontEngineGlyphCache::Type glyphType = ti.fontEngine->glyphFormat >= 0
|
QFontEngine::GlyphFormat glyphFormat = ti.fontEngine->glyphFormat >= 0
|
||||||
? QFontEngineGlyphCache::Type(ti.fontEngine->glyphFormat)
|
? ti.fontEngine->glyphFormat
|
||||||
: d->glyphCacheType;
|
: d->glyphCacheFormat;
|
||||||
|
|
||||||
|
|
||||||
if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) {
|
if (glyphFormat == QFontEngine::Format_A32) {
|
||||||
if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()
|
if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()
|
||||||
|| d->device->alphaRequested() || txtype > QTransform::TxTranslate
|
|| d->device->alphaRequested() || txtype > QTransform::TxTranslate
|
||||||
|| (state()->composition_mode != QPainter::CompositionMode_Source
|
|| (state()->composition_mode != QPainter::CompositionMode_Source
|
||||||
&& state()->composition_mode != QPainter::CompositionMode_SourceOver))
|
&& state()->composition_mode != QPainter::CompositionMode_SourceOver))
|
||||||
{
|
{
|
||||||
glyphType = QFontEngineGlyphCache::Raster_A8;
|
glyphFormat = QFontEngine::Format_A8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1562,7 +1562,7 @@ void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem
|
|||||||
staticTextItem.numGlyphs = glyphs.size();
|
staticTextItem.numGlyphs = glyphs.size();
|
||||||
staticTextItem.glyphPositions = positions.data();
|
staticTextItem.glyphPositions = positions.data();
|
||||||
|
|
||||||
d->drawCachedGlyphs(glyphType, &staticTextItem);
|
d->drawCachedGlyphs(glyphFormat, &staticTextItem);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1587,7 +1587,7 @@ namespace {
|
|||||||
QSize cacheSize;
|
QSize cacheSize;
|
||||||
QGL2PEXVertexArray vertexCoordinateArray;
|
QGL2PEXVertexArray vertexCoordinateArray;
|
||||||
QGL2PEXVertexArray textureCoordinateArray;
|
QGL2PEXVertexArray textureCoordinateArray;
|
||||||
QFontEngineGlyphCache::Type glyphType;
|
QFontEngine::GlyphFormat glyphFormat;
|
||||||
int cacheSerialNumber;
|
int cacheSerialNumber;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1596,7 +1596,7 @@ namespace {
|
|||||||
|
|
||||||
// #define QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO
|
// #define QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO
|
||||||
|
|
||||||
void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyphType,
|
void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngine::GlyphFormat glyphFormat,
|
||||||
QStaticTextItem *staticTextItem)
|
QStaticTextItem *staticTextItem)
|
||||||
{
|
{
|
||||||
Q_Q(QGL2PaintEngineEx);
|
Q_Q(QGL2PaintEngineEx);
|
||||||
@ -1620,9 +1620,9 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
|
|||||||
}
|
}
|
||||||
|
|
||||||
QGLTextureGlyphCache *cache =
|
QGLTextureGlyphCache *cache =
|
||||||
(QGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphType, glyphCacheTransform);
|
(QGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphFormat, glyphCacheTransform);
|
||||||
if (!cache || cache->cacheType() != glyphType || cache->contextGroup() == 0) {
|
if (!cache || cache->glyphFormat() != glyphFormat || cache->contextGroup() == 0) {
|
||||||
cache = new QGLTextureGlyphCache(glyphType, glyphCacheTransform);
|
cache = new QGLTextureGlyphCache(glyphFormat, glyphCacheTransform);
|
||||||
fe->setGlyphCache(cacheKey, cache);
|
fe->setGlyphCache(cacheKey, cache);
|
||||||
recreateVertexArrays = true;
|
recreateVertexArrays = true;
|
||||||
}
|
}
|
||||||
@ -1635,7 +1635,7 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
|
|||||||
recreateVertexArrays = true;
|
recreateVertexArrays = true;
|
||||||
} else {
|
} else {
|
||||||
QOpenGLStaticTextUserData *userData = static_cast<QOpenGLStaticTextUserData *>(staticTextItem->userData());
|
QOpenGLStaticTextUserData *userData = static_cast<QOpenGLStaticTextUserData *>(staticTextItem->userData());
|
||||||
if (userData->glyphType != glyphType) {
|
if (userData->glyphFormat != glyphFormat) {
|
||||||
recreateVertexArrays = true;
|
recreateVertexArrays = true;
|
||||||
} else if (userData->cacheSerialNumber != cache->serialNumber()) {
|
} else if (userData->cacheSerialNumber != cache->serialNumber()) {
|
||||||
recreateVertexArrays = true;
|
recreateVertexArrays = true;
|
||||||
@ -1662,7 +1662,7 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
|
|||||||
|
|
||||||
transferMode(TextDrawingMode);
|
transferMode(TextDrawingMode);
|
||||||
|
|
||||||
int margin = fe->glyphMargin(glyphType);
|
int margin = fe->glyphMargin(glyphFormat);
|
||||||
|
|
||||||
GLfloat dx = 1.0 / cache->width();
|
GLfloat dx = 1.0 / cache->width();
|
||||||
GLfloat dy = 1.0 / cache->height();
|
GLfloat dy = 1.0 / cache->height();
|
||||||
@ -1684,7 +1684,7 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
|
|||||||
userData = static_cast<QOpenGLStaticTextUserData*>(staticTextItem->userData());
|
userData = static_cast<QOpenGLStaticTextUserData*>(staticTextItem->userData());
|
||||||
}
|
}
|
||||||
|
|
||||||
userData->glyphType = glyphType;
|
userData->glyphFormat = glyphFormat;
|
||||||
userData->cacheSerialNumber = cache->serialNumber();
|
userData->cacheSerialNumber = cache->serialNumber();
|
||||||
|
|
||||||
// Use cache if backend optimizations is turned on
|
// Use cache if backend optimizations is turned on
|
||||||
@ -1767,7 +1767,7 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
|
|||||||
QBrush pensBrush = q->state()->pen.brush();
|
QBrush pensBrush = q->state()->pen.brush();
|
||||||
setBrush(pensBrush);
|
setBrush(pensBrush);
|
||||||
|
|
||||||
if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) {
|
if (glyphFormat == QFontEngine::Format_A32) {
|
||||||
|
|
||||||
// Subpixel antialiasing without gamma correction
|
// Subpixel antialiasing without gamma correction
|
||||||
|
|
||||||
@ -2037,11 +2037,11 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev)
|
|||||||
glDisable(GL_MULTISAMPLE);
|
glDisable(GL_MULTISAMPLE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
d->glyphCacheType = QFontEngineGlyphCache::Raster_A8;
|
d->glyphCacheFormat = QFontEngine::Format_A8;
|
||||||
|
|
||||||
#if !defined(QT_OPENGL_ES_2)
|
#if !defined(QT_OPENGL_ES_2)
|
||||||
if (!QOpenGLFunctions::isES()) {
|
if (!QOpenGLFunctions::isES()) {
|
||||||
d->glyphCacheType = QFontEngineGlyphCache::Raster_RGBMask;
|
d->glyphCacheFormat = QFontEngine::Format_A32;
|
||||||
d->multisamplingAlwaysEnabled = false;
|
d->multisamplingAlwaysEnabled = false;
|
||||||
} else {
|
} else {
|
||||||
d->multisamplingAlwaysEnabled = d->device->format().sampleBuffers();
|
d->multisamplingAlwaysEnabled = d->device->format().sampleBuffers();
|
||||||
|
@ -203,7 +203,7 @@ public:
|
|||||||
void drawTexture(const QGLRect& dest, const QGLRect& src, const QSize &textureSize, bool opaque, bool pattern = false);
|
void drawTexture(const QGLRect& dest, const QGLRect& src, const QSize &textureSize, bool opaque, bool pattern = false);
|
||||||
void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap,
|
void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap,
|
||||||
QPainter::PixmapFragmentHints hints);
|
QPainter::PixmapFragmentHints hints);
|
||||||
void drawCachedGlyphs(QFontEngineGlyphCache::Type glyphType, QStaticTextItem *staticTextItem);
|
void drawCachedGlyphs(QFontEngine::GlyphFormat glyphFormat, QStaticTextItem *staticTextItem);
|
||||||
|
|
||||||
// Calls glVertexAttributePointer if the pointer has changed
|
// Calls glVertexAttributePointer if the pointer has changed
|
||||||
inline void setVertexAttributePointer(unsigned int arrayIndex, const GLfloat *pointer);
|
inline void setVertexAttributePointer(unsigned int arrayIndex, const GLfloat *pointer);
|
||||||
@ -255,7 +255,7 @@ public:
|
|||||||
int width, height;
|
int width, height;
|
||||||
QGLContext *ctx;
|
QGLContext *ctx;
|
||||||
EngineMode mode;
|
EngineMode mode;
|
||||||
QFontEngineGlyphCache::Type glyphCacheType;
|
QFontEngine::GlyphFormat glyphCacheFormat;
|
||||||
|
|
||||||
QOpenGLExtensions funcs;
|
QOpenGLExtensions funcs;
|
||||||
|
|
||||||
|
@ -49,8 +49,8 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
QBasicAtomicInt qgltextureglyphcache_serial_number = Q_BASIC_ATOMIC_INITIALIZER(1);
|
QBasicAtomicInt qgltextureglyphcache_serial_number = Q_BASIC_ATOMIC_INITIALIZER(1);
|
||||||
|
|
||||||
QGLTextureGlyphCache::QGLTextureGlyphCache(QFontEngineGlyphCache::Type type, const QTransform &matrix)
|
QGLTextureGlyphCache::QGLTextureGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix)
|
||||||
: QImageTextureGlyphCache(type, matrix)
|
: QImageTextureGlyphCache(format, matrix)
|
||||||
, m_textureResource(0)
|
, m_textureResource(0)
|
||||||
, pex(0)
|
, pex(0)
|
||||||
, m_blitProgram(0)
|
, m_blitProgram(0)
|
||||||
@ -123,7 +123,7 @@ void QGLTextureGlyphCache::createTextureData(int width, int height)
|
|||||||
m_textureResource->m_width = width;
|
m_textureResource->m_width = width;
|
||||||
m_textureResource->m_height = height;
|
m_textureResource->m_height = height;
|
||||||
|
|
||||||
if (m_type == QFontEngineGlyphCache::Raster_RGBMask) {
|
if (m_format == QFontEngine::Format_A32) {
|
||||||
QVarLengthArray<uchar> data(width * height * 4);
|
QVarLengthArray<uchar> data(width * height * 4);
|
||||||
for (int i = 0; i < data.size(); ++i)
|
for (int i = 0; i < data.size(); ++i)
|
||||||
data[i] = 0;
|
data[i] = 0;
|
||||||
|
@ -112,7 +112,7 @@ struct QGLGlyphTexture : public QOpenGLSharedResource
|
|||||||
class Q_OPENGL_EXPORT QGLTextureGlyphCache : public QImageTextureGlyphCache
|
class Q_OPENGL_EXPORT QGLTextureGlyphCache : public QImageTextureGlyphCache
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QGLTextureGlyphCache(QFontEngineGlyphCache::Type type, const QTransform &matrix);
|
QGLTextureGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix);
|
||||||
~QGLTextureGlyphCache();
|
~QGLTextureGlyphCache();
|
||||||
|
|
||||||
virtual void createTextureData(int width, int height);
|
virtual void createTextureData(int width, int height);
|
||||||
|
@ -163,10 +163,10 @@ QCoreTextFontDatabase::QCoreTextFontDatabase()
|
|||||||
[fontImage release];
|
[fontImage release];
|
||||||
}
|
}
|
||||||
QCoreTextFontEngine::defaultGlyphFormat = (font_smoothing > 0
|
QCoreTextFontEngine::defaultGlyphFormat = (font_smoothing > 0
|
||||||
? QFontEngineGlyphCache::Raster_RGBMask
|
? QFontEngine::Format_A32
|
||||||
: QFontEngineGlyphCache::Raster_A8);
|
: QFontEngine::Format_A8);
|
||||||
#else
|
#else
|
||||||
QCoreTextFontEngine::defaultGlyphFormat = QFontEngineGlyphCache::Raster_A8;
|
QCoreTextFontEngine::defaultGlyphFormat = QFontEngine::Format_A8;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ static void loadAdvancesForGlyphs(CTFontRef ctfont,
|
|||||||
|
|
||||||
|
|
||||||
int QCoreTextFontEngine::antialiasingThreshold = 0;
|
int QCoreTextFontEngine::antialiasingThreshold = 0;
|
||||||
QFontEngineGlyphCache::Type QCoreTextFontEngine::defaultGlyphFormat = QFontEngineGlyphCache::Raster_RGBMask;
|
QFontEngine::GlyphFormat QCoreTextFontEngine::defaultGlyphFormat = QFontEngine::Format_A32;
|
||||||
|
|
||||||
CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef)
|
CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef)
|
||||||
{
|
{
|
||||||
@ -155,7 +155,7 @@ void QCoreTextFontEngine::init()
|
|||||||
|
|
||||||
#if defined(Q_OS_IOS) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
#if defined(Q_OS_IOS) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||||
if (supportsColorGlyphs() && (traits & kCTFontColorGlyphsTrait))
|
if (supportsColorGlyphs() && (traits & kCTFontColorGlyphsTrait))
|
||||||
glyphFormat = QFontEngineGlyphCache::Raster_ARGB;
|
glyphFormat = QFontEngine::Format_ARGB;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
glyphFormat = defaultGlyphFormat;
|
glyphFormat = defaultGlyphFormat;
|
||||||
@ -424,7 +424,7 @@ static void convertCGPathToQPainterPath(void *info, const CGPathElement *element
|
|||||||
void QCoreTextFontEngine::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nGlyphs,
|
void QCoreTextFontEngine::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nGlyphs,
|
||||||
QPainterPath *path, QTextItem::RenderFlags)
|
QPainterPath *path, QTextItem::RenderFlags)
|
||||||
{
|
{
|
||||||
if (glyphFormat == QFontEngineGlyphCache::Raster_ARGB)
|
if (glyphFormat == QFontEngine::Format_ARGB)
|
||||||
return; // We can't convert color-glyphs to path
|
return; // We can't convert color-glyphs to path
|
||||||
|
|
||||||
CGAffineTransform cgMatrix = CGAffineTransformIdentity;
|
CGAffineTransform cgMatrix = CGAffineTransformIdentity;
|
||||||
@ -473,7 +473,7 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition
|
|||||||
glyph_metrics_t br = boundingBox(glyph);
|
glyph_metrics_t br = boundingBox(glyph);
|
||||||
qcoretextfontengine_scaleMetrics(br, m);
|
qcoretextfontengine_scaleMetrics(br, m);
|
||||||
|
|
||||||
bool isColorGlyph = glyphFormat == QFontEngineGlyphCache::Raster_ARGB;
|
bool isColorGlyph = glyphFormat == QFontEngine::Format_ARGB;
|
||||||
QImage::Format format = isColorGlyph ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
|
QImage::Format format = isColorGlyph ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
|
||||||
QImage im(qAbs(qRound(br.width)) + 2, qAbs(qRound(br.height)) + 2, format);
|
QImage im(qAbs(qRound(br.width)) + 2, qAbs(qRound(br.height)) + 2, format);
|
||||||
im.fill(0);
|
im.fill(0);
|
||||||
|
@ -104,7 +104,7 @@ public:
|
|||||||
bool supportsTransformation(const QTransform &transform) const;
|
bool supportsTransformation(const QTransform &transform) const;
|
||||||
|
|
||||||
virtual QFontEngine *cloneWithSize(qreal pixelSize) const;
|
virtual QFontEngine *cloneWithSize(qreal pixelSize) const;
|
||||||
virtual int glyphMargin(QFontEngineGlyphCache::Type type) { Q_UNUSED(type); return 0; }
|
virtual int glyphMargin(QFontEngine::GlyphFormat format) { Q_UNUSED(format); return 0; }
|
||||||
|
|
||||||
static bool supportsColorGlyphs()
|
static bool supportsColorGlyphs()
|
||||||
{
|
{
|
||||||
@ -122,7 +122,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int antialiasingThreshold;
|
static int antialiasingThreshold;
|
||||||
static QFontEngineGlyphCache::Type defaultGlyphFormat;
|
static QFontEngine::GlyphFormat defaultGlyphFormat;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class QRawFontPrivate;
|
friend class QRawFontPrivate;
|
||||||
|
@ -1745,7 +1745,7 @@ QFontEngine *QWindowsFontDatabase::createEngine(int script, const QFontDef &requ
|
|||||||
if (!useDirectWrite) {
|
if (!useDirectWrite) {
|
||||||
QWindowsFontEngine *few = new QWindowsFontEngine(request.family, hfont, stockFont, lf, data);
|
QWindowsFontEngine *few = new QWindowsFontEngine(request.family, hfont, stockFont, lf, data);
|
||||||
if (preferClearTypeAA)
|
if (preferClearTypeAA)
|
||||||
few->glyphFormat = QFontEngineGlyphCache::Raster_RGBMask;
|
few->glyphFormat = QFontEngine::Format_A32;
|
||||||
few->initFontInfo(request, fontHdc, dpi);
|
few->initFontInfo(request, fontHdc, dpi);
|
||||||
fe = few;
|
fe = few;
|
||||||
}
|
}
|
||||||
|
@ -1148,7 +1148,7 @@ glyph_metrics_t QWindowsFontEngine::alphaMapBoundingBox(glyph_t glyph, QFixed, c
|
|||||||
{
|
{
|
||||||
int margin = 0;
|
int margin = 0;
|
||||||
if (format == QFontEngine::Format_A32 || format == QFontEngine::Format_ARGB)
|
if (format == QFontEngine::Format_A32 || format == QFontEngine::Format_ARGB)
|
||||||
margin = glyphMargin(QFontEngineGlyphCache::Raster_RGBMask);
|
margin = glyphMargin(QFontEngine::Format_A32);
|
||||||
glyph_metrics_t gm = boundingBox(glyph, matrix);
|
glyph_metrics_t gm = boundingBox(glyph, matrix);
|
||||||
gm.width += margin * 2;
|
gm.width += margin * 2;
|
||||||
gm.height += margin * 2;
|
gm.height += margin * 2;
|
||||||
@ -1221,7 +1221,7 @@ QImage QWindowsFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed, const QTra
|
|||||||
SystemParametersInfo(SPI_GETFONTSMOOTHINGCONTRAST, 0, &contrast, 0);
|
SystemParametersInfo(SPI_GETFONTSMOOTHINGCONTRAST, 0, &contrast, 0);
|
||||||
SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 0, (void *) 1000, 0);
|
SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 0, (void *) 1000, 0);
|
||||||
|
|
||||||
int margin = glyphMargin(QFontEngineGlyphCache::Raster_RGBMask);
|
int margin = glyphMargin(QFontEngine::Format_A32);
|
||||||
QWindowsNativeImage *mask = drawGDIGlyph(font, glyph, margin, t, QImage::Format_RGB32);
|
QWindowsNativeImage *mask = drawGDIGlyph(font, glyph, margin, t, QImage::Format_RGB32);
|
||||||
SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 0, (void *) quintptr(contrast), 0);
|
SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 0, (void *) quintptr(contrast), 0);
|
||||||
|
|
||||||
|
@ -620,7 +620,7 @@ QImage QWindowsFontEngineDirectWrite::alphaRGBMapForGlyph(glyph_t t,
|
|||||||
{
|
{
|
||||||
QImage mask = imageForGlyph(t,
|
QImage mask = imageForGlyph(t,
|
||||||
subPixelPosition,
|
subPixelPosition,
|
||||||
glyphMargin(QFontEngineGlyphCache::Raster_RGBMask),
|
glyphMargin(QFontEngine::Format_A32),
|
||||||
xform);
|
xform);
|
||||||
|
|
||||||
return mask.depth() == 32
|
return mask.depth() == 32
|
||||||
|
Loading…
x
Reference in New Issue
Block a user