Kaydet (Commit) 146e4f8b authored tarafından Jan Holesovsky's avatar Jan Holesovsky

vcl: Abstract the Windows text rendering into a TextRenderImpl descendant.

Change-Id: I7ee9d7e705bb0344ba59c3edd10ed85390636cd4
üst c17f215c
...@@ -660,6 +660,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ ...@@ -660,6 +660,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/win/source/gdi/salprn \ vcl/win/source/gdi/salprn \
vcl/win/source/gdi/salvd \ vcl/win/source/gdi/salvd \
vcl/win/source/gdi/winlayout \ vcl/win/source/gdi/winlayout \
vcl/win/source/gdi/wintextrender \
vcl/win/source/gdi/wntgdi \ vcl/win/source/gdi/wntgdi \
vcl/win/source/window/salframe \ vcl/win/source/window/salframe \
vcl/win/source/window/keynames \ vcl/win/source/window/keynames \
......
...@@ -79,7 +79,7 @@ protected: ...@@ -79,7 +79,7 @@ protected:
virtual cairo_surface_t* getCairoSurface() = 0; virtual cairo_surface_t* getCairoSurface() = 0;
virtual void drawSurface(cairo_t* cr) = 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; virtual void clipRegion(cairo_t* cr) = 0;
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#ifndef INCLUDED_VCL_INC_UNX_CAIROFONTIMPL_HXX #ifndef INCLUDED_VCL_INC_TEXTRENDER_HXX
#define INCLUDED_VCL_INC_UNX_CAIROFONTIMPL_HXX #define INCLUDED_VCL_INC_TEXTRENDER_HXX
#include <sal/types.h> #include <sal/types.h>
#include <vcl/salgtype.hxx> #include <vcl/salgtype.hxx>
...@@ -29,9 +29,6 @@ ...@@ -29,9 +29,6 @@
#include "salglyphid.hxx" #include "salglyphid.hxx"
#include "fontsubset.hxx" #include "fontsubset.hxx"
class PspSalPrinter;
class PspSalInfoPrinter;
class ServerFont;
class ImplLayoutArgs; class ImplLayoutArgs;
class ServerFontLayout; class ServerFontLayout;
class PhysicalFontCollection; class PhysicalFontCollection;
......
...@@ -25,7 +25,9 @@ ...@@ -25,7 +25,9 @@
#include "outfont.hxx" #include "outfont.hxx"
#include "PhysicalFontFace.hxx" #include "PhysicalFontFace.hxx"
#include "impfont.hxx" #include "impfont.hxx"
#include <textrender.hxx>
#include <vcl/fontcapabilities.hxx> #include <vcl/fontcapabilities.hxx>
#include <win/svsys.h>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <boost/unordered_set.hpp> #include <boost/unordered_set.hpp>
...@@ -148,6 +150,7 @@ class WinSalGraphics : public SalGraphics ...@@ -148,6 +150,7 @@ class WinSalGraphics : public SalGraphics
friend class ScopedFont; friend class ScopedFont;
private: private:
boost::scoped_ptr<SalGraphicsImpl> mpImpl; boost::scoped_ptr<SalGraphicsImpl> mpImpl;
boost::scoped_ptr<TextRenderImpl> mpTextRenderImpl;
HDC mhLocalDC; // HDC HDC mhLocalDC; // HDC
bool mbPrinter : 1; // is Printer bool mbPrinter : 1; // is Printer
...@@ -156,26 +159,13 @@ private: ...@@ -156,26 +159,13 @@ private:
bool mbScreen : 1; // is Screen compatible bool mbScreen : 1; // is Screen compatible
HWND mhWnd; // Window-Handle, when Window-Graphics 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 HRGN mhRegion; // vcl::Region Handle
HPEN mhDefPen; // DefaultPen HPEN mhDefPen; // DefaultPen
HBRUSH mhDefBrush; // DefaultBrush HBRUSH mhDefBrush; // DefaultBrush
HFONT mhDefFont; // DefaultFont
HPALETTE mhDefPal; // DefaultPalette HPALETTE mhDefPal; // DefaultPalette
COLORREF mnTextColor; // TextColor COLORREF mnTextColor; // TextColor
RGNDATA* mpClipRgnData; // ClipRegion-Data RGNDATA* mpClipRgnData; // ClipRegion-Data
RGNDATA* mpStdClipRgnData; // Cache Standard-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 int mnPenWidth; // Linienbreite
public: public:
...@@ -285,12 +275,6 @@ protected: ...@@ -285,12 +275,6 @@ protected:
const SalBitmap* pAlphaBitmap); const SalBitmap* pAlphaBitmap);
virtual bool drawAlphaRect( long nX, long nY, long nWidth, long nHeight, sal_uInt8 nTransparency ); 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:
// public SalGraphics methods, the interface to the independent vcl part // public SalGraphics methods, the interface to the independent vcl part
...@@ -382,7 +366,6 @@ public: ...@@ -382,7 +366,6 @@ public:
bool bVertical, bool bVertical,
Int32Vector& rWidths, Int32Vector& rWidths,
Ucs2UIntMap& rUnicodeEnc ); Ucs2UIntMap& rUnicodeEnc );
virtual int GetMinKashidaWidth();
virtual bool GetGlyphBoundRect( sal_GlyphId, Rectangle& ); virtual bool GetGlyphBoundRect( sal_GlyphId, Rectangle& );
virtual bool GetGlyphOutline( sal_GlyphId, ::basegfx::B2DPolyPolygon& ); virtual bool GetGlyphOutline( sal_GlyphId, ::basegfx::B2DPolyPolygon& );
......
/* -*- 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: */
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "salgdiimpl.hxx" #include "salgdiimpl.hxx"
#include "gdiimpl.hxx" #include "gdiimpl.hxx"
#include "opengl/win/gdiimpl.hxx" #include "opengl/win/gdiimpl.hxx"
#include <wintextrender.hxx>
#include <vcl/opengl/OpenGLHelper.hxx> #include <vcl/opengl/OpenGLHelper.hxx>
...@@ -502,8 +503,6 @@ void WinSalGraphics::DeInitGraphics() ...@@ -502,8 +503,6 @@ void WinSalGraphics::DeInitGraphics()
SelectPen( getHDC(), mhDefPen ); SelectPen( getHDC(), mhDefPen );
if ( mhDefBrush ) if ( mhDefBrush )
SelectBrush( getHDC(), mhDefBrush ); SelectBrush( getHDC(), mhDefBrush );
if ( mhDefFont )
SelectFont( getHDC(), mhDefFont );
} }
HDC ImplGetCachedDC( sal_uLong nID, HBITMAP hBmp ) HDC ImplGetCachedDC( sal_uLong nID, HBITMAP hBmp )
...@@ -573,33 +572,22 @@ WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hW ...@@ -573,33 +572,22 @@ WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hW
mbWindow(eType == WinSalGraphics::WINDOW), mbWindow(eType == WinSalGraphics::WINDOW),
mhWnd(hWnd), mhWnd(hWnd),
mbScreen(bScreen), mbScreen(bScreen),
mfCurrentFontScale(1.0),
mhRegion(0), mhRegion(0),
mhDefPen(0), mhDefPen(0),
mhDefBrush(0), mhDefBrush(0),
mhDefFont(0),
mhDefPal(0), mhDefPal(0),
mpStdClipRgnData(NULL), mpStdClipRgnData(NULL),
mpLogFont(NULL),
mpFontCharSets(NULL),
mpFontAttrCache(NULL),
mnFontCharSetCount(0),
mpFontKernPairs(NULL),
mnFontKernPairCount(0),
mbFontKernInit(false),
mnPenWidth(GSL_PEN_WIDTH) mnPenWidth(GSL_PEN_WIDTH)
{ {
if (OpenGLHelper::isVCLOpenGLEnabled() && !mbPrinter) if (OpenGLHelper::isVCLOpenGLEnabled() && !mbPrinter)
{
mpImpl.reset(new WinOpenGLSalGraphicsImpl(*this)); mpImpl.reset(new WinOpenGLSalGraphicsImpl(*this));
mpTextRenderImpl.reset((new WinTextRender(mbPrinter, *this)));
}
else else
mpImpl.reset(new WinSalGraphicsImpl(*this));
for( int i = 0; i < MAX_FALLBACK; ++i )
{ {
mhFonts[ i ] = 0; mpImpl.reset(new WinSalGraphicsImpl(*this));
mpWinFontData[ i ] = NULL; mpTextRenderImpl.reset((new WinTextRender(mbPrinter, *this)));
mpWinFontEntry[ i ] = NULL;
mfFontScale[ i ] = 1.0;
} }
} }
...@@ -616,12 +604,6 @@ WinSalGraphics::~WinSalGraphics() ...@@ -616,12 +604,6 @@ WinSalGraphics::~WinSalGraphics()
// delete cache data // delete cache data
delete [] mpStdClipRgnData; delete [] mpStdClipRgnData;
delete mpLogFont;
delete mpFontCharSets;
delete mpFontKernPairs;
} }
bool WinSalGraphics::isPrinter() const bool WinSalGraphics::isPrinter() const
......
This diff is collapsed.
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "win/salgdi.h" #include "win/salgdi.h"
#include "win/saldata.hxx" #include "win/saldata.hxx"
#include <wintextrender.hxx>
#include "sft.hxx" #include "sft.hxx"
#include "sallayout.hxx" #include "sallayout.hxx"
...@@ -2818,6 +2819,11 @@ void GraphiteWinLayout::Simplify( bool is_base ) ...@@ -2818,6 +2819,11 @@ void GraphiteWinLayout::Simplify( bool is_base )
#endif // ENABLE_GRAPHITE #endif // ENABLE_GRAPHITE
SalLayout* WinSalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLevel ) 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"); DBG_ASSERT( mpWinFontEntry[nFallbackLevel], "WinSalGraphics mpWinFontEntry==NULL");
...@@ -2869,7 +2875,7 @@ SalLayout* WinSalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLe ...@@ -2869,7 +2875,7 @@ SalLayout* WinSalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLe
return pWinLayout; return pWinLayout;
} }
int WinSalGraphics::GetMinKashidaWidth() int WinTextRender::GetMinKashidaWidth()
{ {
if( !mpWinFontEntry[0] ) if( !mpWinFontEntry[0] )
return 0; return 0;
......
/* -*- 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: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment