Coverage Report

Created: 2025-11-16 09:57

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