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

Khaled Hosny khaledhosny at eglug.org
Fri Dec 30 11:52:26 UTC 2016


 vcl/inc/unx/glyphcache.hxx                     |   29 +++----------------------
 vcl/unx/generic/gdi/cairotextrender.cxx        |    3 --
 vcl/unx/generic/glyphs/freetype_glyphcache.cxx |   14 ------------
 vcl/unx/generic/glyphs/glyphcache.cxx          |    6 ++---
 vcl/unx/generic/print/genpspgraphics.cxx       |    3 --
 5 files changed, 10 insertions(+), 45 deletions(-)

New commits:
commit f2a5e6dc8f9c79b31ca1044fac8caa0130205e3c
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Fri Dec 30 11:02:18 2016 +0200

    Get rid of GlyphMetric class
    
    All we need is Rectangle, so lets keep things simple.
    
    Change-Id: I8c47a9159696b52d22c327f257d5e4aa8898d871
    Reviewed-on: https://gerrit.libreoffice.org/32506
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Khaled Hosny <khaledhosny at eglug.org>

diff --git a/vcl/inc/unx/glyphcache.hxx b/vcl/inc/unx/glyphcache.hxx
index c86dbac..935837d 100644
--- a/vcl/inc/unx/glyphcache.hxx
+++ b/vcl/inc/unx/glyphcache.hxx
@@ -94,39 +94,19 @@ private:
     FreetypeManager*        mpFtManager;
 };
 
-class GlyphMetric
-{
-public:
-                            GlyphMetric() {}
-
-    const Point&            GetOffset() const   { return maOffset; }
-    const Size&             GetSize() const     { return maSize; }
-
-protected:
-    friend class GlyphData;
-    void                    SetOffset( int nX, int nY ) { maOffset = Point( nX, nY); }
-    void                    SetSize( const Size& s )    { maSize = s; }
-
-private:
-    Point                   maOffset;
-    Size                    maSize;
-};
-
 class GlyphData
 {
 public:
                             GlyphData() : mnLruValue(0) {}
 
-    const GlyphMetric&      GetMetric() const           { return maGlyphMetric; }
-
-    void                    SetSize( const Size& s)     { maGlyphMetric.SetSize( s ); }
-    void                    SetOffset( int nX, int nY ) { maGlyphMetric.SetOffset( nX, nY ); }
+    const Rectangle&        GetBoundRect() const        { return maBoundRect; }
+    void                    SetBoundRect(Rectangle r)   { maBoundRect = r; }
 
     void                    SetLruValue( int n ) const  { mnLruValue = n; }
     long                    GetLruValue() const         { return mnLruValue;}
 
 private:
-    GlyphMetric             maGlyphMetric;
+    Rectangle               maBoundRect;
 
     // used by GlyphCache for cache LRU algorithm
     mutable long            mnLruValue;
@@ -154,8 +134,7 @@ public:
     const FontCharMapRef    GetFontCharMap() const;
     bool                    GetFontCapabilities(vcl::FontCapabilities &) const;
 
-    const GlyphMetric&      GetGlyphMetric(const GlyphItem& rGlyph);
-
+    const Rectangle&        GetGlyphBoundRect(const GlyphItem& rGlyph);
     bool                    GetGlyphOutline(const GlyphItem& rGlyph, basegfx::B2DPolyPolygon&) const;
     bool                    GetAntialiasAdvice() const;
     hb_font_t*              GetHbFont() { return mpHbFont; }
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx
index b3f6165..842a6b6 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -435,8 +435,7 @@ bool CairoTextRender::GetGlyphBoundRect(const GlyphItem& rGlyph, Rectangle& rRec
     if( !pSF )
         return false;
 
-    const GlyphMetric& rGM = pSF->GetGlyphMetric(rGlyph);
-    Rectangle aRect( rGM.GetOffset(), rGM.GetSize() );
+    Rectangle aRect = pSF->GetGlyphBoundRect(rGlyph);
 
     if ( pSF->mnCos != 0x10000 && pSF->mnSin != 0 )
     {
diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
index ca84009..50c5eba 100644
--- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
@@ -635,12 +635,7 @@ void FreetypeFont::InitGlyphData(const GlyphItem& rGlyph, GlyphData& rGD ) const
     FT_Error rc = FT_Load_Glyph(maFaceFT, rGlyph.maGlyphId, mnLoadFlags);
 
     if( rc != FT_Err_Ok )
-    {
-        // we get here e.g. when a PS font lacks the default glyph
-        rGD.SetOffset( 0, 0 );
-        rGD.SetSize( Size( 0, 0 ) );
         return;
-    }
 
     if (mbArtBold)
         FT_GlyphSlot_Embolden(maFaceFT->glyph);
@@ -652,15 +647,8 @@ void FreetypeFont::InitGlyphData(const GlyphItem& rGlyph, GlyphData& rGD ) const
 
     FT_BBox aBbox;
     FT_Glyph_Get_CBox( pGlyphFT, FT_GLYPH_BBOX_PIXELS, &aBbox );
-    if( aBbox.yMin > aBbox.yMax )   // circumvent freetype bug
-    {
-        int t=aBbox.yMin;
-        aBbox.yMin=aBbox.yMax;
-        aBbox.yMax=t;
-    }
 
-    rGD.SetOffset( aBbox.xMin, -aBbox.yMax );
-    rGD.SetSize( Size( (aBbox.xMax-aBbox.xMin+1), (aBbox.yMax-aBbox.yMin) ) );
+    rGD.SetBoundRect(Rectangle(aBbox.xMin, -aBbox.yMax, aBbox.xMax, -aBbox.yMin));
 
     FT_Done_Glyph( pGlyphFT );
 }
diff --git a/vcl/unx/generic/glyphs/glyphcache.cxx b/vcl/unx/generic/glyphs/glyphcache.cxx
index 103fc54..1a49c52 100644
--- a/vcl/unx/generic/glyphs/glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/glyphcache.cxx
@@ -304,14 +304,14 @@ long FreetypeFont::Release() const
     return --mnRefCount;
 }
 
-const GlyphMetric& FreetypeFont::GetGlyphMetric(const GlyphItem& rGlyph)
+const Rectangle& FreetypeFont::GetGlyphBoundRect(const GlyphItem& rGlyph)
 {
     // usually the GlyphData is cached
     GlyphList::iterator it = maGlyphList.find(rGlyph.maGlyphId);
     if( it != maGlyphList.end() ) {
         GlyphData& rGlyphData = it->second;
         GlyphCache::GetInstance().UsingGlyph( *this, rGlyphData );
-        return rGlyphData.GetMetric();
+        return rGlyphData.GetBoundRect();
     }
 
     // sometimes not => we need to create and initialize it ourselves
@@ -319,7 +319,7 @@ const GlyphMetric& FreetypeFont::GetGlyphMetric(const GlyphItem& rGlyph)
     mnBytesUsed += sizeof( GlyphData );
     InitGlyphData(rGlyph, rGlyphData);
     GlyphCache::GetInstance().AddedGlyph( *this, rGlyphData );
-    return rGlyphData.GetMetric();
+    return rGlyphData.GetBoundRect();
 }
 
 void FreetypeFont::GarbageCollect( long nMinLruIndex )
diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx
index a9ff215..eb89e8b 100644
--- a/vcl/unx/generic/print/genpspgraphics.cxx
+++ b/vcl/unx/generic/print/genpspgraphics.cxx
@@ -768,8 +768,7 @@ bool GenPspGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, Rectangle& rRect
     if( !pSF )
         return false;
 
-    const GlyphMetric& rGM = pSF->GetGlyphMetric(rGlyph);
-    rRect = Rectangle( rGM.GetOffset(), rGM.GetSize() );
+    rRect = pSF->GetGlyphBoundRect(rGlyph);
     return true;
 }
 


More information about the Libreoffice-commits mailing list