Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_VCL_VIRDEV_HXX
21 : #define INCLUDED_VCL_VIRDEV_HXX
22 :
23 : #include <basebmp/bitmapdevice.hxx>
24 : #include <vcl/dllapi.h>
25 : #include <vcl/outdev.hxx>
26 :
27 : class SalVirtualDevice;
28 : struct SystemGraphicsData;
29 :
30 : class VCL_DLLPUBLIC VirtualDevice : public OutputDevice
31 : {
32 : friend class Application;
33 : friend class ::OutputDevice;
34 : friend class Printer;
35 :
36 : private:
37 : SalVirtualDevice* mpVirDev;
38 : VclPtr<VirtualDevice> mpPrev;
39 : VclPtr<VirtualDevice> mpNext;
40 : sal_uInt16 mnBitCount;
41 : bool mbScreenComp;
42 : sal_Int8 mnAlphaDepth;
43 : sal_uInt8 meRefDevMode;
44 :
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,
47 : const basebmp::RawMemorySharedArray &pBuffer,
48 : const bool bTopDown );
49 : SAL_DLLPRIVATE bool ImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
50 : const basebmp::RawMemorySharedArray &pBuffer,
51 : const bool bTopDown );
52 :
53 : VirtualDevice (const VirtualDevice &) SAL_DELETED_FUNCTION;
54 : VirtualDevice & operator= (const VirtualDevice &) SAL_DELETED_FUNCTION;
55 :
56 : /** Used for alpha VDev, to set areas to opaque
57 :
58 : @since \#i32109#
59 : */
60 : SAL_DLLPRIVATE void ImplFillOpaqueRectangle( const Rectangle& rRect );
61 :
62 : // TODO: add extra member for refdev backward compatibility options
63 : #define REFDEV_FORCE_ZERO_EXTLEAD 0x80
64 544111 : SAL_DLLPRIVATE bool ForceZeroExtleadBug() const
65 544111 : { return ((meRefDevMode & REFDEV_FORCE_ZERO_EXTLEAD) != 0); }
66 :
67 : protected:
68 : virtual bool AcquireGraphics() const SAL_OVERRIDE;
69 : virtual void ReleaseGraphics( bool bRelease = true ) SAL_OVERRIDE;
70 :
71 : public:
72 : SalVirtualDevice* getSalVirtualDevice() { return mpVirDev; }
73 :
74 : /** Create a virtual device of size 1x1
75 :
76 : @param nBitCount
77 : Bit depth of the generated virtual device. Use 0 here, to
78 : indicate: take default screen depth. Only 0, 1 and 8
79 : are allowed here, with 1 denoting binary mask and 8 a graylevel mask.
80 : */
81 : explicit VirtualDevice( sal_uInt16 nBitCount = 0 );
82 :
83 : /** Create a virtual device of size 1x1
84 :
85 : @param rCompDev
86 : The generated vdev will be compatible to this device.
87 :
88 : @param nBitCount
89 : Bit depth of the generated virtual device. Use 0 here, to
90 : indicate: take default screen depth.
91 : */
92 : explicit VirtualDevice( const OutputDevice& rCompDev,
93 : sal_uInt16 nBitCount = 0 );
94 :
95 : /** Create a virtual device of size 1x1 with alpha channel
96 :
97 : @param rCompDev
98 : The generated vdev will be compatible to this device.
99 :
100 : @param nBitCount
101 : Bit depth of the generated virtual device. Use 0 here, to
102 : indicate: take default screen depth. Only 0 and 1
103 : are allowed here, with 1 denoting binary mask.
104 :
105 : @param nAlphaBitCount
106 : Bit depth of the generated virtual device. Use 0 here, to
107 : indicate: take default screen depth. Only 0 and 1
108 : are allowed here, with 1 denoting binary mask.
109 : */
110 : explicit VirtualDevice( const OutputDevice& rCompDev,
111 : sal_uInt16 nBitCount, sal_uInt16 nAlphaBitCount );
112 :
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 !
116 : */
117 : explicit VirtualDevice(const SystemGraphicsData *pData, const Size &rSize,
118 : sal_uInt16 nBitCount);
119 :
120 : virtual ~VirtualDevice();
121 : virtual void dispose() SAL_OVERRIDE;
122 :
123 : virtual void EnableRTL( bool bEnable = true ) SAL_OVERRIDE;
124 :
125 : bool SetOutputSizePixel( const Size& rNewSize, bool bErase = true );
126 : bool SetOutputSizePixelScaleOffsetAndBuffer( const Size& rNewSize,
127 : const Fraction& rScale,
128 : const Point& rNewOffset,
129 : const basebmp::RawMemorySharedArray &pBuffer,
130 : const bool bTopDown = false );
131 244 : bool SetOutputSize( const Size& rNewSize, bool bErase = true )
132 244 : { return SetOutputSizePixel( LogicToPixel( rNewSize ), bErase ); }
133 :
134 : // reference device modes for different compatibility levels
135 : enum RefDevMode { REFDEV_NONE = 0,
136 : REFDEV_MODE06 = 1, // 600 dpi
137 : REFDEV_MODE_MSO1 = 3,
138 : REFDEV_MODE_PDF1 = 4,
139 : REFDEV_CUSTOM = 5
140 : };
141 :
142 : void SetReferenceDevice( RefDevMode );
143 :
144 : void Compat_ZeroExtleadBug(); // enable workaround for #i60495#
145 :
146 : void SetReferenceDevice( sal_Int32 i_nDPIX, sal_Int32 i_nDPIY );
147 :
148 : virtual sal_uInt16 GetBitCount() const SAL_OVERRIDE;
149 : virtual sal_uInt16 GetAlphaBitCount() const SAL_OVERRIDE;
150 :
151 : private:
152 : SAL_DLLPRIVATE void ImplSetReferenceDevice( RefDevMode, sal_Int32 i_nDPIX, sal_Int32 i_nDPIY );
153 :
154 : protected:
155 : virtual bool UsePolyPolygonForComplexGradient() SAL_OVERRIDE;
156 :
157 : virtual long GetFontExtLeading() const SAL_OVERRIDE;
158 :
159 : };
160 :
161 : #endif // INCLUDED_VCL_VIRDEV_HXX
162 :
163 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|