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 <basebmp/bitmapdevice.hxx>
24 #include <vcl/dllapi.h>
25 #include <vcl/outdev.hxx>
27 class SalVirtualDevice
;
28 struct SystemGraphicsData
;
30 class VCL_DLLPUBLIC VirtualDevice
: public OutputDevice
32 friend class Application
;
33 friend class OutputDevice
;
37 SalVirtualDevice
* mpVirDev
;
38 VirtualDevice
* mpPrev
;
39 VirtualDevice
* mpNext
;
40 sal_uInt16 mnBitCount
;
42 sal_Int8 mnAlphaDepth
;
43 sal_uInt8 meRefDevMode
;
45 SAL_DLLPRIVATE
void ImplInitVirDev( const OutputDevice
* pOutDev
, long nDX
, long nDY
, sal_uInt16 nBitCount
, const SystemGraphicsData
*pData
= NULL
);
46 SAL_DLLPRIVATE
bool InnerImplSetOutputSizePixel( const Size
& rNewSize
, bool bErase
, const basebmp::RawMemorySharedArray
&pBuffer
);
47 SAL_DLLPRIVATE
bool ImplSetOutputSizePixel( const Size
& rNewSize
, bool bErase
, const basebmp::RawMemorySharedArray
&pBuffer
);
49 // Copy assignment is forbidden and not implemented.
50 VirtualDevice (const VirtualDevice
&);
51 VirtualDevice
& operator= (const VirtualDevice
&);
53 /** Used for alpha VDev, to set areas to opaque
57 SAL_DLLPRIVATE
void ImplFillOpaqueRectangle( const Rectangle
& rRect
);
59 // TODO: add extra member for refdev backward compatibility options
60 #define REFDEV_FORCE_ZERO_EXTLEAD 0x80
61 SAL_DLLPRIVATE
bool ForceZeroExtleadBug() const
62 { return ((meRefDevMode
& REFDEV_FORCE_ZERO_EXTLEAD
) != 0); }
65 virtual bool AcquireGraphics() const SAL_OVERRIDE
;
66 virtual void ReleaseGraphics( bool bRelease
= true ) SAL_OVERRIDE
;
69 /** Create a virtual device of size 1x1
72 Bit depth of the generated virtual device. Use 0 here, to
73 indicate: take default screen depth. Only 0, 1 and 8
74 are allowed here, with 1 denoting binary mask and 8 a graylevel mask.
76 explicit VirtualDevice( sal_uInt16 nBitCount
= 0 );
78 /** Create a virtual device of size 1x1
81 The generated vdev will be compatible to this device.
84 Bit depth of the generated virtual device. Use 0 here, to
85 indicate: take default screen depth. Only 0 and 1
86 are allowed here, with 1 denoting binary mask.
88 explicit VirtualDevice( const OutputDevice
& rCompDev
,
89 sal_uInt16 nBitCount
= 0 );
91 /** Create a virtual device of size 1x1 with alpha channel
94 The generated vdev will be compatible to this device.
97 Bit depth of the generated virtual device. Use 0 here, to
98 indicate: take default screen depth. Only 0 and 1
99 are allowed here, with 1 denoting binary mask.
101 @param nAlphaBitCount
102 Bit depth of the generated virtual device. Use 0 here, to
103 indicate: take default screen depth. Only 0 and 1
104 are allowed here, with 1 denoting binary mask.
106 explicit VirtualDevice( const OutputDevice
& rCompDev
,
107 sal_uInt16 nBitCount
, sal_uInt16 nAlphaBitCount
);
109 /** Create a virtual device using an existing system dependent device or graphics context
110 Any rendering will happen directly on the context and not on any intermediate bitmap.
111 Note: This might not be supported on all platforms !
113 explicit VirtualDevice( const SystemGraphicsData
*pData
, sal_uInt16 nBitCount
);
115 virtual ~VirtualDevice();
117 virtual void EnableRTL( bool bEnable
= true ) SAL_OVERRIDE
;
119 bool SetOutputSizePixel( const Size
& rNewSize
, bool bErase
= true );
120 bool SetOutputSizePixelScaleOffsetAndBuffer( const Size
& rNewSize
, const Fraction
& rScale
, const Point
& rNewOffset
, const basebmp::RawMemorySharedArray
&pBuffer
);
121 bool SetOutputSize( const Size
& rNewSize
, bool bErase
= true )
122 { return SetOutputSizePixel( LogicToPixel( rNewSize
), bErase
); }
124 // reference device modes for different compatibility levels
125 enum RefDevMode
{ REFDEV_NONE
= 0,
126 REFDEV_MODE06
= 1, // 600 dpi
127 REFDEV_MODE_MSO1
= 3,
128 REFDEV_MODE_PDF1
= 4,
132 void SetReferenceDevice( RefDevMode
);
134 void Compat_ZeroExtleadBug(); // enable workaround for #i60495#
136 void SetReferenceDevice( sal_Int32 i_nDPIX
, sal_Int32 i_nDPIY
);
138 virtual sal_uInt16
GetBitCount() const SAL_OVERRIDE
;
139 virtual sal_uInt16
GetAlphaBitCount() const SAL_OVERRIDE
;
142 SAL_DLLPRIVATE
void ImplSetReferenceDevice( RefDevMode
, sal_Int32 i_nDPIX
, sal_Int32 i_nDPIY
);
145 virtual bool UsePolyPolygonForComplexGradient() SAL_OVERRIDE
;
147 virtual long GetFontExtLeading() const SAL_OVERRIDE
;
151 #endif // INCLUDED_VCL_VIRDEV_HXX
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */