1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_INC_UNX_SALGDI_H
21 #define INCLUDED_VCL_INC_UNX_SALGDI_H
25 #include <tools/fract.hxx>
27 #include <vcl/salgtype.hxx>
28 #include <vcl/vclenum.hxx>
29 #include <vcl/metric.hxx>
32 #include "salgeom.hxx"
33 #include "sallayout.hxx"
34 #include "vclpluginapi.h"
39 class ImplFontMetricData
;
40 class FontSelectPattern
;
46 class X11SalVirtualDevice
;
47 class X11SalGraphicsImpl
;
48 class X11OpenGLSalGraphicsImpl
;
49 class X11OpenGLSalVirtualDevice
;
51 class PspSalInfoPrinter
;
54 class ServerFontLayout
;
55 class PhysicalFontCollection
;
56 class PhysicalFontFace
;
57 class SalGraphicsImpl
;
64 class VCLPLUG_GEN_PUBLIC X11SalGraphics
: public SalGraphics
66 friend class ServerFontLayout
;
67 friend class X11SalGraphicsImpl
;
68 friend class X11OpenGLSalGraphicsImpl
;
69 friend class X11CairoTextRender
;
73 virtual ~X11SalGraphics();
75 void Init( SalFrame
*pFrame
, Drawable aDrawable
, SalX11Screen nXScreen
);
76 void Init( X11SalVirtualDevice
*pVirtualDevice
, SalColormap
* pColormap
= NULL
, bool bDeleteColormap
= false );
77 void Init( X11OpenGLSalVirtualDevice
*pVirtualDevice
);
78 void Init( class ImplSalPrinterData
*pPrinter
);
81 virtual SalGraphicsImpl
* GetImpl() const SAL_OVERRIDE
;
82 inline const SalDisplay
* GetDisplay() const;
83 inline Display
* GetXDisplay() const;
84 inline const SalVisual
& GetVisual() const;
85 SalGeometryProvider
* GetGeometryProvider() const;
86 inline Drawable
GetDrawable() const { return hDrawable_
; }
87 void SetDrawable( Drawable d
, SalX11Screen nXScreen
);
88 XRenderPictFormat
* GetXRenderFormat() const;
89 inline void SetXRenderFormat( XRenderPictFormat
* pXRenderFormat
) { m_pXRenderFormat
= pXRenderFormat
; }
90 inline const SalColormap
& GetColormap() const { return *m_pColormap
; }
92 using SalGraphics::GetPixel
;
93 inline Pixel
GetPixel( SalColor nSalColor
) const;
95 SalX11Screen
GetScreenNumber() const { return m_nXScreen
; }
97 // override all pure virtual methods
98 virtual void GetResolution( sal_Int32
& rDPIX
, sal_Int32
& rDPIY
) SAL_OVERRIDE
;
99 virtual sal_uInt16
GetBitCount() const SAL_OVERRIDE
;
100 virtual long GetGraphicsWidth() const SAL_OVERRIDE
;
102 virtual void ResetClipRegion() SAL_OVERRIDE
;
103 virtual bool setClipRegion( const vcl::Region
& ) SAL_OVERRIDE
;
105 virtual void SetLineColor() SAL_OVERRIDE
;
106 virtual void SetLineColor( SalColor nSalColor
) SAL_OVERRIDE
;
107 virtual void SetFillColor() SAL_OVERRIDE
;
109 virtual void SetFillColor( SalColor nSalColor
) SAL_OVERRIDE
;
111 virtual void SetXORMode( bool bSet
, bool ) SAL_OVERRIDE
;
113 virtual void SetROPLineColor( SalROPColor nROPColor
) SAL_OVERRIDE
;
114 virtual void SetROPFillColor( SalROPColor nROPColor
) SAL_OVERRIDE
;
116 virtual void SetTextColor( SalColor nSalColor
) SAL_OVERRIDE
;
117 virtual sal_uInt16
SetFont( FontSelectPattern
*, int nFallbackLevel
) SAL_OVERRIDE
;
118 virtual void GetFontMetric( ImplFontMetricData
*, int nFallbackLevel
) SAL_OVERRIDE
;
119 virtual const FontCharMapPtr
GetFontCharMap() const SAL_OVERRIDE
;
120 virtual bool GetFontCapabilities(vcl::FontCapabilities
&rFontCapabilities
) const SAL_OVERRIDE
;
121 virtual void GetDevFontList( PhysicalFontCollection
* ) SAL_OVERRIDE
;
122 virtual void ClearDevFontCache() SAL_OVERRIDE
;
123 virtual bool AddTempDevFont( PhysicalFontCollection
*, const OUString
& rFileURL
, const OUString
& rFontName
) SAL_OVERRIDE
;
125 virtual bool CreateFontSubset(
126 const OUString
& rToFile
,
127 const PhysicalFontFace
*,
128 const sal_GlyphId
* pGlyphIDs
,
129 const sal_uInt8
* pEncoding
,
132 FontSubsetInfo
& rInfo
) SAL_OVERRIDE
;
134 virtual const Ucs2SIntMap
* GetFontEncodingVector( const PhysicalFontFace
*, const Ucs2OStrMap
** ppNonEncoded
, std::set
<sal_Unicode
> const**) SAL_OVERRIDE
;
136 virtual const void* GetEmbedFontData(
137 const PhysicalFontFace
*,
138 const sal_Ucs
* pUnicodes
,
141 FontSubsetInfo
& rInfo
,
142 long* pDataLen
) SAL_OVERRIDE
;
144 virtual void FreeEmbedFontData( const void* pData
, long nDataLen
) SAL_OVERRIDE
;
146 virtual void GetGlyphWidths(
147 const PhysicalFontFace
*,
149 Int32Vector
& rWidths
,
150 Ucs2UIntMap
& rUnicodeEnc
) SAL_OVERRIDE
;
152 virtual bool GetGlyphBoundRect( sal_GlyphId nIndex
, Rectangle
& ) SAL_OVERRIDE
;
153 virtual bool GetGlyphOutline( sal_GlyphId nIndex
, ::basegfx::B2DPolyPolygon
& ) SAL_OVERRIDE
;
154 virtual SalLayout
* GetTextLayout( ImplLayoutArgs
&, int nFallbackLevel
) SAL_OVERRIDE
;
155 virtual void DrawServerFontLayout( const ServerFontLayout
& ) SAL_OVERRIDE
;
157 virtual bool supportsOperation( OutDevSupportType
) const SAL_OVERRIDE
;
158 virtual void drawPixel( long nX
, long nY
) SAL_OVERRIDE
;
159 virtual void drawPixel( long nX
, long nY
, SalColor nSalColor
) SAL_OVERRIDE
;
160 virtual void drawLine( long nX1
, long nY1
, long nX2
, long nY2
) SAL_OVERRIDE
;
161 virtual void drawRect( long nX
, long nY
, long nWidth
, long nHeight
) SAL_OVERRIDE
;
162 virtual void drawPolyLine( sal_uInt32 nPoints
, const SalPoint
* pPtAry
) SAL_OVERRIDE
;
163 virtual void drawPolygon( sal_uInt32 nPoints
, const SalPoint
* pPtAry
) SAL_OVERRIDE
;
165 virtual void drawPolyPolygon(
167 const sal_uInt32
* pPoints
,
168 PCONSTSALPOINT
* pPtAry
) SAL_OVERRIDE
;
170 virtual bool drawPolyPolygon( const ::basegfx::B2DPolyPolygon
&, double fTransparency
) SAL_OVERRIDE
;
172 virtual bool drawPolyLine(
173 const ::basegfx::B2DPolygon
&,
174 double fTransparency
,
175 const ::basegfx::B2DVector
& rLineWidth
,
176 basegfx::B2DLineJoin
,
177 com::sun::star::drawing::LineCap
) SAL_OVERRIDE
;
179 virtual bool drawGradient( const tools::PolyPolygon
&, const Gradient
& ) SAL_OVERRIDE
;
181 #if 1 // TODO: remove these obselete methods
182 virtual bool drawPolyLineBezier(
184 const SalPoint
* pPtAry
,
185 const sal_uInt8
* pFlgAry
) SAL_OVERRIDE
;
187 virtual bool drawPolygonBezier(
189 const SalPoint
* pPtAry
,
190 const sal_uInt8
* pFlgAry
) SAL_OVERRIDE
;
192 virtual bool drawPolyPolygonBezier(
194 const sal_uInt32
* pPoints
,
195 const SalPoint
* const* pPtAry
,
196 const sal_uInt8
* const* pFlgAry
) SAL_OVERRIDE
;
199 virtual void copyArea(
206 sal_uInt16 nFlags
) SAL_OVERRIDE
;
208 virtual void copyBits(
209 const SalTwoRect
& rPosAry
,
210 SalGraphics
* pSrcGraphics
) SAL_OVERRIDE
;
212 virtual void drawBitmap(
213 const SalTwoRect
& rPosAry
,
214 const SalBitmap
& rSalBitmap
) SAL_OVERRIDE
;
216 virtual void drawBitmap(
217 const SalTwoRect
& rPosAry
,
218 const SalBitmap
& rSalBitmap
,
219 SalColor nTransparentColor
) SAL_OVERRIDE
;
221 virtual void drawBitmap(
222 const SalTwoRect
& rPosAry
,
223 const SalBitmap
& rSalBitmap
,
224 const SalBitmap
& rMaskBitmap
) SAL_OVERRIDE
;
226 virtual void drawMask(
227 const SalTwoRect
& rPosAry
,
228 const SalBitmap
& rSalBitmap
,
229 SalColor nMaskColor
) SAL_OVERRIDE
;
231 virtual SalBitmap
* getBitmap( long nX
, long nY
, long nWidth
, long nHeight
) SAL_OVERRIDE
;
232 virtual SalColor
getPixel( long nX
, long nY
) SAL_OVERRIDE
;
233 virtual void invert( long nX
, long nY
, long nWidth
, long nHeight
, SalInvert nFlags
) SAL_OVERRIDE
;
234 virtual void invert( sal_uInt32 nPoints
, const SalPoint
* pPtAry
, SalInvert nFlags
) SAL_OVERRIDE
;
236 virtual bool drawEPS( long nX
, long nY
, long nWidth
, long nHeight
, void* pPtr
, sal_uIntPtr nSize
) SAL_OVERRIDE
;
238 virtual bool blendBitmap(
240 const SalBitmap
& rBitmap
) SAL_OVERRIDE
;
242 virtual bool blendAlphaBitmap(
244 const SalBitmap
& rSrcBitmap
,
245 const SalBitmap
& rMaskBitmap
,
246 const SalBitmap
& rAlphaBitmap
) SAL_OVERRIDE
;
248 virtual bool drawAlphaBitmap(
250 const SalBitmap
& rSourceBitmap
,
251 const SalBitmap
& rAlphaBitmap
) SAL_OVERRIDE
;
253 virtual bool drawTransformedBitmap(
254 const basegfx::B2DPoint
& rNull
,
255 const basegfx::B2DPoint
& rX
,
256 const basegfx::B2DPoint
& rY
,
257 const SalBitmap
& rSourceBitmap
,
258 const SalBitmap
* pAlphaBitmap
) SAL_OVERRIDE
;
260 virtual bool drawAlphaRect(
261 long nX
, long nY
, long nWidth
,
262 long nHeight
, sal_uInt8 nTransparency
) SAL_OVERRIDE
;
264 virtual SystemGraphicsData
GetGraphicsData() const SAL_OVERRIDE
;
265 virtual bool SupportsCairo() const SAL_OVERRIDE
;
266 virtual cairo::SurfaceSharedPtr
CreateSurface(const cairo::CairoSurfaceSharedPtr
& rSurface
) const SAL_OVERRIDE
;
267 virtual cairo::SurfaceSharedPtr
CreateSurface(const OutputDevice
& rRefDevice
, int x
, int y
, int width
, int height
) const SAL_OVERRIDE
;
268 virtual cairo::SurfaceSharedPtr
CreateBitmapSurface(const OutputDevice
& rRefDevice
, const BitmapSystemData
& rData
, const Size
& rSize
) const SAL_OVERRIDE
;
269 virtual css::uno::Any
GetNativeSurfaceHandle(cairo::SurfaceSharedPtr
& rSurface
, const basegfx::B2ISize
& rSize
) const SAL_OVERRIDE
;
270 virtual SystemFontData
GetSysFontData( int nFallbackLevel
) const SAL_OVERRIDE
;
272 virtual OpenGLContext
*BeginPaint() SAL_OVERRIDE
;
274 bool TryRenderCachedNativeControl(ControlCacheKey
& aControlCacheKey
,
277 bool RenderAndCacheNativeControl(X11Pixmap
* pPixmap
, X11Pixmap
* pMask
, int nX
, int nY
,
278 ControlCacheKey
& aControlCacheKey
);
280 // fill a pixmap from a screen region
281 bool FillPixmapFromScreen( X11Pixmap
* pPixmap
, int nX
, int nY
);
283 // render a pixmap to the screen
284 bool RenderPixmapToScreen( X11Pixmap
* pPixmap
, X11Pixmap
* pMask
, int nX
, int nY
);
287 /* use to handle GraphicsExpose/NoExpose after XCopyArea & friends
288 * if pFrame is not NULL, corresponding Paint events are generated
289 * and dispatched to pFrame
291 * it is imperative to eat up graphics exposes even in case you don't need
292 * them because the next one using XCopyArea can depend on them
294 void YieldGraphicsExpose();
296 // do XCopyArea or XGet/PutImage depending on screen numbers
297 // signature is like XCopyArea with screen numbers added
298 static void CopyScreenArea(
300 Drawable aSrc
, SalX11Screen nXScreenSrc
, int nSrcDepth
,
301 Drawable aDest
, SalX11Screen nXScreenDest
, int nDestDepth
,
303 int src_x
, int src_y
,
304 unsigned int w
, unsigned int h
,
305 int dest_x
, int dest_y
);
307 static void releaseGlyphPeer();
310 using SalGraphics::SetClipRegion
;
311 void SetClipRegion( GC pGC
, Region pXReg
= NULL
) const;
312 bool GetDitherPixmap ( SalColor nSalColor
);
314 using SalGraphics::DrawBitmap
;
316 const SalTwoRect
& rPosAry
,
318 const SalBitmap
&rSalBitmap
,
319 const SalBitmap
&rTransparentBitmap
,
320 SalColor nTransparentColor
);
323 void DrawPrinterString( const SalLayout
& );
324 void DrawServerFontString( const ServerFontLayout
& );
326 void freeResources();
329 SalFrame
* m_pFrame
; // the SalFrame which created this Graphics or NULL
330 SalVirtualDevice
* m_pVDev
; // the SalVirtualDevice which created this Graphics or NULL
332 const SalColormap
* m_pColormap
;
333 SalColormap
* m_pDeleteColormap
;
334 Drawable hDrawable_
; // use
335 SalX11Screen m_nXScreen
;
336 mutable XRenderPictFormat
* m_pXRenderFormat
;
337 XID m_aXRenderPicture
;
339 Region pPaintRegion_
;
342 GC pFontGC_
; // Font attributes
345 Pixmap hBrush_
; // Dither
347 bool bWindow_
: 1; // is Window
348 bool bPrinter_
: 1; // is Printer
349 bool bVirDev_
: 1; // is VirDev
350 bool bFontGC_
: 1; // is Font GC valid
353 std::unique_ptr
<SalGraphicsImpl
> mxImpl
;
354 std::unique_ptr
<TextRenderImpl
> mxTextRenderImpl
;
358 inline const SalDisplay
*X11SalGraphics::GetDisplay() const
359 { return GetColormap().GetDisplay(); }
361 inline const SalVisual
& X11SalGraphics::GetVisual() const
362 { return GetColormap().GetVisual(); }
364 inline Display
*X11SalGraphics::GetXDisplay() const
365 { return GetColormap().GetXDisplay(); }
367 inline Pixel
X11SalGraphics::GetPixel( SalColor nSalColor
) const
368 { return GetColormap().GetPixel( nSalColor
); }
371 #define stderr0( s ) fprintf( stderr, s )
373 #define stderr0( s ) ;
376 #endif // INCLUDED_VCL_INC_UNX_SALGDI_H
378 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */