bump product version to 6.4.0.3
[LibreOffice.git] / vcl / inc / unx / salgdi.h
blobd2bbeeb128af35eaf34a6a689e7abb2f7b835b80
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
23 #include <X11/Xlib.h>
24 #include <X11/Xutil.h>
25 #include <X11/extensions/Xrender.h>
27 #include <vcl/salgtype.hxx>
28 #include <vcl/vclenum.hxx>
30 #include <unx/saldisp.hxx>
31 #include <salgdi.hxx>
32 #include <salgeom.hxx>
33 #include <sallayout.hxx>
34 #include <vclpluginapi.h>
35 #include <ControlCacheKey.hxx>
37 #include <memory>
39 /* From <X11/Intrinsic.h> */
40 typedef unsigned long Pixel;
42 class FontAttributes;
43 class FontSelectPattern;
44 class SalBitmap;
45 class SalColormap;
46 class SalDisplay;
47 class SalFrame;
48 class X11Pixmap;
49 class X11SalVirtualDevice;
50 class X11SalGraphicsImpl;
51 class X11OpenGLSalGraphicsImpl;
52 class X11OpenGLSalVirtualDevice;
53 class FreetypeFont;
54 class ImplLayoutArgs;
55 class PhysicalFontCollection;
56 class PhysicalFontFace;
57 class SalGraphicsImpl;
58 class TextRenderImpl;
60 namespace basegfx {
61 class B2DTrapezoid;
64 class VCLPLUG_GEN_PUBLIC X11SalGraphics : public SalGraphics
66 friend class X11SalGraphicsImpl;
67 friend class X11OpenGLSalGraphicsImpl;
68 friend class X11CairoTextRender;
70 public:
71 X11SalGraphics();
72 virtual ~X11SalGraphics() COVERITY_NOEXCEPT_FALSE override;
74 void Init( SalFrame *pFrame, Drawable aDrawable, SalX11Screen nXScreen );
75 void Init( X11SalVirtualDevice *pVirtualDevice, SalColormap* pColormap = nullptr, bool bDeleteColormap = false );
76 void Init( X11OpenGLSalVirtualDevice *pVirtualDevice );
77 void DeInit();
79 virtual SalGraphicsImpl* GetImpl() const override;
80 inline const SalDisplay* GetDisplay() const;
81 inline Display* GetXDisplay() const;
82 inline const SalVisual& GetVisual() const;
83 SalGeometryProvider* GetGeometryProvider() const;
84 Drawable GetDrawable() const { return hDrawable_; }
85 void SetDrawable( Drawable d, SalX11Screen nXScreen );
86 XRenderPictFormat* GetXRenderFormat() const;
87 void SetXRenderFormat( XRenderPictFormat* pXRenderFormat ) { m_pXRenderFormat = pXRenderFormat; }
88 const SalColormap& GetColormap() const { return *m_pColormap; }
90 using SalGraphics::GetPixel;
91 inline Pixel GetPixel( Color nColor ) const;
93 const SalX11Screen& GetScreenNumber() const { return m_nXScreen; }
95 // override all pure virtual methods
96 virtual void GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) override;
97 virtual sal_uInt16 GetBitCount() const override;
98 virtual long GetGraphicsWidth() const override;
100 virtual void ResetClipRegion() override;
101 virtual bool setClipRegion( const vcl::Region& ) override;
103 virtual void SetLineColor() override;
104 virtual void SetLineColor( Color nColor ) override;
105 virtual void SetFillColor() override;
107 virtual void SetFillColor( Color nColor ) override;
109 virtual void SetXORMode( bool bSet, bool ) override;
111 virtual void SetROPLineColor( SalROPColor nROPColor ) override;
112 virtual void SetROPFillColor( SalROPColor nROPColor ) override;
114 virtual void SetTextColor( Color nColor ) override;
115 virtual void SetFont(LogicalFontInstance*, int nFallbackLevel) override;
116 virtual void GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) override;
117 virtual FontCharMapRef GetFontCharMap() const override;
118 virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const override;
119 virtual void GetDevFontList( PhysicalFontCollection* ) override;
120 virtual void ClearDevFontCache() override;
121 virtual bool AddTempDevFont( PhysicalFontCollection*, const OUString& rFileURL, const OUString& rFontName ) override;
123 virtual bool CreateFontSubset(
124 const OUString& rToFile,
125 const PhysicalFontFace*,
126 const sal_GlyphId* pGlyphIDs,
127 const sal_uInt8* pEncoding,
128 sal_Int32* pWidths,
129 int nGlyphs,
130 FontSubsetInfo& rInfo ) override;
132 virtual const void* GetEmbedFontData(const PhysicalFontFace*, long* pDataLen) override;
133 virtual void FreeEmbedFontData( const void* pData, long nDataLen ) override;
135 virtual void GetGlyphWidths(
136 const PhysicalFontFace*,
137 bool bVertical,
138 std::vector< sal_Int32 >& rWidths,
139 Ucs2UIntMap& rUnicodeEnc ) override;
141 virtual std::unique_ptr<GenericSalLayout>
142 GetTextLayout(int nFallbackLevel) override;
143 virtual void DrawTextLayout( const GenericSalLayout& ) override;
145 virtual bool supportsOperation( OutDevSupportType ) const override;
146 virtual void drawPixel( long nX, long nY ) override;
147 virtual void drawPixel( long nX, long nY, Color nColor ) override;
148 virtual void drawLine( long nX1, long nY1, long nX2, long nY2 ) override;
149 virtual void drawRect( long nX, long nY, long nWidth, long nHeight ) override;
150 virtual void drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry ) override;
151 virtual void drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ) override;
153 virtual void drawPolyPolygon(
154 sal_uInt32 nPoly,
155 const sal_uInt32* pPoints,
156 PCONSTSALPOINT* pPtAry ) override;
158 virtual bool drawPolyPolygon(
159 const basegfx::B2DHomMatrix& rObjectToDevice,
160 const basegfx::B2DPolyPolygon&,
161 double fTransparency) override;
163 virtual bool drawPolyLine(
164 const basegfx::B2DHomMatrix& rObjectToDevice,
165 const basegfx::B2DPolygon&,
166 double fTransparency,
167 const basegfx::B2DVector& rLineWidth,
168 basegfx::B2DLineJoin,
169 css::drawing::LineCap,
170 double fMiterMinimumAngle,
171 bool bPixelSnapHairline) override;
173 virtual bool drawGradient( const tools::PolyPolygon&, const Gradient& ) override;
175 #if 1 // TODO: remove these obsolete methods
176 virtual bool drawPolyLineBezier(
177 sal_uInt32 nPoints,
178 const SalPoint* pPtAry,
179 const PolyFlags* pFlgAry ) override;
181 virtual bool drawPolygonBezier(
182 sal_uInt32 nPoints,
183 const SalPoint* pPtAry,
184 const PolyFlags* pFlgAry ) override;
186 virtual bool drawPolyPolygonBezier(
187 sal_uInt32 nPoly,
188 const sal_uInt32* pPoints,
189 const SalPoint* const* pPtAry,
190 const PolyFlags* const* pFlgAry ) override;
191 #endif
193 virtual void copyArea(
194 long nDestX,
195 long nDestY,
196 long nSrcX,
197 long nSrcY,
198 long nSrcWidth,
199 long nSrcHeight,
200 bool bWindowInvalidate ) override;
202 virtual void copyBits(
203 const SalTwoRect& rPosAry,
204 SalGraphics* pSrcGraphics ) override;
206 virtual void drawBitmap(
207 const SalTwoRect& rPosAry,
208 const SalBitmap& rSalBitmap ) override;
210 virtual void drawBitmap(
211 const SalTwoRect& rPosAry,
212 const SalBitmap& rSalBitmap,
213 const SalBitmap& rMaskBitmap ) override;
215 virtual void drawMask(
216 const SalTwoRect& rPosAry,
217 const SalBitmap& rSalBitmap,
218 Color nMaskColor ) override;
220 virtual std::shared_ptr<SalBitmap> getBitmap( long nX, long nY, long nWidth, long nHeight ) override;
221 virtual Color getPixel( long nX, long nY ) override;
222 virtual void invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags ) override;
223 virtual void invert( sal_uInt32 nPoints, const SalPoint* pPtAry, SalInvert nFlags ) override;
225 virtual bool drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uInt32 nSize ) override;
227 virtual bool blendBitmap(
228 const SalTwoRect&,
229 const SalBitmap& rBitmap ) override;
231 virtual bool blendAlphaBitmap(
232 const SalTwoRect&,
233 const SalBitmap& rSrcBitmap,
234 const SalBitmap& rMaskBitmap,
235 const SalBitmap& rAlphaBitmap ) override;
237 virtual bool drawAlphaBitmap(
238 const SalTwoRect&,
239 const SalBitmap& rSourceBitmap,
240 const SalBitmap& rAlphaBitmap ) override;
242 virtual bool drawTransformedBitmap(
243 const basegfx::B2DPoint& rNull,
244 const basegfx::B2DPoint& rX,
245 const basegfx::B2DPoint& rY,
246 const SalBitmap& rSourceBitmap,
247 const SalBitmap* pAlphaBitmap) override;
249 virtual bool drawAlphaRect(
250 long nX, long nY, long nWidth,
251 long nHeight, sal_uInt8 nTransparency ) override;
253 virtual SystemGraphicsData GetGraphicsData() const override;
255 #if ENABLE_CAIRO_CANVAS
256 virtual bool SupportsCairo() const override;
257 virtual cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const override;
258 virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y, int width, int height) const override;
259 virtual cairo::SurfaceSharedPtr CreateBitmapSurface(const OutputDevice& rRefDevice, const BitmapSystemData& rData, const Size& rSize) const override;
260 virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize) const override;
261 virtual SystemFontData GetSysFontData( int nFallbackLevel ) const override;
263 void clipRegion(cairo_t* cr);
264 #endif // ENABLE_CAIRO_CANVAS
266 /* use to handle GraphicsExpose/NoExpose after XCopyArea & friends
267 * if pFrame is not NULL, corresponding Paint events are generated
268 * and dispatched to pFrame
270 * it is imperative to eat up graphics exposes even in case you don't need
271 * them because the next one using XCopyArea can depend on them
273 void YieldGraphicsExpose();
275 cairo_t* getCairoContext();
276 static void releaseCairoContext(cairo_t* cr);
279 protected:
280 using SalGraphics::SetClipRegion;
281 void SetClipRegion( GC pGC, Region pXReg = nullptr ) const;
282 bool GetDitherPixmap ( Color nColor );
284 using SalGraphics::DrawBitmap;
286 void freeResources();
288 protected:
289 SalFrame* m_pFrame; // the SalFrame which created this Graphics or NULL
290 SalVirtualDevice* m_pVDev; // the SalVirtualDevice which created this Graphics or NULL
292 const SalColormap* m_pColormap;
293 std::unique_ptr<SalColormap> m_pDeleteColormap;
294 Drawable hDrawable_; // use
295 SalX11Screen m_nXScreen;
296 mutable XRenderPictFormat* m_pXRenderFormat;
297 XID m_aXRenderPicture;
299 Region mpClipRegion;
300 #if ENABLE_CAIRO_CANVAS
301 vcl::Region maClipRegion;
302 Color mnPenColor;
303 Color mnFillColor;
304 #endif // ENABLE_CAIRO_CANVAS
306 Pixel nTextPixel_;
308 Pixmap hBrush_; // Dither
310 bool bWindow_ : 1; // is Window
311 bool bVirDev_ : 1; // is VirDev
312 bool const m_bOpenGL : 1;
314 private:
315 std::unique_ptr<SalGraphicsImpl> mxImpl;
316 std::unique_ptr<TextRenderImpl> mxTextRenderImpl;
320 inline const SalDisplay *X11SalGraphics::GetDisplay() const
321 { return GetColormap().GetDisplay(); }
323 inline const SalVisual& X11SalGraphics::GetVisual() const
324 { return GetColormap().GetVisual(); }
326 inline Display *X11SalGraphics::GetXDisplay() const
327 { return GetColormap().GetXDisplay(); }
329 inline Pixel X11SalGraphics::GetPixel( Color nColor ) const
330 { return GetColormap().GetPixel( nColor ); }
332 #endif // INCLUDED_VCL_INC_UNX_SALGDI_H
334 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */