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 _SVP_SVPGDI_HXX
21 : #define _SVP_SVPGDI_HXX
22 :
23 : #include <basebmp/bitmapdevice.hxx>
24 : #include <basebmp/color.hxx>
25 :
26 : #include "salgdi.hxx"
27 : #include "sallayout.hxx"
28 :
29 : #ifdef IOS
30 : #include "coretext/salgdi2.h"
31 : #include <premac.h>
32 : #include <CoreGraphics/CoreGraphics.h>
33 : #include <postmac.h>
34 : #endif
35 :
36 : class ServerFont;
37 :
38 : #ifdef IOS
39 : // To keep changes to the CoreText code shared with AOO to a minimum,
40 : // let's continue calling the SalGraphics subclass "AquaSalGraphics" even if it
41 : // is used by us also on iOS, where of course the term "Aqua" has no meaning at all.
42 : // (Note that even on OS X, using the term "Aqua" is a misunderstanding or obsolete.)
43 : #define SvpSalGraphics AquaSalGraphics
44 : #endif
45 :
46 : class SvpSalGraphics : public SalGraphics
47 : {
48 : basebmp::BitmapDeviceSharedPtr m_aDevice;
49 : basebmp::BitmapDeviceSharedPtr m_aOrigDevice;
50 :
51 : bool m_bUseLineColor;
52 : basebmp::Color m_aLineColor;
53 : bool m_bUseFillColor;
54 : basebmp::Color m_aFillColor;
55 :
56 : basebmp::DrawMode m_aDrawMode;
57 :
58 : #ifndef IOS
59 : // These fields are used only when we use FreeType to draw into a
60 : // headless backend, i.e. not on iOS.
61 : basebmp::Color m_aTextColor;
62 : ServerFont* m_pServerFont[ MAX_FALLBACK ];
63 : sal_uInt32 m_eTextFmt;
64 : #endif
65 :
66 : basebmp::BitmapDeviceSharedPtr m_aClipMap;
67 :
68 : protected:
69 : Region m_aClipRegion;
70 : basegfx::B2IVector GetSize() { return m_aOrigDevice->getSize(); }
71 :
72 : private:
73 : bool m_bClipSetup;
74 : struct ClipUndoHandle {
75 : SvpSalGraphics &m_rGfx;
76 : basebmp::BitmapDeviceSharedPtr m_aDevice;
77 1125682 : ClipUndoHandle( SvpSalGraphics *pGfx ) : m_rGfx( *pGfx ) {}
78 : ~ClipUndoHandle();
79 : };
80 : bool isClippedSetup( const basegfx::B2IBox &aRange, ClipUndoHandle &rUndo );
81 : void ensureClip();
82 :
83 : protected:
84 :
85 : #ifdef IOS
86 : friend class CTLayout;
87 :
88 : CGContextRef mrContext;
89 : double mfFakeDPIScale;
90 :
91 : // Device Font settings
92 : const ImplMacFontData* mpMacFontData;
93 : ImplMacTextStyle* mpMacTextStyle;
94 : RGBAColor maTextColor;
95 : /// allows text to be rendered without antialiasing
96 : bool mbNonAntialiasedText;
97 :
98 : #endif
99 :
100 : virtual bool drawAlphaBitmap( const SalTwoRect&, const SalBitmap& rSourceBitmap, const SalBitmap& rAlphaBitmap );
101 : virtual bool drawTransformedBitmap(
102 : const basegfx::B2DPoint& rNull,
103 : const basegfx::B2DPoint& rX,
104 : const basegfx::B2DPoint& rY,
105 : const SalBitmap& rSourceBitmap,
106 : const SalBitmap* pAlphaBitmap);
107 : virtual bool drawAlphaRect( long nX, long nY, long nWidth, long nHeight, sal_uInt8 nTransparency );
108 :
109 : public:
110 : SvpSalGraphics();
111 : virtual ~SvpSalGraphics();
112 :
113 : void setDevice( basebmp::BitmapDeviceSharedPtr& rDevice );
114 :
115 : virtual void GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY );
116 : virtual sal_uInt16 GetBitCount() const;
117 : virtual long GetGraphicsWidth() const;
118 :
119 : virtual void ResetClipRegion();
120 : virtual bool setClipRegion( const Region& );
121 :
122 : virtual void SetLineColor();
123 : virtual void SetLineColor( SalColor nSalColor );
124 : virtual void SetFillColor();
125 : virtual void SetFillColor( SalColor nSalColor );
126 :
127 : virtual void SetXORMode( bool bSet, bool );
128 :
129 : virtual void SetROPLineColor( SalROPColor nROPColor );
130 : virtual void SetROPFillColor( SalROPColor nROPColor );
131 :
132 : virtual void SetTextColor( SalColor nSalColor );
133 : virtual sal_uInt16 SetFont( FontSelectPattern*, int nFallbackLevel );
134 : virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel );
135 : virtual sal_uLong GetKernPairs( sal_uLong nPairs, ImplKernPairData* pKernPairs );
136 : virtual const ImplFontCharMap* GetImplFontCharMap() const;
137 : virtual bool GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const;
138 : virtual void GetDevFontList( ImplDevFontList* );
139 : virtual void ClearDevFontCache();
140 : virtual void GetDevFontSubstList( OutputDevice* );
141 : virtual bool AddTempDevFont( ImplDevFontList*, const OUString& rFileURL, const OUString& rFontName );
142 : virtual sal_Bool CreateFontSubset( const OUString& rToFile,
143 : const PhysicalFontFace*,
144 : sal_Int32* pGlyphIDs,
145 : sal_uInt8* pEncoding,
146 : sal_Int32* pWidths,
147 : int nGlyphs,
148 : FontSubsetInfo& rInfo
149 : );
150 : virtual const Ucs2SIntMap* GetFontEncodingVector( const PhysicalFontFace*, const Ucs2OStrMap** ppNonEncoded );
151 : virtual const void* GetEmbedFontData( const PhysicalFontFace*,
152 : const sal_Ucs* pUnicodes,
153 : sal_Int32* pWidths,
154 : FontSubsetInfo& rInfo,
155 : long* pDataLen );
156 : virtual void FreeEmbedFontData( const void* pData, long nDataLen );
157 : virtual void GetGlyphWidths( const PhysicalFontFace*,
158 : bool bVertical,
159 : Int32Vector& rWidths,
160 : Ucs2UIntMap& rUnicodeEnc );
161 : virtual sal_Bool GetGlyphBoundRect( sal_GlyphId nIndex, Rectangle& );
162 : virtual sal_Bool GetGlyphOutline( sal_GlyphId nIndex, ::basegfx::B2DPolyPolygon& );
163 : virtual SalLayout* GetTextLayout( ImplLayoutArgs&, int nFallbackLevel );
164 : virtual void DrawServerFontLayout( const ServerFontLayout& );
165 : virtual bool supportsOperation( OutDevSupportType ) const;
166 : virtual void drawPixel( long nX, long nY );
167 : virtual void drawPixel( long nX, long nY, SalColor nSalColor );
168 : virtual void drawLine( long nX1, long nY1, long nX2, long nY2 );
169 : virtual void drawRect( long nX, long nY, long nWidth, long nHeight );
170 : virtual bool drawPolyPolygon( const ::basegfx::B2DPolyPolygon&, double fTransparency );
171 : virtual bool drawPolyLine( const ::basegfx::B2DPolygon&,
172 : double fTransparency,
173 : const ::basegfx::B2DVector& rLineWidths,
174 : basegfx::B2DLineJoin,
175 : com::sun::star::drawing::LineCap);
176 : virtual void drawPolyLine( sal_uLong nPoints, const SalPoint* pPtAry );
177 : virtual void drawPolygon( sal_uLong nPoints, const SalPoint* pPtAry );
178 : virtual void drawPolyPolygon( sal_uInt32 nPoly,
179 : const sal_uInt32* pPoints,
180 : PCONSTSALPOINT* pPtAry );
181 : virtual sal_Bool drawPolyLineBezier( sal_uLong nPoints,
182 : const SalPoint* pPtAry,
183 : const sal_uInt8* pFlgAry );
184 : virtual sal_Bool drawPolygonBezier( sal_uLong nPoints,
185 : const SalPoint* pPtAry,
186 : const sal_uInt8* pFlgAry );
187 : virtual sal_Bool drawPolyPolygonBezier( sal_uInt32 nPoly,
188 : const sal_uInt32* pPoints,
189 : const SalPoint* const* pPtAry,
190 : const sal_uInt8* const* pFlgAry );
191 :
192 : virtual void copyArea( long nDestX,
193 : long nDestY,
194 : long nSrcX,
195 : long nSrcY,
196 : long nSrcWidth,
197 : long nSrcHeight,
198 : sal_uInt16 nFlags );
199 : virtual void copyBits( const SalTwoRect& rPosAry,
200 : SalGraphics* pSrcGraphics );
201 : virtual void drawBitmap( const SalTwoRect& rPosAry,
202 : const SalBitmap& rSalBitmap );
203 : virtual void drawBitmap( const SalTwoRect& rPosAry,
204 : const SalBitmap& rSalBitmap,
205 : SalColor nTransparentColor );
206 : virtual void drawBitmap( const SalTwoRect& rPosAry,
207 : const SalBitmap& rSalBitmap,
208 : const SalBitmap& rTransparentBitmap );
209 : virtual void drawMask( const SalTwoRect& rPosAry,
210 : const SalBitmap& rSalBitmap,
211 : SalColor nMaskColor );
212 : virtual SalBitmap* getBitmap( long nX, long nY, long nWidth, long nHeight );
213 : virtual SalColor getPixel( long nX, long nY );
214 : virtual void invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags );
215 : virtual void invert( sal_uLong nPoints, const SalPoint* pPtAry, SalInvert nFlags );
216 :
217 : virtual sal_Bool drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uLong nSize );
218 :
219 : virtual SystemGraphicsData GetGraphicsData() const;
220 : virtual SystemFontData GetSysFontData( int nFallbacklevel ) const;
221 :
222 : #ifdef IOS
223 : bool CheckContext();
224 : CGContextRef GetContext();
225 : bool GetRawFontData( const PhysicalFontFace* pFontData,
226 : std::vector<unsigned char>& rBuffer,
227 : bool* pJustCFF );
228 : #endif
229 : };
230 :
231 : #endif
232 :
233 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|