Coverage Report

Created: 2026-09-28 10:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/vcl/virdev.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
#ifndef INCLUDED_VCL_VIRDEV_HXX
21
#define INCLUDED_VCL_VIRDEV_HXX
22
23
#include <vcl/dllapi.h>
24
#include <vcl/outdev.hxx>
25
#include <vcl/salgtype.hxx>
26
#include <memory>
27
28
class SalVirtualDevice;
29
struct SystemGraphicsData;
30
typedef struct _cairo_surface cairo_surface_t;
31
32
class SAL_WARN_UNUSED VCL_DLLPUBLIC VirtualDevice : public OutputDevice
33
{
34
    friend class Application;
35
    friend class ::OutputDevice;
36
    friend class Printer;
37
    friend VCL_DLLPUBLIC cairo_surface_t* get_underlying_cairo_surface(const VirtualDevice&);
38
public:
39
    // reference device modes for different compatibility levels
40
    enum class RefDevMode { NONE = 0,
41
                            Dpi600 = 1,      // 600 dpi
42
                            MSO1 = 3,
43
                            PDF1 = 4,
44
                            Custom = 5
45
                          };
46
47
private:
48
    std::unique_ptr<SalVirtualDevice> mpVirDev;
49
    VclPtr<VirtualDevice>  mpPrev;
50
    VclPtr<VirtualDevice>  mpNext;
51
    sal_uInt16          mnBitCount;
52
    bool                mbScreenComp;
53
    const DeviceFormat meFormatAndAlpha;
54
    RefDevMode          meRefDevMode;
55
    bool                mbForceZeroExtleadBug;
56
57
    SAL_DLLPRIVATE void ImplInitVirDev( const OutputDevice* pOutDev, tools::Long nDX, tools::Long nDY, const SystemGraphicsData *pData = nullptr );
58
59
    VirtualDevice (const VirtualDevice &) = delete;
60
    VirtualDevice & operator= (const VirtualDevice &) = delete;
61
62
protected:
63
    virtual bool AcquireGraphics() const override;
64
    virtual void ReleaseGraphics( bool bRelease = true ) override;
65
66
    /** Create a virtual device of size 1x1
67
68
        @param pCompDev
69
        The generated vdev will be compatible to this device.
70
        If it's the nullptr, it uses Application::GetDefaultDevice().
71
72
        @param eFormat
73
        Device format of the generated virtual device.
74
75
        @param eOutDevType
76
        This real virtual output device type.
77
     */
78
    explicit VirtualDevice(const OutputDevice* pCompDev, DeviceFormat eFormat,
79
                           OutDevType eOutDevType);
80
81
public:
82
83
    /** Create a virtual device of size 1x1
84
85
        @param eFormat
86
        Device format of the generated virtual device.
87
     */
88
    explicit VirtualDevice(DeviceFormat eFormat = DeviceFormat::WITHOUT_ALPHA)
89
906k
        : VirtualDevice(nullptr, eFormat, OUTDEV_VIRDEV) {}
90
91
    /** Create a virtual device of size 1x1
92
93
        @param rCompDev
94
        The generated vdev will be compatible to this device.
95
96
        @param eFormat
97
        Device format of the generated virtual device.
98
     */
99
    explicit VirtualDevice(const OutputDevice& rCompDev,
100
                           DeviceFormat eFormat = DeviceFormat::WITHOUT_ALPHA)
101
38.9k
        : VirtualDevice(&rCompDev, eFormat, OUTDEV_VIRDEV) {}
102
103
    /** Create a virtual device using an existing system dependent device or graphics context
104
        Any rendering will happen directly on the context and not on any intermediate bitmap.
105
        Note: This might not be supported on all platforms !
106
     */
107
    explicit VirtualDevice(const SystemGraphicsData& rData, const Size &rSize,
108
                           DeviceFormat eFormat);
109
110
    virtual             ~VirtualDevice() override;
111
    virtual void        dispose() override;
112
113
    bool                CanEnableNativeWidget() const override;
114
115
0
    bool                CanAnimate() const override { return false; }
116
117
    virtual void        EnableRTL( bool bEnable = true ) override;
118
119
    bool                SetOutputSizePixel( const Size& rNewSize, bool bErase = true, bool bAlphaMaskTransparent = false );
120
    bool                SetOutputSizePixelScaleOffsetAndLOKBuffer( const Size& rNewSize,
121
                                                                   double fScale,
122
                                                                   const Point& rNewOffset,
123
                                                                   sal_uInt8* pBuffer);
124
125
    bool                SetOutputSize( const Size& rNewSize )
126
0
                            { return SetOutputSizePixel( LogicToPixel( rNewSize ) ); }
127
128
    void                SetReferenceDevice( RefDevMode );
129
130
    void                Compat_ZeroExtleadBug(); // enable workaround for #i60495#
131
132
    void                SetReferenceDevice( sal_Int32 i_nDPIX, sal_Int32 i_nDPIY );
133
134
    virtual sal_uInt16  GetBitCount() const override;
135
136
    bool IsVirtual() const override;
137
138
0
    bool                IsScreenComp() const override { return mbScreenComp; }
139
140
6.47k
    bool IsWithoutAlpha() const { return meFormatAndAlpha == DeviceFormat::WITHOUT_ALPHA; }
141
142
0
    virtual bool HasAlpha() const override { return meFormatAndAlpha != DeviceFormat::WITHOUT_ALPHA; }
143
144
private:
145
    SAL_DLLPRIVATE void ImplSetReferenceDevice( RefDevMode, sal_Int32 i_nDPIX, sal_Int32 i_nDPIY );
146
147
protected:
148
    virtual bool        UsePolyPolygonForComplexGradient() override;
149
150
    virtual tools::Long        GetFontExtLeading() const override;
151
152
};
153
154
#endif // INCLUDED_VCL_VIRDEV_HXX
155
156
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */