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 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
, long nDX
, 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.
108 explicit VirtualDevice(DeviceFormat eFormat
= DeviceFormat::DEFAULT
)
109 : VirtualDevice(nullptr, eFormat
, DeviceFormat::NONE
, OUTDEV_VIRDEV
) {}
111 /** Create a virtual device of size 1x1
114 The generated vdev will be compatible to this device.
117 Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to
118 indicate: take default screen depth. Only DeviceFormat::BITMASK
119 is the other possibility to denote a binary mask.
121 explicit VirtualDevice(const OutputDevice
& rCompDev
,
122 DeviceFormat eFormat
= DeviceFormat::DEFAULT
)
123 : VirtualDevice(&rCompDev
, eFormat
, DeviceFormat::NONE
, OUTDEV_VIRDEV
) {}
125 /** Create a virtual device of size 1x1 with alpha channel
128 The generated vdev will be compatible to this device.
131 Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to
132 indicate: take default screen depth. Only DeviceFormat::BITMASK
133 is the other possibility to denote a binary mask.
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.
140 explicit VirtualDevice(const OutputDevice
& rCompDev
,
141 DeviceFormat eFormat
, DeviceFormat eAlphaFormat
)
142 : VirtualDevice(&rCompDev
, eFormat
, eAlphaFormat
, OUTDEV_VIRDEV
) {}
144 /** Create a virtual device using an existing system dependent device or graphics context
145 Any rendering will happen directly on the context and not on any intermediate bitmap.
146 Note: This might not be supported on all platforms !
148 explicit VirtualDevice(const SystemGraphicsData
& rData
, const Size
&rSize
,
149 DeviceFormat eFormat
);
151 virtual ~VirtualDevice() override
;
152 virtual void dispose() override
;
154 virtual void EnableRTL( bool bEnable
= true ) override
;
156 bool SetOutputSizePixel( const Size
& rNewSize
, bool bErase
= true );
157 bool SetOutputSizePixelScaleOffsetAndBuffer( const Size
& rNewSize
,
158 const Fraction
& rScale
,
159 const Point
& rNewOffset
,
162 bool SetOutputSize( const Size
& rNewSize
)
163 { return SetOutputSizePixel( LogicToPixel( rNewSize
) ); }
165 void SetReferenceDevice( RefDevMode
);
167 void Compat_ZeroExtleadBug(); // enable workaround for #i60495#
169 void SetReferenceDevice( sal_Int32 i_nDPIX
, sal_Int32 i_nDPIY
);
171 virtual sal_uInt16
GetBitCount() const override
;
173 bool IsVirtual() const override
;
176 SAL_DLLPRIVATE
void ImplSetReferenceDevice( RefDevMode
, sal_Int32 i_nDPIX
, sal_Int32 i_nDPIY
);
179 virtual bool UsePolyPolygonForComplexGradient() override
;
181 virtual long GetFontExtLeading() const override
;
185 #endif // INCLUDED_VCL_VIRDEV_HXX
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */