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_SPRITEDEVICEHELPER_HXX
25 #define _DXCANVAS_SPRITEDEVICEHELPER_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_surfacebitmap.hxx"
33 #include "dx_devicehelper.hxx"
34 
35 #include <canvas/rendering/isurfaceproxymanager.hxx>
36 
37 #include <boost/utility.hpp>
38 
39 
40 namespace dxcanvas
41 {
42     class SpriteCanvas;
43     class SpriteCanvasHelper;
44 
45     class SpriteDeviceHelper : public DeviceHelper
46     {
47     public:
48         SpriteDeviceHelper();
49 
50         void init( Window&                                  rWindow,
51                    SpriteCanvas&                            rSpriteCanvas,
52                    const ::com::sun::star::awt::Rectangle&	rRect,
53                    bool                                     bFullscreen );
54 
55         /// Dispose all internal references
56         void disposing();
57 
58         // partial override XWindowGraphicDevice
59         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > createCompatibleBitmap(
60             const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& 	rDevice,
61             const ::com::sun::star::geometry::IntegerSize2D& 										size );
62         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XVolatileBitmap > createVolatileBitmap(
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::XBitmap > createCompatibleAlphaBitmap(
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::XVolatileBitmap > createVolatileAlphaBitmap(
69             const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& 	rDevice,
70             const ::com::sun::star::geometry::IntegerSize2D& 										size );
71 
72         sal_Bool hasFullScreenMode(  );
73         sal_Bool enterFullScreenMode( sal_Bool bEnter );
74 
75         ::sal_Int32 createBuffers( ::sal_Int32 nBuffers );
76         void 		destroyBuffers(  );
77         ::sal_Bool  showBuffer( bool bIsVisible, ::sal_Bool bUpdateAll );
78         ::sal_Bool  switchBuffer( bool bIsVisible, ::sal_Bool bUpdateAll );
79 
getRenderModule() const80         const IDXRenderModuleSharedPtr& getRenderModule() const { return mpRenderModule; }
getBackBuffer() const81         const DXSurfaceBitmapSharedPtr&	getBackBuffer() const { return mpBackBuffer; }
getSurfaceProxy() const82 		const ::canvas::ISurfaceProxyManagerSharedPtr &getSurfaceProxy() const { return mpSurfaceProxyManager; }
83 
84         ::com::sun::star::uno::Any isAccelerated() const;
85 
86         void notifySizeUpdate( const ::com::sun::star::awt::Rectangle& rBounds );
87 
88         /** called when DumpScreenContent property is enabled on
89             XGraphicDevice, and writes out bitmaps of current screen.
90          */
91         void dumpScreenContent() const;
92 
93     private:
94         void resizeBackBuffer( const ::basegfx::B2ISize& rNewSize );
95         HWND getHwnd() const;
96 
97         /// Pointer to sprite canvas (owner of this helper), needed to create bitmaps
98         SpriteCanvas*                           mpSpriteCanvas;
99 
100         DXSurfaceBitmapSharedPtr                mpBackBuffer;
101 
102 		/// Instance passing out HW textures
103         ::canvas::ISurfaceProxyManagerSharedPtr mpSurfaceProxyManager;
104 
105         /// Our encapsulation interface to DirectX
106         IDXRenderModuleSharedPtr                mpRenderModule;
107     };
108 }
109 
110 #endif /* _DXCANVAS_SPRITEDEVICEHELPER_HXX */
111