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/salgtype.hxx>
25 #include <vcl/outdev.hxx>
28 class SalVirtualDevice
;
29 struct SystemGraphicsData
;
31 class VCL_DLLPUBLIC VirtualDevice
: public OutputDevice
33 friend class Application
;
34 friend class ::OutputDevice
;
37 // reference device modes for different compatibility levels
38 enum class RefDevMode
{ NONE
= 0,
39 Dpi600
= 1, // 600 dpi
46 SalVirtualDevice
* mpVirDev
;
47 VclPtr
<VirtualDevice
> mpPrev
;
48 VclPtr
<VirtualDevice
> mpNext
;
49 sal_uInt16 mnBitCount
;
51 DeviceFormat meFormat
;
52 DeviceFormat meAlphaFormat
;
53 RefDevMode meRefDevMode
;
54 bool mbForceZeroExtleadBug
;
56 SAL_DLLPRIVATE
void ImplInitVirDev( const OutputDevice
* pOutDev
, long nDX
, long nDY
, DeviceFormat eFormat
, const SystemGraphicsData
*pData
= nullptr );
57 SAL_DLLPRIVATE
bool InnerImplSetOutputSizePixel( const Size
& rNewSize
, bool bErase
,
59 SAL_DLLPRIVATE
bool ImplSetOutputSizePixel( const Size
& rNewSize
, bool bErase
,
62 VirtualDevice (const VirtualDevice
&) = delete;
63 VirtualDevice
& operator= (const VirtualDevice
&) = delete;
65 /** Used for alpha VDev, to set areas to opaque
69 SAL_DLLPRIVATE
void ImplFillOpaqueRectangle( const tools::Rectangle
& rRect
);
72 virtual bool AcquireGraphics() const override
;
73 virtual void ReleaseGraphics( bool bRelease
= true ) override
;
77 /** Create a virtual device of size 1x1
80 Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to
81 indicate: take default screen depth. Only DeviceFormat::BITMASK
82 is the other possibility to denote a binary mask.
84 explicit VirtualDevice(DeviceFormat eFormat
= DeviceFormat::DEFAULT
);
86 /** Create a virtual device of size 1x1
89 The generated vdev will be compatible to this device.
92 Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to
93 indicate: take default screen depth. Only DeviceFormat::BITMASK
94 is the other possibility to denote a binary mask.
96 explicit VirtualDevice(const OutputDevice
& rCompDev
,
97 DeviceFormat eFormat
= DeviceFormat::DEFAULT
);
99 /** Create a virtual device of size 1x1 with alpha channel
102 The generated vdev will be compatible to this device.
105 Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to
106 indicate: take default screen depth. Only DeviceFormat::BITMASK
107 is the other possibility to denote a binary mask.
110 Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to
111 indicate: take default screen depth. Only DeviceFormat::BITMASK
112 is the other possibility to denote a binary mask.
114 explicit VirtualDevice( const OutputDevice
& rCompDev
,
115 DeviceFormat eFormat
, DeviceFormat eAlphaFormat
);
117 /** Create a virtual device using an existing system dependent device or graphics context
118 Any rendering will happen directly on the context and not on any intermediate bitmap.
119 Note: This might not be supported on all platforms !
121 explicit VirtualDevice(const SystemGraphicsData
*pData
, const Size
&rSize
,
122 DeviceFormat eFormat
);
124 virtual ~VirtualDevice() override
;
125 virtual void dispose() override
;
127 virtual void EnableRTL( bool bEnable
= true ) override
;
129 bool SetOutputSizePixel( const Size
& rNewSize
, bool bErase
= true );
130 bool SetOutputSizePixelScaleOffsetAndBuffer( const Size
& rNewSize
,
131 const Fraction
& rScale
,
132 const Point
& rNewOffset
,
135 bool SetOutputSize( const Size
& rNewSize
)
136 { return SetOutputSizePixel( LogicToPixel( rNewSize
) ); }
138 void SetReferenceDevice( RefDevMode
);
140 void Compat_ZeroExtleadBug(); // enable workaround for #i60495#
142 void SetReferenceDevice( sal_Int32 i_nDPIX
, sal_Int32 i_nDPIY
);
144 virtual sal_uInt16
GetBitCount() const override
;
147 SAL_DLLPRIVATE
void ImplSetReferenceDevice( RefDevMode
, sal_Int32 i_nDPIX
, sal_Int32 i_nDPIY
);
150 virtual bool UsePolyPolygonForComplexGradient() override
;
152 virtual long GetFontExtLeading() const override
;
156 #endif // INCLUDED_VCL_VIRDEV_HXX
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */