[Libreoffice-commits] core.git: include/vcl vcl/inc vcl/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Aug 16 15:33:23 UTC 2018
include/vcl/outdev.hxx | 5 ++++-
include/vcl/vcllayout.hxx | 2 +-
vcl/inc/sallayout.hxx | 4 ++--
vcl/source/gdi/CommonSalLayout.cxx | 9 ++++++++-
vcl/source/gdi/sallayout.cxx | 2 +-
vcl/source/outdev/font.cxx | 4 ++--
vcl/source/outdev/text.cxx | 6 ++++--
7 files changed, 22 insertions(+), 10 deletions(-)
New commits:
commit 46b3a2401d371b20bdbfca6a47c09408259d595f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
AuthorDate: Thu Aug 16 13:51:43 2018 +0200
Commit: Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Thu Aug 16 17:32:56 2018 +0200
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 at collabora.co.uk>
Tested-by: Jenkins
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index fe9af36994b8..6a91fd2527e8 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -150,6 +150,8 @@ namespace o3tl
}
typedef std::vector< tools::Rectangle > MetricVector;
+struct GlyphItem;
+typedef std::vector<GlyphItem> SalLayoutGlyphs;
// OutputDevice-Types
@@ -1328,7 +1330,8 @@ public:
ImplLayout( const OUString&, sal_Int32 nIndex, sal_Int32 nLen,
const Point& rLogicPos = Point(0,0), long nLogicWidth=0,
const long* pLogicDXArray=nullptr, SalLayoutFlags flags = SalLayoutFlags::NONE,
- vcl::TextLayoutCache const* = nullptr) const;
+ vcl::TextLayoutCache const* = nullptr,
+ const SalLayoutGlyphs* pGlyphs = nullptr) const;
SAL_DLLPRIVATE ImplLayoutArgs ImplPrepareLayoutArgs( OUString&, const sal_Int32 nIndex, const sal_Int32 nLen,
DeviceCoordinate nPixelWidth, const DeviceCoordinate* pPixelDXArray,
SalLayoutFlags flags = SalLayoutFlags::NONE,
diff --git a/include/vcl/vcllayout.hxx b/include/vcl/vcllayout.hxx
index ac61892fb415..735dc4cf748f 100644
--- a/include/vcl/vcllayout.hxx
+++ b/include/vcl/vcllayout.hxx
@@ -131,7 +131,7 @@ public:
const Point& DrawOffset() const { return maDrawOffset; }
Point GetDrawPosition( const Point& rRelative = Point(0,0) ) const;
- virtual bool LayoutText( ImplLayoutArgs& ) = 0; // first step of layouting
+ virtual bool LayoutText( ImplLayoutArgs&, const SalLayoutGlyphs* ) = 0; // first step of layouting
virtual void AdjustLayout( ImplLayoutArgs& ); // adjusting after fallback etc.
virtual void InitFont() const {}
virtual void DrawText( SalGraphics& ) const = 0;
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();
}
More information about the Libreoffice-commits
mailing list