summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-11-27 18:28:12 +0100
committerFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-11-27 18:28:12 +0100
commitce6990c3e742e0833df0561246554cf07a888efb (patch)
tree412380582040f5bb314eb90ae029b41a883aa439 /src/gui
parent09e674849a40f5eb7e9f95fd2a952c621aec86d1 (diff)
parentfa9bde7d3a12ede956339c570f7b32f95d231e57 (diff)
Merge remote-tracking branch 'origin/5.4' into dev
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qevent.cpp4
-rw-r--r--src/gui/kernel/qguiapplication.cpp14
-rw-r--r--src/gui/kernel/qplatforminputcontext.cpp11
-rw-r--r--src/gui/kernel/qplatforminputcontext.h5
-rw-r--r--src/gui/kernel/qplatformwindow.cpp2
-rw-r--r--src/gui/kernel/qshapedpixmapdndwindow.cpp2
-rw-r--r--src/gui/kernel/qsurfaceformat.cpp2
-rw-r--r--src/gui/kernel/qsurfaceformat.h2
-rw-r--r--src/gui/kernel/qwindow.cpp9
-rw-r--r--src/gui/kernel/qwindow_p.h1
-rw-r--r--src/gui/opengl/qopengltexture.cpp4
-rw-r--r--src/gui/opengl/qopengltexture.h4
-rw-r--r--src/gui/painting/qpaintbuffer.cpp9
-rw-r--r--src/gui/painting/qpainter.cpp7
-rw-r--r--src/gui/text/qdistancefield.cpp2
-rw-r--r--src/gui/text/qfont.cpp2
-rw-r--r--src/gui/text/qfontdatabase.cpp3
-rw-r--r--src/gui/text/qfontengine_ft.cpp126
-rw-r--r--src/gui/text/qstatictext.cpp11
19 files changed, 100 insertions, 120 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index a0b6256e72..9eefa968ad 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -207,7 +207,9 @@ QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton but
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
: QInputEvent(type, modifiers), l(localPos), w(localPos), b(button), mouseState(buttons), caps(0)
{
+#ifndef QT_NO_CURSOR
s = QCursor::pos();
+#endif
}
@@ -1594,7 +1596,9 @@ QContextMenuEvent::~QContextMenuEvent()
QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos)
: QInputEvent(ContextMenu), p(pos), reas(reason)
{
+#ifndef QT_NO_CURSOR
gp = QCursor::pos();
+#endif
}
/*!
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index e421f79e91..ded3788dbf 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -869,7 +869,7 @@ QWindowList QGuiApplication::topLevelWindows()
/*!
Returns the primary (or default) screen of the application.
- This will be the screen where QWindows are shown, unless otherwise specified.
+ This will be the screen where QWindows are initially shown, unless otherwise specified.
*/
QScreen *QGuiApplication::primaryScreen()
{
@@ -3386,15 +3386,21 @@ void QGuiApplicationPrivate::_q_updateFocusObject(QObject *object)
{
Q_Q(QGuiApplication);
+ QPlatformInputContext *inputContext = platformIntegration()->inputContext();
bool enabled = false;
- if (object) {
- QInputMethodQueryEvent query(Qt::ImEnabled);
+ if (object && inputContext) {
+ QInputMethodQueryEvent query(Qt::ImEnabled | Qt::ImHints);
QGuiApplication::sendEvent(object, &query);
enabled = query.value(Qt::ImEnabled).toBool();
+ if (enabled) {
+ static const bool supportsHiddenText = inputContext->hasCapability(QPlatformInputContext::HiddenTextCapability);
+ const Qt::InputMethodHints hints = static_cast<Qt::InputMethodHints>(query.value(Qt::ImHints).toInt());
+ if ((hints & Qt::ImhHiddenText) && !supportsHiddenText)
+ enabled = false;
+ }
}
QPlatformInputContextPrivate::setInputMethodAccepted(enabled);
- QPlatformInputContext *inputContext = platformIntegration()->inputContext();
if (inputContext)
inputContext->setFocusObject(object);
emit q->focusObjectChanged(object);
diff --git a/src/gui/kernel/qplatforminputcontext.cpp b/src/gui/kernel/qplatforminputcontext.cpp
index 71dd609868..5937c65cc7 100644
--- a/src/gui/kernel/qplatforminputcontext.cpp
+++ b/src/gui/kernel/qplatforminputcontext.cpp
@@ -92,6 +92,17 @@ bool QPlatformInputContext::isValid() const
}
/*!
+ Returns whether the implementation supports \a capability.
+ \internal
+ \since 5.4
+ */
+bool QPlatformInputContext::hasCapability(Capability capability) const
+{
+ Q_UNUSED(capability)
+ return true;
+}
+
+/*!
Method to be called when input method needs to be reset. Called by QInputMethod::reset().
No further QInputMethodEvents should be sent as response.
*/
diff --git a/src/gui/kernel/qplatforminputcontext.h b/src/gui/kernel/qplatforminputcontext.h
index 7dd89ecd00..0c8953f89c 100644
--- a/src/gui/kernel/qplatforminputcontext.h
+++ b/src/gui/kernel/qplatforminputcontext.h
@@ -55,10 +55,15 @@ class Q_GUI_EXPORT QPlatformInputContext : public QObject
Q_DECLARE_PRIVATE(QPlatformInputContext)
public:
+ enum Capability {
+ HiddenTextCapability = 0x1
+ };
+
QPlatformInputContext();
virtual ~QPlatformInputContext();
virtual bool isValid() const;
+ virtual bool hasCapability(Capability capability) const;
virtual void reset();
virtual void commit();
diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp
index c6e5cfb9d6..167bd44f0e 100644
--- a/src/gui/kernel/qplatformwindow.cpp
+++ b/src/gui/kernel/qplatformwindow.cpp
@@ -526,12 +526,14 @@ static inline const QScreen *effectiveScreen(const QWindow *window)
if (!screen)
return QGuiApplication::primaryScreen();
const QList<QScreen *> siblings = screen->virtualSiblings();
+#ifndef QT_NO_CURSOR
if (siblings.size() > 1) {
const QPoint referencePoint = window->transientParent() ? window->transientParent()->geometry().center() : QCursor::pos();
foreach (const QScreen *sibling, siblings)
if (sibling->geometry().contains(referencePoint))
return sibling;
}
+#endif
return screen;
}
diff --git a/src/gui/kernel/qshapedpixmapdndwindow.cpp b/src/gui/kernel/qshapedpixmapdndwindow.cpp
index af60b36647..c8e9c2544d 100644
--- a/src/gui/kernel/qshapedpixmapdndwindow.cpp
+++ b/src/gui/kernel/qshapedpixmapdndwindow.cpp
@@ -88,12 +88,14 @@ void QShapedPixmapWindow::setHotspot(const QPoint &hotspot)
void QShapedPixmapWindow::updateGeometry()
{
+#ifndef QT_NO_CURSOR
QRect rect(QCursor::pos() - m_hotSpot, m_pixmap.size());
if (m_pixmap.isNull())
m_backingStore->resize(QSize(1,1));
else if (m_backingStore->size() != m_pixmap.size())
m_backingStore->resize(m_pixmap.size());
setGeometry(rect);
+#endif
}
void QShapedPixmapWindow::exposeEvent(QExposeEvent *)
diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp
index 8049e303a7..b7f8e375a4 100644
--- a/src/gui/kernel/qsurfaceformat.cpp
+++ b/src/gui/kernel/qsurfaceformat.cpp
@@ -308,6 +308,7 @@ void QSurfaceFormat::setSamples(int numSamples)
}
}
+#if QT_DEPRECATED_SINCE(5, 2)
/*!
\obsolete
\overload
@@ -343,6 +344,7 @@ bool QSurfaceFormat::testOption(QSurfaceFormat::FormatOptions opt) const
{
return d->opts & opt;
}
+#endif // QT_DEPRECATED_SINCE(5, 2)
/*!
\since 5.3
diff --git a/src/gui/kernel/qsurfaceformat.h b/src/gui/kernel/qsurfaceformat.h
index 797331e5a7..b33f4d1f6b 100644
--- a/src/gui/kernel/qsurfaceformat.h
+++ b/src/gui/kernel/qsurfaceformat.h
@@ -119,8 +119,10 @@ public:
bool stereo() const;
void setStereo(bool enable);
+#if QT_DEPRECATED_SINCE(5, 2)
QT_DEPRECATED void setOption(QSurfaceFormat::FormatOptions opt);
QT_DEPRECATED bool testOption(QSurfaceFormat::FormatOptions opt) const;
+#endif
void setOptions(QSurfaceFormat::FormatOptions options);
void setOption(FormatOption option, bool on = true);
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index fa99390af0..b9dba10f22 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -416,6 +416,15 @@ void QWindowPrivate::clearFocusObject()
{
}
+// Allows for manipulating the suggested geometry before a resize/move
+// event in derived classes for platforms that support it, for example to
+// implement heightForWidth().
+QRectF QWindowPrivate::closestAcceptableGeometry(const QRectF &rect) const
+{
+ Q_UNUSED(rect)
+ return QRectF();
+}
+
/*!
Sets the \a surfaceType of the window.
diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h
index 40f23b1c36..c496d7716b 100644
--- a/src/gui/kernel/qwindow_p.h
+++ b/src/gui/kernel/qwindow_p.h
@@ -136,6 +136,7 @@ public:
void emitScreenChangedRecursion(QScreen *newScreen);
virtual void clearFocusObject();
+ virtual QRectF closestAcceptableGeometry(const QRectF &rect) const;
bool isPopup() const { return (windowFlags & Qt::WindowType_Mask) == Qt::Popup; }
diff --git a/src/gui/opengl/qopengltexture.cpp b/src/gui/opengl/qopengltexture.cpp
index 8ba139d003..30ca7fce66 100644
--- a/src/gui/opengl/qopengltexture.cpp
+++ b/src/gui/opengl/qopengltexture.cpp
@@ -2965,6 +2965,7 @@ void QOpenGLTexture::setData(PixelFormat sourceFormat, PixelType sourceType,
d->setData(0, 0, QOpenGLTexture::CubeMapPositiveX, sourceFormat, sourceType, data, options);
}
+#if QT_DEPRECATED_SINCE(5, 3)
/*!
\obsolete
\overload
@@ -3022,6 +3023,7 @@ void QOpenGLTexture::setData(PixelFormat sourceFormat, PixelType sourceType,
Q_ASSERT(d->textureId);
d->setData(0, 0, QOpenGLTexture::CubeMapPositiveX, sourceFormat, sourceType, data, options);
}
+#endif
/*!
This overload of setData() will allocate storage for you.
@@ -3110,6 +3112,7 @@ void QOpenGLTexture::setCompressedData(int dataSize, const void *data,
d->setCompressedData(0, 0, QOpenGLTexture::CubeMapPositiveX, dataSize, data, options);
}
+#if QT_DEPRECATED_SINCE(5, 3)
/*!
\obsolete
\overload
@@ -3163,6 +3166,7 @@ void QOpenGLTexture::setCompressedData(int dataSize, void *data,
Q_ASSERT(d->textureId);
d->setCompressedData(0, 0, QOpenGLTexture::CubeMapPositiveX, dataSize, data, options);
}
+#endif
/*!
Returns \c true if your OpenGL implementation and version supports the texture
diff --git a/src/gui/opengl/qopengltexture.h b/src/gui/opengl/qopengltexture.h
index 0f999a8409..1cf5fdc12a 100644
--- a/src/gui/opengl/qopengltexture.h
+++ b/src/gui/opengl/qopengltexture.h
@@ -404,6 +404,7 @@ public:
// Pixel transfer
// ### Qt 6: remove the non-const void * overloads
+#if QT_DEPRECATED_SINCE(5, 3)
QT_DEPRECATED void setData(int mipLevel, int layer, CubeMapFace cubeFace,
PixelFormat sourceFormat, PixelType sourceType,
void *data, const QOpenGLPixelTransferOptions * const options = 0);
@@ -415,6 +416,7 @@ public:
void *data, const QOpenGLPixelTransferOptions * const options = 0);
QT_DEPRECATED void setData(PixelFormat sourceFormat, PixelType sourceType,
void *data, const QOpenGLPixelTransferOptions * const options = 0);
+#endif // QT_DEPRECATED_SINCE(5, 3)
void setData(int mipLevel, int layer, CubeMapFace cubeFace,
PixelFormat sourceFormat, PixelType sourceType,
@@ -430,6 +432,7 @@ public:
// Compressed data upload
// ### Qt 6: remove the non-const void * overloads
+#if QT_DEPRECATED_SINCE(5, 3)
QT_DEPRECATED void setCompressedData(int mipLevel, int layer, CubeMapFace cubeFace,
int dataSize, void *data,
const QOpenGLPixelTransferOptions * const options = 0);
@@ -440,6 +443,7 @@ public:
const QOpenGLPixelTransferOptions * const options = 0);
QT_DEPRECATED void setCompressedData(int dataSize, void *data,
const QOpenGLPixelTransferOptions * const options = 0);
+#endif // QT_DEPRECATED_SINCE(5, 3)
void setCompressedData(int mipLevel, int layer, CubeMapFace cubeFace,
int dataSize, const void *data,
diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp
index a9a2c91fd6..be147ec842 100644
--- a/src/gui/painting/qpaintbuffer.cpp
+++ b/src/gui/painting/qpaintbuffer.cpp
@@ -39,7 +39,6 @@
#include <private/qimage_p.h>
#include <qstatictext.h>
#include <private/qstatictext_p.h>
-#include <private/qrawfont_p.h>
#include <QDebug>
@@ -1744,14 +1743,8 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd)
painter->setFont(font);
- QRawFont rawFont;
- QRawFontPrivate *rawFontD = QRawFontPrivate::get(rawFont);
- QFontPrivate *fontD = QFontPrivate::get(font);
- rawFontD->fontEngine = fontD->engineForScript(QChar::Script_Common);
- rawFontD->fontEngine->ref.ref();
-
QGlyphRun glyphs;
- glyphs.setRawFont(rawFont);
+ glyphs.setRawFont(QRawFont::fromFont(font, QFontDatabase::Any));
glyphs.setGlyphIndexes(glyphIndexes);
glyphs.setPositions(positions);
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index eeebfde98c..b99a32df27 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -6358,7 +6358,7 @@ void QPainterPrivate::drawTextItem(const QPointF &p, const QTextItem &_ti, QText
return;
const QPainter::RenderHints oldRenderHints = state->renderHints;
- if (!state->renderHints & QPainter::Antialiasing && state->matrix.type() >= QTransform::TxScale) {
+ if (!(state->renderHints & QPainter::Antialiasing) && state->matrix.type() >= QTransform::TxScale) {
// draw antialias decoration (underline/overline/strikeout) with
// transformed text
@@ -6428,7 +6428,10 @@ void QPainterPrivate::drawTextItem(const QPointF &p, const QTextItem &_ti, QText
if (rtl)
x -= ti2.width.toReal();
- engine->drawTextItem(QPointF(x, y), ti2);
+ if (extended)
+ extended->drawTextItem(QPointF(x, y), ti2);
+ else
+ engine->drawTextItem(QPointF(x, y), ti2);
if (!rtl)
x += ti2.width.toReal();
diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp
index 38215cd418..10fe1a2c84 100644
--- a/src/gui/text/qdistancefield.cpp
+++ b/src/gui/text/qdistancefield.cpp
@@ -752,7 +752,7 @@ bool qt_fontHasNarrowOutlines(const QRawFont &f)
return false;
QVector<quint32> glyphIndices = font.glyphIndexesForString(QLatin1String("O"));
- if (glyphIndices.size() < 1)
+ if (glyphIndices.isEmpty() || glyphIndices[0] == 0)
return false;
return imageHasNarrowOutlines(font.alphaMapForGlyph(glyphIndices.at(0),
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index a0cbd052e4..b867dc6ef2 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -1950,6 +1950,7 @@ static void set_extended_font_bits(quint8 bits, QFontPrivate *f)
}
#endif
+#if QT_DEPRECATED_SINCE(5, 3)
/*!
\fn QString QFont::rawName() const
\deprecated
@@ -1986,6 +1987,7 @@ QString QFont::rawName() const
void QFont::setRawName(const QString &)
{
}
+#endif
/*!
Returns the font's key, a textual representation of a font. It is
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index c00d3d18a6..8134e3012b 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -2482,11 +2482,12 @@ bool QFontDatabase::removeAllApplicationFonts()
\sa {Thread-Support in Qt Modules#Painting In Threads}{Painting In Threads}
*/
-// QT_DEPRECATED_SINCE(5, 2)
+#if QT_DEPRECATED_SINCE(5, 2)
bool QFontDatabase::supportsThreadedFontRendering()
{
return true;
}
+#endif
/*!
\internal
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 4c5bab77d6..ef397e532c 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -1345,20 +1345,28 @@ void QFontEngineFT::doKerning(QGlyphLayout *g, QFontEngine::ShaperFlags flags) c
QFontEngine::doKerning(g, flags);
}
+static inline FT_Matrix QTransformToFTMatrix(const QTransform &matrix)
+{
+ FT_Matrix m;
+
+ m.xx = FT_Fixed(matrix.m11() * 65536);
+ m.xy = FT_Fixed(-matrix.m21() * 65536);
+ m.yx = FT_Fixed(-matrix.m12() * 65536);
+ m.yy = FT_Fixed(matrix.m22() * 65536);
+
+ return m;
+}
+
QFontEngineFT::QGlyphSet *QFontEngineFT::loadTransformedGlyphSet(const QTransform &matrix)
{
- if (matrix.type() > QTransform::TxShear)
+ if (matrix.type() > QTransform::TxShear || !cacheEnabled)
return 0;
// FT_Set_Transform only supports scalable fonts
if (!FT_IS_SCALABLE(freetype->face))
return 0;
- FT_Matrix m;
- m.xx = FT_Fixed(matrix.m11() * 65536);
- m.xy = FT_Fixed(-matrix.m21() * 65536);
- m.yx = FT_Fixed(-matrix.m12() * 65536);
- m.yy = FT_Fixed(matrix.m22() * 65536);
+ FT_Matrix m = QTransformToFTMatrix(matrix);
QGlyphSet *gs = 0;
@@ -1377,11 +1385,6 @@ QFontEngineFT::QGlyphSet *QFontEngineFT::loadTransformedGlyphSet(const QTransfor
}
if (!gs) {
- // don't try to load huge fonts
- bool draw_as_outline = fontDef.pixelSize * qSqrt(qAbs(matrix.det())) >= QT_MAX_CACHED_GLYPH_SIZE;
- if (draw_as_outline)
- return 0;
-
// don't cache more than 10 transformations
if (transformedGlyphSets.count() >= 10) {
transformedGlyphSets.move(transformedGlyphSets.size() - 1, 0);
@@ -1391,8 +1394,9 @@ QFontEngineFT::QGlyphSet *QFontEngineFT::loadTransformedGlyphSet(const QTransfor
gs = &transformedGlyphSets[0];
gs->clear();
gs->transformationMatrix = m;
- gs->outline_drawing = draw_as_outline;
+ gs->outline_drawing = fontDef.pixelSize * fontDef.pixelSize * qAbs(matrix.det()) >= QT_MAX_CACHED_GLYPH_SIZE * QT_MAX_CACHED_GLYPH_SIZE;
}
+ Q_ASSERT(gs != 0);
return gs;
}
@@ -1742,76 +1746,21 @@ glyph_metrics_t QFontEngineFT::boundingBox(glyph_t glyph, const QTransform &matr
return alphaMapBoundingBox(glyph, 0, matrix, QFontEngine::Format_None);
}
-static FT_Matrix QTransformToFTMatrix(const QTransform &matrix)
-{
- FT_Matrix m;
-
- m.xx = FT_Fixed(matrix.m11() * 65536);
- m.xy = FT_Fixed(-matrix.m21() * 65536);
- m.yx = FT_Fixed(-matrix.m12() * 65536);
- m.yy = FT_Fixed(matrix.m22() * 65536);
-
- return m;
-}
-
glyph_metrics_t QFontEngineFT::alphaMapBoundingBox(glyph_t glyph, QFixed subPixelPosition, const QTransform &matrix, QFontEngine::GlyphFormat format)
{
- FT_Face face = 0;
- glyph_metrics_t overall;
- QGlyphSet *glyphSet = 0;
- FT_Matrix ftMatrix = QTransformToFTMatrix(matrix);
- if (cacheEnabled) {
- if (matrix.type() > QTransform::TxTranslate && FT_IS_SCALABLE(freetype->face)) {
- // TODO move everything here to a method of its own to access glyphSets
- // to be shared with a new method that will replace loadTransformedGlyphSet()
- for (int i = 0; i < transformedGlyphSets.count(); ++i) {
- const QGlyphSet &g = transformedGlyphSets.at(i);
- if (g.transformationMatrix.xx == ftMatrix.xx
- && g.transformationMatrix.xy == ftMatrix.xy
- && g.transformationMatrix.yx == ftMatrix.yx
- && g.transformationMatrix.yy == ftMatrix.yy) {
-
- // found a match, move it to the front
- transformedGlyphSets.move(i, 0);
- glyphSet = &transformedGlyphSets[0];
- break;
- }
- }
-
- if (!glyphSet) {
- // don't cache more than 10 transformations
- if (transformedGlyphSets.count() >= 10) {
- transformedGlyphSets.move(transformedGlyphSets.size() - 1, 0);
- } else {
- transformedGlyphSets.prepend(QGlyphSet());
- }
- glyphSet = &transformedGlyphSets[0];
- glyphSet->clear();
- glyphSet->transformationMatrix = ftMatrix;
- }
- Q_ASSERT(glyphSet);
- } else {
- glyphSet = &defaultGlyphSet;
- }
- }
- Glyph * g = glyphSet ? glyphSet->getGlyph(glyph, subPixelPosition) : 0;
- if (!g || g->format != format) {
- face = lockFace();
- FT_Matrix m = this->matrix;
- FT_Matrix_Multiply(&ftMatrix, &m);
- freetype->matrix = m;
- g = loadGlyph(glyphSet, glyph, subPixelPosition, format, false);
- }
+ Glyph *g = loadGlyphFor(glyph, subPixelPosition, format, matrix);
+ glyph_metrics_t overall;
if (g) {
overall.x = g->x;
overall.y = -g->y;
overall.width = g->width;
overall.height = g->height;
overall.xoff = g->advance;
- if (!glyphSet && g != &emptyGlyph)
+ if (!cacheEnabled && g != &emptyGlyph)
delete g;
} else {
+ FT_Face face = lockFace();
int left = FLOOR(face->glyph->metrics.horiBearingX);
int right = CEIL(face->glyph->metrics.horiBearingX + face->glyph->metrics.width);
int top = CEIL(face->glyph->metrics.horiBearingY);
@@ -1822,9 +1771,9 @@ glyph_metrics_t QFontEngineFT::alphaMapBoundingBox(glyph_t glyph, QFixed subPixe
overall.x = TRUNC(left);
overall.y = -TRUNC(top);
overall.xoff = TRUNC(ROUND(face->glyph->advance.x));
+ if (face)
+ unlockFace();
}
- if (face)
- unlockFace();
return overall;
}
@@ -1949,35 +1898,10 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyphFor(glyph_t g,
QGlyphSet *glyphSet = 0;
FT_Matrix ftMatrix = QTransformToFTMatrix(t);
if (cacheEnabled) {
- if (t.type() > QTransform::TxTranslate && FT_IS_SCALABLE(freetype->face)) {
- for (int i = 0; i < transformedGlyphSets.count(); ++i) {
- const QGlyphSet &g = transformedGlyphSets.at(i);
- if (g.transformationMatrix.xx == ftMatrix.xx
- && g.transformationMatrix.xy == ftMatrix.xy
- && g.transformationMatrix.yx == ftMatrix.yx
- && g.transformationMatrix.yy == ftMatrix.yy) {
-
- // found a match, move it to the front
- transformedGlyphSets.move(i, 0);
- glyphSet = &transformedGlyphSets[0];
- break;
- }
- }
-
- if (!glyphSet) {
- // don't cache more than 10 transformations
- if (transformedGlyphSets.count() >= 10) {
- transformedGlyphSets.move(transformedGlyphSets.size() - 1, 0);
- } else {
- transformedGlyphSets.prepend(QGlyphSet());
- }
- glyphSet = &transformedGlyphSets[0];
- glyphSet->clear();
- glyphSet->transformationMatrix = ftMatrix;
- }
- } else {
+ if (t.type() > QTransform::TxTranslate && FT_IS_SCALABLE(freetype->face))
+ glyphSet = loadTransformedGlyphSet(t);
+ else
glyphSet = &defaultGlyphSet;
- }
Q_ASSERT(glyphSet != 0);
}
diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp
index efced94397..a7868f36ab 100644
--- a/src/gui/text/qstatictext.cpp
+++ b/src/gui/text/qstatictext.cpp
@@ -722,14 +722,19 @@ QStaticTextItem::~QStaticTextItem()
{
if (m_userData != 0 && !m_userData->ref.deref())
delete m_userData;
- m_fontEngine->ref.deref();
+ setFontEngine(0);
}
void QStaticTextItem::setFontEngine(QFontEngine *fe)
{
- if (m_fontEngine != 0)
- m_fontEngine->ref.deref();
+ if (m_fontEngine == fe)
+ return;
+
+ if (m_fontEngine != 0 && !m_fontEngine->ref.deref())
+ delete m_fontEngine;
+
m_fontEngine = fe;
+
if (m_fontEngine != 0)
m_fontEngine->ref.ref();
}