[Libreoffice-commits] core.git: include/vcl vcl/inc vcl/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Aug 16 11:50:49 UTC 2018


 include/vcl/outdev.hxx             |    3 +
 include/vcl/vcllayout.hxx          |   57 ++++++++++++++++++++++++++++++++++++-
 vcl/inc/sallayout.hxx              |   55 +----------------------------------
 vcl/source/gdi/CommonSalLayout.cxx |    5 +++
 vcl/source/gdi/sallayout.cxx       |    6 +++
 vcl/source/outdev/text.cxx         |    3 +
 6 files changed, 74 insertions(+), 55 deletions(-)

New commits:
commit 88e601188c6902769e0c8f2ecfd2ade5c4f27703
Author:     Miklos Vajna <vmiklos at collabora.co.uk>
AuthorDate: Thu Aug 16 12:13:18 2018 +0200
Commit:     Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Thu Aug 16 13:50:25 2018 +0200

    vcl: introduce a SalLayoutFlags::GlyphItemsOnly
    
    OutputDevice::ImplLayout() does a number of things: first it calls the
    expensive SalLayout::LayoutText(), then it does a number of remaing
    tweaks to the resulting SalLayout based on the rLogicalPos and pDXArray
    parameters.
    
    This means that the resulting layout is not easy to reuse for Writer
    purposes, as it typically operates with the same text multiple times,
    but with different LogicalPos/DXArray.
    
    Add a new flag that returns the glyph items early, with the hope that
    this way the result only depends on the output device state and the
    string only, nothing else.
    
    Change-Id: I7c4a23d0f230495c8ba0ebbd1cfc3421e4a6e43c
    Reviewed-on: https://gerrit.libreoffice.org/59159
    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 471d9a39fa0e..fe9af36994b8 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -142,10 +142,11 @@ enum class SalLayoutFlags
     SubstituteDigits        = 0x0400,
     KashidaJustification    = 0x0800,
     ForFallback             = 0x2000,
+    GlyphItemsOnly          = 0x4000,
 };
 namespace o3tl
 {
-    template<> struct typed_flags<SalLayoutFlags> : is_typed_flags<SalLayoutFlags, 0x2e77> {};
+    template<> struct typed_flags<SalLayoutFlags> : is_typed_flags<SalLayoutFlags, 0x6e77> {};
 }
 
 typedef std::vector< tools::Rectangle > MetricVector;
diff --git a/include/vcl/vcllayout.hxx b/include/vcl/vcllayout.hxx
index d9d4e0c42b99..ac61892fb415 100644
--- a/include/vcl/vcllayout.hxx
+++ b/include/vcl/vcllayout.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_VCL_VCLLAYOUT_HXX
 
 #include <memory>
+#include <vector>
 
 #include <basegfx/polygon/b2dpolypolygon.hxx>
 #include <tools/gen.hxx>
@@ -30,12 +31,65 @@
 class ImplLayoutArgs;
 class PhysicalFontFace;
 class SalGraphics;
-struct GlyphItem;
 namespace vcl
 {
 class TextLayoutCache;
 }
 
+typedef sal_uInt16 sal_GlyphId;
+
+struct VCL_DLLPUBLIC GlyphItem
+{
+    int     mnFlags;
+    int     mnCharPos;      // index in string
+    int     mnCharCount;    // number of characters making up this glyph
+
+    int     mnOrigWidth;    // original glyph width
+    int     mnNewWidth;     // width after adjustments
+    int     mnXOffset;
+
+    sal_GlyphId maGlyphId;
+    Point   maLinearPos;    // absolute position of non rotated string
+
+    int     mnFallbackLevel;
+
+public:
+            GlyphItem(int nCharPos, int nCharCount, sal_GlyphId aGlyphId, const Point& rLinearPos,
+                long nFlags, int nOrigWidth, int nXOffset )
+            :   mnFlags(nFlags)
+            ,   mnCharPos(nCharPos)
+            ,   mnCharCount(nCharCount)
+            ,   mnOrigWidth(nOrigWidth)
+            ,   mnNewWidth(nOrigWidth)
+            ,   mnXOffset(nXOffset)
+            ,   maGlyphId(aGlyphId)
+            ,   maLinearPos(rLinearPos)
+            ,   mnFallbackLevel(0)
+            { }
+
+    enum {
+        IS_IN_CLUSTER = 0x001,
+        IS_RTL_GLYPH  = 0x002,
+        IS_DIACRITIC  = 0x004,
+        IS_VERTICAL   = 0x008,
+        IS_SPACING    = 0x010,
+        ALLOW_KASHIDA = 0x020,
+        IS_DROPPED    = 0x040,
+        IS_CLUSTER_START = 0x080
+    };
+
+    bool    IsInCluster() const     { return ((mnFlags & IS_IN_CLUSTER) != 0); }
+    bool    IsRTLGlyph() const      { return ((mnFlags & IS_RTL_GLYPH) != 0); }
+    bool    IsDiacritic() const     { return ((mnFlags & IS_DIACRITIC) != 0); }
+    bool    IsVertical() const      { return ((mnFlags & IS_VERTICAL) != 0); }
+    bool    IsSpacing() const       { return ((mnFlags & IS_SPACING) != 0); }
+    bool    AllowKashida() const    { return ((mnFlags & ALLOW_KASHIDA) != 0); }
+    bool    IsDropped() const       { return ((mnFlags & IS_DROPPED) != 0); }
+    bool    IsClusterStart() const  { return ((mnFlags & IS_CLUSTER_START) != 0); }
+};
+
+typedef std::vector<GlyphItem> SalLayoutGlyphs;
+
 // all positions/widths are in font units
 // one exception: drawposition is in pixel units
 
@@ -105,6 +159,7 @@ public:
 
     virtual std::shared_ptr<vcl::TextLayoutCache>
         CreateTextLayoutCache(OUString const&) const;
+    virtual SalLayoutGlyphs GetGlyphs() const;
 
 protected:
     // used by layout engines
diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx
index 123c339b525a..2aa650a1c75a 100644
--- a/vcl/inc/sallayout.hxx
+++ b/vcl/inc/sallayout.hxx
@@ -165,58 +165,6 @@ private:
     bool            mbIncomplete;
 };
 
-typedef sal_uInt16 sal_GlyphId;
-
-struct GlyphItem
-{
-    int     mnFlags;
-    int     mnCharPos;      // index in string
-    int     mnCharCount;    // number of characters making up this glyph
-
-    int     mnOrigWidth;    // original glyph width
-    int     mnNewWidth;     // width after adjustments
-    int     mnXOffset;
-
-    sal_GlyphId maGlyphId;
-    Point   maLinearPos;    // absolute position of non rotated string
-
-    int     mnFallbackLevel;
-
-public:
-            GlyphItem(int nCharPos, int nCharCount, sal_GlyphId aGlyphId, const Point& rLinearPos,
-                long nFlags, int nOrigWidth, int nXOffset )
-            :   mnFlags(nFlags)
-            ,   mnCharPos(nCharPos)
-            ,   mnCharCount(nCharCount)
-            ,   mnOrigWidth(nOrigWidth)
-            ,   mnNewWidth(nOrigWidth)
-            ,   mnXOffset(nXOffset)
-            ,   maGlyphId(aGlyphId)
-            ,   maLinearPos(rLinearPos)
-            ,   mnFallbackLevel(0)
-            { }
-
-    enum {
-        IS_IN_CLUSTER = 0x001,
-        IS_RTL_GLYPH  = 0x002,
-        IS_DIACRITIC  = 0x004,
-        IS_VERTICAL   = 0x008,
-        IS_SPACING    = 0x010,
-        ALLOW_KASHIDA = 0x020,
-        IS_DROPPED    = 0x040,
-        IS_CLUSTER_START = 0x080
-    };
-
-    bool    IsInCluster() const     { return ((mnFlags & IS_IN_CLUSTER) != 0); }
-    bool    IsRTLGlyph() const      { return ((mnFlags & IS_RTL_GLYPH) != 0); }
-    bool    IsDiacritic() const     { return ((mnFlags & IS_DIACRITIC) != 0); }
-    bool    IsVertical() const      { return ((mnFlags & IS_VERTICAL) != 0); }
-    bool    IsSpacing() const       { return ((mnFlags & IS_SPACING) != 0); }
-    bool    AllowKashida() const    { return ((mnFlags & ALLOW_KASHIDA) != 0); }
-    bool    IsDropped() const       { return ((mnFlags & IS_DROPPED) != 0); }
-    bool    IsClusterStart() const  { return ((mnFlags & IS_CLUSTER_START) != 0); }
-};
-
 class VCL_PLUGIN_PUBLIC GenericSalLayout : public SalLayout
 {
 public:
@@ -227,6 +175,7 @@ public:
     bool            LayoutText(ImplLayoutArgs&) final override;
     void            DrawText(SalGraphics&) const final override;
     std::shared_ptr<vcl::TextLayoutCache> CreateTextLayoutCache(OUString const&) const final override;
+    SalLayoutGlyphs GetGlyphs() const final override;
 
     bool            IsKashidaPosValid(int nCharPos) const final override;
 
@@ -267,7 +216,7 @@ private:
     rtl::Reference<LogicalFontInstance> const mpFont;
     css::uno::Reference<css::i18n::XBreakIterator> mxBreak;
 
-    std::vector<GlyphItem> m_GlyphItems;
+    SalLayoutGlyphs m_GlyphItems;
 
     OString         msLanguage;
     std::vector<hb_feature_t> maFeatures;
diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx
index 7f3d9d851797..32d8e572156a 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -169,6 +169,11 @@ std::shared_ptr<vcl::TextLayoutCache> GenericSalLayout::CreateTextLayoutCache(OU
     return std::make_shared<vcl::TextLayoutCache>(rString.getStr(), rString.getLength());
 }
 
+SalLayoutGlyphs GenericSalLayout::GetGlyphs() const
+{
+    return m_GlyphItems;
+}
+
 void GenericSalLayout::SetNeedFallback(ImplLayoutArgs& rArgs, sal_Int32 nCharPos, bool bRightToLeft)
 {
     if (nCharPos < 0 || mbFuzzing)
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index 4ab8e9376cb4..74fbd98b1c08 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -1579,4 +1579,10 @@ std::shared_ptr<vcl::TextLayoutCache> SalLayout::CreateTextLayoutCache(
     return nullptr; // by default, nothing to cache
 }
 
+SalLayoutGlyphs SalLayout::GetGlyphs() const
+{
+    // No access to the glyphs by default.
+    return SalLayoutGlyphs();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index 659a9b6a82da..2ac6bd470451 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -1360,6 +1360,9 @@ std::unique_ptr<SalLayout> OutputDevice::ImplLayout(const OUString& rOrigStr,
     if( !pSalLayout )
         return nullptr;
 
+    if (flags & SalLayoutFlags::GlyphItemsOnly)
+        return pSalLayout;
+
     // do glyph fallback if needed
     // #105768# avoid fallback for very small font sizes
     if (aLayoutArgs.NeedFallback() && mpFontInstance->GetFontSelectPattern().mnHeight >= 3)


More information about the Libreoffice-commits mailing list