[Libreoffice-commits] core.git: vcl/inc vcl/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Fri Nov 8 12:18:07 UTC 2019
vcl/inc/fontinstance.hxx | 3 +++
vcl/source/font/fontinstance.cxx | 10 ++++++++++
vcl/source/gdi/CommonSalLayout.cxx | 2 +-
3 files changed, 14 insertions(+), 1 deletion(-)
New commits:
commit 37e3573bb5739c94890c18ed11b4f4cc8a4df67f
Author: Noel Grandin <noel at peralex.com>
AuthorDate: Fri Nov 8 11:05:04 2019 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Nov 8 13:16:27 2019 +0100
tdf#121740 speed up font loading
by caching whether the font is a graphite font.
Takes load time from 27s to 23s for me.
Change-Id: I7b14a8bd305b27a088f363d19ebfb6fe774d3b02
Reviewed-on: https://gerrit.libreoffice.org/82267
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/vcl/inc/fontinstance.hxx b/vcl/inc/fontinstance.hxx
index da5af02b1089..ed4d92e8ef57 100644
--- a/vcl/inc/fontinstance.hxx
+++ b/vcl/inc/fontinstance.hxx
@@ -30,6 +30,7 @@
#include <tools/fontenum.hxx>
#include <vcl/glyphitem.hxx>
+#include <boost/optional.hpp>
#include <unordered_map>
#include <memory>
@@ -64,6 +65,7 @@ public: // TODO: make data members private
void IgnoreFallbackForUnicode( sal_UCS4, FontWeight eWeight, const OUString& rFontName );
inline hb_font_t* GetHbFont();
+ bool IsGraphiteFont();
void SetAverageWidthFactor(double nFactor) { m_nAveWidthFactor = std::abs(nFactor); }
double GetAverageWidthFactor() const { return m_nAveWidthFactor; }
const FontSelectPattern& GetFontSelectPattern() const { return m_aFontSelData; }
@@ -100,6 +102,7 @@ private:
hb_font_t* m_pHbFont;
double m_nAveWidthFactor;
rtl::Reference<PhysicalFontFace> m_pFontFace;
+ boost::optional<bool> m_xbIsGraphiteFont;
};
inline hb_font_t* LogicalFontInstance::GetHbFont()
diff --git a/vcl/source/font/fontinstance.cxx b/vcl/source/font/fontinstance.cxx
index 58d72083f130..40e334bd6d5c 100644
--- a/vcl/source/font/fontinstance.cxx
+++ b/vcl/source/font/fontinstance.cxx
@@ -19,6 +19,7 @@
#include <hb-ot.h>
+#include <hb-graphite2.h>
#include <fontinstance.hxx>
#include <impfontcache.hxx>
@@ -155,4 +156,13 @@ bool LogicalFontInstance::GetGlyphBoundRect(sal_GlyphId nID, tools::Rectangle &r
return res;
}
+bool LogicalFontInstance::IsGraphiteFont()
+{
+ if (!m_xbIsGraphiteFont)
+ {
+ m_xbIsGraphiteFont = hb_graphite2_face_get_gr_face(hb_font_get_face(GetHbFont())) != nullptr;
+ }
+ return *m_xbIsGraphiteFont;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx
index b77eca31a389..f0acbdd99114 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -291,7 +291,7 @@ bool GenericSalLayout::LayoutText(ImplLayoutArgs& rArgs, const SalLayoutGlyphs*
}
hb_font_t *pHbFont = GetFont().GetHbFont();
- bool isGraphite = hb_graphite2_face_get_gr_face(hb_font_get_face(pHbFont)) != nullptr;
+ bool isGraphite = GetFont().IsGraphiteFont();
int nGlyphCapacity = 2 * (rArgs.mnEndCharPos - rArgs.mnMinCharPos);
m_GlyphItems.Impl()->reserve(nGlyphCapacity);
More information about the Libreoffice-commits
mailing list