merge the formfield patch from ooo-build
[ooovba.git] / vcl / unx / inc / salgdi.h
blobd05ddac4aded1d35c2457258c86d84e260b5ffd4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: salgdi.h,v $
10 * $Revision: 1.49 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SV_SALGDI_H
32 #define _SV_SALGDI_H
35 // -=-= exports -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
36 class SalFontCacheItem;
38 // -=-= includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
39 #include "salstd.hxx"
40 #include "vcl/salgdi.hxx"
41 #include "vcl/salgtype.hxx"
42 #include "tools/fract.hxx"
43 #include "vcl/dllapi.h"
44 #include <deque>
45 #include "xfont.hxx"
47 // -=-= forwards -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
48 struct ImplFontMetricData;
49 struct ImplFontSelectData;
50 class SalBitmap;
51 class SalColormap;
52 class SalDisplay;
53 class SalFrame;
54 class X11SalVirtualDevice;
55 class SalPolyLine;
56 class PspSalPrinter;
57 class PspSalInfoPrinter;
58 class ServerFont;
59 class ImplLayoutArgs;
60 class X11FontLayout;
61 class ServerFontLayout;
63 // -=-= SalGraphicsData =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
65 class CairoFontsCache
67 private:
68 static int mnRefCount;
69 typedef std::deque< std::pair<void *, void*> > LRUFonts;
70 static LRUFonts maLRUFonts;
71 public:
72 CairoFontsCache();
73 static void CacheFont(void *pFont, void *pId);
74 static void* FindCachedFont(void *pId);
75 ~CairoFontsCache();
78 class VCL_DLLPUBLIC X11SalGraphics : public SalGraphics
80 friend class X11FontLayout;
81 friend class ServerFontLayout;
82 protected:
83 SalFrame* m_pFrame; // the SalFrame which created this Graphics or NULL
84 X11SalVirtualDevice* m_pVDev; // the SalVirtualDevice which created this Graphics or NULL
86 const SalColormap* m_pColormap;
87 SalColormap *m_pDeleteColormap;
88 Drawable hDrawable_; // use
89 int m_nScreen;
90 void* m_pRenderFormat;
91 XID m_aRenderPicture;
92 CairoFontsCache m_aCairoFontsCache;
94 XLIB_Region pPaintRegion_;
95 XLIB_Region pClipRegion_;
97 GC pPenGC_; // Pen attributes
98 SalColor nPenColor_;
99 Pixel nPenPixel_;
101 GC pFontGC_; // Font attributes
102 ExtendedFontStructRef mXFont[ MAX_FALLBACK ];
103 ServerFont* mpServerFont[ MAX_FALLBACK ];
105 SalColor nTextColor_;
106 Pixel nTextPixel_;
107 BOOL bFontVertical_;
109 BOOL bDisableGraphite_;
111 GC pBrushGC_; // Brush attributes
112 SalColor nBrushColor_;
113 Pixel nBrushPixel_;
114 Pixmap hBrush_; // Dither
116 GC pMonoGC_;
117 GC pCopyGC_;
118 GC pMaskGC_;
119 GC pInvertGC_;
120 GC pInvert50GC_;
121 GC pStippleGC_;
122 GC pTrackingGC_;
124 BOOL bWindow_ : 1; // is Window
125 BOOL bPrinter_ : 1; // is Printer
126 BOOL bVirDev_ : 1; // is VirDev
127 BOOL bPenGC_ : 1; // is Pen GC valid
128 BOOL bFontGC_ : 1; // is Font GC valid
129 BOOL bBrushGC_ : 1; // is Brush GC valid
130 BOOL bMonoGC_ : 1; // is Mono GC valid
131 BOOL bCopyGC_ : 1; // is Copy GC valid
132 BOOL bInvertGC_ : 1; // is Invert GC valid
133 BOOL bInvert50GC_ : 1; // is Invert50 GC valid
134 BOOL bStippleGC_ : 1; // is Stipple GC valid
135 BOOL bTrackingGC_ : 1; // is Tracking GC valid
136 bool bXORMode_ : 1; // is ROP XOR Mode set
137 BOOL bDitherBrush_ : 1; // is solid or tile
139 void SetClipRegion( GC pGC,
140 XLIB_Region pXReg = NULL ) const;
142 GC GetTrackingGC();
143 GC GetInvertGC();
144 GC GetInvert50GC();
145 GC CreateGC( Drawable hDrawable,
146 unsigned long nMask = GCGraphicsExposures );
147 GC SelectPen();
148 GC SelectBrush();
149 void DrawLines( ULONG nPoints,
150 const SalPolyLine &rPoints,
151 GC pGC,
152 bool bClose
154 BOOL GetDitherPixmap ( SalColor nSalColor );
156 inline GC GetMonoGC( Pixmap hPixmap );
157 inline GC GetCopyGC();
158 inline GC GetStippleGC();
160 int Clip ( XLIB_Region pRegion,
161 int &nX,
162 int &nY,
163 unsigned int &nDX,
164 unsigned int &nDY,
165 int &nSrcX,
166 int &nSrcY ) const;
167 int Clip ( int &nX,
168 int &nY,
169 unsigned int &nDX,
170 unsigned int &nDY,
171 int &nSrcX,
172 int &nSrcY ) const;
173 GC SetMask ( int &nX,
174 int &nY,
175 unsigned int &nDX,
176 unsigned int &nDY,
177 int &nSrcX,
178 int &nSrcY,
179 Pixmap hClipMask );
180 using SalGraphics::DrawBitmap;
181 void DrawBitmap( const SalTwoRect *pPosAry,
182 SalGraphics *pThis,
183 const SalBitmap &rSalBitmap,
184 const SalBitmap &rTransparentBitmap,
185 SalColor nTransparentColor );
187 GC SelectFont();
188 bool setFont( const ImplFontSelectData* pEntry, int nFallbackLevel );
190 void drawMaskedBitmap( const SalTwoRect* pPosAry,
191 const SalBitmap& rSalBitmap,
192 const SalBitmap& rTransparentBitmap );
194 protected:
195 void DrawStringUCS2MB( ExtendedFontStruct& rFont, const Point&,
196 const sal_Unicode* pStr, int nLength );
198 void DrawPrinterString( const SalLayout& );
200 void DrawServerFontString( const ServerFontLayout& );
201 void DrawServerSimpleFontString( const ServerFontLayout& );
202 void DrawServerAAFontString( const ServerFontLayout& );
203 bool DrawServerAAForcedString( const ServerFontLayout& );
204 void DrawCairoAAFontString( const ServerFontLayout& );
206 void freeResources();
207 public:
208 X11SalGraphics();
209 virtual ~X11SalGraphics();
211 void Init( SalFrame *pFrame, Drawable aDrawable, int nScreen );
212 void Init( X11SalVirtualDevice *pVirtualDevice, SalColormap* pColormap = NULL, bool bDeleteColormap = false );
213 void Init( class ImplSalPrinterData *pPrinter );
214 void DeInit();
216 inline const SalDisplay* GetDisplay() const;
217 inline Display* GetXDisplay() const;
218 inline const SalVisual& GetVisual() const;
219 inline Drawable GetDrawable() const { return hDrawable_; }
220 void SetDrawable( Drawable d, int nScreen );
221 XID GetXRenderPicture();
222 void* GetXRenderFormat() const { return m_pRenderFormat; }
223 inline void SetXRenderFormat( void* pRenderFormat ) { m_pRenderFormat = pRenderFormat; }
224 inline const SalColormap& GetColormap() const { return *m_pColormap; }
225 using SalGraphics::GetPixel;
226 inline Pixel GetPixel( SalColor nSalColor ) const;
228 int GetScreenNumber() const { return m_nScreen; }
230 // overload all pure virtual methods
231 virtual void GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY );
232 virtual USHORT GetBitCount();
233 virtual long GetGraphicsWidth() const;
234 virtual long GetGraphicsHeight() const;
236 virtual void ResetClipRegion();
237 virtual void BeginSetClipRegion( ULONG nCount );
238 virtual BOOL unionClipRegion( long nX, long nY, long nWidth, long nHeight );
239 virtual bool unionClipRegion( const ::basegfx::B2DPolyPolygon& );
240 virtual void EndSetClipRegion();
242 virtual void SetLineColor();
243 virtual void SetLineColor( SalColor nSalColor );
244 virtual void SetFillColor();
246 virtual void SetFillColor( SalColor nSalColor );
248 virtual void SetXORMode( bool bSet, bool );
250 virtual void SetROPLineColor( SalROPColor nROPColor );
251 virtual void SetROPFillColor( SalROPColor nROPColor );
253 virtual void SetTextColor( SalColor nSalColor );
254 virtual USHORT SetFont( ImplFontSelectData*, int nFallbackLevel );
255 virtual void GetFontMetric( ImplFontMetricData* );
256 virtual ULONG GetKernPairs( ULONG nPairs, ImplKernPairData* pKernPairs );
257 virtual ImplFontCharMap* GetImplFontCharMap() const;
258 virtual void GetDevFontList( ImplDevFontList* );
259 virtual void GetDevFontSubstList( OutputDevice* );
260 virtual bool AddTempDevFont( ImplDevFontList*, const String& rFileURL, const String& rFontName );
261 virtual BOOL CreateFontSubset( const rtl::OUString& rToFile,
262 const ImplFontData*,
263 sal_Int32* pGlyphIDs,
264 sal_uInt8* pEncoding,
265 sal_Int32* pWidths,
266 int nGlyphs,
267 FontSubsetInfo& rInfo
269 virtual const Ucs2SIntMap* GetFontEncodingVector( const ImplFontData*, const Ucs2OStrMap** ppNonEncoded );
270 virtual const void* GetEmbedFontData( const ImplFontData*,
271 const sal_Ucs* pUnicodes,
272 sal_Int32* pWidths,
273 FontSubsetInfo& rInfo,
274 long* pDataLen );
275 virtual void FreeEmbedFontData( const void* pData, long nDataLen );
276 virtual void GetGlyphWidths( const ImplFontData*,
277 bool bVertical,
278 Int32Vector& rWidths,
279 Ucs2UIntMap& rUnicodeEnc );
280 virtual BOOL GetGlyphBoundRect( long nIndex, Rectangle& );
281 virtual BOOL GetGlyphOutline( long nIndex, ::basegfx::B2DPolyPolygon& );
282 virtual SalLayout* GetTextLayout( ImplLayoutArgs&, int nFallbackLevel );
283 virtual void DrawServerFontLayout( const ServerFontLayout& );
284 virtual bool supportsOperation( OutDevSupportType ) const;
285 virtual void drawPixel( long nX, long nY );
286 virtual void drawPixel( long nX, long nY, SalColor nSalColor );
287 virtual void drawLine( long nX1, long nY1, long nX2, long nY2 );
288 virtual void drawRect( long nX, long nY, long nWidth, long nHeight );
289 void drawPolyLine( ULONG nPoints, const SalPoint* pPtAry, bool bClose );
290 virtual void drawPolyLine( ULONG nPoints, const SalPoint* pPtAry );
291 virtual void drawPolygon( ULONG nPoints, const SalPoint* pPtAry );
292 virtual void drawPolyPolygon( sal_uInt32 nPoly,
293 const sal_uInt32* pPoints,
294 PCONSTSALPOINT* pPtAry );
295 virtual bool drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPolygon, double fTransparency );
296 virtual bool drawPolyLine( const ::basegfx::B2DPolygon& rPolygon, const ::basegfx::B2DVector& rLineWidth, basegfx::B2DLineJoin);
297 virtual sal_Bool drawPolyLineBezier( ULONG nPoints,
298 const SalPoint* pPtAry,
299 const BYTE* pFlgAry );
300 virtual sal_Bool drawPolygonBezier( ULONG nPoints,
301 const SalPoint* pPtAry,
302 const BYTE* pFlgAry );
303 virtual sal_Bool drawPolyPolygonBezier( sal_uInt32 nPoly,
304 const sal_uInt32* pPoints,
305 const SalPoint* const* pPtAry,
306 const BYTE* const* pFlgAry );
307 virtual void copyArea( long nDestX,
308 long nDestY,
309 long nSrcX,
310 long nSrcY,
311 long nSrcWidth,
312 long nSrcHeight,
313 USHORT nFlags );
314 virtual void copyBits( const SalTwoRect* pPosAry,
315 SalGraphics* pSrcGraphics );
316 virtual void drawBitmap( const SalTwoRect* pPosAry,
317 const SalBitmap& rSalBitmap );
318 virtual void drawBitmap( const SalTwoRect* pPosAry,
319 const SalBitmap& rSalBitmap,
320 SalColor nTransparentColor );
321 virtual void drawBitmap( const SalTwoRect* pPosAry,
322 const SalBitmap& rSalBitmap,
323 const SalBitmap& rMaskBitmap );
324 virtual void drawMask( const SalTwoRect* pPosAry,
325 const SalBitmap& rSalBitmap,
326 SalColor nMaskColor );
327 virtual SalBitmap* getBitmap( long nX, long nY, long nWidth, long nHeight );
328 virtual SalColor getPixel( long nX, long nY );
329 virtual void invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags );
330 virtual void invert( ULONG nPoints, const SalPoint* pPtAry, SalInvert nFlags );
332 virtual BOOL drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, ULONG nSize );
334 virtual bool drawAlphaBitmap( const SalTwoRect&,
335 const SalBitmap& rSourceBitmap,
336 const SalBitmap& rAlphaBitmap );
338 virtual bool drawAlphaRect( long nX, long nY, long nWidth,
339 long nHeight, sal_uInt8 nTransparency );
341 virtual SystemGraphicsData GetGraphicsData() const;
342 virtual SystemFontData GetSysFontData( int nFallbacklevel ) const;
344 /* use to handle GraphicsExpose/NoExpose after XCopyArea & friends
345 * if pFrame is not NULL, corresponding Paint events are generated
346 * and dispatched to pFrame
348 * it is imperative to eat up graphics exposes even in case you don't need
349 * them because the next one using XCopyArea can depend on them
351 void YieldGraphicsExpose();
353 // do XCopyArea or XGet/PutImage depending on screen numbers
354 // signature is like XCopyArea with screen numbers added
355 static void CopyScreenArea( Display* pDisplay,
356 Drawable aSrc, int nScreenSrc, int nSrcDepth,
357 Drawable aDest, int nScreenDest, int nDestDepth,
358 GC aDestGC,
359 int src_x, int src_y,
360 unsigned int w, unsigned int h,
361 int dest_x, int dest_y );
362 static void releaseGlyphPeer();
366 inline const SalDisplay *X11SalGraphics::GetDisplay() const
367 { return GetColormap().GetDisplay(); }
369 inline const SalVisual& X11SalGraphics::GetVisual() const
370 { return GetColormap().GetVisual(); }
372 inline Display *X11SalGraphics::GetXDisplay() const
373 { return GetColormap().GetXDisplay(); }
375 inline Pixel X11SalGraphics::GetPixel( SalColor nSalColor ) const
376 { return GetColormap().GetPixel( nSalColor ); }
379 // -=-= Shortcuts =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
381 #ifdef DBG_UTIL
382 #define stderr0( s ) fprintf( stderr, s )
383 #define stderr1( s, a ) fprintf( stderr, s, a )
384 #define stderr2( s, a, b ) fprintf( stderr, s, a, b )
385 #define stderr3( s, a, b, c ) fprintf( stderr, s, a, b, c )
386 #define stdass0( b ) (void)( !(b) \
387 ? fprintf( stderr, "\"%s\" (%s line %d)\n", \
388 #b, __FILE__, __LINE__ ) \
389 : 0 )
390 #else
391 #define stderr0( s ) ;
392 #define stderr1( s, a ) ;
393 #define stderr2( s, a, b ) ;
394 #define stderr3( s, a, b, c ) ;
395 #define stdass0( b ) ;
396 #endif
398 #endif // _SV_SALGDI_H