diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-08-16 13:51:43 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-08-16 17:32:56 +0200 |
commit | 46b3a2401d371b20bdbfca6a47c09408259d595f (patch) | |
tree | f89d3f274688d66c8a92249de5130dfe2ee73ded /vcl | |
parent | a518d1acf7f2f9952ab1d20f3185615351655ef8 (diff) |
vcl: support pre-computed glyph items in OutputDevice::ImplLayout()
This allows using the SalLayoutGlyphs obtained from
GenericSalLayout::GetGlyphs() to return early in
GenericSalLayout::LayoutText().
Change-Id: If3a004f983f3578915786668bfcada00227d2eeb
Reviewed-on: https://gerrit.libreoffice.org/59169
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/sallayout.hxx | 4 | ||||
-rw-r--r-- | vcl/source/gdi/CommonSalLayout.cxx | 9 | ||||
-rw-r--r-- | vcl/source/gdi/sallayout.cxx | 2 | ||||
-rw-r--r-- | vcl/source/outdev/font.cxx | 4 | ||||
-rw-r--r-- | vcl/source/outdev/text.cxx | 6 |
5 files changed, 17 insertions, 8 deletions
diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx index 2aa650a1c75a..a8b9e233f450 100644 --- a/vcl/inc/sallayout.hxx +++ b/vcl/inc/sallayout.hxx @@ -139,7 +139,7 @@ public: explicit MultiSalLayout( std::unique_ptr<SalLayout> pBaseLayout ); void AddFallback( std::unique_ptr<SalLayout> pFallbackLayout, ImplLayoutRuns const &, const PhysicalFontFace* pFallbackFont ); - bool LayoutText(ImplLayoutArgs&) override; + bool LayoutText(ImplLayoutArgs&, const SalLayoutGlyphs*) override; void AdjustLayout(ImplLayoutArgs&) override; void InitFont() const override; @@ -172,7 +172,7 @@ public: ~GenericSalLayout() override; void AdjustLayout(ImplLayoutArgs&) final override; - bool LayoutText(ImplLayoutArgs&) final override; + bool LayoutText(ImplLayoutArgs&, const SalLayoutGlyphs*) final override; void DrawText(SalGraphics&) const final override; std::shared_ptr<vcl::TextLayoutCache> CreateTextLayoutCache(OUString const&) const final override; SalLayoutGlyphs GetGlyphs() const final override; diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index 32d8e572156a..fc38b33437e1 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -263,12 +263,19 @@ bool GenericSalLayout::HasVerticalAlternate(sal_UCS4 aChar, sal_UCS4 aVariationS return hb_set_has(mpVertGlyphs, nGlyphIndex) != 0; } -bool GenericSalLayout::LayoutText(ImplLayoutArgs& rArgs) +bool GenericSalLayout::LayoutText(ImplLayoutArgs& rArgs, const SalLayoutGlyphs* pGlyphs) { // No need to touch m_GlyphItems at all for an empty string. if (rArgs.mnEndCharPos - rArgs.mnMinCharPos <= 0) return true; + if (pGlyphs) + { + // Work with pre-computed glyph items. + m_GlyphItems = *pGlyphs; + return true; + } + hb_font_t *pHbFont = mpFont->GetHbFont(); hb_face_t* pHbFace = hb_font_get_face(pHbFont); diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 74fbd98b1c08..09cf35d8fdfe 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -1017,7 +1017,7 @@ void MultiSalLayout::AddFallback( std::unique_ptr<SalLayout> pFallback, ++mnLevel; } -bool MultiSalLayout::LayoutText( ImplLayoutArgs& rArgs ) +bool MultiSalLayout::LayoutText( ImplLayoutArgs& rArgs, const SalLayoutGlyphs* ) { if( mnLevel <= 1 ) return false; diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index de8fae5a578d..d41ba14a0414 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -1334,7 +1334,7 @@ std::unique_ptr<SalLayout> OutputDevice::getFallbackFont( if (!pFallback) return nullptr; - if (!pFallback->LayoutText(rLayoutArgs)) + if (!pFallback->LayoutText(rLayoutArgs, nullptr)) { // there is no need for a font that couldn't resolve anything return nullptr; @@ -1418,7 +1418,7 @@ std::unique_ptr<SalLayout> OutputDevice::ImplGlyphFallbackLayout( std::unique_pt break; } - if( pMultiSalLayout && pMultiSalLayout->LayoutText( rLayoutArgs ) ) + if( pMultiSalLayout && pMultiSalLayout->LayoutText( rLayoutArgs, nullptr ) ) pSalLayout = std::move(pMultiSalLayout); // restore orig font settings diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index 2ac6bd470451..f1747895e947 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -1277,7 +1277,8 @@ std::unique_ptr<SalLayout> OutputDevice::ImplLayout(const OUString& rOrigStr, sal_Int32 nMinIndex, sal_Int32 nLen, const Point& rLogicalPos, long nLogicalWidth, const long* pDXArray, SalLayoutFlags flags, - vcl::TextLayoutCache const* pLayoutCache) const + vcl::TextLayoutCache const* pLayoutCache, + const SalLayoutGlyphs* pGlyphs) const { // we need a graphics if( !mpGraphics ) @@ -1307,6 +1308,7 @@ std::unique_ptr<SalLayout> OutputDevice::ImplLayout(const OUString& rOrigStr, if( mpFontInstance->mpConversion ) { mpFontInstance->mpConversion->RecodeString( aStr, 0, aStr.getLength() ); pLayoutCache = nullptr; // don't use cache with modified string! + pGlyphs = nullptr; } DeviceCoordinate nPixelWidth = static_cast<DeviceCoordinate>(nLogicalWidth); std::unique_ptr<DeviceCoordinate[]> xDXPixelArray; @@ -1352,7 +1354,7 @@ std::unique_ptr<SalLayout> OutputDevice::ImplLayout(const OUString& rOrigStr, std::unique_ptr<SalLayout> pSalLayout = mpGraphics->GetTextLayout( aLayoutArgs, 0 ); // layout text - if( pSalLayout && !pSalLayout->LayoutText( aLayoutArgs ) ) + if( pSalLayout && !pSalLayout->LayoutText( aLayoutArgs, pGlyphs ) ) { pSalLayout.reset(); } |