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_UNX_SALGDI_H
21 : #define INCLUDED_VCL_INC_UNX_SALGDI_H
22 :
23 : #include <prex.h>
24 : #include <postx.h>
25 : #include <tools/fract.hxx>
26 :
27 : #include <vcl/salgtype.hxx>
28 : #include <vcl/vclenum.hxx>
29 : #include <vcl/metric.hxx>
30 :
31 : #include "salgdi.hxx"
32 : #include "salgeom.hxx"
33 : #include "sallayout.hxx"
34 : #include "vclpluginapi.h"
35 :
36 : #include <deque>
37 : #include <memory>
38 :
39 : class ImplFontMetricData;
40 : class FontSelectPattern;
41 : class SalBitmap;
42 : class SalColormap;
43 : class SalDisplay;
44 : class SalFrame;
45 : class X11Pixmap;
46 : class X11SalVirtualDevice;
47 : class X11SalGraphicsImpl;
48 : class X11OpenGLSalGraphicsImpl;
49 : class X11OpenGLSalVirtualDevice;
50 : class PspSalPrinter;
51 : class PspSalInfoPrinter;
52 : class ServerFont;
53 : class ImplLayoutArgs;
54 : class ServerFontLayout;
55 : class PhysicalFontCollection;
56 : class PhysicalFontFace;
57 : class SalGraphicsImpl;
58 : class TextRenderImpl;
59 :
60 : namespace basegfx {
61 : class B2DTrapezoid;
62 : }
63 :
64 : class VCLPLUG_GEN_PUBLIC X11SalGraphics : public SalGraphics
65 : {
66 : friend class ServerFontLayout;
67 : friend class X11SalGraphicsImpl;
68 : friend class X11OpenGLSalGraphicsImpl;
69 : friend class X11CairoTextRender;
70 :
71 : public:
72 : X11SalGraphics();
73 : virtual ~X11SalGraphics();
74 :
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 );
79 : void DeInit();
80 :
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 191 : inline Drawable GetDrawable() const { return hDrawable_; }
87 : void SetDrawable( Drawable d, SalX11Screen nXScreen );
88 : XRenderPictFormat* GetXRenderFormat() const;
89 413 : inline void SetXRenderFormat( XRenderPictFormat* pXRenderFormat ) { m_pXRenderFormat = pXRenderFormat; }
90 2121 : inline const SalColormap& GetColormap() const { return *m_pColormap; }
91 :
92 : using SalGraphics::GetPixel;
93 : inline Pixel GetPixel( SalColor nSalColor ) const;
94 :
95 177 : SalX11Screen GetScreenNumber() const { return m_nXScreen; }
96 :
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;
101 :
102 : virtual void ResetClipRegion() SAL_OVERRIDE;
103 : virtual bool setClipRegion( const vcl::Region& ) SAL_OVERRIDE;
104 :
105 : virtual void SetLineColor() SAL_OVERRIDE;
106 : virtual void SetLineColor( SalColor nSalColor ) SAL_OVERRIDE;
107 : virtual void SetFillColor() SAL_OVERRIDE;
108 :
109 : virtual void SetFillColor( SalColor nSalColor ) SAL_OVERRIDE;
110 :
111 : virtual void SetXORMode( bool bSet, bool ) SAL_OVERRIDE;
112 :
113 : virtual void SetROPLineColor( SalROPColor nROPColor ) SAL_OVERRIDE;
114 : virtual void SetROPFillColor( SalROPColor nROPColor ) SAL_OVERRIDE;
115 :
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;
124 :
125 : virtual bool CreateFontSubset(
126 : const OUString& rToFile,
127 : const PhysicalFontFace*,
128 : const sal_GlyphId* pGlyphIDs,
129 : const sal_uInt8* pEncoding,
130 : sal_Int32* pWidths,
131 : int nGlyphs,
132 : FontSubsetInfo& rInfo ) SAL_OVERRIDE;
133 :
134 : virtual const Ucs2SIntMap* GetFontEncodingVector( const PhysicalFontFace*, const Ucs2OStrMap** ppNonEncoded, std::set<sal_Unicode> const**) SAL_OVERRIDE;
135 :
136 : virtual const void* GetEmbedFontData(
137 : const PhysicalFontFace*,
138 : const sal_Ucs* pUnicodes,
139 : sal_Int32* pWidths,
140 : size_t nLen,
141 : FontSubsetInfo& rInfo,
142 : long* pDataLen ) SAL_OVERRIDE;
143 :
144 : virtual void FreeEmbedFontData( const void* pData, long nDataLen ) SAL_OVERRIDE;
145 :
146 : virtual void GetGlyphWidths(
147 : const PhysicalFontFace*,
148 : bool bVertical,
149 : Int32Vector& rWidths,
150 : Ucs2UIntMap& rUnicodeEnc ) SAL_OVERRIDE;
151 :
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;
156 :
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;
164 :
165 : virtual void drawPolyPolygon(
166 : sal_uInt32 nPoly,
167 : const sal_uInt32* pPoints,
168 : PCONSTSALPOINT* pPtAry ) SAL_OVERRIDE;
169 :
170 : virtual bool drawPolyPolygon( const ::basegfx::B2DPolyPolygon&, double fTransparency ) SAL_OVERRIDE;
171 :
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;
178 :
179 : virtual bool drawGradient( const tools::PolyPolygon&, const Gradient& ) SAL_OVERRIDE;
180 :
181 : #if 1 // TODO: remove these obselete methods
182 : virtual bool drawPolyLineBezier(
183 : sal_uInt32 nPoints,
184 : const SalPoint* pPtAry,
185 : const sal_uInt8* pFlgAry ) SAL_OVERRIDE;
186 :
187 : virtual bool drawPolygonBezier(
188 : sal_uInt32 nPoints,
189 : const SalPoint* pPtAry,
190 : const sal_uInt8* pFlgAry ) SAL_OVERRIDE;
191 :
192 : virtual bool drawPolyPolygonBezier(
193 : sal_uInt32 nPoly,
194 : const sal_uInt32* pPoints,
195 : const SalPoint* const* pPtAry,
196 : const sal_uInt8* const* pFlgAry ) SAL_OVERRIDE;
197 : #endif
198 :
199 : virtual void copyArea(
200 : long nDestX,
201 : long nDestY,
202 : long nSrcX,
203 : long nSrcY,
204 : long nSrcWidth,
205 : long nSrcHeight,
206 : sal_uInt16 nFlags ) SAL_OVERRIDE;
207 :
208 : virtual void copyBits(
209 : const SalTwoRect& rPosAry,
210 : SalGraphics* pSrcGraphics ) SAL_OVERRIDE;
211 :
212 : virtual void drawBitmap(
213 : const SalTwoRect& rPosAry,
214 : const SalBitmap& rSalBitmap ) SAL_OVERRIDE;
215 :
216 : virtual void drawBitmap(
217 : const SalTwoRect& rPosAry,
218 : const SalBitmap& rSalBitmap,
219 : SalColor nTransparentColor ) SAL_OVERRIDE;
220 :
221 : virtual void drawBitmap(
222 : const SalTwoRect& rPosAry,
223 : const SalBitmap& rSalBitmap,
224 : const SalBitmap& rMaskBitmap ) SAL_OVERRIDE;
225 :
226 : virtual void drawMask(
227 : const SalTwoRect& rPosAry,
228 : const SalBitmap& rSalBitmap,
229 : SalColor nMaskColor ) SAL_OVERRIDE;
230 :
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;
235 :
236 : virtual bool drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uIntPtr nSize ) SAL_OVERRIDE;
237 :
238 : virtual bool blendBitmap(
239 : const SalTwoRect&,
240 : const SalBitmap& rBitmap ) SAL_OVERRIDE;
241 :
242 : virtual bool blendAlphaBitmap(
243 : const SalTwoRect&,
244 : const SalBitmap& rSrcBitmap,
245 : const SalBitmap& rMaskBitmap,
246 : const SalBitmap& rAlphaBitmap ) SAL_OVERRIDE;
247 :
248 : virtual bool drawAlphaBitmap(
249 : const SalTwoRect&,
250 : const SalBitmap& rSourceBitmap,
251 : const SalBitmap& rAlphaBitmap ) SAL_OVERRIDE;
252 :
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;
259 :
260 : virtual bool drawAlphaRect(
261 : long nX, long nY, long nWidth,
262 : long nHeight, sal_uInt8 nTransparency ) SAL_OVERRIDE;
263 :
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;
271 :
272 : virtual void BeginPaint() SAL_OVERRIDE;
273 : virtual void EndPaint() SAL_OVERRIDE;
274 :
275 : // fill a pixmap from a screen region
276 : bool FillPixmapFromScreen( X11Pixmap* pPixmap, int nX, int nY );
277 :
278 : // render a pixmap to the screen
279 : bool RenderPixmapToScreen( X11Pixmap* pPixmap, X11Pixmap* pMask, int nX, int nY );
280 :
281 :
282 : /* use to handle GraphicsExpose/NoExpose after XCopyArea & friends
283 : * if pFrame is not NULL, corresponding Paint events are generated
284 : * and dispatched to pFrame
285 : *
286 : * it is imperative to eat up graphics exposes even in case you don't need
287 : * them because the next one using XCopyArea can depend on them
288 : */
289 : void YieldGraphicsExpose();
290 :
291 : // do XCopyArea or XGet/PutImage depending on screen numbers
292 : // signature is like XCopyArea with screen numbers added
293 : static void CopyScreenArea(
294 : Display* pDisplay,
295 : Drawable aSrc, SalX11Screen nXScreenSrc, int nSrcDepth,
296 : Drawable aDest, SalX11Screen nXScreenDest, int nDestDepth,
297 : GC aDestGC,
298 : int src_x, int src_y,
299 : unsigned int w, unsigned int h,
300 : int dest_x, int dest_y );
301 :
302 : static void releaseGlyphPeer();
303 :
304 : protected:
305 : using SalGraphics::SetClipRegion;
306 : void SetClipRegion( GC pGC, Region pXReg = NULL ) const;
307 : bool GetDitherPixmap ( SalColor nSalColor );
308 :
309 : using SalGraphics::DrawBitmap;
310 : void DrawBitmap(
311 : const SalTwoRect& rPosAry,
312 : SalGraphics *pThis,
313 : const SalBitmap &rSalBitmap,
314 : const SalBitmap &rTransparentBitmap,
315 : SalColor nTransparentColor );
316 :
317 : GC GetFontGC();
318 : void DrawPrinterString( const SalLayout& );
319 : void DrawServerFontString( const ServerFontLayout& );
320 :
321 : void freeResources();
322 :
323 : protected:
324 : SalFrame* m_pFrame; // the SalFrame which created this Graphics or NULL
325 : SalVirtualDevice* m_pVDev; // the SalVirtualDevice which created this Graphics or NULL
326 :
327 : const SalColormap* m_pColormap;
328 : SalColormap* m_pDeleteColormap;
329 : Drawable hDrawable_; // use
330 : SalX11Screen m_nXScreen;
331 : mutable XRenderPictFormat* m_pXRenderFormat;
332 : XID m_aXRenderPicture;
333 :
334 : Region pPaintRegion_;
335 : Region mpClipRegion;
336 :
337 : GC pFontGC_; // Font attributes
338 : Pixel nTextPixel_;
339 :
340 : Pixmap hBrush_; // Dither
341 :
342 : bool bWindow_ : 1; // is Window
343 : bool bPrinter_ : 1; // is Printer
344 : bool bVirDev_ : 1; // is VirDev
345 : bool bFontGC_ : 1; // is Font GC valid
346 :
347 : private:
348 : std::unique_ptr<SalGraphicsImpl> mxImpl;
349 : std::unique_ptr<TextRenderImpl> mxTextRenderImpl;
350 :
351 : };
352 :
353 38 : inline const SalDisplay *X11SalGraphics::GetDisplay() const
354 38 : { return GetColormap().GetDisplay(); }
355 :
356 351 : inline const SalVisual& X11SalGraphics::GetVisual() const
357 351 : { return GetColormap().GetVisual(); }
358 :
359 946 : inline Display *X11SalGraphics::GetXDisplay() const
360 946 : { return GetColormap().GetXDisplay(); }
361 :
362 779 : inline Pixel X11SalGraphics::GetPixel( SalColor nSalColor ) const
363 779 : { return GetColormap().GetPixel( nSalColor ); }
364 :
365 : #ifdef DBG_UTIL
366 : #define stderr0( s ) fprintf( stderr, s )
367 : #else
368 : #define stderr0( s ) ;
369 : #endif
370 :
371 : #endif // INCLUDED_VCL_INC_UNX_SALGDI_H
372 :
373 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|