Coverage Report

Created: 2025-12-31 10:39

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 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
    SAL_DLLPRIVATE bool InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase, bool bAlphaMaskTransparent );
59
60
    VirtualDevice (const VirtualDevice &) = delete;
61
    VirtualDevice & operator= (const VirtualDevice &) = delete;
62
63
protected:
64
    virtual bool AcquireGraphics() const override;
65
    virtual void ReleaseGraphics( bool bRelease = true ) override;
66
67
    /** Create a virtual device of size 1x1
68
69
        @param pCompDev
70
        The generated vdev will be compatible to this device.
71
        If it's the nullptr, it uses Application::GetDefaultDevice().
72
73
        @param eFormat
74
        Device format of the generated virtual device.
75
76
        @param eOutDevType
77
        This real virtual output device type.
78
     */
79
    explicit VirtualDevice(const OutputDevice* pCompDev, DeviceFormat eFormat,
80
                           OutDevType eOutDevType);
81
82
public:
83
84
    /** Create a virtual device of size 1x1
85
86
        @param eFormat
87
        Device format of the generated virtual device.
88
     */
89
    explicit VirtualDevice(DeviceFormat eFormat = DeviceFormat::WITHOUT_ALPHA)
90
1.73M
        : VirtualDevice(nullptr, eFormat, OUTDEV_VIRDEV) {}
91
92
    /** Create a virtual device of size 1x1
93
94
        @param rCompDev
95
        The generated vdev will be compatible to this device.
96
97
        @param eFormat
98
        Device format of the generated virtual device.
99
     */
100
    explicit VirtualDevice(const OutputDevice& rCompDev,
101
                           DeviceFormat eFormat = DeviceFormat::WITHOUT_ALPHA)
102
22.0k
        : VirtualDevice(&rCompDev, eFormat, OUTDEV_VIRDEV) {}
103
104
    /** Create a virtual device using an existing system dependent device or graphics context
105
        Any rendering will happen directly on the context and not on any intermediate bitmap.
106
        Note: This might not be supported on all platforms !
107
     */
108
    explicit VirtualDevice(const SystemGraphicsData& rData, const Size &rSize,
109
                           DeviceFormat eFormat);
110
111
    virtual             ~VirtualDevice() override;
112
    virtual void        dispose() override;
113
114
    bool                CanEnableNativeWidget() const override;
115
116
0
    bool                CanAnimate() const override { return false; }
117
118
    virtual void        EnableRTL( bool bEnable = true ) override;
119
120
    bool                SetOutputSizePixel( const Size& rNewSize, bool bErase = true, bool bAlphaMaskTransparent = false );
121
    bool                SetOutputSizePixelScaleOffsetAndLOKBuffer( const Size& rNewSize,
122
                                                                   const Fraction& rScale,
123
                                                                   const Point& rNewOffset,
124
                                                                   sal_uInt8* pBuffer);
125
126
    bool                SetOutputSize( const Size& rNewSize )
127
0
                            { return SetOutputSizePixel( LogicToPixel( rNewSize ) ); }
128
129
    void                SetReferenceDevice( RefDevMode );
130
131
    void                Compat_ZeroExtleadBug(); // enable workaround for #i60495#
132
133
    void                SetReferenceDevice( sal_Int32 i_nDPIX, sal_Int32 i_nDPIY );
134
135
    virtual sal_uInt16  GetBitCount() const override;
136
137
    bool IsVirtual() const override;
138
139
0
    bool                IsScreenComp() const override { return mbScreenComp; }
140
141
6.40k
    bool IsWithoutAlpha() const { return meFormatAndAlpha == DeviceFormat::WITHOUT_ALPHA; }
142
143
0
    virtual bool HasAlpha() const override { return meFormatAndAlpha != DeviceFormat::WITHOUT_ALPHA; }
144
145
private:
146
    SAL_DLLPRIVATE void ImplSetReferenceDevice( RefDevMode, sal_Int32 i_nDPIX, sal_Int32 i_nDPIY );
147
148
protected:
149
    virtual bool        UsePolyPolygonForComplexGradient() override;
150
151
    virtual tools::Long        GetFontExtLeading() const override;
152
153
};
154
155
#endif // INCLUDED_VCL_VIRDEV_HXX
156
157
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */