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
24 #include <X11/Xutil.h>
25 #include <X11/extensions/Xrender.h>
27 #include <tools/fract.hxx>
29 #include <vcl/salgtype.hxx>
30 #include <vcl/vclenum.hxx>
31 #include <vcl/metric.hxx>
34 #include "salgeom.hxx"
35 #include "sallayout.hxx"
36 #include "vclpluginapi.h"
41 /* From <X11/Intrinsic.h> */
42 typedef unsigned long Pixel
;
45 class FontSelectPattern
;
51 class X11SalVirtualDevice
;
52 class X11SalGraphicsImpl
;
53 class X11OpenGLSalGraphicsImpl
;
54 class X11OpenGLSalVirtualDevice
;
57 class ServerFontLayout
;
58 class PhysicalFontCollection
;
59 class PhysicalFontFace
;
60 class SalGraphicsImpl
;
67 class VCLPLUG_GEN_PUBLIC X11SalGraphics
: public SalGraphics
69 friend class ServerFontLayout
;
70 friend class X11SalGraphicsImpl
;
71 friend class X11OpenGLSalGraphicsImpl
;
72 friend class X11CairoTextRender
;
76 virtual ~X11SalGraphics();
78 void Init( SalFrame
*pFrame
, Drawable aDrawable
, SalX11Screen nXScreen
);
79 void Init( X11SalVirtualDevice
*pVirtualDevice
, SalColormap
* pColormap
= NULL
, bool bDeleteColormap
= false );
80 void Init( X11OpenGLSalVirtualDevice
*pVirtualDevice
);
83 virtual SalGraphicsImpl
* GetImpl() const override
;
84 inline const SalDisplay
* GetDisplay() const;
85 inline Display
* GetXDisplay() const;
86 inline const SalVisual
& GetVisual() const;
87 SalGeometryProvider
* GetGeometryProvider() const;
88 inline Drawable
GetDrawable() const { return hDrawable_
; }
89 void SetDrawable( Drawable d
, SalX11Screen nXScreen
);
90 XRenderPictFormat
* GetXRenderFormat() const;
91 inline void SetXRenderFormat( XRenderPictFormat
* pXRenderFormat
) { m_pXRenderFormat
= pXRenderFormat
; }
92 inline const SalColormap
& GetColormap() const { return *m_pColormap
; }
94 using SalGraphics::GetPixel
;
95 inline Pixel
GetPixel( SalColor nSalColor
) const;
97 const SalX11Screen
& GetScreenNumber() const { return m_nXScreen
; }
99 // override all pure virtual methods
100 virtual void GetResolution( sal_Int32
& rDPIX
, sal_Int32
& rDPIY
) override
;
101 virtual sal_uInt16
GetBitCount() const override
;
102 virtual long GetGraphicsWidth() const override
;
104 virtual void ResetClipRegion() override
;
105 virtual bool setClipRegion( const vcl::Region
& ) override
;
107 virtual void SetLineColor() override
;
108 virtual void SetLineColor( SalColor nSalColor
) override
;
109 virtual void SetFillColor() override
;
111 virtual void SetFillColor( SalColor nSalColor
) override
;
113 virtual void SetXORMode( bool bSet
, bool ) override
;
115 virtual void SetROPLineColor( SalROPColor nROPColor
) override
;
116 virtual void SetROPFillColor( SalROPColor nROPColor
) override
;
118 virtual void SetTextColor( SalColor nSalColor
) override
;
119 virtual void SetFont( FontSelectPattern
*, int nFallbackLevel
) override
;
120 virtual void GetFontMetric( ImplFontMetricDataPtr
&, int nFallbackLevel
) override
;
121 virtual const FontCharMapPtr
GetFontCharMap() const override
;
122 virtual bool GetFontCapabilities(vcl::FontCapabilities
&rFontCapabilities
) const override
;
123 virtual void GetDevFontList( PhysicalFontCollection
* ) override
;
124 virtual void ClearDevFontCache() override
;
125 virtual bool AddTempDevFont( PhysicalFontCollection
*, const OUString
& rFileURL
, const OUString
& rFontName
) override
;
127 virtual bool CreateFontSubset(
128 const OUString
& rToFile
,
129 const PhysicalFontFace
*,
130 const sal_GlyphId
* pGlyphIDs
,
131 const sal_uInt8
* pEncoding
,
134 FontSubsetInfo
& rInfo
) override
;
136 virtual const Ucs2SIntMap
* GetFontEncodingVector( const PhysicalFontFace
*, const Ucs2OStrMap
** ppNonEncoded
, std::set
<sal_Unicode
> const**) override
;
138 virtual const void* GetEmbedFontData(
139 const PhysicalFontFace
*,
140 const sal_Ucs
* pUnicodes
,
143 FontSubsetInfo
& rInfo
,
144 long* pDataLen
) override
;
146 virtual void FreeEmbedFontData( const void* pData
, long nDataLen
) override
;
148 virtual void GetGlyphWidths(
149 const PhysicalFontFace
*,
151 Int32Vector
& rWidths
,
152 Ucs2UIntMap
& rUnicodeEnc
) override
;
154 virtual bool GetGlyphBoundRect( sal_GlyphId nIndex
, Rectangle
& ) override
;
155 virtual bool GetGlyphOutline( sal_GlyphId nIndex
, basegfx::B2DPolyPolygon
& ) override
;
156 virtual SalLayout
* GetTextLayout( ImplLayoutArgs
&, int nFallbackLevel
) override
;
157 virtual void DrawServerFontLayout( const ServerFontLayout
& ) override
;
159 virtual bool supportsOperation( OutDevSupportType
) const override
;
160 virtual void drawPixel( long nX
, long nY
) override
;
161 virtual void drawPixel( long nX
, long nY
, SalColor nSalColor
) override
;
162 virtual void drawLine( long nX1
, long nY1
, long nX2
, long nY2
) override
;
163 virtual void drawRect( long nX
, long nY
, long nWidth
, long nHeight
) override
;
164 virtual void drawPolyLine( sal_uInt32 nPoints
, const SalPoint
* pPtAry
) override
;
165 virtual void drawPolygon( sal_uInt32 nPoints
, const SalPoint
* pPtAry
) override
;
167 virtual void drawPolyPolygon(
169 const sal_uInt32
* pPoints
,
170 PCONSTSALPOINT
* pPtAry
) override
;
172 virtual bool drawPolyPolygon( const basegfx::B2DPolyPolygon
&, double fTransparency
) override
;
174 virtual bool drawPolyLine(
175 const basegfx::B2DPolygon
&,
176 double fTransparency
,
177 const basegfx::B2DVector
& rLineWidth
,
178 basegfx::B2DLineJoin
,
179 css::drawing::LineCap
,
180 double fMiterMinimumAngle
) override
;
182 virtual bool drawGradient( const tools::PolyPolygon
&, const Gradient
& ) override
;
184 #if 1 // TODO: remove these obsolete methods
185 virtual bool drawPolyLineBezier(
187 const SalPoint
* pPtAry
,
188 const sal_uInt8
* pFlgAry
) override
;
190 virtual bool drawPolygonBezier(
192 const SalPoint
* pPtAry
,
193 const sal_uInt8
* pFlgAry
) override
;
195 virtual bool drawPolyPolygonBezier(
197 const sal_uInt32
* pPoints
,
198 const SalPoint
* const* pPtAry
,
199 const sal_uInt8
* const* pFlgAry
) override
;
202 virtual void copyArea(
209 bool bWindowInvalidate
) override
;
211 virtual void copyBits(
212 const SalTwoRect
& rPosAry
,
213 SalGraphics
* pSrcGraphics
) override
;
215 virtual void drawBitmap(
216 const SalTwoRect
& rPosAry
,
217 const SalBitmap
& rSalBitmap
) override
;
219 virtual void drawBitmap(
220 const SalTwoRect
& rPosAry
,
221 const SalBitmap
& rSalBitmap
,
222 const SalBitmap
& rMaskBitmap
) override
;
224 virtual void drawMask(
225 const SalTwoRect
& rPosAry
,
226 const SalBitmap
& rSalBitmap
,
227 SalColor nMaskColor
) override
;
229 virtual SalBitmap
* getBitmap( long nX
, long nY
, long nWidth
, long nHeight
) override
;
230 virtual SalColor
getPixel( long nX
, long nY
) override
;
231 virtual void invert( long nX
, long nY
, long nWidth
, long nHeight
, SalInvert nFlags
) override
;
232 virtual void invert( sal_uInt32 nPoints
, const SalPoint
* pPtAry
, SalInvert nFlags
) override
;
234 virtual bool drawEPS( long nX
, long nY
, long nWidth
, long nHeight
, void* pPtr
, sal_uIntPtr nSize
) override
;
236 virtual bool blendBitmap(
238 const SalBitmap
& rBitmap
) override
;
240 virtual bool blendAlphaBitmap(
242 const SalBitmap
& rSrcBitmap
,
243 const SalBitmap
& rMaskBitmap
,
244 const SalBitmap
& rAlphaBitmap
) override
;
246 virtual bool drawAlphaBitmap(
248 const SalBitmap
& rSourceBitmap
,
249 const SalBitmap
& rAlphaBitmap
) override
;
251 virtual bool drawTransformedBitmap(
252 const basegfx::B2DPoint
& rNull
,
253 const basegfx::B2DPoint
& rX
,
254 const basegfx::B2DPoint
& rY
,
255 const SalBitmap
& rSourceBitmap
,
256 const SalBitmap
* pAlphaBitmap
) override
;
258 virtual bool drawAlphaRect(
259 long nX
, long nY
, long nWidth
,
260 long nHeight
, sal_uInt8 nTransparency
) override
;
262 virtual SystemGraphicsData
GetGraphicsData() const override
;
263 virtual bool SupportsCairo() const override
;
264 virtual cairo::SurfaceSharedPtr
CreateSurface(const cairo::CairoSurfaceSharedPtr
& rSurface
) const override
;
265 virtual cairo::SurfaceSharedPtr
CreateSurface(const OutputDevice
& rRefDevice
, int x
, int y
, int width
, int height
) const override
;
266 virtual cairo::SurfaceSharedPtr
CreateBitmapSurface(const OutputDevice
& rRefDevice
, const BitmapSystemData
& rData
, const Size
& rSize
) const override
;
267 virtual css::uno::Any
GetNativeSurfaceHandle(cairo::SurfaceSharedPtr
& rSurface
, const basegfx::B2ISize
& rSize
) const override
;
268 virtual SystemFontData
GetSysFontData( int nFallbackLevel
) const override
;
270 bool TryRenderCachedNativeControl(ControlCacheKey
& aControlCacheKey
,
273 bool RenderAndCacheNativeControl(X11Pixmap
* pPixmap
, X11Pixmap
* pMask
, int nX
, int nY
,
274 ControlCacheKey
& aControlCacheKey
);
276 // fill a pixmap from a screen region
277 void FillPixmapFromScreen( X11Pixmap
* pPixmap
, int nX
, int nY
);
279 // render a pixmap to the screen
280 bool RenderPixmapToScreen( X11Pixmap
* pPixmap
, X11Pixmap
* pMask
, int nX
, int nY
);
283 /* use to handle GraphicsExpose/NoExpose after XCopyArea & friends
284 * if pFrame is not NULL, corresponding Paint events are generated
285 * and dispatched to pFrame
287 * it is imperative to eat up graphics exposes even in case you don't need
288 * them because the next one using XCopyArea can depend on them
290 void YieldGraphicsExpose();
292 cairo_t
* getCairoContext();
293 static void releaseCairoContext(cairo_t
* cr
);
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
;
318 void freeResources();
321 SalFrame
* m_pFrame
; // the SalFrame which created this Graphics or NULL
322 SalVirtualDevice
* m_pVDev
; // the SalVirtualDevice which created this Graphics or NULL
324 const SalColormap
* m_pColormap
;
325 SalColormap
* m_pDeleteColormap
;
326 Drawable hDrawable_
; // use
327 SalX11Screen m_nXScreen
;
328 mutable XRenderPictFormat
* m_pXRenderFormat
;
329 XID m_aXRenderPicture
;
331 Region pPaintRegion_
;
334 GC pFontGC_
; // Font attributes
337 Pixmap hBrush_
; // Dither
339 bool bWindow_
: 1; // is Window
340 bool bPrinter_
: 1; // is Printer
341 bool bVirDev_
: 1; // is VirDev
342 bool bFontGC_
: 1; // is Font GC valid
345 std::unique_ptr
<SalGraphicsImpl
> mxImpl
;
346 std::unique_ptr
<TextRenderImpl
> mxTextRenderImpl
;
350 inline const SalDisplay
*X11SalGraphics::GetDisplay() const
351 { return GetColormap().GetDisplay(); }
353 inline const SalVisual
& X11SalGraphics::GetVisual() const
354 { return GetColormap().GetVisual(); }
356 inline Display
*X11SalGraphics::GetXDisplay() const
357 { return GetColormap().GetXDisplay(); }
359 inline Pixel
X11SalGraphics::GetPixel( SalColor nSalColor
) const
360 { return GetColormap().GetPixel( nSalColor
); }
362 #endif // INCLUDED_VCL_INC_UNX_SALGDI_H
364 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */