diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2018-07-08 11:23:24 +0200 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2018-08-17 11:06:20 +0000 |
commit | 36c6b727c5f433ce3f22e18d93e2502df1c526aa (patch) | |
tree | 4c57debdf593897440d9d012935bfca16ba7cb66 /src/quick/scenegraph/qsgadaptationlayer.cpp | |
parent | 9fbdc8c4c2c028427b19907d636a7a83d79cbd09 (diff) |
Load pregenerated glyph cache in default DF cache
In order to support quick loading of scenes with lots of text,
we support preloading the contents of the distance field cache
from a generated file instead of creating all the distance fields
on startup.
The idea is that when creating a distance field cache for a specific
font, the data will be prepopulated. This is stored in a table in
the font file and is picked up automatically by Qt when available.
[ChangeLog][Text] Support pregenerated loading distance field
glyph caches to decrease startup time for applications with
large amounts of text.
Task-number: QTBUG-69356
Change-Id: I7cff0c4c782f819b1c893041405970ea4553fb8d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/quick/scenegraph/qsgadaptationlayer.cpp')
-rw-r--r-- | src/quick/scenegraph/qsgadaptationlayer.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/quick/scenegraph/qsgadaptationlayer.cpp b/src/quick/scenegraph/qsgadaptationlayer.cpp index 46af0f28f0..c99e149aa5 100644 --- a/src/quick/scenegraph/qsgadaptationlayer.cpp +++ b/src/quick/scenegraph/qsgadaptationlayer.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2018 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtQuick module of the Qt Toolkit. @@ -82,19 +82,26 @@ QSGDistanceFieldGlyphCache::~QSGDistanceFieldGlyphCache() { } +QSGDistanceFieldGlyphCache::GlyphData &QSGDistanceFieldGlyphCache::emptyData(glyph_t glyph) +{ + GlyphData gd; + gd.texture = &s_emptyTexture; + QHash<glyph_t, GlyphData>::iterator it = m_glyphsData.insert(glyph, gd); + return it.value(); +} + QSGDistanceFieldGlyphCache::GlyphData &QSGDistanceFieldGlyphCache::glyphData(glyph_t glyph) { QHash<glyph_t, GlyphData>::iterator data = m_glyphsData.find(glyph); if (data == m_glyphsData.end()) { - GlyphData gd; - gd.texture = &s_emptyTexture; + GlyphData &gd = emptyData(glyph); gd.path = m_referenceFont.pathForGlyph(glyph); // need bounding rect in base font size scale qreal scaleFactor = qreal(1) / QT_DISTANCEFIELD_SCALE(m_doubleGlyphResolution); QTransform scaleDown; scaleDown.scale(scaleFactor, scaleFactor); gd.boundingRect = scaleDown.mapRect(gd.path.boundingRect()); - data = m_glyphsData.insert(glyph, gd); + return gd; } return data.value(); } |