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 _NULLCANVAS_DEVICEHELPER_HXX
25 #define _NULLCANVAS_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 <boost/utility.hpp>
32 
33 
34 /* Definition of DeviceHelper class */
35 
36 namespace nullcanvas
37 {
38     class SpriteCanvas;
39     class SpriteCanvasHelper;
40 
41     class DeviceHelper : private ::boost::noncopyable
42     {
43     public:
44         DeviceHelper();
45 
46         void init( SpriteCanvas&				rSpriteCanvas,
47                    const ::basegfx::B2ISize&	rSize,
48                    bool                         bFullscreen );
49 
50         /// Dispose all internal references
51         void disposing();
52 
53         // XWindowGraphicDevice
54         ::com::sun::star::geometry::RealSize2D getPhysicalResolution();
55         ::com::sun::star::geometry::RealSize2D getPhysicalSize();
56         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XLinePolyPolygon2D > createCompatibleLinePolyPolygon(
57             const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& 								 rDevice,
58             const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealPoint2D > >& points );
59         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBezierPolyPolygon2D > createCompatibleBezierPolyPolygon(
60             const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& 								 		 rDevice,
61             const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealBezierSegment2D > >& points );
62         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > createCompatibleBitmap(
63             const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& 	rDevice,
64             const ::com::sun::star::geometry::IntegerSize2D& 										size );
65         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XVolatileBitmap > createVolatileBitmap(
66             const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& 	rDevice,
67             const ::com::sun::star::geometry::IntegerSize2D& 										size );
68         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > createCompatibleAlphaBitmap(
69             const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& 	rDevice,
70             const ::com::sun::star::geometry::IntegerSize2D& 										size );
71         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XVolatileBitmap > createVolatileAlphaBitmap(
72             const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& 	rDevice,
73             const ::com::sun::star::geometry::IntegerSize2D& 										size );
74         sal_Bool hasFullScreenMode(  );
75         sal_Bool enterFullScreenMode( sal_Bool bEnter );
76 
77         ::sal_Int32 createBuffers( ::sal_Int32 nBuffers );
78         void 		destroyBuffers(  );
79         ::sal_Bool  showBuffer( bool bIsVisible, ::sal_Bool bUpdateAll );
80         ::sal_Bool  switchBuffer( bool bIsVisible, ::sal_Bool bUpdateAll );
81 
82         ::com::sun::star::uno::Any isAccelerated() const;
83         ::com::sun::star::uno::Any getDeviceHandle() const;
84         ::com::sun::star::uno::Any getSurfaceHandle() const;
85         ::com::sun::star::uno::Reference<
86             ::com::sun::star::rendering::XColorSpace> getColorSpace() const;
87 
88         void notifySizeUpdate( const ::com::sun::star::awt::Rectangle& rBounds );
89 
90         /** called when DumpScreenContent property is enabled on
91             XGraphicDevice, and writes out bitmaps of current screen.
92          */
93         void dumpScreenContent() const;
94 
95     private:
96         /// Pointer to sprite canvas (owner of this helper), needed to create bitmaps
97         SpriteCanvas*			mpSpriteCanvas;
98         ::basegfx::B2ISize      maSize;
99         bool                    mbFullScreen;
100     };
101 }
102 
103 #endif /* _NULLCANVAS_WINDOWGRAPHICDEVICE_HXX */
104