summaryrefslogtreecommitdiff
path: root/vcl/unx/generic
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2018-10-28 13:41:10 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2018-10-30 20:42:19 +0100
commit996d7f36ddcd6d518f4b44d132b3c5e3300f0c24 (patch)
tree5fb211f185c06dac6c2ff620b4c5982dca25dc86 /vcl/unx/generic
parent0ea92ad5332ddb6583c82275071c3be3939ebf28 (diff)
Move SalGraphics glyph functions into FontInstance
As we already rely on the GlyphItem's font instance, consequently this removes the SalGraphics GlyphItem based functions. Also unifies the glyph bound rect cache handling. An interesting aspect is the rotated glyph bounding box handling moved from CairoTextRender to FreetypeFont. It doesn't look like an implementation detail for Cairo, so it may have been a bug. Change-Id: I81bbb5d8ee98fb77a1eee05568c456f9e4553023 Reviewed-on: https://gerrit.libreoffice.org/62503 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/unx/generic')
-rw-r--r--vcl/unx/generic/gdi/cairotextrender.cxx36
-rw-r--r--vcl/unx/generic/gdi/font.cxx11
-rw-r--r--vcl/unx/generic/glyphs/freetype_glyphcache.cxx30
-rw-r--r--vcl/unx/generic/glyphs/glyphcache.cxx16
-rw-r--r--vcl/unx/generic/print/genpspgraphics.cxx19
5 files changed, 34 insertions, 78 deletions
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx
index 13c8e156dc5b..c8956d02226b 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -442,42 +442,6 @@ void CairoTextRender::GetFontMetric( ImplFontMetricDataRef& rxFontMetric, int nF
mpFreetypeFont[nFallbackLevel]->GetFontMetric(rxFontMetric);
}
-bool CairoTextRender::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& rRect)
-{
- FreetypeFont* pSF = getFreetypeFontFromGlyph(rGlyph);
- if( !pSF )
- return false;
-
- tools::Rectangle aRect;
- if (!pSF->GetGlyphBoundRect(rGlyph, aRect))
- return false;
-
- if ( pSF->mnCos != 0x10000 && pSF->mnSin != 0 )
- {
- double nCos = pSF->mnCos / 65536.0;
- double nSin = pSF->mnSin / 65536.0;
- rRect.SetLeft( nCos*aRect.Left() + nSin*aRect.Top() );
- rRect.SetTop( -nSin*aRect.Left() - nCos*aRect.Top() );
-
- rRect.SetRight( nCos*aRect.Right() + nSin*aRect.Bottom() );
- rRect.SetBottom( -nSin*aRect.Right() - nCos*aRect.Bottom() );
- }
- else
- rRect = aRect;
-
- return true;
-}
-
-bool CairoTextRender::GetGlyphOutline(const GlyphItem& rGlyph,
- basegfx::B2DPolyPolygon& rPolyPoly )
-{
- const FreetypeFont* pSF = getFreetypeFontFromGlyph(rGlyph);
- if( !pSF )
- return false;
-
- return pSF->GetGlyphOutline(rGlyph, rPolyPoly);
-}
-
std::unique_ptr<SalLayout> CairoTextRender::GetTextLayout(ImplLayoutArgs& /*rArgs*/, int nFallbackLevel)
{
if (!mpFreetypeFont[nFallbackLevel])
diff --git a/vcl/unx/generic/gdi/font.cxx b/vcl/unx/generic/gdi/font.cxx
index 381e79373953..85ad6600dd99 100644
--- a/vcl/unx/generic/gdi/font.cxx
+++ b/vcl/unx/generic/gdi/font.cxx
@@ -105,17 +105,6 @@ X11SalGraphics::GetFontMetric( ImplFontMetricDataRef &rxFontMetric, int nFallbac
mxTextRenderImpl->GetFontMetric(rxFontMetric, nFallbackLevel);
}
-bool X11SalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& rRect)
-{
- return mxTextRenderImpl->GetGlyphBoundRect(rGlyph, rRect);
-}
-
-bool X11SalGraphics::GetGlyphOutline(const GlyphItem& rGlyph,
- basegfx::B2DPolyPolygon& rPolyPoly )
-{
- return mxTextRenderImpl->GetGlyphOutline(rGlyph, rPolyPoly);
-}
-
std::unique_ptr<SalLayout> X11SalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLevel )
{
return mxTextRenderImpl->GetTextLayout(rArgs, nFallbackLevel);
diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
index 50f1b8d451c6..42bf6d0a98b9 100644
--- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
@@ -589,14 +589,11 @@ void FreetypeFont::ApplyGlyphTransform(bool bVertical, FT_Glyph pGlyphFT ) const
}
}
-bool FreetypeFont::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& rRect)
+bool FreetypeFont::GetGlyphBoundRect(sal_GlyphId nID, tools::Rectangle& rRect, bool bVertical) const
{
- if (rGlyph.GetCachedGlyphBoundRect(rRect))
- return true;
-
FT_Activate_Size( maSizeFT );
- FT_Error rc = FT_Load_Glyph(maFaceFT, rGlyph.m_aGlyphId, mnLoadFlags);
+ FT_Error rc = FT_Load_Glyph(maFaceFT, nID, mnLoadFlags);
if (rc != FT_Err_Ok)
return false;
@@ -609,14 +606,24 @@ bool FreetypeFont::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle&
if (rc != FT_Err_Ok)
return false;
- ApplyGlyphTransform(rGlyph.IsVertical(), pGlyphFT);
+ ApplyGlyphTransform(bVertical, pGlyphFT);
FT_BBox aBbox;
FT_Glyph_Get_CBox( pGlyphFT, FT_GLYPH_BBOX_PIXELS, &aBbox );
FT_Done_Glyph( pGlyphFT );
- rRect = tools::Rectangle(aBbox.xMin, -aBbox.yMax, aBbox.xMax, -aBbox.yMin);
- rGlyph.CacheGlyphBoundRect(rRect);
+ tools::Rectangle aRect(aBbox.xMin, -aBbox.yMax, aBbox.xMax, -aBbox.yMin);
+ if (mnCos != 0x10000 && mnSin != 0)
+ {
+ const double nCos = mnCos / 65536.0;
+ const double nSin = mnSin / 65536.0;
+ rRect.SetLeft( nCos*aRect.Left() + nSin*aRect.Top() );
+ rRect.SetTop( -nSin*aRect.Left() - nCos*aRect.Top() );
+ rRect.SetRight( nCos*aRect.Right() + nSin*aRect.Bottom() );
+ rRect.SetBottom( -nSin*aRect.Right() - nCos*aRect.Bottom() );
+ }
+ else
+ rRect = aRect;
return true;
}
@@ -876,8 +883,7 @@ static int FT_cubic_to( const FT_Vector* p1, const FT_Vector* p2, const FT_Vecto
} // extern "C"
-bool FreetypeFont::GetGlyphOutline(const GlyphItem& rGlyph,
- basegfx::B2DPolyPolygon& rB2DPolyPoly ) const
+bool FreetypeFont::GetGlyphOutline(sal_GlyphId nId, basegfx::B2DPolyPolygon& rB2DPolyPoly, bool bIsVertical) const
{
if( maSizeFT )
FT_Activate_Size( maSizeFT );
@@ -891,7 +897,7 @@ bool FreetypeFont::GetGlyphOutline(const GlyphItem& rGlyph,
nLoadFlags |= FT_LOAD_TARGET_LIGHT;
#endif
- FT_Error rc = FT_Load_Glyph(maFaceFT, rGlyph.m_aGlyphId, nLoadFlags);
+ FT_Error rc = FT_Load_Glyph(maFaceFT, nId, nLoadFlags);
if( rc != FT_Err_Ok )
return false;
@@ -929,7 +935,7 @@ bool FreetypeFont::GetGlyphOutline(const GlyphItem& rGlyph,
tools::PolyPolygon aToolPolyPolygon;
PolyArgs aPolyArg( aToolPolyPolygon, nMaxPoints );
- ApplyGlyphTransform(rGlyph.IsVertical(), pGlyphFT);
+ ApplyGlyphTransform(bIsVertical, pGlyphFT);
FT_Outline_Funcs aFuncs;
aFuncs.move_to = &FT_move_to;
diff --git a/vcl/unx/generic/glyphs/glyphcache.cxx b/vcl/unx/generic/glyphs/glyphcache.cxx
index f008a0294df0..29e0d1ba65b6 100644
--- a/vcl/unx/generic/glyphs/glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/glyphcache.cxx
@@ -299,4 +299,20 @@ hb_font_t* FreetypeFontInstance::ImplInitHbFont()
return InitHbFont(hb_face_create_for_tables(getFontTable, this, nullptr));
}
+bool FreetypeFontInstance::ImplGetGlyphBoundRect(sal_GlyphId nId, tools::Rectangle& rRect, bool bVertical) const
+{
+ assert(mpFreetypeFont);
+ if (!mpFreetypeFont)
+ return false;
+ return mpFreetypeFont->GetGlyphBoundRect(nId, rRect, bVertical);
+}
+
+bool FreetypeFontInstance::GetGlyphOutline(sal_GlyphId nId, basegfx::B2DPolyPolygon& rPoly, bool bVertical) const
+{
+ assert(mpFreetypeFont);
+ if (!mpFreetypeFont)
+ return false;
+ return mpFreetypeFont->GetGlyphOutline(nId, rPoly, bVertical);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx
index 67621170b999..3043d99e01be 100644
--- a/vcl/unx/generic/print/genpspgraphics.cxx
+++ b/vcl/unx/generic/print/genpspgraphics.cxx
@@ -733,25 +733,6 @@ void GenPspGraphics::GetFontMetric(ImplFontMetricDataRef& rxFontMetric, int nFal
m_pFreetypeFont[nFallbackLevel]->GetFontMetric(rxFontMetric);
}
-bool GenPspGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& rRect)
-{
- FreetypeFont* pSF = getFreetypeFontFromGlyph(rGlyph);
- if( !pSF )
- return false;
-
- return pSF->GetGlyphBoundRect(rGlyph, rRect);
-}
-
-bool GenPspGraphics::GetGlyphOutline(const GlyphItem& rGlyph,
- basegfx::B2DPolyPolygon& rB2DPolyPoly )
-{
- FreetypeFont* pSF = getFreetypeFontFromGlyph(rGlyph);
- if( !pSF )
- return false;
-
- return pSF->GetGlyphOutline(rGlyph, rB2DPolyPoly);
-}
-
std::unique_ptr<SalLayout> GenPspGraphics::GetTextLayout(ImplLayoutArgs& /*rArgs*/, int nFallbackLevel)
{
if (!m_pFreetypeFont[nFallbackLevel])