Bump version to 21.06.18.1
[LibreOffice.git] / include / vcl / virdev.hxx
blobb13a2a0d9ef82ed5f2ffa50717ba268c83d7b46b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
26 #include <memory>
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;
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
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 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,
60 sal_uInt8* pBuffer );
61 SAL_DLLPRIVATE bool ImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
62 sal_uInt8* pBuffer );
64 VirtualDevice (const VirtualDevice &) = delete;
65 VirtualDevice & operator= (const VirtualDevice &) = delete;
67 /** Used for alpha VDev, to set areas to opaque
69 @since \#i32109#
71 SAL_DLLPRIVATE void ImplFillOpaqueRectangle( const tools::Rectangle& rRect );
73 protected:
74 virtual bool AcquireGraphics() const override;
75 virtual void ReleaseGraphics( bool bRelease = true ) override;
77 /** Create a virtual device of size 1x1
79 @param pCompDev
80 The generated vdev will be compatible to this device.
81 If it's the nullptr, it uses Application::GetDefaultDevice().
83 @param eFormat
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.
88 @param eAlphaFormat
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.
93 @param eOutDevType
94 This real virtual output device type.
96 explicit VirtualDevice(const OutputDevice* pCompDev, DeviceFormat eFormat,
97 DeviceFormat eAlphaFormat, OutDevType eOutDevType);
99 public:
101 /** Create a virtual device of size 1x1
103 @param eFormat
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 @param eAlphaFormat
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
118 @param rCompDev
119 The generated vdev will be compatible to this device.
121 @param eFormat
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
132 @param rCompDev
133 The generated vdev will be compatible to this device.
135 @param eFormat
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 @param eAlphaFormat
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,
165 sal_uInt8* pBuffer);
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; }
182 private:
183 SAL_DLLPRIVATE void ImplSetReferenceDevice( RefDevMode, sal_Int32 i_nDPIX, sal_Int32 i_nDPIY );
185 protected:
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: */