summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-03-16 15:04:08 +0100
committerLuboš Luňák <l.lunak@collabora.com>2021-03-17 22:49:33 +0100
commit7439cabc643de2f07c18adc35056f802997f484a (patch)
tree1fb8f6bd207a81936617263091dca32d3536f1d6 /include
parent9d02d86e8a9111b7a689062eb9a856146a9e80b1 (diff)
make SalLayoutGlyphs work with MultiSalLayout
Code that needs to lay out texts repeatedly can cache the result of SalLayout::GetGlyphs() can reuse it. But GetGlyphs() returns nullptr for MultiSalLayout, so caching for it doesn't work. Worse still, it actually increases the number of layout calls, because there's the initial layout for caching and then each call will need to do the layout again because of the nullptr that's not cached. This commit changes SalLayoutGlyphs to possibly include multiple SalLayoutGlyphsImpl objects, one for each SalLayout handled by MultiSalLayout. Changes include making GenericSalLayout work directly with the Impl class, which avoids an indirection and simplifies code. Change-Id: Ic4b19934a8a06d4955b51527fe3777c5e91107b2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112590 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'include')
-rw-r--r--include/vcl/glyphitem.hxx19
-rw-r--r--include/vcl/outdev.hxx6
-rw-r--r--include/vcl/vcllayout.hxx6
3 files changed, 20 insertions, 11 deletions
diff --git a/include/vcl/glyphitem.hxx b/include/vcl/glyphitem.hxx
index 7634bd3a4413..02d783a3e166 100644
--- a/include/vcl/glyphitem.hxx
+++ b/include/vcl/glyphitem.hxx
@@ -23,23 +23,30 @@
#include <sal/types.h>
#include <vcl/dllapi.h>
+#include <vector>
+
typedef sal_uInt16 sal_GlyphId;
class SalLayoutGlyphsImpl;
class VCL_DLLPUBLIC SalLayoutGlyphs final
{
- friend class SalLayoutGlyphsImpl;
- SalLayoutGlyphsImpl* m_pImpl;
+ std::vector<SalLayoutGlyphsImpl*> m_pImpls;
public:
- SalLayoutGlyphs();
- SalLayoutGlyphs(const SalLayoutGlyphs&);
+ SalLayoutGlyphs() = default;
+ SalLayoutGlyphs(const SalLayoutGlyphs&) = delete;
+ SalLayoutGlyphs(SalLayoutGlyphs&&);
~SalLayoutGlyphs();
- SalLayoutGlyphs& operator=(const SalLayoutGlyphs&);
+ SalLayoutGlyphs& operator=(const SalLayoutGlyphs&) = delete;
+ SalLayoutGlyphs& operator=(SalLayoutGlyphs&&);
- SalLayoutGlyphsImpl* Impl() const { return m_pImpl; }
+ SalLayoutGlyphsImpl* Impl(unsigned int nLevel) const
+ {
+ return nLevel < m_pImpls.size() ? m_pImpls[nLevel] : nullptr;
+ }
+ void AppendImpl(SalLayoutGlyphsImpl* pImpl) { m_pImpls.push_back(pImpl); }
bool IsValid() const;
void Invalidate();
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index a8d77c77b30e..ce7d54e75689 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1352,11 +1352,13 @@ public:
SalLayoutFlags flags = SalLayoutFlags::NONE,
vcl::TextLayoutCache const* = nullptr) const;
SAL_DLLPRIVATE std::unique_ptr<SalLayout>
- ImplGlyphFallbackLayout( std::unique_ptr<SalLayout>, ImplLayoutArgs& ) const;
+ ImplGlyphFallbackLayout( std::unique_ptr<SalLayout>,
+ ImplLayoutArgs&,
+ const SalLayoutGlyphs* ) const;
SAL_DLLPRIVATE std::unique_ptr<SalLayout>
getFallbackLayout(
LogicalFontInstance* pLogicalFont, int nFallbackLevel,
- ImplLayoutArgs& rLayoutArgs) const;
+ ImplLayoutArgs& rLayoutArgs, const SalLayoutGlyphs* ) const;
// Enabling/disabling RTL only makes sense for OutputDevices that use a mirroring SalGraphicsLayout
diff --git a/include/vcl/vcllayout.hxx b/include/vcl/vcllayout.hxx
index 7d53d12bd40b..e09e54f59d65 100644
--- a/include/vcl/vcllayout.hxx
+++ b/include/vcl/vcllayout.hxx
@@ -24,13 +24,13 @@
#include <tools/gen.hxx>
#include <tools/degree.hxx>
#include <vcl/devicecoordinate.hxx>
+#include <vcl/glyphitem.hxx>
#include <vcl/dllapi.h>
class ImplLayoutArgs;
class PhysicalFontFace;
class SalGraphics;
class GlyphItem;
-class SalLayoutGlyphs;
// all positions/widths are in font units
// one exception: drawposition is in pixel units
@@ -73,7 +73,7 @@ public:
const Point& DrawOffset() const { return maDrawOffset; }
Point GetDrawPosition( const Point& rRelative = Point(0,0) ) const;
- virtual bool LayoutText( ImplLayoutArgs&, const SalLayoutGlyphs* ) = 0; // first step of layouting
+ virtual bool LayoutText( ImplLayoutArgs&, const SalLayoutGlyphsImpl* ) = 0; // first step of layouting
virtual void AdjustLayout( ImplLayoutArgs& ); // adjusting after fallback etc.
virtual void InitFont() const {}
virtual void DrawText( SalGraphics& ) const = 0;
@@ -94,7 +94,7 @@ public:
virtual bool GetOutline(basegfx::B2DPolyPolygonVector&) const;
bool GetBoundRect(tools::Rectangle&) const;
- virtual const SalLayoutGlyphs* GetGlyphs() const;
+ virtual SalLayoutGlyphs GetGlyphs() const;
protected:
// used by layout engines