From 070d9c00c488a5ee6811f04170cf488ead79bf80 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 16 Sep 2011 16:00:04 +0200 Subject: Avoid double caching glyphs in raster/QPA/FreeType MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since FreeType has internal caching, it has had a special code path in the raster engine which avoided using Qt's glyph cache, as that would be redundant. However, when compiling with QPA, we want the same behavior without being able to access the QFontEngineFT class. To achieve this, I've made a new abstraction and added it to QFontEngine which allows the FT engine to provide direct pointers into the alpha maps stored by FT. This requires a locking/unlocking mechanism. Yes, the QFontEngine::alphaMap* API is slowly becoming a horrible mess, but due to time constraints, the task of refactoring these functions into a more flexible API needs to wait. I've added a TODO comment for this. Change-Id: I08237403c2967f8fb952258178676f33a87c0353 Reviewed-on: http://codereview.qt-project.org/5155 Reviewed-by: Qt Sanity Bot Reviewed-by: Samuel Rødal --- src/gui/image/qimage.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/gui/image/qimage.cpp') diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 2dbb2f4b52..d0de95366f 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -69,6 +69,11 @@ QT_BEGIN_NAMESPACE +static inline bool isLocked(QImageData *data) +{ + return data != 0 && data->is_locked; +} + static inline bool checkPixelSize(const QImage::Format format) { switch (format) { @@ -130,7 +135,7 @@ QImageData::QImageData() dpmx(qt_defaultDpiX() * 100 / qreal(2.54)), dpmy(qt_defaultDpiY() * 100 / qreal(2.54)), offset(0, 0), own_data(true), ro_data(false), has_alpha_clut(false), - is_cached(false), paintEngine(0) + is_cached(false), is_locked(false), paintEngine(0) { } @@ -1022,7 +1027,7 @@ QImage::QImage(const char * const xpm[]) QImage::QImage(const QImage &image) : QPaintDevice() { - if (image.paintingActive()) { + if (image.paintingActive() || isLocked(image.d)) { d = 0; operator=(image.copy()); } else { @@ -1054,7 +1059,7 @@ QImage::~QImage() QImage &QImage::operator=(const QImage &image) { - if (image.paintingActive()) { + if (image.paintingActive() || isLocked(image.d)) { operator=(image.copy()); } else { if (image.d) -- cgit v1.2.3