Bump version to 6.4-15
[LibreOffice.git] / include / vcl / virdev.hxx
blob9baba707e23a3f5d15b12e622a1fc498452b4e8b
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 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, long nDX, 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 explicit VirtualDevice(DeviceFormat eFormat = DeviceFormat::DEFAULT)
109 : VirtualDevice(nullptr, eFormat, DeviceFormat::NONE, OUTDEV_VIRDEV) {}
111 /** Create a virtual device of size 1x1
113 @param rCompDev
114 The generated vdev will be compatible to this device.
116 @param eFormat
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
127 @param rCompDev
128 The generated vdev will be compatible to this device.
130 @param eFormat
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.
135 @param eAlphaFormat
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,
160 sal_uInt8* pBuffer);
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;
175 private:
176 SAL_DLLPRIVATE void ImplSetReferenceDevice( RefDevMode, sal_Int32 i_nDPIX, sal_Int32 i_nDPIY );
178 protected:
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: */