[Libreoffice-commits] core.git: Branch 'feature/opengl-vcl' - vcl/inc vcl/Library_vcl.mk vcl/win
Jan Holesovsky
kendy at collabora.com
Thu Nov 13 06:52:06 PST 2014
vcl/Library_vcl.mk | 1
vcl/inc/cairotextrender.hxx | 2
vcl/inc/textrender.hxx | 7 -
vcl/inc/win/salgdi.h | 23 -----
vcl/inc/wintextrender.hxx | 140 +++++++++++++++++++++++++++++++++++
vcl/win/source/gdi/salgdi.cxx | 30 +------
vcl/win/source/gdi/salgdi3.cxx | 131 ++++++++++++++++++++++++++------
vcl/win/source/gdi/winlayout.cxx | 8 +-
vcl/win/source/gdi/wintextrender.cxx | 64 ++++++++++++++++
9 files changed, 330 insertions(+), 76 deletions(-)
New commits:
commit 309257ddadfdc3e46506036ed81f6e0695211ebe
Author: Jan Holesovsky <kendy at collabora.com>
Date: Thu Nov 13 13:18:46 2014 +0100
vcl: Abstract the Windows text rendering into a TextRenderImpl descendant.
Change-Id: I7ee9d7e705bb0344ba59c3edd10ed85390636cd4
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 81f774a..f15e5b6 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -660,6 +660,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/win/source/gdi/salprn \
vcl/win/source/gdi/salvd \
vcl/win/source/gdi/winlayout \
+ vcl/win/source/gdi/wintextrender \
vcl/win/source/gdi/wntgdi \
vcl/win/source/window/salframe \
vcl/win/source/window/keynames \
diff --git a/vcl/inc/cairotextrender.hxx b/vcl/inc/cairotextrender.hxx
index e5db2ab..ea995bb 100644
--- a/vcl/inc/cairotextrender.hxx
+++ b/vcl/inc/cairotextrender.hxx
@@ -79,7 +79,7 @@ protected:
virtual cairo_surface_t* getCairoSurface() = 0;
virtual void drawSurface(cairo_t* cr) = 0;
-bool setFont( const FontSelectPattern *pEntry, int nFallbackLevel );
+ bool setFont(const FontSelectPattern *pEntry, int nFallbackLevel);
virtual void clipRegion(cairo_t* cr) = 0;
diff --git a/vcl/inc/textrender.hxx b/vcl/inc/textrender.hxx
index b18b630..a004143 100644
--- a/vcl/inc/textrender.hxx
+++ b/vcl/inc/textrender.hxx
@@ -17,8 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_VCL_INC_UNX_CAIROFONTIMPL_HXX
-#define INCLUDED_VCL_INC_UNX_CAIROFONTIMPL_HXX
+#ifndef INCLUDED_VCL_INC_TEXTRENDER_HXX
+#define INCLUDED_VCL_INC_TEXTRENDER_HXX
#include <tools/rational.hxx>
#include <vcl/salgtype.hxx>
@@ -29,9 +29,6 @@
#include "salglyphid.hxx"
#include "fontsubset.hxx"
-class PspSalPrinter;
-class PspSalInfoPrinter;
-class ServerFont;
class ImplLayoutArgs;
class ServerFontLayout;
class PhysicalFontCollection;
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 69ea4cf..18709e1 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -25,7 +25,9 @@
#include "outfont.hxx"
#include "PhysicalFontFace.hxx"
#include "impfont.hxx"
+#include <textrender.hxx>
#include <vcl/fontcapabilities.hxx>
+#include <win/svsys.h>
#include <boost/scoped_ptr.hpp>
#include <boost/unordered_set.hpp>
@@ -148,6 +150,7 @@ class WinSalGraphics : public SalGraphics
friend class ScopedFont;
private:
boost::scoped_ptr<SalGraphicsImpl> mpImpl;
+ boost::scoped_ptr<TextRenderImpl> mpTextRenderImpl;
HDC mhLocalDC; // HDC
bool mbPrinter : 1; // is Printer
@@ -156,26 +159,13 @@ private:
bool mbScreen : 1; // is Screen compatible
HWND mhWnd; // Window-Handle, when Window-Graphics
- HFONT mhFonts[ MAX_FALLBACK ]; // Font + Fallbacks
- const ImplWinFontData* mpWinFontData[ MAX_FALLBACK ]; // pointer to the most recent font face
- ImplWinFontEntry* mpWinFontEntry[ MAX_FALLBACK ]; // pointer to the most recent font instance
- float mfFontScale[ MAX_FALLBACK ]; // allows metrics emulation of huge font sizes
- float mfCurrentFontScale;
HRGN mhRegion; // vcl::Region Handle
HPEN mhDefPen; // DefaultPen
HBRUSH mhDefBrush; // DefaultBrush
- HFONT mhDefFont; // DefaultFont
HPALETTE mhDefPal; // DefaultPalette
COLORREF mnTextColor; // TextColor
RGNDATA* mpClipRgnData; // ClipRegion-Data
RGNDATA* mpStdClipRgnData; // Cache Standard-ClipRegion-Data
- LOGFONTA* mpLogFont; // LOG-Font which is currently selected (only W9x)
- ImplFontAttrCache* mpFontAttrCache; // Cache font attributes from files in so/share/fonts
- BYTE* mpFontCharSets; // All Charsets for the current font
- BYTE mnFontCharSetCount; // Number of Charsets of the current font; 0 - if not queried
- bool mbFontKernInit; // FALSE: FontKerns must be queried
- KERNINGPAIR* mpFontKernPairs; // Kerning Pairs of the current Font
- sal_uIntPtr mnFontKernPairCount;// Number of Kerning Pairs of the current Font
int mnPenWidth; // Linienbreite
public:
@@ -285,12 +275,6 @@ protected:
const SalBitmap* pAlphaBitmap);
virtual bool drawAlphaRect( long nX, long nY, long nWidth, long nHeight, sal_uInt8 nTransparency );
-private:
- // local helpers
-
- // get kernign pairs of the current font
- sal_uLong GetKernPairs();
-
public:
// public SalGraphics methods, the interface to the independent vcl part
@@ -382,7 +366,6 @@ public:
bool bVertical,
Int32Vector& rWidths,
Ucs2UIntMap& rUnicodeEnc );
- virtual int GetMinKashidaWidth();
virtual bool GetGlyphBoundRect( sal_GlyphId, Rectangle& );
virtual bool GetGlyphOutline( sal_GlyphId, ::basegfx::B2DPolyPolygon& );
diff --git a/vcl/inc/wintextrender.hxx b/vcl/inc/wintextrender.hxx
new file mode 100644
index 0000000..90b0561
--- /dev/null
+++ b/vcl/inc/wintextrender.hxx
@@ -0,0 +1,140 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_VCL_INC_WINTEXTRENDER_HXX
+#define INCLUDED_VCL_INC_WINTEXTRENDER_HXX
+
+#include <tools/rational.hxx>
+#include <vcl/salgtype.hxx>
+#include <vcl/sysdata.hxx>
+#include <vcl/vclenum.hxx>
+#include <vcl/metric.hxx>
+
+#include "salgdi.hxx"
+#include "salglyphid.hxx"
+#include "fontsubset.hxx"
+#include <textrender.hxx>
+#include <win/salgdi.h>
+
+class ImplLayoutArgs;
+class ServerFontLayout;
+class PhysicalFontCollection;
+class PhysicalFontFace;
+
+/// Implementation of the GDI text rendering.
+class WinTextRender : public TextRenderImpl
+{
+ /// Rendering for a printer?
+ bool mbPrinter;
+
+ /// Parent WinSalGraphics.
+ WinSalGraphics& mrGraphics;
+
+ HFONT mhFonts[ MAX_FALLBACK ]; ///< Font + Fallbacks
+ const ImplWinFontData* mpWinFontData[ MAX_FALLBACK ]; ///< pointer to the most recent font face
+ ImplWinFontEntry* mpWinFontEntry[ MAX_FALLBACK ]; ///< pointer to the most recent font instance
+ float mfFontScale[ MAX_FALLBACK ]; ///< allows metrics emulation of huge font sizes
+ float mfCurrentFontScale;
+ HFONT mhDefFont; ///< DefaultFont
+
+ LOGFONTA* mpLogFont; ///< LOG-Font which is currently selected (only W9x)
+ ImplFontAttrCache* mpFontAttrCache; ///< Cache font attributes from files in so/share/fonts
+ BYTE* mpFontCharSets; ///< All Charsets for the current font
+ BYTE mnFontCharSetCount; ///< Number of Charsets of the current font; 0 - if not queried
+ bool mbFontKernInit; ///< FALSE: FontKerns must be queried
+ KERNINGPAIR* mpFontKernPairs; ///< Kerning Pairs of the current Font
+ sal_uIntPtr mnFontKernPairCount; ///< Number of Kerning Pairs of the current Font
+
+public:
+ WinTextRender(bool bPrinter, WinSalGraphics& rGraphics);
+ virtual ~WinTextRender();
+
+ virtual void SetTextColor(SalColor nSalColor) SAL_OVERRIDE;
+
+ virtual sal_uInt16 SetFont(FontSelectPattern*, int nFallbackLevel) SAL_OVERRIDE;
+
+ virtual void GetFontMetric(ImplFontMetricData*, int nFallbackLevel) SAL_OVERRIDE;
+
+ virtual const FontCharMapPtr GetFontCharMap() const SAL_OVERRIDE;
+
+ virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const SAL_OVERRIDE;
+
+ virtual void GetDevFontList(PhysicalFontCollection*) SAL_OVERRIDE;
+
+ virtual void ClearDevFontCache() SAL_OVERRIDE;
+
+ virtual bool AddTempDevFont(PhysicalFontCollection*, const OUString& rFileURL, const OUString& rFontName) SAL_OVERRIDE;
+
+ virtual bool CreateFontSubset(const OUString& rToFile,
+ const PhysicalFontFace*,
+ sal_GlyphId* pGlyphIDs,
+ sal_uInt8* pEncoding,
+ sal_Int32* pWidths,
+ int nGlyphs,
+ FontSubsetInfo& rInfo) SAL_OVERRIDE;
+
+ virtual const Ucs2SIntMap* GetFontEncodingVector(const PhysicalFontFace*, const Ucs2OStrMap** ppNonEncoded) SAL_OVERRIDE;
+
+ virtual const void* GetEmbedFontData(const PhysicalFontFace*,
+ const sal_Ucs* pUnicodes,
+ sal_Int32* pWidths,
+ FontSubsetInfo& rInfo,
+ long* pDataLen) SAL_OVERRIDE;
+
+ virtual void FreeEmbedFontData(const void* pData, long nDataLen) SAL_OVERRIDE;
+
+ virtual void GetGlyphWidths(const PhysicalFontFace*,
+ bool bVertical,
+ Int32Vector& rWidths,
+ Ucs2UIntMap& rUnicodeEnc) SAL_OVERRIDE;
+
+ virtual bool GetGlyphBoundRect(sal_GlyphId nIndex, Rectangle&) SAL_OVERRIDE;
+
+ virtual bool GetGlyphOutline(sal_GlyphId nIndex, ::basegfx::B2DPolyPolygon&) SAL_OVERRIDE;
+
+ virtual SalLayout* GetTextLayout(ImplLayoutArgs&, int nFallbackLevel) SAL_OVERRIDE;
+
+ virtual void DrawServerFontLayout(const ServerFontLayout&) SAL_OVERRIDE;
+
+ virtual SystemFontData GetSysFontData(int nFallbackLevel) const SAL_OVERRIDE;
+
+private:
+ HDC getHDC() const;
+
+ /// Get kerning pairs of the current font.
+ sal_uLong GetKernPairs();
+
+ int GetMinKashidaWidth();
+
+ class ScopedFont
+ {
+ public:
+ explicit ScopedFont(WinTextRender & rData);
+
+ ~ScopedFont();
+
+ private:
+ WinTextRender & m_rData;
+ HFONT m_hOrigFont;
+ };
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/win/source/gdi/salgdi.cxx b/vcl/win/source/gdi/salgdi.cxx
index 8f8f7ab..95180c3 100644
--- a/vcl/win/source/gdi/salgdi.cxx
+++ b/vcl/win/source/gdi/salgdi.cxx
@@ -35,6 +35,7 @@
#include "salgdiimpl.hxx"
#include "gdiimpl.hxx"
#include "opengl/win/gdiimpl.hxx"
+#include <wintextrender.hxx>
#include <vcl/opengl/OpenGLHelper.hxx>
@@ -503,8 +504,6 @@ void WinSalGraphics::DeInitGraphics()
SelectPen( getHDC(), mhDefPen );
if ( mhDefBrush )
SelectBrush( getHDC(), mhDefBrush );
- if ( mhDefFont )
- SelectFont( getHDC(), mhDefFont );
}
HDC ImplGetCachedDC( sal_uLong nID, HBITMAP hBmp )
@@ -574,33 +573,22 @@ WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hW
mbWindow(eType == WinSalGraphics::WINDOW),
mhWnd(hWnd),
mbScreen(bScreen),
- mfCurrentFontScale(1.0),
mhRegion(0),
mhDefPen(0),
mhDefBrush(0),
- mhDefFont(0),
mhDefPal(0),
mpStdClipRgnData(NULL),
- mpLogFont(NULL),
- mpFontCharSets(NULL),
- mpFontAttrCache(NULL),
- mnFontCharSetCount(0),
- mpFontKernPairs(NULL),
- mnFontKernPairCount(0),
- mbFontKernInit(false),
mnPenWidth(GSL_PEN_WIDTH)
{
if (OpenGLHelper::isVCLOpenGLEnabled() && !mbPrinter)
+ {
mpImpl.reset(new WinOpenGLSalGraphicsImpl(*this));
+ mpTextRenderImpl.reset((new WinTextRender(mbPrinter, *this)));
+ }
else
- mpImpl.reset(new WinSalGraphicsImpl(*this));
-
- for( int i = 0; i < MAX_FALLBACK; ++i )
{
- mhFonts[ i ] = 0;
- mpWinFontData[ i ] = NULL;
- mpWinFontEntry[ i ] = NULL;
- mfFontScale[ i ] = 1.0;
+ mpImpl.reset(new WinSalGraphicsImpl(*this));
+ mpTextRenderImpl.reset((new WinTextRender(mbPrinter, *this)));
}
}
@@ -617,12 +605,6 @@ WinSalGraphics::~WinSalGraphics()
// delete cache data
delete [] mpStdClipRgnData;
-
- delete mpLogFont;
-
- delete mpFontCharSets;
-
- delete mpFontKernPairs;
}
bool WinSalGraphics::isPrinter() const
diff --git a/vcl/win/source/gdi/salgdi3.cxx b/vcl/win/source/gdi/salgdi3.cxx
index f3933d9..bd69703 100644
--- a/vcl/win/source/gdi/salgdi3.cxx
+++ b/vcl/win/source/gdi/salgdi3.cxx
@@ -49,6 +49,7 @@
#include "sft.hxx"
#include "win/saldata.hxx"
#include "win/salgdi.h"
+#include <wintextrender.hxx>
using namespace vcl;
@@ -1357,6 +1358,11 @@ void ImplWinFontData::GetFontCapabilities( HDC hDC ) const
void WinSalGraphics::SetTextColor( SalColor nSalColor )
{
+ mpTextRenderImpl->SetTextColor(nSalColor);
+}
+
+void WinTextRender::SetTextColor(SalColor nSalColor)
+{
COLORREF aCol = PALETTERGB( SALCOLOR_RED( nSalColor ),
SALCOLOR_GREEN( nSalColor ),
SALCOLOR_BLUE( nSalColor ) );
@@ -1525,6 +1531,11 @@ HFONT WinSalGraphics::ImplDoSetFont( FontSelectPattern* i_pFont, float& o_rFontS
sal_uInt16 WinSalGraphics::SetFont( FontSelectPattern* pFont, int nFallbackLevel )
{
+ return mpTextRenderImpl->SetFont(pFont, nFallbackLevel);
+}
+
+sal_uInt16 WinTextRender::SetFont(FontSelectPattern* pFont, int nFallbackLevel)
+{
// return early if there is no new font
if( !pFont )
{
@@ -1548,7 +1559,7 @@ sal_uInt16 WinSalGraphics::SetFont( FontSelectPattern* pFont, int nFallbackLevel
mpWinFontData[ nFallbackLevel ] = static_cast<const ImplWinFontData*>( pFont->mpFontData );
HFONT hOldFont = 0;
- HFONT hNewFont = ImplDoSetFont( pFont, mfFontScale[ nFallbackLevel ], hOldFont );
+ HFONT hNewFont = mrGraphics.ImplDoSetFont( pFont, mfFontScale[ nFallbackLevel ], hOldFont );
mfCurrentFontScale = mfFontScale[nFallbackLevel];
if( !mhDefFont )
@@ -1599,6 +1610,11 @@ sal_uInt16 WinSalGraphics::SetFont( FontSelectPattern* pFont, int nFallbackLevel
void WinSalGraphics::GetFontMetric( ImplFontMetricData* pMetric, int nFallbackLevel )
{
+ mpTextRenderImpl->GetFontMetric(pMetric, nFallbackLevel);
+}
+
+void WinTextRender::GetFontMetric(ImplFontMetricData* pMetric, int nFallbackLevel)
+{
// temporarily change the HDC to the font in the fallback level
HFONT hOldFont = SelectFont( getHDC(), mhFonts[nFallbackLevel] );
@@ -1673,7 +1689,7 @@ void WinSalGraphics::GetFontMetric( ImplFontMetricData* pMetric, int nFallbackLe
pMetric->mnMinKashida = GetMinKashidaWidth();
}
-sal_uLong WinSalGraphics::GetKernPairs()
+sal_uLong WinTextRender::GetKernPairs()
{
if ( mbFontKernInit )
{
@@ -1704,6 +1720,11 @@ sal_uLong WinSalGraphics::GetKernPairs()
const FontCharMapPtr WinSalGraphics::GetFontCharMap() const
{
+ return mpTextRenderImpl->GetFontCharMap();
+}
+
+const FontCharMapPtr WinTextRender::GetFontCharMap() const
+{
if( !mpWinFontData[0] )
{
FontCharMapPtr pDefFontCharMap( new FontCharMap() );
@@ -1714,6 +1735,11 @@ const FontCharMapPtr WinSalGraphics::GetFontCharMap() const
bool WinSalGraphics::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const
{
+ return mpTextRenderImpl->GetFontCapabilities(rFontCapabilities);
+}
+
+bool WinTextRender::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const
+{
if( !mpWinFontData[0] )
return false;
return mpWinFontData[0]->GetFontCapabilities(rFontCapabilities);
@@ -2024,6 +2050,11 @@ static bool ImplGetFontAttrFromFile( const OUString& rFontFileURL,
bool WinSalGraphics::AddTempDevFont( PhysicalFontCollection* pFontCollection,
const OUString& rFontFileURL, const OUString& rFontName )
{
+ return mpTextRenderImpl->AddTempDevFont(pFontCollection, rFontFileURL, rFontName);
+}
+
+bool WinTextRender::AddTempDevFont(PhysicalFontCollection* pFontCollection, const OUString& rFontFileURL, const OUString& rFontName)
+{
SAL_INFO( "vcl.gdi", "WinSalGraphics::AddTempDevFont(): " << OUStringToOString( rFontFileURL, RTL_TEXTENCODING_UTF8 ).getStr() );
ImplDevFontAttributes aDFA;
@@ -2079,6 +2110,11 @@ bool WinSalGraphics::AddTempDevFont( PhysicalFontCollection* pFontCollection,
void WinSalGraphics::GetDevFontList( PhysicalFontCollection* pFontCollection )
{
+ mpTextRenderImpl->GetDevFontList(pFontCollection);
+}
+
+void WinTextRender::GetDevFontList(PhysicalFontCollection* pFontCollection)
+{
// make sure all fonts are registered at least temporarily
static bool bOnce = true;
if( bOnce )
@@ -2174,11 +2210,21 @@ void WinSalGraphics::GetDevFontList( PhysicalFontCollection* pFontCollection )
void WinSalGraphics::ClearDevFontCache()
{
+ mpTextRenderImpl->ClearDevFontCache();
+}
+
+void WinTextRender::ClearDevFontCache()
+{
//anything to do here ?
}
bool WinSalGraphics::GetGlyphBoundRect( sal_GlyphId aGlyphId, Rectangle& rRect )
{
+ return mpTextRenderImpl->GetGlyphBoundRect(aGlyphId, rRect);
+}
+
+bool WinTextRender::GetGlyphBoundRect(sal_GlyphId aGlyphId, Rectangle& rRect)
+{
HDC hDC = getHDC();
// use unity matrix
@@ -2210,6 +2256,11 @@ bool WinSalGraphics::GetGlyphBoundRect( sal_GlyphId aGlyphId, Rectangle& rRect )
bool WinSalGraphics::GetGlyphOutline( sal_GlyphId aGlyphId,
::basegfx::B2DPolyPolygon& rB2DPolyPoly )
{
+ return mpTextRenderImpl->GetGlyphOutline(aGlyphId, rB2DPolyPoly);
+}
+
+bool WinTextRender::GetGlyphOutline(sal_GlyphId aGlyphId, ::basegfx::B2DPolyPolygon& rB2DPolyPoly)
+{
rB2DPolyPoly.clear();
HDC hDC = getHDC();
@@ -2389,25 +2440,13 @@ bool WinSalGraphics::GetGlyphOutline( sal_GlyphId aGlyphId,
return true;
}
-class ScopedFont
-{
-public:
- explicit ScopedFont(WinSalGraphics & rData);
-
- ~ScopedFont();
-
-private:
- WinSalGraphics & m_rData;
- HFONT m_hOrigFont;
-};
-
-ScopedFont::ScopedFont(WinSalGraphics & rData): m_rData(rData)
+WinTextRender::ScopedFont::ScopedFont(WinTextRender & rData): m_rData(rData)
{
m_hOrigFont = m_rData.mhFonts[0];
m_rData.mhFonts[0] = 0; // avoid deletion of current font
}
-ScopedFont::~ScopedFont()
+WinTextRender::ScopedFont::~ScopedFont()
{
if( m_hOrigFont )
{
@@ -2451,6 +2490,13 @@ bool WinSalGraphics::CreateFontSubset( const OUString& rToFile,
const PhysicalFontFace* pFont, sal_GlyphId* pGlyphIds, sal_uInt8* pEncoding,
sal_Int32* pGlyphWidths, int nGlyphCount, FontSubsetInfo& rInfo )
{
+ return mpTextRenderImpl->CreateFontSubset(rToFile, pFont, pGlyphIds, pEncoding, pGlyphWidths, nGlyphCount, rInfo);
+}
+
+bool WinTextRender::CreateFontSubset(const OUString& rToFile,
+ const PhysicalFontFace* pFont, sal_GlyphId* pGlyphIds, sal_uInt8* pEncoding,
+ sal_Int32* pGlyphWidths, int nGlyphCount, FontSubsetInfo& rInfo)
+{
// TODO: use more of the central font-subsetting code, move stuff there if needed
// create matching FontSelectPattern
@@ -2462,7 +2508,7 @@ bool WinSalGraphics::CreateFontSubset( const OUString& rToFile,
ScopedFont aOldFont(*this);
float fScale = 1.0;
HFONT hOldFont = 0;
- ImplDoSetFont( &aIFSD, fScale, hOldFont );
+ mrGraphics.ImplDoSetFont( &aIFSD, fScale, hOldFont );
ImplWinFontData* pWinFontData = (ImplWinFontData*)aIFSD.mpFontData;
@@ -2605,6 +2651,13 @@ const void* WinSalGraphics::GetEmbedFontData( const PhysicalFontFace* pFont,
const sal_Unicode* pUnicodes, sal_Int32* pCharWidths,
FontSubsetInfo& rInfo, long* pDataLen )
{
+ return mpTextRenderImpl->GetEmbedFontData(pFont, pUnicodes, pCharWidths, rInfo, pDataLen);
+}
+
+const void* WinTextRender::GetEmbedFontData(const PhysicalFontFace* pFont,
+ const sal_Unicode* pUnicodes, sal_Int32* pCharWidths,
+ FontSubsetInfo& rInfo, long* pDataLen)
+{
// create matching FontSelectPattern
// we need just enough to get to the font file data
FontSelectPattern aIFSD( *pFont, Size(0,1000), 1000.0, 0, false );
@@ -2656,13 +2709,23 @@ const void* WinSalGraphics::GetEmbedFontData( const PhysicalFontFace* pFont,
return (void*)pData;
}
-void WinSalGraphics::FreeEmbedFontData( const void* pData, long /*nLen*/ )
+void WinSalGraphics::FreeEmbedFontData(const void* pData, long nLen)
+{
+ mpTextRenderImpl->FreeEmbedFontData(pData, nLen);
+}
+
+void WinTextRender::FreeEmbedFontData(const void* pData, long /*nLen*/)
{
delete[] reinterpret_cast<char*>(const_cast<void*>(pData));
}
const Ucs2SIntMap* WinSalGraphics::GetFontEncodingVector( const PhysicalFontFace* pFont, const Ucs2OStrMap** pNonEncoded )
{
+ return mpTextRenderImpl->GetFontEncodingVector(pFont, pNonEncoded);
+}
+
+const Ucs2SIntMap* WinTextRender::GetFontEncodingVector(const PhysicalFontFace* pFont, const Ucs2OStrMap** pNonEncoded)
+{
// TODO: even for builtin fonts we get here... why?
if( !pFont->IsEmbeddable() )
return NULL;
@@ -2691,6 +2754,12 @@ void WinSalGraphics::GetGlyphWidths( const PhysicalFontFace* pFont,
Int32Vector& rWidths,
Ucs2UIntMap& rUnicodeEnc )
{
+ mpTextRenderImpl->GetGlyphWidths(pFont, bVertical, rWidths, rUnicodeEnc);
+}
+
+void WinTextRender::GetGlyphWidths(const PhysicalFontFace* pFont, bool bVertical,
+ Int32Vector& rWidths, Ucs2UIntMap& rUnicodeEnc)
+{
// create matching FontSelectPattern
// we need just enough to get to the font file data
FontSelectPattern aIFSD( *pFont, Size(0,1000), 1000.0, 0, false );
@@ -2700,7 +2769,7 @@ void WinSalGraphics::GetGlyphWidths( const PhysicalFontFace* pFont,
float fScale = 0.0;
HFONT hOldFont = 0;
- ImplDoSetFont( &aIFSD, fScale, hOldFont );
+ mrGraphics.ImplDoSetFont( &aIFSD, fScale, hOldFont );
if( pFont->IsSubsettable() )
{
@@ -2777,20 +2846,32 @@ void WinSalGraphics::GetGlyphWidths( const PhysicalFontFace* pFont,
}
}
-void WinSalGraphics::DrawServerFontLayout( const ServerFontLayout& )
+void WinSalGraphics::DrawServerFontLayout(const ServerFontLayout& rLayout)
+{
+ mpTextRenderImpl->DrawServerFontLayout(rLayout);
+}
+
+void WinTextRender::DrawServerFontLayout(const ServerFontLayout&)
{}
-SystemFontData WinSalGraphics::GetSysFontData( int nFallbacklevel ) const
+SystemFontData WinSalGraphics::GetSysFontData(int nFallbackLevel) const
+{
+ return mpTextRenderImpl->GetSysFontData(nFallbackLevel);
+}
+
+SystemFontData WinTextRender::GetSysFontData(int nFallbackLevel) const
{
SystemFontData aSysFontData;
- if (nFallbacklevel >= MAX_FALLBACK) nFallbacklevel = MAX_FALLBACK - 1;
- if (nFallbacklevel < 0 ) nFallbacklevel = 0;
+ if (nFallbackLevel >= MAX_FALLBACK)
+ nFallbackLevel = MAX_FALLBACK - 1;
+ if (nFallbackLevel < 0)
+ nFallbackLevel = 0;
- aSysFontData.hFont = mhFonts[nFallbacklevel];
+ aSysFontData.hFont = mhFonts[nFallbackLevel];
OSL_TRACE("\r\n:WinSalGraphics::GetSysFontData(): FontID: %p, Fallback level: %d",
- aSysFontData.hFont, nFallbacklevel);
+ aSysFontData.hFont, nFallbackLevel);
return aSysFontData;
}
diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx
index 958348f..1c8eeb3 100644
--- a/vcl/win/source/gdi/winlayout.cxx
+++ b/vcl/win/source/gdi/winlayout.cxx
@@ -27,6 +27,7 @@
#include "win/salgdi.h"
#include "win/saldata.hxx"
+#include <wintextrender.hxx>
#include "sft.hxx"
#include "sallayout.hxx"
@@ -2819,6 +2820,11 @@ void GraphiteWinLayout::Simplify( bool is_base )
SalLayout* WinSalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLevel )
{
+ return mpTextRenderImpl->GetTextLayout(rArgs, nFallbackLevel);
+}
+
+SalLayout* WinTextRender::GetTextLayout(ImplLayoutArgs& rArgs, int nFallbackLevel)
+{
DBG_ASSERT( mpWinFontEntry[nFallbackLevel], "WinSalGraphics mpWinFontEntry==NULL");
WinLayout* pWinLayout = NULL;
@@ -2869,7 +2875,7 @@ SalLayout* WinSalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLe
return pWinLayout;
}
-int WinSalGraphics::GetMinKashidaWidth()
+int WinTextRender::GetMinKashidaWidth()
{
if( !mpWinFontEntry[0] )
return 0;
diff --git a/vcl/win/source/gdi/wintextrender.cxx b/vcl/win/source/gdi/wintextrender.cxx
new file mode 100644
index 0000000..df2382f
--- /dev/null
+++ b/vcl/win/source/gdi/wintextrender.cxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <wintextrender.hxx>
+
+#include <win/salgdi.h>
+#include <win/wincomp.hxx>
+
+WinTextRender::WinTextRender(bool bPrinter, WinSalGraphics& rGraphics)
+ : mbPrinter(bPrinter)
+ , mrGraphics(rGraphics)
+ , mfCurrentFontScale(1.0)
+ , mhDefFont(0)
+ , mpLogFont(NULL)
+ , mpFontAttrCache(NULL)
+ , mpFontCharSets(NULL)
+ , mnFontCharSetCount(0)
+ , mbFontKernInit(false)
+ , mpFontKernPairs(NULL)
+ , mnFontKernPairCount(0)
+{
+ for (int i = 0; i < MAX_FALLBACK; ++i)
+ {
+ mhFonts[i] = 0;
+ mpWinFontData[i] = NULL;
+ mpWinFontEntry[i] = NULL;
+ mfFontScale[i] = 1.0;
+ }
+}
+
+WinTextRender::~WinTextRender()
+{
+ if (mhDefFont)
+ SelectFont(getHDC(), mhDefFont);
+
+ delete[] mpLogFont;
+
+ delete[] mpFontCharSets;
+
+ delete[] mpFontKernPairs;
+}
+
+HDC WinTextRender::getHDC() const
+{
+ return mrGraphics.getHDC();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list