Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_VCL_INC_HEADLESS_SVPGDI_HXX
21 : #define INCLUDED_VCL_INC_HEADLESS_SVPGDI_HXX
22 :
23 : #include <basebmp/bitmapdevice.hxx>
24 : #include <basebmp/color.hxx>
25 : #include <vcl/sysdata.hxx>
26 : #include <vcl/metric.hxx>
27 :
28 : #include "salgdi.hxx"
29 : #include "sallayout.hxx"
30 : #include "textrender.hxx"
31 :
32 : #ifdef IOS
33 : #define SvpSalGraphics AquaSalGraphics
34 : #else
35 :
36 : class GlyphCache;
37 : class ServerFont;
38 :
39 : class VCL_DLLPUBLIC SvpSalGraphics : public SalGraphics
40 : {
41 : basebmp::BitmapDeviceSharedPtr m_aDevice;
42 : basebmp::BitmapDeviceSharedPtr m_aOrigDevice;
43 :
44 : basebmp::BitmapDeviceSharedPtr m_aClipMap;
45 :
46 : bool m_bUseLineColor;
47 : basebmp::Color m_aLineColor;
48 : bool m_bUseFillColor;
49 : basebmp::Color m_aFillColor;
50 :
51 : basebmp::DrawMode m_aDrawMode;
52 :
53 : protected:
54 : basegfx::B2IVector GetSize() { return m_aOrigDevice->getSize(); }
55 :
56 : public:
57 : static GlyphCache& getPlatformGlyphCache();
58 : void setDevice(basebmp::BitmapDeviceSharedPtr& rDevice);
59 : void BlendTextColor(const basebmp::Color &rTextColor, const basebmp::BitmapDeviceSharedPtr &rAlphaMask,
60 : const basegfx::B2IPoint &rDstPoint);
61 :
62 : private:
63 : bool m_bClipSetup;
64 : struct ClipUndoHandle {
65 : SvpSalGraphics &m_rGfx;
66 : basebmp::BitmapDeviceSharedPtr m_aDevice;
67 1803917 : ClipUndoHandle( SvpSalGraphics *pGfx ) : m_rGfx( *pGfx ) {}
68 : ~ClipUndoHandle();
69 : };
70 : bool isClippedSetup( const basegfx::B2IBox &aRange, ClipUndoHandle &rUndo );
71 : void ensureClip();
72 :
73 : protected:
74 : vcl::Region m_aClipRegion;
75 : std::unique_ptr<TextRenderImpl> m_xTextRenderImpl;
76 :
77 : protected:
78 : virtual bool blendBitmap( const SalTwoRect&, const SalBitmap& rBitmap ) SAL_OVERRIDE;
79 : virtual bool blendAlphaBitmap( const SalTwoRect&,
80 : const SalBitmap& rSrcBitmap,
81 : const SalBitmap& rMaskBitmap,
82 : const SalBitmap& rAlphaBitmap ) SAL_OVERRIDE;
83 : virtual bool drawAlphaBitmap( const SalTwoRect&, const SalBitmap& rSourceBitmap, const SalBitmap& rAlphaBitmap ) SAL_OVERRIDE;
84 : virtual bool drawTransformedBitmap(
85 : const basegfx::B2DPoint& rNull,
86 : const basegfx::B2DPoint& rX,
87 : const basegfx::B2DPoint& rY,
88 : const SalBitmap& rSourceBitmap,
89 : const SalBitmap* pAlphaBitmap) SAL_OVERRIDE;
90 : virtual bool drawAlphaRect( long nX, long nY, long nWidth, long nHeight, sal_uInt8 nTransparency ) SAL_OVERRIDE;
91 :
92 : public:
93 : SvpSalGraphics();
94 : virtual ~SvpSalGraphics();
95 :
96 210 : virtual SalGraphicsImpl* GetImpl() const SAL_OVERRIDE { return NULL; };
97 : virtual void GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) SAL_OVERRIDE;
98 : virtual sal_uInt16 GetBitCount() const SAL_OVERRIDE;
99 : virtual long GetGraphicsWidth() const SAL_OVERRIDE;
100 :
101 : virtual void ResetClipRegion() SAL_OVERRIDE;
102 : virtual bool setClipRegion( const vcl::Region& ) SAL_OVERRIDE;
103 :
104 : virtual void SetLineColor() SAL_OVERRIDE;
105 : virtual void SetLineColor( SalColor nSalColor ) SAL_OVERRIDE;
106 : virtual void SetFillColor() SAL_OVERRIDE;
107 : virtual void SetFillColor( SalColor nSalColor ) SAL_OVERRIDE;
108 :
109 : virtual void SetXORMode( bool bSet, bool ) SAL_OVERRIDE;
110 :
111 : virtual void SetROPLineColor( SalROPColor nROPColor ) SAL_OVERRIDE;
112 : virtual void SetROPFillColor( SalROPColor nROPColor ) SAL_OVERRIDE;
113 :
114 : virtual void SetTextColor( SalColor nSalColor ) SAL_OVERRIDE;
115 : virtual sal_uInt16 SetFont( FontSelectPattern*, int nFallbackLevel ) SAL_OVERRIDE;
116 : virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel ) SAL_OVERRIDE;
117 : virtual const FontCharMapPtr GetFontCharMap() const SAL_OVERRIDE;
118 : virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const SAL_OVERRIDE;
119 : virtual void GetDevFontList( PhysicalFontCollection* ) SAL_OVERRIDE;
120 : virtual void ClearDevFontCache() SAL_OVERRIDE;
121 : virtual bool AddTempDevFont( PhysicalFontCollection*, const OUString& rFileURL, const OUString& rFontName ) SAL_OVERRIDE;
122 : virtual bool CreateFontSubset( const OUString& rToFile,
123 : const PhysicalFontFace*,
124 : const sal_GlyphId* pGlyphIds,
125 : const sal_uInt8* pEncoding,
126 : sal_Int32* pWidths,
127 : int nGlyphs,
128 : FontSubsetInfo& rInfo
129 : ) SAL_OVERRIDE;
130 : virtual const Ucs2SIntMap* GetFontEncodingVector( const PhysicalFontFace*, const Ucs2OStrMap** ppNonEncoded, std::set<sal_Unicode> const** ) SAL_OVERRIDE;
131 : virtual const void* GetEmbedFontData( const PhysicalFontFace*,
132 : const sal_Ucs* pUnicodes,
133 : sal_Int32* pWidths,
134 : size_t nLen,
135 : FontSubsetInfo& rInfo,
136 : long* pDataLen ) SAL_OVERRIDE;
137 : virtual void FreeEmbedFontData( const void* pData, long nDataLen ) SAL_OVERRIDE;
138 : virtual void GetGlyphWidths( const PhysicalFontFace*,
139 : bool bVertical,
140 : Int32Vector& rWidths,
141 : Ucs2UIntMap& rUnicodeEnc ) SAL_OVERRIDE;
142 : virtual bool GetGlyphBoundRect( sal_GlyphId nIndex, Rectangle& ) SAL_OVERRIDE;
143 : virtual bool GetGlyphOutline( sal_GlyphId nIndex, ::basegfx::B2DPolyPolygon& ) SAL_OVERRIDE;
144 : virtual SalLayout* GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) SAL_OVERRIDE;
145 : virtual void DrawServerFontLayout( const ServerFontLayout& ) SAL_OVERRIDE;
146 : virtual bool supportsOperation( OutDevSupportType ) const SAL_OVERRIDE;
147 : virtual void drawPixel( long nX, long nY ) SAL_OVERRIDE;
148 : virtual void drawPixel( long nX, long nY, SalColor nSalColor ) SAL_OVERRIDE;
149 : virtual void drawLine( long nX1, long nY1, long nX2, long nY2 ) SAL_OVERRIDE;
150 : virtual void drawRect( long nX, long nY, long nWidth, long nHeight ) SAL_OVERRIDE;
151 : virtual bool drawPolyPolygon( const ::basegfx::B2DPolyPolygon&, double fTransparency ) SAL_OVERRIDE;
152 : virtual bool drawPolyLine( const ::basegfx::B2DPolygon&,
153 : double fTransparency,
154 : const ::basegfx::B2DVector& rLineWidths,
155 : basegfx::B2DLineJoin,
156 : com::sun::star::drawing::LineCap) SAL_OVERRIDE;
157 : virtual void drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry ) SAL_OVERRIDE;
158 : virtual void drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ) SAL_OVERRIDE;
159 : virtual void drawPolyPolygon( sal_uInt32 nPoly,
160 : const sal_uInt32* pPoints,
161 : PCONSTSALPOINT* pPtAry ) SAL_OVERRIDE;
162 : virtual bool drawPolyLineBezier( sal_uInt32 nPoints,
163 : const SalPoint* pPtAry,
164 : const sal_uInt8* pFlgAry ) SAL_OVERRIDE;
165 : virtual bool drawPolygonBezier( sal_uInt32 nPoints,
166 : const SalPoint* pPtAry,
167 : const sal_uInt8* pFlgAry ) SAL_OVERRIDE;
168 : virtual bool drawPolyPolygonBezier( sal_uInt32 nPoly,
169 : const sal_uInt32* pPoints,
170 : const SalPoint* const* pPtAry,
171 : const sal_uInt8* const* pFlgAry ) SAL_OVERRIDE;
172 155833 : virtual bool drawGradient( const tools::PolyPolygon&, const Gradient& ) SAL_OVERRIDE { return false; };
173 :
174 : virtual void copyArea( long nDestX,
175 : long nDestY,
176 : long nSrcX,
177 : long nSrcY,
178 : long nSrcWidth,
179 : long nSrcHeight,
180 : sal_uInt16 nFlags ) SAL_OVERRIDE;
181 : virtual void copyBits( const SalTwoRect& rPosAry,
182 : SalGraphics* pSrcGraphics ) SAL_OVERRIDE;
183 : virtual void drawBitmap( const SalTwoRect& rPosAry,
184 : const SalBitmap& rSalBitmap ) SAL_OVERRIDE;
185 : virtual void drawBitmap( const SalTwoRect& rPosAry,
186 : const SalBitmap& rSalBitmap,
187 : SalColor nTransparentColor ) SAL_OVERRIDE;
188 : virtual void drawBitmap( const SalTwoRect& rPosAry,
189 : const SalBitmap& rSalBitmap,
190 : const SalBitmap& rTransparentBitmap ) SAL_OVERRIDE;
191 : virtual void drawMask( const SalTwoRect& rPosAry,
192 : const SalBitmap& rSalBitmap,
193 : SalColor nMaskColor ) SAL_OVERRIDE;
194 : virtual SalBitmap* getBitmap( long nX, long nY, long nWidth, long nHeight ) SAL_OVERRIDE;
195 : virtual SalColor getPixel( long nX, long nY ) SAL_OVERRIDE;
196 : virtual void invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags ) SAL_OVERRIDE;
197 : virtual void invert( sal_uInt32 nPoints, const SalPoint* pPtAry, SalInvert nFlags ) SAL_OVERRIDE;
198 :
199 : virtual bool drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uLong nSize ) SAL_OVERRIDE;
200 :
201 : virtual SystemGraphicsData GetGraphicsData() const SAL_OVERRIDE;
202 : virtual bool SupportsCairo() const SAL_OVERRIDE;
203 : virtual cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const SAL_OVERRIDE;
204 : virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y, int width, int height) const SAL_OVERRIDE;
205 : virtual cairo::SurfaceSharedPtr CreateBitmapSurface(const OutputDevice& rRefDevice, const BitmapSystemData& rData, const Size& rSize) const SAL_OVERRIDE;
206 : virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize) const SAL_OVERRIDE;
207 :
208 : virtual SystemFontData GetSysFontData( int nFallbacklevel ) const SAL_OVERRIDE;
209 :
210 162136 : virtual void BeginPaint() SAL_OVERRIDE { };
211 162136 : virtual void EndPaint() SAL_OVERRIDE { };
212 : };
213 :
214 : #endif
215 :
216 : #endif // INCLUDED_VCL_INC_HEADLESS_SVPGDI_HXX
217 :
218 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|