/src/libreoffice/vcl/inc/salgdi.hxx
Line | Count | Source |
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 | | #pragma once |
21 | | |
22 | | #include <sal/config.h> |
23 | | |
24 | | #include <vcl/outdev.hxx> |
25 | | #include <config_vclplug.h> |
26 | | |
27 | | #include "font/FontMetricData.hxx" |
28 | | #include "salgdiimpl.hxx" |
29 | | #include "sallayout.hxx" |
30 | | #include "SalGradient.hxx" |
31 | | #include <basegfx/matrix/b2dhommatrix.hxx> |
32 | | #include "WidgetDrawInterface.hxx" |
33 | | |
34 | | #include <config_cairo_canvas.h> |
35 | | |
36 | | #include <vector> |
37 | | |
38 | | class SalBitmap; |
39 | | namespace vcl::font { |
40 | | class PhysicalFontCollection; |
41 | | } |
42 | | namespace tools { class Rectangle; } |
43 | | struct SystemGraphicsData; |
44 | | |
45 | | namespace basegfx { |
46 | | class B2DPolygon; |
47 | | class B2DPolyPolygon; |
48 | | } |
49 | | |
50 | | namespace vcl |
51 | | { |
52 | | class FileDefinitionWidgetDraw; |
53 | | } |
54 | | |
55 | | typedef sal_Unicode sal_Ucs; // TODO: use sal_UCS4 instead of sal_Unicode |
56 | | |
57 | | // note: if you add any new methods to class SalGraphics using coordinates |
58 | | // make sure they have a corresponding protected pure virtual method |
59 | | // which has to be implemented by the platform dependent part. |
60 | | // Add a method that performs coordinate mirroring if required, (see |
61 | | // existing methods as sample) and then calls the equivalent pure method. |
62 | | |
63 | | // note: all positions are in pixel and relative to |
64 | | // the top/left-position of the virtual output area |
65 | | |
66 | | class VCL_PLUGIN_PUBLIC SalGraphics : protected vcl::WidgetDrawInterface |
67 | | { |
68 | | public: |
69 | | SalGraphics(); |
70 | | ~SalGraphics() override; |
71 | | |
72 | | virtual SalGraphicsImpl* GetImpl() const = 0; |
73 | | |
74 | | void setAntiAlias(bool bNew) |
75 | 676k | { |
76 | 676k | m_bAntiAlias = bNew; |
77 | | |
78 | | // Temporary store in both |
79 | 676k | if (GetImpl()) |
80 | 676k | GetImpl()->setAntiAlias(bNew); |
81 | 676k | } |
82 | | |
83 | | bool getAntiAlias() const |
84 | 53.1k | { |
85 | 53.1k | return m_bAntiAlias; |
86 | 53.1k | } |
87 | | |
88 | | // public SalGraphics methods, the interface to the independent vcl part |
89 | | |
90 | | // get device resolution |
91 | | virtual void GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) = 0; |
92 | | |
93 | | // get the depth of the device |
94 | | virtual sal_uInt16 GetBitCount() const = 0; |
95 | | |
96 | | // get the width of the device |
97 | | virtual tools::Long GetGraphicsWidth() const = 0; |
98 | | |
99 | | // set the clip region to empty |
100 | | virtual void ResetClipRegion() = 0; |
101 | | |
102 | | // set the line color to transparent (= don't draw lines) |
103 | | |
104 | | virtual void SetLineColor() = 0; |
105 | | |
106 | | // set the line color to a specific color |
107 | | virtual void SetLineColor( Color nColor ) = 0; |
108 | | |
109 | | // set the fill color to transparent (= don't fill) |
110 | | virtual void SetFillColor() = 0; |
111 | | |
112 | | // set the fill color to a specific color, shapes will be |
113 | | // filled accordingly |
114 | | virtual void SetFillColor( Color nColor ) = 0; |
115 | | |
116 | | // enable/disable XOR drawing |
117 | | virtual void SetXORMode( bool bSet, bool bInvertOnly ) = 0; |
118 | | |
119 | | // set line color for raster operations |
120 | | virtual void SetROPLineColor( SalROPColor nROPColor ) = 0; |
121 | | |
122 | | // set fill color for raster operations |
123 | | virtual void SetROPFillColor( SalROPColor nROPColor ) = 0; |
124 | | |
125 | | // set the text color to a specific color |
126 | | virtual void SetTextColor( Color nColor ) = 0; |
127 | | |
128 | | // set the font |
129 | | virtual void SetFont(LogicalFontInstance*, int nFallbackLevel) = 0; |
130 | | |
131 | | // release the fonts |
132 | 1.33M | void ReleaseFonts() { SetFont( nullptr, 0 ); } |
133 | | |
134 | | // get the current font's metrics |
135 | | virtual void GetFontMetric( FontMetricDataRef&, int nFallbackLevel ) = 0; |
136 | | |
137 | | // get the repertoire of the current font |
138 | | virtual FontCharMapRef GetFontCharMap() const = 0; |
139 | | |
140 | | // get the layout capabilities of the current font |
141 | | virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const = 0; |
142 | | |
143 | | // graphics must fill supplied font list |
144 | | virtual void GetDevFontList( vcl::font::PhysicalFontCollection* ) = 0; |
145 | | |
146 | | // graphics must drop any cached font info |
147 | | virtual void ClearDevFontCache() = 0; |
148 | | |
149 | | virtual bool AddTempDevFont( |
150 | | vcl::font::PhysicalFontCollection*, |
151 | | const OUString& rFileURL, |
152 | | const OUString& rFontName ) = 0; |
153 | | |
154 | | // Returns true, when the font was unregistered, and its file can be safely deleted |
155 | | virtual bool RemoveTempDevFont(const OUString& rFileURL, |
156 | | const OUString& rFontName) = 0; |
157 | | |
158 | | virtual std::unique_ptr<GenericSalLayout> |
159 | | GetTextLayout(int nFallbackLevel) = 0; |
160 | | virtual void DrawTextLayout( const GenericSalLayout& ) = 0; |
161 | 0 | virtual void DrawSalLayout(const GenericSalLayout&, void*, const basegfx::BColor&, bool ) const {} |
162 | | |
163 | | virtual bool supportsOperation( OutDevSupportType ) const = 0; |
164 | | |
165 | | // mirroring specifics |
166 | 216k | SalLayoutFlags GetLayout() const { return m_nLayout; } |
167 | 12.8k | void SetLayout( SalLayoutFlags aLayout ) { m_nLayout = aLayout;} |
168 | | |
169 | | SAL_DLLPRIVATE void mirror( tools::Long& nX, const OutputDevice& rOutDev ) const; |
170 | | // only called mirror2 to avoid ambiguity |
171 | | [[nodiscard]] SAL_DLLPRIVATE tools::Long mirror2( tools::Long nX, const OutputDevice& rOutDev ) const; |
172 | | SAL_DLLPRIVATE void mirror( tools::Long& nX, tools::Long nWidth, const OutputDevice& rOutDev, bool bBack = false ) const; |
173 | | SAL_DLLPRIVATE bool mirror( sal_uInt32 nPoints, const Point *pPtAry, Point *pPtAry2, const OutputDevice& rOutDev ) const; |
174 | | SAL_DLLPRIVATE void mirror( tools::Rectangle& rRect, const OutputDevice&, bool bBack = false ) const; |
175 | | SAL_DLLPRIVATE void mirror( vcl::Region& rRgn, const OutputDevice& rOutDev ) const; |
176 | | SAL_DLLPRIVATE void mirror( ImplControlValue&, const OutputDevice& ) const; |
177 | | SAL_DLLPRIVATE basegfx::B2DPolyPolygon mirror( const basegfx::B2DPolyPolygon& i_rPoly, const OutputDevice& rOutDev ) const; |
178 | | SAL_DLLPRIVATE const basegfx::B2DHomMatrix& getMirror( const OutputDevice& rOutDev ) const; |
179 | | |
180 | | // non virtual methods; these do possible coordinate mirroring and |
181 | | // then delegate to protected virtual methods |
182 | | SAL_DLLPRIVATE void SetClipRegion( const vcl::Region&, const OutputDevice& rOutDev ); |
183 | | |
184 | | // draw --> LineColor and FillColor and RasterOp and ClipRegion |
185 | | SAL_DLLPRIVATE void DrawPixel( tools::Long nX, tools::Long nY, const OutputDevice& rOutDev ); |
186 | | SAL_DLLPRIVATE void DrawPixel( tools::Long nX, tools::Long nY, Color nColor, const OutputDevice& rOutDev ); |
187 | | |
188 | | SAL_DLLPRIVATE void DrawLine( tools::Long nX1, tools::Long nY1, tools::Long nX2, tools::Long nY2, const OutputDevice& rOutDev ); |
189 | | |
190 | | SAL_DLLPRIVATE void DrawRect( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, const OutputDevice& rOutDev ); |
191 | | |
192 | | SAL_DLLPRIVATE void DrawPolyLine( sal_uInt32 nPoints, Point const * pPtAry, const OutputDevice& rOutDev ); |
193 | | |
194 | | SAL_DLLPRIVATE void DrawPolygon( sal_uInt32 nPoints, const Point* pPtAry, const OutputDevice& rOutDev ); |
195 | | |
196 | | SAL_DLLPRIVATE void DrawPolyPolygon( |
197 | | sal_uInt32 nPoly, |
198 | | const sal_uInt32* pPoints, |
199 | | const Point** pPtAry, |
200 | | const OutputDevice& rOutDev ); |
201 | | |
202 | | SAL_DLLPRIVATE void DrawPolyPolygon( |
203 | | const basegfx::B2DHomMatrix& rObjectToDevice, |
204 | | const basegfx::B2DPolyPolygon &i_rPolyPolygon, |
205 | | double i_fTransparency, |
206 | | const OutputDevice& i_rOutDev); |
207 | | |
208 | | SAL_DLLPRIVATE bool DrawPolyLine( |
209 | | const basegfx::B2DHomMatrix& rObjectToDevice, |
210 | | const basegfx::B2DPolygon& i_rPolygon, |
211 | | double i_fTransparency, |
212 | | double i_fLineWidth, |
213 | | const std::vector< double >* i_pStroke, // MM01 |
214 | | basegfx::B2DLineJoin i_eLineJoin, |
215 | | css::drawing::LineCap i_eLineCap, |
216 | | double i_fMiterMinimumAngle, |
217 | | bool bPixelSnapHairline, |
218 | | const OutputDevice& i_rOutDev); |
219 | | |
220 | | SAL_DLLPRIVATE bool DrawPolyLineBezier( |
221 | | sal_uInt32 nPoints, |
222 | | const Point* pPtAry, |
223 | | const PolyFlags* pFlgAry, |
224 | | const OutputDevice& rOutDev ); |
225 | | |
226 | | SAL_DLLPRIVATE bool DrawPolygonBezier( |
227 | | sal_uInt32 nPoints, |
228 | | const Point* pPtAry, |
229 | | const PolyFlags* pFlgAry, |
230 | | const OutputDevice& rOutDev ); |
231 | | |
232 | | SAL_DLLPRIVATE bool DrawPolyPolygonBezier( |
233 | | sal_uInt32 nPoly, |
234 | | const sal_uInt32* pPoints, |
235 | | const Point* const* pPtAry, |
236 | | const PolyFlags* const* pFlgAry, |
237 | | const OutputDevice& rOutDev ); |
238 | | |
239 | | SAL_DLLPRIVATE bool DrawGradient( |
240 | | const tools::PolyPolygon& rPolyPoly, |
241 | | const Gradient& rGradient, |
242 | | const OutputDevice& rOutDev); |
243 | | |
244 | | // CopyArea --> No RasterOp, but ClipRegion |
245 | | void CopyArea( |
246 | | tools::Long nDestX, tools::Long nDestY, |
247 | | tools::Long nSrcX, tools::Long nSrcY, |
248 | | tools::Long nSrcWidth, tools::Long nSrcHeight, |
249 | | const OutputDevice& rOutDev ); |
250 | | |
251 | | // CopyBits --> RasterOp and ClipRegion |
252 | | // CopyBits() CopyBits on same Graphics |
253 | | SAL_DLLPRIVATE void CopyBits( |
254 | | const SalTwoRect& rPosAry, |
255 | | const OutputDevice& rOutDev); |
256 | | |
257 | | // CopyBits --> RasterOp and ClipRegion |
258 | | // CopyBits() CopyBits on different Graphics |
259 | | void CopyBits( |
260 | | const SalTwoRect& rPosAry, |
261 | | SalGraphics& rSrcGraphics, |
262 | | const OutputDevice& rOutDev, |
263 | | const OutputDevice& rSrcOutDev ); |
264 | | |
265 | | |
266 | | SAL_DLLPRIVATE void DrawBitmap( |
267 | | const SalTwoRect& rPosAry, |
268 | | const SalBitmap& rSalBitmap, |
269 | | const OutputDevice& rOutDev ); |
270 | | |
271 | | SAL_DLLPRIVATE void DrawMask( |
272 | | const SalTwoRect& rPosAry, |
273 | | const SalBitmap& rSalBitmap, |
274 | | Color nMaskColor, |
275 | | const OutputDevice& rOutDev ); |
276 | | |
277 | | SAL_DLLPRIVATE std::shared_ptr<SalBitmap> GetBitmap( |
278 | | tools::Long nX, tools::Long nY, |
279 | | tools::Long nWidth, tools::Long nHeight, |
280 | | const OutputDevice& rOutDev, |
281 | | bool bWithoutAlpha ); |
282 | | |
283 | | SAL_DLLPRIVATE Color GetPixel( |
284 | | tools::Long nX, tools::Long nY, |
285 | | const OutputDevice& rOutDev ); |
286 | | |
287 | | // invert --> ClipRegion (only Windows) |
288 | | SAL_DLLPRIVATE void Invert( |
289 | | tools::Long nX, tools::Long nY, |
290 | | tools::Long nWidth, tools::Long nHeight, |
291 | | SalInvert nFlags, |
292 | | const OutputDevice& rOutDev ); |
293 | | |
294 | | SAL_DLLPRIVATE void Invert( |
295 | | sal_uInt32 nPoints, |
296 | | const Point* pPtAry, |
297 | | SalInvert nFlags, |
298 | | const OutputDevice& rOutDev ); |
299 | | |
300 | | SAL_DLLPRIVATE bool DrawEPS( |
301 | | tools::Long nX, tools::Long nY, |
302 | | tools::Long nWidth, tools::Long nHeight, |
303 | | void* pPtr, |
304 | | sal_uInt32 nSize, |
305 | | const OutputDevice& rOutDev ); |
306 | | |
307 | | // native widget rendering functions |
308 | | |
309 | | /** |
310 | | * @see WidgetDrawInterface::isNativeControlSupported |
311 | | */ |
312 | | inline bool IsNativeControlSupported(ControlType, ControlPart); |
313 | | |
314 | | /** |
315 | | * @see WidgetDrawInterface::hitTestNativeControl |
316 | | */ |
317 | | SAL_DLLPRIVATE bool HitTestNativeScrollbar( |
318 | | ControlPart nPart, |
319 | | const tools::Rectangle& rControlRegion, |
320 | | const Point& aPos, |
321 | | bool& rIsInside, |
322 | | const OutputDevice& rOutDev); |
323 | | |
324 | | /** |
325 | | * @see WidgetDrawInterface::drawNativeControl |
326 | | */ |
327 | | SAL_DLLPRIVATE bool DrawNativeControl( |
328 | | ControlType nType, |
329 | | ControlPart nPart, |
330 | | const tools::Rectangle& rControlRegion, |
331 | | ControlState nState, |
332 | | const ImplControlValue& aValue, |
333 | | const OUString& aCaption, |
334 | | const OutputDevice& rOutDev, |
335 | | const Color& rBackgroundColor = COL_AUTO ); |
336 | | |
337 | | /** |
338 | | * @see WidgetDrawInterface::getNativeControlRegion |
339 | | */ |
340 | | SAL_DLLPRIVATE bool GetNativeControlRegion( |
341 | | ControlType nType, |
342 | | ControlPart nPart, |
343 | | const tools::Rectangle& rControlRegion, |
344 | | ControlState nState, |
345 | | const ImplControlValue& aValue, |
346 | | tools::Rectangle &rNativeBoundingRegion, |
347 | | tools::Rectangle &rNativeContentRegion, |
348 | | const OutputDevice& rOutDev ); |
349 | | |
350 | | /** |
351 | | * @see WidgetDrawInterface::updateSettings |
352 | | */ |
353 | | inline bool UpdateSettings(AllSettings&); |
354 | | |
355 | | SAL_DLLPRIVATE void DrawAlphaBitmap( |
356 | | const SalTwoRect&, |
357 | | const SalBitmap& rSourceBitmap, |
358 | | const OutputDevice& rOutDev ); |
359 | | |
360 | | SAL_DLLPRIVATE bool DrawTransformedBitmap( |
361 | | const basegfx::B2DPoint& rNull, |
362 | | const basegfx::B2DPoint& rX, |
363 | | const basegfx::B2DPoint& rY, |
364 | | const SalBitmap& rSourceBitmap, |
365 | | double fAlpha, |
366 | | const OutputDevice& rOutDev ); |
367 | | |
368 | | SAL_DLLPRIVATE bool HasFastDrawTransformedBitmap() const; |
369 | | |
370 | | SAL_DLLPRIVATE bool DrawAlphaRect( |
371 | | tools::Long nX, tools::Long nY, |
372 | | tools::Long nWidth, tools::Long nHeight, |
373 | | sal_uInt8 nTransparency, |
374 | | const OutputDevice& rOutDev ); |
375 | | |
376 | | /** fill/tile with given bitmap |
377 | | * |
378 | | * @returns true if successfully drawn, false if not able to draw |
379 | | */ |
380 | | virtual bool DrawBitmapWallpaper(tools::Long nStartX, tools::Long nStartY, tools::Long nRight, tools::Long nBottom, tools::Long nBmpWidth, tools::Long nBmpHeight, const SalBitmap& aBmp); |
381 | | |
382 | | SAL_DLLPRIVATE virtual OUString getRenderBackendName() const; |
383 | | |
384 | | virtual SystemGraphicsData GetGraphicsData() const = 0; |
385 | | #if USE_HEADLESS_CODE |
386 | 0 | virtual void ApplyFullDamage() const {} |
387 | | #endif |
388 | | |
389 | | // Backends like the svp/gtk ones use cairo and hidpi scale at the surface |
390 | | // but bitmaps aren't hidpi, so if this returns true for the case that the |
391 | | // surface is hidpi then pScaleOut contains the scaling factor. So we can |
392 | | // create larger hires bitmaps which we know will be logically scaled down |
393 | | // by this factor but physically just copied |
394 | | virtual bool ShouldDownscaleIconsAtSurface(double& rScaleOut) const; |
395 | | |
396 | | |
397 | | #if ENABLE_CAIRO_CANVAS |
398 | | |
399 | | // override these methods in subclasses in order to support Cairo |
400 | | /// Check whether cairo will work |
401 | | virtual bool SupportsCairo() const; |
402 | | /// Create Surface from given cairo surface |
403 | | virtual cairo::SurfaceSharedPtr |
404 | | CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const; |
405 | | /// Create surface with given dimensions |
406 | | virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y, |
407 | | int width, int height) const; |
408 | | /// Create Surface for given bitmap data |
409 | | virtual cairo::SurfaceSharedPtr CreateBitmapSurface(const OutputDevice& rRefDevice, |
410 | | const BitmapSystemData& rData, |
411 | | const Size& rSize) const; |
412 | | virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, |
413 | | const basegfx::B2ISize& rSize) const; |
414 | | |
415 | | #endif // ENABLE_CAIRO_CANVAS |
416 | | |
417 | | protected: |
418 | | |
419 | | friend class vcl::FileDefinitionWidgetDraw; |
420 | | |
421 | | virtual void setClipRegion( const vcl::Region& ) = 0; |
422 | | |
423 | | // draw --> LineColor and FillColor and RasterOp and ClipRegion |
424 | | virtual void drawPixel( tools::Long nX, tools::Long nY ) = 0; |
425 | | virtual void drawPixel( tools::Long nX, tools::Long nY, Color nColor ) = 0; |
426 | | |
427 | | virtual void drawLine( tools::Long nX1, tools::Long nY1, tools::Long nX2, tools::Long nY2 ) = 0; |
428 | | |
429 | | virtual void drawRect( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) = 0; |
430 | | |
431 | | virtual void drawPolyLine( sal_uInt32 nPoints, const Point* pPtAry ) = 0; |
432 | | |
433 | | virtual void drawPolygon( sal_uInt32 nPoints, const Point* pPtAry ) = 0; |
434 | | |
435 | | virtual void drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pPoints, const Point** pPtAry ) = 0; |
436 | | |
437 | | virtual void drawPolyPolygon( |
438 | | const basegfx::B2DHomMatrix& rObjectToDevice, |
439 | | const basegfx::B2DPolyPolygon&, |
440 | | double fTransparency) = 0; |
441 | | |
442 | | virtual bool drawPolyLine( |
443 | | const basegfx::B2DHomMatrix& rObjectToDevice, |
444 | | const basegfx::B2DPolygon&, |
445 | | double fTransparency, |
446 | | double fLineWidth, |
447 | | const std::vector< double >* pStroke, // MM01 |
448 | | basegfx::B2DLineJoin, |
449 | | css::drawing::LineCap, |
450 | | double fMiterMinimumAngle, |
451 | | bool bPixelSnapHairline) = 0; |
452 | | |
453 | | virtual bool drawPolyLineBezier( |
454 | | sal_uInt32 nPoints, |
455 | | const Point* pPtAry, |
456 | | const PolyFlags* pFlgAry ) = 0; |
457 | | |
458 | | virtual bool drawPolygonBezier( |
459 | | sal_uInt32 nPoints, |
460 | | const Point* pPtAry, |
461 | | const PolyFlags* pFlgAry ) = 0; |
462 | | |
463 | | virtual bool drawPolyPolygonBezier( |
464 | | sal_uInt32 nPoly, |
465 | | const sal_uInt32* pPoints, |
466 | | const Point* const* pPtAry, |
467 | | const PolyFlags* const* pFlgAry ) = 0; |
468 | | |
469 | | virtual bool drawGradient( |
470 | | const tools::PolyPolygon& rPolyPoly, |
471 | | const Gradient& rGradient ) = 0; |
472 | | |
473 | | virtual bool implDrawGradient(basegfx::B2DPolyPolygon const & /*rPolyPolygon*/, |
474 | | SalGradient const & /*rGradient*/) |
475 | 0 | { |
476 | 0 | return false; |
477 | 0 | } |
478 | | |
479 | | // CopyArea --> No RasterOp, but ClipRegion |
480 | | virtual void copyArea( |
481 | | tools::Long nDestX, tools::Long nDestY, |
482 | | tools::Long nSrcX, tools::Long nSrcY, |
483 | | tools::Long nSrcWidth, tools::Long nSrcHeight, |
484 | | bool bWindowInvalidate ) = 0; |
485 | | |
486 | | // CopyBits and DrawBitmap --> RasterOp and ClipRegion |
487 | | // CopyBits() --> pSrcGraphics == NULL, then CopyBits on same Graphics |
488 | | virtual void copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) = 0; |
489 | | |
490 | | virtual void drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap ) = 0; |
491 | | |
492 | | virtual void drawMask( |
493 | | const SalTwoRect& rPosAry, |
494 | | const SalBitmap& rSalBitmap, |
495 | | Color nMaskColor ) = 0; |
496 | | |
497 | | virtual std::shared_ptr<SalBitmap> getBitmap( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, bool bWithoutAlpha ) = 0; |
498 | | |
499 | | virtual Color getPixel( tools::Long nX, tools::Long nY ) = 0; |
500 | | |
501 | | // invert --> ClipRegion (only Windows or VirDevs) |
502 | | virtual void invert( |
503 | | tools::Long nX, tools::Long nY, |
504 | | tools::Long nWidth, tools::Long nHeight, |
505 | | SalInvert nFlags) = 0; |
506 | | |
507 | | virtual void invert( sal_uInt32 nPoints, const Point* pPtAry, SalInvert nFlags ) = 0; |
508 | | |
509 | | /// Only implemented by the macOS Quartz backend and the MS-Windows GDI backend. |
510 | | virtual bool drawEPS( |
511 | | tools::Long /*nX*/, tools::Long /*nY*/, |
512 | | tools::Long /*nWidth*/, tools::Long /*nHeight*/, |
513 | | void* /*pPtr*/, |
514 | 0 | sal_uInt32 /*nSize*/ ) { return false; } |
515 | | |
516 | | /** Render bitmap with alpha channel |
517 | | |
518 | | @param rSourceBitmap |
519 | | Source bitmap to blit |
520 | | */ |
521 | | virtual void drawAlphaBitmap( |
522 | | const SalTwoRect&, |
523 | | const SalBitmap& rSourceBitmap ) = 0; |
524 | | |
525 | | /** draw transformed bitmap (maybe with alpha) where Null, X, Y define the coordinate system |
526 | | |
527 | | @param fAlpha additional alpha (0 to 1) to apply while drawing |
528 | | */ |
529 | | virtual bool drawTransformedBitmap( |
530 | | const basegfx::B2DPoint& rNull, |
531 | | const basegfx::B2DPoint& rX, |
532 | | const basegfx::B2DPoint& rY, |
533 | | const SalBitmap& rSourceBitmap, |
534 | | double fAlpha) = 0; |
535 | | |
536 | | /// Returns true if the drawTransformedBitmap() call is fast, and so it should |
537 | | /// be used directly without trying to optimize some calls e.g. by calling drawBitmap() |
538 | | /// instead (which is faster for most VCL backends). These optimizations are not |
539 | | /// done unconditionally because they may be counter-productive for some fast VCL backends |
540 | | /// (for example, some OutputDevice optimizations could try access the pixels, which |
541 | | /// would make performance worse for GPU-backed backends). |
542 | | /// See also tdf#138068. |
543 | | /// Only currently true for SkiaSalGraphicsImpl |
544 | 0 | virtual bool hasFastDrawTransformedBitmap() const { return false; } |
545 | | |
546 | | /** Render solid rectangle with given transparency |
547 | | * |
548 | | * @param nX Top left coordinate of rectangle |
549 | | * @param nY Bottom right coordinate of rectangle |
550 | | * @param nWidth Width of rectangle |
551 | | * @param nHeight Height of rectangle |
552 | | * @param nTransparency Transparency value (0-255) to use. 0 blits and opaque, 255 a |
553 | | * fully transparent rectangle |
554 | | * @returns true if successfully drawn, false if not able to draw rectangle |
555 | | */ |
556 | | virtual bool drawAlphaRect( |
557 | | tools::Long nX, tools::Long nY, |
558 | | tools::Long nWidth, tools::Long nHeight, |
559 | | sal_uInt8 nTransparency ) = 0; |
560 | | |
561 | | private: |
562 | | SalLayoutFlags m_nLayout; //< 0: mirroring off, 1: mirror x-axis |
563 | | |
564 | | // for buffering the Mirror-Matrix, see ::getMirror |
565 | | enum class MirrorMode |
566 | | { |
567 | | NONE, |
568 | | Antiparallel, |
569 | | AntiparallelBiDi, |
570 | | BiDi |
571 | | }; |
572 | | MirrorMode m_eLastMirrorMode; |
573 | | tools::Long m_nLastMirrorTranslation; |
574 | | basegfx::B2DHomMatrix m_aLastMirror; |
575 | | |
576 | | SAL_DLLPRIVATE MirrorMode GetMirrorMode(const OutputDevice& rOutDev) const; |
577 | | |
578 | | protected: |
579 | | /// flags which hold the SetAntialiasing() value from OutputDevice |
580 | | bool m_bAntiAlias : 1; |
581 | | |
582 | | inline tools::Long GetDeviceWidth(const OutputDevice& rOutDev) const; |
583 | | |
584 | | /** |
585 | | * Handle damage done by drawing with a widget draw override |
586 | | * |
587 | | * If a m_pWidgetDraw is set and successfully draws using drawNativeControl, |
588 | | * this function is called to handle the damage done to the graphics buffer. |
589 | | * |
590 | | * @param rDamagedRegion the region damaged by drawNativeControl. |
591 | | **/ |
592 | | virtual inline void handleDamage(const tools::Rectangle& rDamagedRegion); |
593 | | |
594 | | // native controls |
595 | | bool initWidgetDrawBackends(bool bForce = false); |
596 | | |
597 | | std::unique_ptr<vcl::WidgetDrawInterface> m_pWidgetDraw; |
598 | 32.7k | vcl::WidgetDrawInterface* forWidget() { return m_pWidgetDraw ? m_pWidgetDraw.get() : this; } |
599 | | }; |
600 | | |
601 | | bool SalGraphics::IsNativeControlSupported(ControlType eType, ControlPart ePart) |
602 | 32.7k | { |
603 | 32.7k | return forWidget()->isNativeControlSupported(eType, ePart); |
604 | 32.7k | } |
605 | | |
606 | | bool SalGraphics::UpdateSettings(AllSettings& rSettings) |
607 | 0 | { |
608 | 0 | return forWidget()->updateSettings(rSettings); |
609 | 0 | } |
610 | | |
611 | 0 | void SalGraphics::handleDamage(const tools::Rectangle&) {} |
612 | | |
613 | | |
614 | | class VCL_DLLPUBLIC SalGraphicsAutoDelegateToImpl : public SalGraphics |
615 | | { |
616 | | public: |
617 | | sal_uInt16 GetBitCount() const override |
618 | 1.51M | { |
619 | 1.51M | return GetImpl()->GetBitCount(); |
620 | 1.51M | } |
621 | | |
622 | | tools::Long GetGraphicsWidth() const override |
623 | 0 | { |
624 | 0 | return GetImpl()->GetGraphicsWidth(); |
625 | 0 | } |
626 | | |
627 | | void ResetClipRegion() override |
628 | 11.6k | { |
629 | 11.6k | GetImpl()->ResetClipRegion(); |
630 | 11.6k | } |
631 | | |
632 | | void setClipRegion( const vcl::Region& i_rClip ) override |
633 | 18.6k | { |
634 | 18.6k | GetImpl()->setClipRegion(i_rClip); |
635 | 18.6k | } |
636 | | |
637 | | void SetLineColor() override |
638 | 272k | { |
639 | 272k | GetImpl()->SetLineColor(); |
640 | 272k | } |
641 | | |
642 | | void SetLineColor( Color nColor ) override |
643 | 13.0k | { |
644 | 13.0k | GetImpl()->SetLineColor(nColor); |
645 | 13.0k | } |
646 | | |
647 | | void SetFillColor() override |
648 | 2.78k | { |
649 | 2.78k | GetImpl()->SetFillColor(); |
650 | 2.78k | } |
651 | | |
652 | | void SetFillColor( Color nColor ) override |
653 | 6.23M | { |
654 | 6.23M | GetImpl()->SetFillColor (nColor); |
655 | 6.23M | } |
656 | | |
657 | | void SetROPLineColor(SalROPColor aColor) override |
658 | 2.01k | { |
659 | 2.01k | GetImpl()->SetROPLineColor(aColor); |
660 | 2.01k | } |
661 | | |
662 | | void SetROPFillColor( SalROPColor aColor) override |
663 | 2.12k | { |
664 | 2.12k | GetImpl()->SetROPFillColor(aColor); |
665 | 2.12k | } |
666 | | |
667 | | void SetXORMode(bool bSet, bool bInvertOnly) override |
668 | 691k | { |
669 | 691k | GetImpl()->SetXORMode(bSet, bInvertOnly); |
670 | 691k | } |
671 | | |
672 | | void drawPixel( tools::Long nX, tools::Long nY ) override |
673 | 1.31M | { |
674 | 1.31M | GetImpl()->drawPixel(nX, nY); |
675 | 1.31M | } |
676 | | |
677 | | void drawPixel( tools::Long nX, tools::Long nY, Color nColor ) override |
678 | 448k | { |
679 | 448k | GetImpl()->drawPixel(nX, nY, nColor); |
680 | 448k | } |
681 | | |
682 | | void drawLine( tools::Long nX1, tools::Long nY1, tools::Long nX2, tools::Long nY2 ) override |
683 | 1.97M | { |
684 | 1.97M | GetImpl()->drawLine(nX1, nY1, nX2, nY2); |
685 | 1.97M | } |
686 | | |
687 | | void drawRect( tools::Long nX, tools::Long nY, tools::Long nDX, tools::Long nDY ) override |
688 | 1.34M | { |
689 | 1.34M | GetImpl()->drawRect(nX, nY, nDX, nDY); |
690 | 1.34M | } |
691 | | |
692 | | void drawPolyLine( sal_uInt32 nPoints, const Point *pPtAry ) override |
693 | 8.84k | { |
694 | 8.84k | GetImpl()->drawPolyLine(nPoints, pPtAry); |
695 | 8.84k | } |
696 | | |
697 | | void drawPolygon( sal_uInt32 nPoints, const Point* pPtAry ) override |
698 | 8.69M | { |
699 | 8.69M | GetImpl()->drawPolygon(nPoints, pPtAry); |
700 | 8.69M | } |
701 | | |
702 | | void drawPolyPolygon(sal_uInt32 nPoly, const sal_uInt32* pPoints, const Point** pPtAry) override |
703 | 490k | { |
704 | 490k | GetImpl()->drawPolyPolygon (nPoly, pPoints, pPtAry); |
705 | 490k | } |
706 | | |
707 | | void drawPolyPolygon( |
708 | | const basegfx::B2DHomMatrix& rObjectToDevice, |
709 | | const basegfx::B2DPolyPolygon& rPolyPolygon, |
710 | | double fTransparency) override |
711 | 1.29M | { |
712 | 1.29M | GetImpl()->drawPolyPolygon(rObjectToDevice, rPolyPolygon, fTransparency); |
713 | 1.29M | } |
714 | | |
715 | | bool drawPolyLine( |
716 | | const basegfx::B2DHomMatrix& rObjectToDevice, |
717 | | const basegfx::B2DPolygon& rPolygon, |
718 | | double fTransparency, |
719 | | double fLineWidth, |
720 | | const std::vector< double >* pStroke, |
721 | | basegfx::B2DLineJoin eJoin, |
722 | | css::drawing::LineCap eLineCap, |
723 | | double fMiterMinimumAngle, |
724 | | bool bPixelSnapHairline) override |
725 | 532k | { |
726 | 532k | return GetImpl()->drawPolyLine(rObjectToDevice, rPolygon, fTransparency, fLineWidth, pStroke, eJoin, eLineCap, fMiterMinimumAngle, bPixelSnapHairline); |
727 | 532k | } |
728 | | |
729 | | bool drawPolyLineBezier( sal_uInt32 nPoints, const Point* pPtAry, const PolyFlags* pFlgAry ) override |
730 | 0 | { |
731 | 0 | return GetImpl()->drawPolyLineBezier(nPoints, pPtAry, pFlgAry); |
732 | 0 | } |
733 | | |
734 | | bool drawPolygonBezier( sal_uInt32 nPoints, const Point* pPtAry, const PolyFlags* pFlgAry ) override |
735 | 157k | { |
736 | 157k | return GetImpl()->drawPolygonBezier(nPoints, pPtAry, pFlgAry); |
737 | 157k | } |
738 | | |
739 | | bool drawPolyPolygonBezier( sal_uInt32 nPoly, |
740 | | const sal_uInt32* pPoints, |
741 | | const Point* const* pPtAry, |
742 | | const PolyFlags* const* pFlgAry) override |
743 | 52.5k | { |
744 | 52.5k | return GetImpl()->drawPolyPolygonBezier(nPoly, pPoints, pPtAry, pFlgAry); |
745 | 52.5k | } |
746 | | |
747 | | void invert(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, |
748 | | SalInvert nFlags) override |
749 | 0 | { |
750 | 0 | GetImpl()->invert(nX, nY, nWidth, nHeight, nFlags); |
751 | 0 | } |
752 | | |
753 | | void invert(sal_uInt32 nPoints, const Point* pPtAry, SalInvert nFlags) override |
754 | 0 | { |
755 | 0 | GetImpl()->invert(nPoints, pPtAry, nFlags); |
756 | 0 | } |
757 | | |
758 | | bool drawEPS(tools::Long nX, tools::Long nY, tools::Long nWidth, |
759 | | tools::Long nHeight, void* pPtr, sal_uInt32 nSize) override |
760 | 1.18k | { |
761 | 1.18k | return GetImpl()->drawEPS(nX, nY, nWidth, nHeight, pPtr, nSize); |
762 | 1.18k | } |
763 | | |
764 | | void copyBits(const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics) override |
765 | 0 | { |
766 | 0 | GetImpl()->copyBits(rPosAry, pSrcGraphics); |
767 | 0 | } |
768 | | |
769 | | void copyArea (tools::Long nDestX, tools::Long nDestY, tools::Long nSrcX, |
770 | | tools::Long nSrcY, tools::Long nSrcWidth, tools::Long nSrcHeight, |
771 | | bool bWindowInvalidate) override |
772 | 0 | { |
773 | 0 | GetImpl()->copyArea(nDestX, nDestY, nSrcX, nSrcY, nSrcWidth, nSrcHeight, bWindowInvalidate); |
774 | 0 | } |
775 | | |
776 | | void drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap) override |
777 | 10.1k | { |
778 | 10.1k | GetImpl()->drawBitmap(rPosAry, rSalBitmap); |
779 | 10.1k | } |
780 | | |
781 | | void drawMask(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap, Color nMaskColor) override |
782 | 1.98k | { |
783 | 1.98k | GetImpl()->drawMask(rPosAry, rSalBitmap, nMaskColor); |
784 | 1.98k | } |
785 | | |
786 | | std::shared_ptr<SalBitmap> getBitmap(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, bool bWithoutAlpha) override |
787 | 7.10k | { |
788 | 7.10k | return GetImpl()->getBitmap(nX, nY, nWidth, nHeight, bWithoutAlpha); |
789 | 7.10k | } |
790 | | |
791 | | Color getPixel(tools::Long nX, tools::Long nY) override |
792 | 461k | { |
793 | 461k | return GetImpl()->getPixel(nX, nY); |
794 | 461k | } |
795 | | |
796 | | void drawAlphaBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSourceBitmap) override |
797 | 61 | { |
798 | 61 | GetImpl()->drawAlphaBitmap(rPosAry, rSourceBitmap); |
799 | 61 | } |
800 | | |
801 | | bool drawTransformedBitmap(const basegfx::B2DPoint& rNull, |
802 | | const basegfx::B2DPoint& rX, |
803 | | const basegfx::B2DPoint& rY, |
804 | | const SalBitmap& rSourceBitmap, |
805 | | double fAlpha) override |
806 | 0 | { |
807 | 0 | return GetImpl()->drawTransformedBitmap(rNull, rX, rY, rSourceBitmap, fAlpha); |
808 | 0 | } |
809 | | |
810 | | bool hasFastDrawTransformedBitmap() const override |
811 | 0 | { |
812 | 0 | return GetImpl()->hasFastDrawTransformedBitmap(); |
813 | 0 | } |
814 | | |
815 | | bool drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long nWidth, |
816 | | tools::Long nHeight, sal_uInt8 nTransparency) override |
817 | 0 | { |
818 | 0 | return GetImpl()->drawAlphaRect(nX, nY, nWidth, nHeight, nTransparency); |
819 | 0 | } |
820 | | |
821 | | bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) override |
822 | 12.1k | { |
823 | 12.1k | return GetImpl()->drawGradient(rPolygon, rGradient); |
824 | 12.1k | } |
825 | | |
826 | | bool implDrawGradient(basegfx::B2DPolyPolygon const& rPolyPolygon, |
827 | | SalGradient const& rGradient) override |
828 | 0 | { |
829 | 0 | return GetImpl()->implDrawGradient(rPolyPolygon, rGradient); |
830 | 0 | } |
831 | | |
832 | | bool supportsOperation(OutDevSupportType eType) const override |
833 | 0 | { |
834 | 0 | return GetImpl()->supportsOperation(eType); |
835 | 0 | } |
836 | | |
837 | | OUString getRenderBackendName() const override |
838 | 0 | { |
839 | 0 | return GetImpl()->getRenderBackendName(); |
840 | 0 | } |
841 | | |
842 | | bool DrawBitmapWallpaper(tools::Long nStartX, tools::Long nStartY, tools::Long nRight, tools::Long nBottom, tools::Long nBmpWidth, tools::Long nBmpHeight, const SalBitmap& rBmp) override |
843 | 0 | { |
844 | 0 | return GetImpl()->DrawBitmapWallpaper(nStartX, nStartY, nRight, nBottom, nBmpWidth, nBmpHeight, rBmp); |
845 | 0 | } |
846 | | }; |
847 | | |
848 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |