[Libreoffice-commits] core.git: include/vcl vcl/inc vcl/qt5 vcl/quartz vcl/source vcl/unx vcl/win

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Oct 25 12:02:59 UTC 2018


 include/vcl/outdev.hxx                   |    2 +-
 include/vcl/vcllayout.hxx                |    5 -----
 vcl/inc/sallayout.hxx                    |   24 +++++++++---------------
 vcl/qt5/Qt5Graphics_Text.cxx             |    6 +++---
 vcl/quartz/salgdi.cxx                    |    7 +++----
 vcl/source/gdi/pdfwriter_impl.cxx        |    4 ++--
 vcl/source/gdi/sallayout.cxx             |   18 +++++++++---------
 vcl/source/outdev/font.cxx               |    7 +++----
 vcl/unx/generic/gdi/cairotextrender.cxx  |    8 ++++----
 vcl/unx/generic/print/genpspgraphics.cxx |    8 ++++----
 vcl/win/gdi/winlayout.cxx                |    4 ++--
 11 files changed, 40 insertions(+), 53 deletions(-)

New commits:
commit dd16804e52984ded1ee739a22822daa068a13707
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Sun Sep 30 16:10:58 2018 +0200
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Thu Oct 25 14:02:32 2018 +0200

    Drop duplicate PhysicalFontFace reference
    
    A LogicalFontInstance has a pointer to its parent font face.
    And don't pretend we can actually nest MultiSalLayout, so
    store the GenericSalLayout internally.
    
    Change-Id: I801acbc34497fc57e8e185eee34c1a1162dbea93
    Reviewed-on: https://gerrit.libreoffice.org/62314
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>

diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 04bd178ed300..fe7507213256 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1345,7 +1345,7 @@ public:
                                 ImplGlyphFallbackLayout( std::unique_ptr<SalLayout>, ImplLayoutArgs& ) const;
     // tells whether this output device is RTL in an LTR UI or LTR in a RTL UI
     SAL_DLLPRIVATE std::unique_ptr<SalLayout>
-                                getFallbackFont(
+                                getFallbackLayout(
                                     LogicalFontInstance* pLogicalFont, int nFallbackLevel,
                                     ImplLayoutArgs& rLayoutArgs) const;
 
diff --git a/include/vcl/vcllayout.hxx b/include/vcl/vcllayout.hxx
index fad06ef4646c..ebd8c24ea401 100644
--- a/include/vcl/vcllayout.hxx
+++ b/include/vcl/vcllayout.hxx
@@ -152,11 +152,6 @@ public:
     virtual bool    GetOutline( SalGraphics&, basegfx::B2DPolyPolygonVector& ) const;
     virtual bool    GetBoundRect( SalGraphics&, tools::Rectangle& ) const;
 
-    // used by glyph+font+script fallback
-    virtual void    MoveGlyph( int nStart, long nNewXPos ) = 0;
-    virtual void    DropGlyph( int nStart ) = 0;
-    virtual void    Simplify( bool bIsBase ) = 0;
-
     virtual std::shared_ptr<vcl::TextLayoutCache>
         CreateTextLayoutCache(OUString const&) const;
     virtual const SalLayoutGlyphs* GetGlyphs() const;
diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx
index a9dc45b78d44..0cbe025ea290 100644
--- a/vcl/inc/sallayout.hxx
+++ b/vcl/inc/sallayout.hxx
@@ -44,6 +44,7 @@
 
 class SalGraphics;
 class PhysicalFontFace;
+class GenericSalLayout;
 struct GlyphItem;
 enum class SalLayoutFlags;
 namespace vcl {
@@ -137,8 +138,7 @@ public:
 
     // used only by OutputDevice::ImplLayout, TODO: make friend
     explicit        MultiSalLayout( std::unique_ptr<SalLayout> pBaseLayout );
-    void            AddFallback( std::unique_ptr<SalLayout> pFallbackLayout,
-                                 ImplLayoutRuns const &, const PhysicalFontFace* pFallbackFont );
+    void            AddFallback(std::unique_ptr<SalLayout> pFallbackLayout, ImplLayoutRuns const &);
     bool            LayoutText(ImplLayoutArgs&, const SalLayoutGlyphs*) override;
     void            AdjustLayout(ImplLayoutArgs&) override;
     void            InitFont() const override;
@@ -149,17 +149,10 @@ public:
     virtual         ~MultiSalLayout() override;
 
 private:
-    // dummy implementations
-    void            MoveGlyph(int, long) override {}
-    void            DropGlyph(int) override {}
-    void            Simplify(bool) override {}
-
                     MultiSalLayout( const MultiSalLayout& ) = delete;
                     MultiSalLayout& operator=( const MultiSalLayout& ) = delete;
 
-private:
-    std::unique_ptr<SalLayout> mpLayouts[ MAX_FALLBACK ];
-    const PhysicalFontFace* mpFallbackFonts[ MAX_FALLBACK ];
+    std::unique_ptr<GenericSalLayout> mpLayouts[ MAX_FALLBACK ];
     ImplLayoutRuns  maFallbackRuns[ MAX_FALLBACK ];
     int             mnLevel;
     bool            mbIncomplete;
@@ -167,6 +160,8 @@ private:
 
 class VCL_PLUGIN_PUBLIC GenericSalLayout : public SalLayout
 {
+    friend void MultiSalLayout::AdjustLayout(ImplLayoutArgs&);
+
 public:
                     GenericSalLayout(LogicalFontInstance&);
                     ~GenericSalLayout() override;
@@ -191,13 +186,12 @@ public:
     bool            GetNextGlyph(const GlyphItem** pGlyph, Point& rPos, int&,
                                  const PhysicalFontFace** pFallbackFont = nullptr) const final override;
 
-protected:
+private:
     // for glyph+font+script fallback
-    void            MoveGlyph(int nStart, long nNewXPos) final override;
-    void            DropGlyph(int nStart) final override;
-    void            Simplify(bool bIsBase) final override;
+    void            MoveGlyph(int nStart, long nNewXPos);
+    void            DropGlyph(int nStart);
+    void            Simplify(bool bIsBase);
 
-private:
                     GenericSalLayout( const GenericSalLayout& ) = delete;
                     GenericSalLayout& operator=( const GenericSalLayout& ) = delete;
 
diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx
index 94aa069db0c1..103aa3655372 100644
--- a/vcl/qt5/Qt5Graphics_Text.cxx
+++ b/vcl/qt5/Qt5Graphics_Text.cxx
@@ -182,9 +182,9 @@ public:
 
 std::unique_ptr<SalLayout> Qt5Graphics::GetTextLayout(ImplLayoutArgs&, int nFallbackLevel)
 {
-    if (m_pTextStyle[nFallbackLevel])
-        return std::unique_ptr<SalLayout>(new Qt5CommonSalLayout(*m_pTextStyle[nFallbackLevel]));
-    return std::unique_ptr<SalLayout>();
+    if (!m_pTextStyle[nFallbackLevel])
+        return nullptr;
+    return o3tl::make_unique<Qt5CommonSalLayout>(*m_pTextStyle[nFallbackLevel]);
 }
 
 void Qt5Graphics::DrawTextLayout(const GenericSalLayout& rLayout)
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index b9cdd2c5195a..eaf1d2b9c273 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -529,10 +529,9 @@ void AquaSalGraphics::SetFont(LogicalFontInstance* pReqFont, int nFallbackLevel)
 
 std::unique_ptr<SalLayout> AquaSalGraphics::GetTextLayout(ImplLayoutArgs& /*rArgs*/, int nFallbackLevel)
 {
-    if (mpTextStyle[nFallbackLevel])
-        return std::unique_ptr<SalLayout>(new GenericSalLayout(*mpTextStyle[nFallbackLevel]));
-
-    return nullptr;
+    if (!mpTextStyle[nFallbackLevel])
+        return nullptr;
+    return o3tl::make_unique<GenericSalLayout>(*mpTextStyle[nFallbackLevel]);
 }
 
 const FontCharMapRef AquaSalGraphics::GetFontCharMap() const
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 0148c11c40c4..8d92f1aa5400 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -6502,8 +6502,6 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool
 
     const int nMaxGlyphs = 256;
 
-    const GlyphItem* pGlyph = nullptr;
-    const PhysicalFontFace* pFallbackFont = nullptr;
     std::vector<sal_Ucs> aCodeUnits;
     bool bVertical = m_aCurrentPDFState.m_aFont.IsVertical();
     int nIndex = 0;
@@ -6622,6 +6620,8 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool
 
     FontMetric aRefDevFontMetric = GetFontMetric();
     const PhysicalFontFace* pDevFont = GetFontInstance()->GetFontFace();
+    const GlyphItem* pGlyph = nullptr;
+    const PhysicalFontFace* pFallbackFont = nullptr;
 
     // collect the glyphs into a single array
     std::vector< PDFGlyph > aGlyphs;
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index 510120b9c068..309b3b0c9b21 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -989,9 +989,9 @@ MultiSalLayout::MultiSalLayout( std::unique_ptr<SalLayout> pBaseLayout )
 ,   mnLevel( 1 )
 ,   mbIncomplete( false )
 {
-    //maFallbackRuns[0].Clear();
-    mpFallbackFonts[ 0 ] = nullptr;
-    mpLayouts[ 0 ]  = std::move(pBaseLayout);
+    assert(dynamic_cast<GenericSalLayout*>(pBaseLayout.get()));
+
+    mpLayouts[ 0 ].reset(static_cast<GenericSalLayout*>(pBaseLayout.release()));
     mnUnitsPerPixel = mpLayouts[ 0 ]->GetUnitsPerPixel();
 }
 
@@ -1006,13 +1006,13 @@ MultiSalLayout::~MultiSalLayout()
 }
 
 void MultiSalLayout::AddFallback( std::unique_ptr<SalLayout> pFallback,
-    ImplLayoutRuns const & rFallbackRuns, const PhysicalFontFace* pFallbackFont )
+    ImplLayoutRuns const & rFallbackRuns)
 {
+    assert(dynamic_cast<GenericSalLayout*>(pFallback.get()));
     if( mnLevel >= MAX_FALLBACK )
         return;
 
-    mpFallbackFonts[ mnLevel ]  = pFallbackFont;
-    mpLayouts[ mnLevel ]        = std::move(pFallback);
+    mpLayouts[ mnLevel ].reset(static_cast<GenericSalLayout*>(pFallback.release()));
     maFallbackRuns[ mnLevel-1 ] = rFallbackRuns;
     ++mnLevel;
 }
@@ -1153,7 +1153,6 @@ void MultiSalLayout::AdjustLayout( ImplLayoutArgs& rArgs )
             if( nLevel != n )
             {
                 mpLayouts[ nLevel ]         = std::move(mpLayouts[ n ]);
-                mpFallbackFonts[ nLevel ]   = mpFallbackFonts[ n ];
                 maFallbackRuns[ nLevel ]    = maFallbackRuns[ n ];
             }
             ++nLevel;
@@ -1511,8 +1510,9 @@ bool MultiSalLayout::GetNextGlyph(const GlyphItem** pGlyph,
     nStart &= ~GF_FONTMASK;
     for(; nLevel < mnLevel; ++nLevel, nStart=0 )
     {
-        SalLayout& rLayout = *mpLayouts[ nLevel ];
+        GenericSalLayout& rLayout = *mpLayouts[ nLevel ];
         rLayout.InitFont();
+        const PhysicalFontFace* pFontFace = rLayout.GetFont().GetFontFace();
         if (rLayout.GetNextGlyph(pGlyph, rPos, nStart))
         {
             int nFontTag = nLevel << GF_FONTSHIFT;
@@ -1520,7 +1520,7 @@ bool MultiSalLayout::GetNextGlyph(const GlyphItem** pGlyph,
             // FIXME: This cast is ugly!
             const_cast<GlyphItem*>(*pGlyph)->mnFallbackLevel = nLevel;
             if (pFallbackFont)
-                *pFallbackFont = mpFallbackFonts[nLevel];
+                *pFallbackFont = pFontFace;
             rPos += maDrawBase;
             rPos += maDrawOffset;
             return true;
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index 432aa87101c0..7868b9ba0b3d 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -1300,7 +1300,7 @@ void OutputDevice::ImplDrawEmphasisMarks( SalLayout& rSalLayout )
     mpMetaFile = pOldMetaFile;
 }
 
-std::unique_ptr<SalLayout> OutputDevice::getFallbackFont(
+std::unique_ptr<SalLayout> OutputDevice::getFallbackLayout(
     LogicalFontInstance* pLogicalFont, int nFallbackLevel,
     ImplLayoutArgs& rLayoutArgs) const
 {
@@ -1381,14 +1381,13 @@ std::unique_ptr<SalLayout> OutputDevice::ImplGlyphFallbackLayout( std::unique_pt
         }
 
         // create and add glyph fallback layout to multilayout
-        std::unique_ptr<SalLayout> pFallback = getFallbackFont(pFallbackFont.get(),
+        std::unique_ptr<SalLayout> pFallback = getFallbackLayout(pFallbackFont.get(),
             nFallbackLevel, rLayoutArgs);
         if (pFallback)
         {
             if( !pMultiSalLayout )
                 pMultiSalLayout.reset( new MultiSalLayout( std::move(pSalLayout) ) );
-            pMultiSalLayout->AddFallback( std::move(pFallback),
-                rLayoutArgs.maRuns, pFallbackFont->GetFontFace() );
+            pMultiSalLayout->AddFallback(std::move(pFallback), rLayoutArgs.maRuns);
             if (nFallbackLevel == MAX_FALLBACK-1)
                 pMultiSalLayout->SetIncomplete(true);
         }
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx
index b7356eda56a5..adcb0deec8ac 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -40,6 +40,7 @@
 #include <cairo.h>
 #include <cairo-ft.h>
 #include <sallayout.hxx>
+#include <o3tl/make_unique.hxx>
 
 namespace {
 
@@ -487,10 +488,9 @@ bool CairoTextRender::GetGlyphOutline(const GlyphItem& rGlyph,
 
 std::unique_ptr<SalLayout> CairoTextRender::GetTextLayout(ImplLayoutArgs& /*rArgs*/, int nFallbackLevel)
 {
-    if (mpFreetypeFont[nFallbackLevel])
-        return std::unique_ptr<SalLayout>(new GenericSalLayout(*mpFreetypeFont[nFallbackLevel]->GetFontInstance()));
-
-    return nullptr;
+    if (!mpFreetypeFont[nFallbackLevel])
+        return nullptr;
+    return o3tl::make_unique<GenericSalLayout>(*mpFreetypeFont[nFallbackLevel]->GetFontInstance());
 }
 
 #if ENABLE_CAIRO_CANVAS
diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx
index ae30cfad6286..b11a87083c68 100644
--- a/vcl/unx/generic/print/genpspgraphics.cxx
+++ b/vcl/unx/generic/print/genpspgraphics.cxx
@@ -55,6 +55,7 @@
 #include <salbmp.hxx>
 #include <salprn.hxx>
 #include <sallayout.hxx>
+#include <o3tl/make_unique.hxx>
 
 using namespace psp;
 
@@ -761,10 +762,9 @@ bool GenPspGraphics::GetGlyphOutline(const GlyphItem& rGlyph,
 
 std::unique_ptr<SalLayout> GenPspGraphics::GetTextLayout(ImplLayoutArgs& /*rArgs*/, int nFallbackLevel)
 {
-    if (m_pFreetypeFont[nFallbackLevel])
-        return std::unique_ptr<SalLayout>(new PspSalLayout(*m_pPrinterGfx, *m_pFreetypeFont[nFallbackLevel]));
-
-    return nullptr;
+    if (!m_pFreetypeFont[nFallbackLevel])
+        return nullptr;
+    return o3tl::make_unique<PspSalLayout>(*m_pPrinterGfx, *m_pFreetypeFont[nFallbackLevel]);
 }
 
 bool GenPspGraphics::CreateFontSubset(
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index efbbd0c1edb3..d7c9258473a3 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -24,6 +24,7 @@
 
 #include <comphelper/windowserrorstring.hxx>
 #include <comphelper/scopeguard.hxx>
+#include <o3tl/make_unique.hxx>
 
 #include <opengl/texture.hxx>
 #include <opengl/win/gdiimpl.hxx>
@@ -305,8 +306,7 @@ std::unique_ptr<SalLayout> WinSalGraphics::GetTextLayout(ImplLayoutArgs& /*rArgs
     assert(mpWinFontEntry[nFallbackLevel]->GetFontFace());
 
     mpWinFontEntry[nFallbackLevel]->SetGraphics(this);
-    GenericSalLayout *aLayout = new GenericSalLayout(*mpWinFontEntry[nFallbackLevel]);
-    return std::unique_ptr<SalLayout>(aLayout);
+    return o3tl::make_unique<GenericSalLayout>(*mpWinFontEntry[nFallbackLevel]);
 }
 
 WinFontInstance::WinFontInstance(const WinFontFace& rPFF, const FontSelectPattern& rFSP)


More information about the Libreoffice-commits mailing list