workaround segfault in compiler on macos-clang-intel
[LibreOffice.git] / include / vcl / virdev.hxx
blob40cf445f03908e64ca010928a071332fe3ce1c13
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 meFormatAndAlpha;
54 RefDevMode meRefDevMode;
55 bool mbForceZeroExtleadBug;
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,
59 sal_uInt8* pBuffer );
60 SAL_DLLPRIVATE bool ImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
61 sal_uInt8* pBuffer, bool bAlphaMaskTransparent = false );
63 VirtualDevice (const VirtualDevice &) = delete;
64 VirtualDevice & operator= (const VirtualDevice &) = delete;
66 /** Used for alpha VDev, to set areas to opaque
68 @since \#i32109#
70 SAL_DLLPRIVATE void ImplFillOpaqueRectangle( const tools::Rectangle& rRect );
72 protected:
73 virtual bool AcquireGraphics() const override;
74 virtual void ReleaseGraphics( bool bRelease = true ) override;
76 /** Create a virtual device of size 1x1
78 @param pCompDev
79 The generated vdev will be compatible to this device.
80 If it's the nullptr, it uses Application::GetDefaultDevice().
82 @param eFormat
83 Device format of the generated virtual device.
85 @param eOutDevType
86 This real virtual output device type.
88 explicit VirtualDevice(const OutputDevice* pCompDev, DeviceFormat eFormat,
89 OutDevType eOutDevType);
91 public:
93 /** Create a virtual device of size 1x1
95 @param eFormat
96 Device format of the generated virtual device.
98 explicit VirtualDevice(DeviceFormat eFormat = DeviceFormat::WITHOUT_ALPHA)
99 : VirtualDevice(nullptr, eFormat, OUTDEV_VIRDEV) {}
101 /** Create a virtual device of size 1x1
103 @param rCompDev
104 The generated vdev will be compatible to this device.
106 @param eFormat
107 Device format of the generated virtual device.
109 explicit VirtualDevice(const OutputDevice& rCompDev,
110 DeviceFormat eFormat = DeviceFormat::WITHOUT_ALPHA)
111 : VirtualDevice(&rCompDev, eFormat, OUTDEV_VIRDEV) {}
113 /** Create a virtual device using an existing system dependent device or graphics context
114 Any rendering will happen directly on the context and not on any intermediate bitmap.
115 Note: This might not be supported on all platforms !
117 explicit VirtualDevice(const SystemGraphicsData& rData, const Size &rSize,
118 DeviceFormat eFormat);
120 virtual ~VirtualDevice() override;
121 virtual void dispose() override;
123 bool CanEnableNativeWidget() const override;
125 virtual void EnableRTL( bool bEnable = true ) override;
127 bool SetOutputSizePixel( const Size& rNewSize, bool bErase = true, bool bAlphaMaskTransparent = false );
128 bool SetOutputSizePixelScaleOffsetAndLOKBuffer( const Size& rNewSize,
129 const Fraction& rScale,
130 const Point& rNewOffset,
131 sal_uInt8* pBuffer);
133 bool SetOutputSize( const Size& rNewSize )
134 { return SetOutputSizePixel( LogicToPixel( rNewSize ) ); }
136 void SetReferenceDevice( RefDevMode );
138 void Compat_ZeroExtleadBug(); // enable workaround for #i60495#
140 void SetReferenceDevice( sal_Int32 i_nDPIX, sal_Int32 i_nDPIY );
142 virtual sal_uInt16 GetBitCount() const override;
144 bool IsVirtual() const override;
146 bool IsScreenComp() const override { return mbScreenComp; }
148 private:
149 SAL_DLLPRIVATE void ImplSetReferenceDevice( RefDevMode, sal_Int32 i_nDPIX, sal_Int32 i_nDPIY );
151 protected:
152 virtual bool UsePolyPolygonForComplexGradient() override;
154 virtual tools::Long GetFontExtLeading() const override;
158 #endif // INCLUDED_VCL_VIRDEV_HXX
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */