1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _DXCANVAS_DEVICEHELPER_HXX
25 #define _DXCANVAS_DEVICEHELPER_HXX
26 
27 #include <com/sun/star/awt/Rectangle.hpp>
28 #include <com/sun/star/rendering/XGraphicDevice.hpp>
29 #include <com/sun/star/rendering/XBufferController.hpp>
30 
31 #include "dx_rendermodule.hxx"
32 #include "dx_bitmap.hxx"
33 
34 #include <canvas/rendering/isurfaceproxymanager.hxx>
35 
36 #include <boost/utility.hpp>
37 
38 
39 /* Definition of DeviceHelper class */
40 
41 namespace dxcanvas
42 {
43     class DeviceHelper : private ::boost::noncopyable
44     {
45     public:
46         DeviceHelper();
47 
48         /** Init the device helper
49 
50             @param hdc
51             private or class dc of the output device. is only stored,
52             not release
53 
54             @param rDevice
55             Ref back to owning UNO device
56          */
57         void init( HDC                                        hdc,
58                    com::sun::star::rendering::XGraphicDevice& rDevice );
59 
60         /// Dispose all internal references
61         void disposing();
62 
63         // XWindowGraphicDevice
64         ::com::sun::star::geometry::RealSize2D getPhysicalResolution();
65         ::com::sun::star::geometry::RealSize2D getPhysicalSize();
66         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XLinePolyPolygon2D > createCompatibleLinePolyPolygon(
67             const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& 								 rDevice,
68             const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealPoint2D > >& points );
69         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBezierPolyPolygon2D > createCompatibleBezierPolyPolygon(
70             const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& 								 		 rDevice,
71             const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealBezierSegment2D > >& points );
72         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > createCompatibleBitmap(
73             const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& 	rDevice,
74             const ::com::sun::star::geometry::IntegerSize2D& 										size );
75         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XVolatileBitmap > createVolatileBitmap(
76             const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& 	rDevice,
77             const ::com::sun::star::geometry::IntegerSize2D& 										size );
78         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > createCompatibleAlphaBitmap(
79             const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& 	rDevice,
80             const ::com::sun::star::geometry::IntegerSize2D& 										size );
81         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XVolatileBitmap > createVolatileAlphaBitmap(
82             const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& 	rDevice,
83             const ::com::sun::star::geometry::IntegerSize2D& 										size );
84 
85         sal_Bool hasFullScreenMode();
86         sal_Bool enterFullScreenMode( sal_Bool bEnter );
87 
88         ::com::sun::star::uno::Any isAccelerated() const;
89         ::com::sun::star::uno::Any getDeviceHandle() const;
90         ::com::sun::star::uno::Any getSurfaceHandle() const;
91         ::com::sun::star::uno::Reference<
92             ::com::sun::star::rendering::XColorSpace > getColorSpace() const;
93 
94         /** called when DumpScreenContent property is enabled on
95             XGraphicDevice, and writes out bitmaps of current screen.
96          */
dumpScreenContent() const97         void dumpScreenContent() const {}
98 
99     protected:
getHDC() const100         HDC getHDC() const { return mnHDC; }
getDevice() const101         com::sun::star::rendering::XGraphicDevice* getDevice() const { return mpDevice; }
102 
103     private:
104         /** Phyical output device
105 
106             Deliberately not a refcounted reference, because of
107             potential circular references for canvas. Needed to
108             create bitmaps
109          */
110         com::sun::star::rendering::XGraphicDevice* mpDevice;
111         HDC                                        mnHDC;
112     };
113 
114     typedef ::rtl::Reference< com::sun::star::rendering::XGraphicDevice > DeviceRef;
115 }
116 
117 #endif /* _DXCANVAS_DEVICEHELPER_HXX */
118