1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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_VIRDEV_HXX
21 #define INCLUDED_VCL_VIRDEV_HXX
23 #include <vcl/dllapi.h>
24 #include <vcl/outdev.hxx>
25 #include <vcl/salgtype.hxx>
28 class SalVirtualDevice
;
29 struct SystemGraphicsData
;
30 typedef struct _cairo_surface cairo_surface_t
;
32 class SAL_WARN_UNUSED VCL_DLLPUBLIC VirtualDevice
: public OutputDevice
34 friend class Application
;
35 friend class ::OutputDevice
;
37 friend cairo_surface_t
* get_underlying_cairo_surface(const VirtualDevice
&);
39 // reference device modes for different compatibility levels
40 enum class RefDevMode
{ NONE
= 0,
41 Dpi600
= 1, // 600 dpi
48 std::unique_ptr
<SalVirtualDevice
> mpVirDev
;
49 VclPtr
<VirtualDevice
> mpPrev
;
50 VclPtr
<VirtualDevice
> mpNext
;
51 sal_uInt16 mnBitCount
;
53 const DeviceFormat meFormat
;
54 const DeviceFormat meAlphaFormat
;
55 RefDevMode meRefDevMode
;
56 bool mbForceZeroExtleadBug
;
58 SAL_DLLPRIVATE
void ImplInitVirDev( const OutputDevice
* pOutDev
, tools::Long nDX
, tools::Long nDY
, const SystemGraphicsData
*pData
= nullptr );
59 SAL_DLLPRIVATE
bool InnerImplSetOutputSizePixel( const Size
& rNewSize
, bool bErase
,
61 SAL_DLLPRIVATE
bool ImplSetOutputSizePixel( const Size
& rNewSize
, bool bErase
,
64 VirtualDevice (const VirtualDevice
&) = delete;
65 VirtualDevice
& operator= (const VirtualDevice
&) = delete;
67 /** Used for alpha VDev, to set areas to opaque
71 SAL_DLLPRIVATE
void ImplFillOpaqueRectangle( const tools::Rectangle
& rRect
);
74 virtual bool AcquireGraphics() const override
;
75 virtual void ReleaseGraphics( bool bRelease
= true ) override
;
77 /** Create a virtual device of size 1x1
80 The generated vdev will be compatible to this device.
81 If it's the nullptr, it uses Application::GetDefaultDevice().
84 Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to
85 indicate: take default screen depth. Only DeviceFormat::BITMASK
86 is the other possibility to denote a binary mask.
89 Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to
90 indicate: take default screen depth. Only DeviceFormat::BITMASK
91 is the other possibility to denote a binary mask.
94 This real virtual output device type.
96 explicit VirtualDevice(const OutputDevice
* pCompDev
, DeviceFormat eFormat
,
97 DeviceFormat eAlphaFormat
, OutDevType eOutDevType
);
101 /** Create a virtual device of size 1x1
104 Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to
105 indicate: take default screen depth. Only DeviceFormat::BITMASK
106 is the other possibility to denote a binary mask.
109 Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to
110 indicate: take default screen depth. Only DeviceFormat::BITMASK
111 is the other possibility to denote a binary mask.
113 explicit VirtualDevice(DeviceFormat eFormat
= DeviceFormat::DEFAULT
, DeviceFormat eAlphaFormat
= DeviceFormat::NONE
)
114 : VirtualDevice(nullptr, eFormat
, eAlphaFormat
, OUTDEV_VIRDEV
) {}
116 /** Create a virtual device of size 1x1
119 The generated vdev will be compatible to this device.
122 Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to
123 indicate: take default screen depth. Only DeviceFormat::BITMASK
124 is the other possibility to denote a binary mask.
126 explicit VirtualDevice(const OutputDevice
& rCompDev
,
127 DeviceFormat eFormat
= DeviceFormat::DEFAULT
)
128 : VirtualDevice(&rCompDev
, eFormat
, DeviceFormat::NONE
, OUTDEV_VIRDEV
) {}
130 /** Create a virtual device of size 1x1 with alpha channel
133 The generated vdev will be compatible to this device.
136 Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to
137 indicate: take default screen depth. Only DeviceFormat::BITMASK
138 is the other possibility to denote a binary mask.
141 Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to
142 indicate: take default screen depth. Only DeviceFormat::BITMASK
143 is the other possibility to denote a binary mask.
145 explicit VirtualDevice(const OutputDevice
& rCompDev
,
146 DeviceFormat eFormat
, DeviceFormat eAlphaFormat
)
147 : VirtualDevice(&rCompDev
, eFormat
, eAlphaFormat
, OUTDEV_VIRDEV
) {}
149 /** Create a virtual device using an existing system dependent device or graphics context
150 Any rendering will happen directly on the context and not on any intermediate bitmap.
151 Note: This might not be supported on all platforms !
153 explicit VirtualDevice(const SystemGraphicsData
& rData
, const Size
&rSize
,
154 DeviceFormat eFormat
);
156 virtual ~VirtualDevice() override
;
157 virtual void dispose() override
;
159 virtual void EnableRTL( bool bEnable
= true ) override
;
161 bool SetOutputSizePixel( const Size
& rNewSize
, bool bErase
= true );
162 bool SetOutputSizePixelScaleOffsetAndBuffer( const Size
& rNewSize
,
163 const Fraction
& rScale
,
164 const Point
& rNewOffset
,
167 bool SetOutputSize( const Size
& rNewSize
)
168 { return SetOutputSizePixel( LogicToPixel( rNewSize
) ); }
170 void SetReferenceDevice( RefDevMode
);
172 void Compat_ZeroExtleadBug(); // enable workaround for #i60495#
174 void SetReferenceDevice( sal_Int32 i_nDPIX
, sal_Int32 i_nDPIY
);
176 virtual sal_uInt16
GetBitCount() const override
;
178 bool IsVirtual() const override
;
180 bool IsScreenComp() const override
{ return mbScreenComp
; }
183 SAL_DLLPRIVATE
void ImplSetReferenceDevice( RefDevMode
, sal_Int32 i_nDPIX
, sal_Int32 i_nDPIY
);
186 virtual bool UsePolyPolygonForComplexGradient() override
;
188 virtual tools::Long
GetFontExtLeading() const override
;
192 #endif // INCLUDED_VCL_VIRDEV_HXX
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */