[Libreoffice-commits] core.git: Branch 'feature/commonsallayout' - vcl/headless vcl/inc vcl/source vcl/unx
Akash Jain
akash96j at gmail.com
Mon Jun 20 18:21:35 UTC 2016
vcl/headless/svptext.cxx | 5
vcl/inc/CommonSalLayout.hxx | 5
vcl/inc/headless/svpgdi.hxx | 2
vcl/inc/salgdi.hxx | 2
vcl/inc/textrender.hxx | 2
vcl/inc/unx/cairotextrender.hxx | 2
vcl/inc/unx/genpspgraphics.h | 1
vcl/inc/unx/salgdi.h | 2
vcl/source/gdi/CommonSalLayout.cxx | 25 ++--
vcl/unx/generic/gdi/cairotextrender.cxx | 176 +++++++++++++++++++++++++++++++
vcl/unx/generic/gdi/font.cxx | 4
vcl/unx/generic/print/genpspgraphics.cxx | 5
12 files changed, 222 insertions(+), 9 deletions(-)
New commits:
commit 38c7eb826d47e37f751ff58c0d880e91a00e3141
Author: Akash Jain <akash96j at gmail.com>
Date: Mon Jun 20 23:49:53 2016 +0530
Integrate CommonSalLayout in unx/ code path
Change-Id: I7591d4b159d2d92027dba162b5752468cb69e7a7
diff --git a/vcl/headless/svptext.cxx b/vcl/headless/svptext.cxx
index e8fd525..c4bf42c 100644
--- a/vcl/headless/svptext.cxx
+++ b/vcl/headless/svptext.cxx
@@ -121,6 +121,11 @@ void SvpSalGraphics::DrawServerFontLayout( const ServerFontLayout& rSalLayout )
m_aTextRenderImpl.DrawServerFontLayout(rSalLayout );
}
+void SvpSalGraphics::DrawCommonSalLayout( const CommonSalLayout& rSalLayout )
+{
+ m_aTextRenderImpl.DrawCommonSalLayout( rSalLayout );
+}
+
void SvpSalGraphics::SetTextColor( SalColor nSalColor )
{
m_aTextRenderImpl.SetTextColor(nSalColor);
diff --git a/vcl/inc/CommonSalLayout.hxx b/vcl/inc/CommonSalLayout.hxx
index 0d941f9..6d6d19e 100755
--- a/vcl/inc/CommonSalLayout.hxx
+++ b/vcl/inc/CommonSalLayout.hxx
@@ -36,6 +36,9 @@ class CommonSalLayout : public GenericSalLayout
css::uno::Reference<css::i18n::XBreakIterator> mxBreak;
#ifdef _WIN32
HDC mhDC;
+#elif defined(MACOSX) || defined(IOS)
+#else
+ ServerFont& mrServerFont;
#endif
public:
@@ -45,7 +48,9 @@ public:
explicit CommonSalLayout(const CoreTextStyle*);
#else
explicit CommonSalLayout(ServerFont&);
+ ServerFont& GetServerFont() const {return mrServerFont;}
#endif
+
virtual ~CommonSalLayout();
void SetNeedFallback(ImplLayoutArgs&, sal_Int32, bool);
void AdjustLayout(ImplLayoutArgs&) override;
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index dc88a60..626aab9 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -46,6 +46,7 @@
struct BitmapBuffer;
class GlyphCache;
class ServerFont;
+class CommonSalLayout;
typedef struct _cairo cairo_t;
typedef struct _cairo_surface cairo_surface_t;
typedef struct _cairo_user_data_key cairo_user_data_key_t;
@@ -153,6 +154,7 @@ public:
virtual bool GetGlyphOutline( sal_GlyphId nIndex, basegfx::B2DPolyPolygon& ) override;
virtual SalLayout* GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) override;
virtual void DrawServerFontLayout( const ServerFontLayout& ) override;
+ virtual void DrawCommonSalLayout( const CommonSalLayout& ) override;
virtual bool supportsOperation( OutDevSupportType ) const override;
virtual void drawPixel( long nX, long nY ) override;
virtual void drawPixel( long nX, long nY, SalColor nSalColor ) override;
diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index 56fe42d..79ea307 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -44,6 +44,7 @@ class FontSubsetInfo;
class OpenGLContext;
class OutputDevice;
class ServerFontLayout;
+class CommonSalLayout;
struct SystemGraphicsData;
#if ENABLE_CAIRO_CANVAS
@@ -218,6 +219,7 @@ public:
virtual SalLayout* GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) = 0;
virtual void DrawServerFontLayout( const ServerFontLayout& ) = 0;
+ virtual void DrawCommonSalLayout( const CommonSalLayout& ) = 0;
virtual bool supportsOperation( OutDevSupportType ) const = 0;
diff --git a/vcl/inc/textrender.hxx b/vcl/inc/textrender.hxx
index e08274e..1f49591 100644
--- a/vcl/inc/textrender.hxx
+++ b/vcl/inc/textrender.hxx
@@ -27,6 +27,7 @@
class ImplLayoutArgs;
class ImplFontMetricData;
class ServerFontLayout;
+class CommonSalLayout;
class PhysicalFontCollection;
class PhysicalFontFace;
@@ -72,6 +73,7 @@ public:
virtual bool GetGlyphOutline( sal_GlyphId nIndex, basegfx::B2DPolyPolygon& ) = 0;
virtual SalLayout* GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) = 0;
virtual void DrawServerFontLayout( const ServerFontLayout& ) = 0;
+ virtual void DrawCommonSalLayout( const CommonSalLayout& ) = 0;
#if ENABLE_CAIRO_CANVAS
virtual SystemFontData GetSysFontData( int nFallbackLevel ) const = 0;
#endif // ENABLE_CAIRO_CANVAS
diff --git a/vcl/inc/unx/cairotextrender.hxx b/vcl/inc/unx/cairotextrender.hxx
index 612daae..04ab8ce 100644
--- a/vcl/inc/unx/cairotextrender.hxx
+++ b/vcl/inc/unx/cairotextrender.hxx
@@ -29,6 +29,7 @@
typedef struct FT_FaceRec_* FT_Face;
class ServerFont;
+class CommonSalLayout;
class GlyphCache;
typedef struct _cairo cairo_t;
@@ -119,6 +120,7 @@ public:
virtual bool GetGlyphOutline( sal_GlyphId nIndex, basegfx::B2DPolyPolygon& ) override;
virtual SalLayout* GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) override;
virtual void DrawServerFontLayout( const ServerFontLayout& ) override;
+ virtual void DrawCommonSalLayout( const CommonSalLayout& ) override;
#if ENABLE_CAIRO_CANVAS
virtual SystemFontData GetSysFontData( int nFallbackLevel ) const override;
#endif
diff --git a/vcl/inc/unx/genpspgraphics.h b/vcl/inc/unx/genpspgraphics.h
index b7658b9..ac0551c 100644
--- a/vcl/inc/unx/genpspgraphics.h
+++ b/vcl/inc/unx/genpspgraphics.h
@@ -132,6 +132,7 @@ public:
virtual bool GetGlyphOutline( sal_GlyphId, basegfx::B2DPolyPolygon& ) override;
virtual SalLayout* GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) override;
virtual void DrawServerFontLayout( const ServerFontLayout& ) override;
+ virtual void DrawCommonSalLayout( const CommonSalLayout& ) override;
virtual bool supportsOperation( OutDevSupportType ) const override;
virtual void drawPixel( long nX, long nY ) override;
virtual void drawPixel( long nX, long nY, SalColor nSalColor ) override;
diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h
index 40aa91b..e376f02 100644
--- a/vcl/inc/unx/salgdi.h
+++ b/vcl/inc/unx/salgdi.h
@@ -55,6 +55,7 @@ class X11OpenGLSalVirtualDevice;
class ServerFont;
class ImplLayoutArgs;
class ServerFontLayout;
+class CommonSalLayout;
class PhysicalFontCollection;
class PhysicalFontFace;
class SalGraphicsImpl;
@@ -155,6 +156,7 @@ public:
virtual bool GetGlyphOutline( sal_GlyphId nIndex, basegfx::B2DPolyPolygon& ) override;
virtual SalLayout* GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) override;
virtual void DrawServerFontLayout( const ServerFontLayout& ) override;
+ virtual void DrawCommonSalLayout( const CommonSalLayout& ) override;
virtual bool supportsOperation( OutDevSupportType ) const override;
virtual void drawPixel( long nX, long nY ) override;
diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx
index c01b2eb..414869c 100755
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -24,6 +24,7 @@
#include <com/sun/star/i18n/CharacterIteratorMode.hpp>
#include <i18nlangtag/mslangid.hxx>
#include <limits>
+#include <salgdi.hxx>
#if defined(_WIN32)
struct WinFontFaceWithHDC
@@ -86,18 +87,19 @@ CommonSalLayout::CommonSalLayout(HDC hDC, const WinFontFace& rWinFontFace, WinFo
}
#elif defined(MACOSX) || defined(IOS)
-CommonSalLayout::CommonSalLayout(CoreTextStyle* rCoreTextStyle)
+CommonSalLayout::CommonSalLayout(CoreTextStyle* pCoreTextStyle)
: mpHBFace(nullptr),
- maFontSelData(rCoreTextStyle)
+ maFontSelData(pCoreTextStyle)
{
- mpHBFace = hb_face_create_for_tables(getFontTable, rCoreTextStyle->mpFontData, nullptr);
+ mpHBFace = hb_face_create_for_tables(getFontTable, pCoreTextStyle->mpFontData, nullptr);
//XXX modify coretextstyle to also store fsd
}
#else
CommonSalLayout::CommonSalLayout(ServerFont& rServerFont)
: mpHBFace(nullptr),
- maFontSelData(rServerFont.GetFontSelData())
+ maFontSelData(rServerFont.GetFontSelData()),
+ mrServerFont(rServerFont)
{
mpHBFace = hb_face_create_for_tables(getFontTable, &rServerFont, nullptr);
}
@@ -194,9 +196,14 @@ void CommonSalLayout::AdjustLayout(ImplLayoutArgs& rArgs)
//XXX Kashida
}
-void CommonSalLayout::DrawText( SalGraphics& ) const
+void CommonSalLayout::DrawText(SalGraphics& rSalGraphics) const
{
//call platform dependent DrawText functions
+#if defined(_WIN32)
+#elif defined(MACOSX) || defined(IOS)
+#else
+ rSalGraphics.DrawCommonSalLayout( *this );
+#endif
}
bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
@@ -204,9 +211,10 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
//XXX WinLayout object DOESN'T derive from GSL
GenericSalLayout& rLayout = *this;
- hb_font_t* pHBFont = hb_font_create(mpHBFace);
- hb_font_set_ppem(pHBFont, maFontSelData.mnWidth, maFontSelData.mnHeight);
- hb_font_set_scale(pHBFont, maFontSelData.mnWidth << 6, maFontSelData.mnHeight << 6);
+ hb_font_t *pHBFont = hb_font_create(mpHBFace);
+ hb_font_set_ppem(pHBFont, maFontSelData.mnWidth? maFontSelData.mnWidth:maFontSelData.mnHeight , maFontSelData.mnHeight);
+ hb_font_set_scale(pHBFont, (uint64_t)(maFontSelData.mnWidth? maFontSelData.mnWidth:maFontSelData.mnHeight) << 6
+ , (uint64_t)maFontSelData.mnHeight << 6);
hb_ot_font_set_funcs(pHBFont);
int nGlyphCapacity = 2 * (rArgs.mnEndCharPos - rArgs.mnMinCharPos);
@@ -374,7 +382,6 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
int32_t nYOffset = pHbPositions[i].y_offset >> 6;
int32_t nXAdvance = pHbPositions[i].x_advance >> 6;
int32_t nYAdvance = pHbPositions[i].y_advance >> 6;
-
Point aNewPos = Point(aCurrPos.X() + nXOffset, -(aCurrPos.Y() + nYOffset));
// Definiton of glyphitem may have to change to support system graphics lib
const GlyphItem aGI(nCharPos, nGlyphIndex, aNewPos, nGlyphFlags, nXAdvance, nXOffset);
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx
index 513f5e5..14d45b3 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -42,6 +42,7 @@
#include <cairo.h>
#include <cairo-ft.h>
+#include "CommonSalLayout.hxx"
CairoTextRender::CairoTextRender()
: mnTextColor(MAKE_SALCOLOR(0x00, 0x00, 0x00)) //black
@@ -152,6 +153,178 @@ namespace
}
}
+void CairoTextRender::DrawCommonSalLayout( const CommonSalLayout& rLayout )
+{
+ std::vector<cairo_glyph_t> cairo_glyphs;
+ std::vector<int> glyph_extrarotation;
+ cairo_glyphs.reserve( 256 );
+
+ Point aPos;
+ sal_GlyphId aGlyphId;
+ for( int nStart = 0; rLayout.GetNextGlyphs( 1, &aGlyphId, aPos, nStart ); )
+ {
+ cairo_glyph_t aGlyph;
+ aGlyph.index = aGlyphId & GF_IDXMASK;
+ aGlyph.x = aPos.X();
+ aGlyph.y = aPos.Y();
+ cairo_glyphs.push_back(aGlyph);
+
+ switch (aGlyphId & GF_ROTMASK)
+ {
+ case GF_ROTL: // left
+ glyph_extrarotation.push_back(1);
+ break;
+ case GF_ROTR: // right
+ glyph_extrarotation.push_back(-1);
+ break;
+ default:
+ glyph_extrarotation.push_back(0);
+ break;
+ }
+ }
+
+ if (cairo_glyphs.empty())
+ return;
+
+ ServerFont& rFont = rLayout.GetServerFont();
+ const FontSelectPattern& rFSD = rFont.GetFontSelData();
+ int nHeight = rFSD.mnHeight;
+ int nWidth = rFSD.mnWidth ? rFSD.mnWidth : nHeight;
+ if (nWidth == 0 || nHeight == 0)
+ return;
+
+ cairo_t *cr = getCairoContext();
+ if (!cr)
+ {
+ SAL_WARN("vcl", "no cairo context for text");
+ return;
+ }
+
+ ImplSVData* pSVData = ImplGetSVData();
+ if (const cairo_font_options_t* pFontOptions = pSVData->mpDefInst->GetCairoFontOptions())
+ cairo_set_font_options(cr, pFontOptions);
+
+ double nDX, nDY;
+ getSurfaceOffset(nDX, nDY);
+ cairo_translate(cr, nDX, nDY);
+
+ clipRegion(cr);
+
+ cairo_set_source_rgb(cr,
+ SALCOLOR_RED(mnTextColor)/255.0,
+ SALCOLOR_GREEN(mnTextColor)/255.0,
+ SALCOLOR_BLUE(mnTextColor)/255.0);
+
+ FT_Face aFace = rFont.GetFtFace();
+ CairoFontsCache::CacheId aId;
+ aId.maFace = aFace;
+ aId.mpOptions = rFont.GetFontOptions().get();
+ aId.mbEmbolden = rFont.NeedsArtificialBold();
+
+ cairo_matrix_t m;
+
+ std::vector<int>::const_iterator aEnd = glyph_extrarotation.end();
+ std::vector<int>::const_iterator aStart = glyph_extrarotation.begin();
+ std::vector<int>::const_iterator aI = aStart;
+ while (aI != aEnd)
+ {
+ int nGlyphRotation = *aI;
+
+ std::vector<int>::const_iterator aNext = nGlyphRotation?(aI+1):std::find_if(aI+1, aEnd, hasRotation);
+
+ size_t nStartIndex = std::distance(aStart, aI);
+ size_t nLen = std::distance(aI, aNext);
+
+ aId.mbVerticalMetrics = nGlyphRotation != 0.0;
+ cairo_font_face_t* font_face = static_cast<cairo_font_face_t*>(CairoFontsCache::FindCachedFont(aId));
+ if (!font_face)
+ {
+ const FontConfigFontOptions *pOptions = rFont.GetFontOptions().get();
+ void *pPattern = pOptions ? pOptions->GetPattern(aFace, aId.mbEmbolden) : nullptr;
+ if (pPattern)
+ font_face = cairo_ft_font_face_create_for_pattern(static_cast<FcPattern*>(pPattern));
+ if (!font_face)
+ font_face = cairo_ft_font_face_create_for_ft_face(reinterpret_cast<FT_Face>(aFace), rFont.GetLoadFlags());
+ CairoFontsCache::CacheFont(font_face, aId);
+ }
+ cairo_set_font_face(cr, font_face);
+
+ cairo_set_font_size(cr, nHeight);
+
+ cairo_matrix_init_identity(&m);
+
+ if (rLayout.GetOrientation())
+ cairo_matrix_rotate(&m, toRadian(rLayout.GetOrientation()));
+
+ cairo_matrix_scale(&m, nWidth, nHeight);
+
+ if (nGlyphRotation)
+ {
+ cairo_matrix_rotate(&m, toRadian(nGlyphRotation*900));
+
+ cairo_matrix_t em_square;
+ cairo_matrix_init_identity(&em_square);
+ cairo_get_matrix(cr, &em_square);
+
+ cairo_matrix_scale(&em_square, aFace->units_per_EM,
+ aFace->units_per_EM);
+ cairo_set_matrix(cr, &em_square);
+
+ cairo_font_extents_t font_extents;
+ cairo_font_extents(cr, &font_extents);
+
+ cairo_matrix_init_identity(&em_square);
+ cairo_set_matrix(cr, &em_square);
+
+ //gives the same positions as pre-cairo conversion, but I don't
+ //like them
+ double xdiff = 0.0;
+ double ydiff = 0.0;
+ if (nGlyphRotation == 1)
+ {
+ ydiff = font_extents.ascent/nHeight;
+ xdiff = -font_extents.descent/nHeight;
+ }
+ else if (nGlyphRotation == -1)
+ {
+ cairo_text_extents_t text_extents;
+ cairo_glyph_extents(cr, &cairo_glyphs[nStartIndex], nLen,
+ &text_extents);
+
+ xdiff = -text_extents.x_advance/nHeight;
+ //to restore an apparent bug in the original X11 impl, replace
+ //nHeight with nWidth below
+ xdiff += font_extents.descent/nHeight;
+ }
+ cairo_matrix_translate(&m, xdiff, ydiff);
+ }
+
+ if (rFont.NeedsArtificialItalic())
+ {
+ cairo_matrix_t shear;
+ cairo_matrix_init_identity(&shear);
+ shear.xy = -shear.xx * 0x6000L / 0x10000L;
+ cairo_matrix_multiply(&m, &shear, &m);
+ }
+
+ cairo_set_font_matrix(cr, &m);
+ cairo_show_glyphs(cr, &cairo_glyphs[nStartIndex], nLen);
+
+#if OSL_DEBUG_LEVEL > 2
+ //draw origin
+ cairo_save (cr);
+ cairo_rectangle (cr, cairo_glyphs[nStartIndex].x, cairo_glyphs[nStartIndex].y, 5, 5);
+ cairo_set_source_rgba (cr, 1, 0, 0, 0.80);
+ cairo_fill (cr);
+ cairo_restore (cr);
+#endif
+
+ aI = aNext;
+ }
+
+ releaseCairoContext(cr);
+
+}
void CairoTextRender::DrawServerFontLayout( const ServerFontLayout& rLayout )
{
std::vector<cairo_glyph_t> cairo_glyphs;
@@ -507,6 +680,9 @@ SalLayout* CairoTextRender::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackL
}
else
#endif
+ if(getenv("LO_CSL"))
+ pLayout = new CommonSalLayout( *mpServerFont[ nFallbackLevel ] );
+ else
pLayout = new ServerFontLayout( *mpServerFont[ nFallbackLevel ] );
}
diff --git a/vcl/unx/generic/gdi/font.cxx b/vcl/unx/generic/gdi/font.cxx
index 1669465..dacfd11 100644
--- a/vcl/unx/generic/gdi/font.cxx
+++ b/vcl/unx/generic/gdi/font.cxx
@@ -56,6 +56,10 @@ void X11SalGraphics::DrawServerFontLayout( const ServerFontLayout& rLayout )
{
mxTextRenderImpl->DrawServerFontLayout(rLayout);
}
+void X11SalGraphics::DrawCommonSalLayout( const CommonSalLayout& rLayout )
+{
+ mxTextRenderImpl->DrawCommonSalLayout(rLayout);
+}
const FontCharMapPtr X11SalGraphics::GetFontCharMap() const
{
diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx
index 78eee82..ff87e3f 100644
--- a/vcl/unx/generic/print/genpspgraphics.cxx
+++ b/vcl/unx/generic/print/genpspgraphics.cxx
@@ -767,6 +767,11 @@ void GenPspGraphics::DrawServerFontLayout( const ServerFontLayout& rLayout )
DrawPrinterLayout( rLayout, *m_pPrinterGfx, true );
}
+void GenPspGraphics::DrawCommonSalLayout( const CommonSalLayout& /*rLayout*/ )
+{
+ // TODO
+}
+
const FontCharMapPtr GenPspGraphics::GetFontCharMap() const
{
if( !m_pServerFont[0] )
More information about the Libreoffice-commits
mailing list