1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _DXCANVAS_SPRITEDEVICEHELPER_HXX
29 #define _DXCANVAS_SPRITEDEVICEHELPER_HXX
30 
31 #include <com/sun/star/awt/Rectangle.hpp>
32 #include <com/sun/star/rendering/XGraphicDevice.hpp>
33 #include <com/sun/star/rendering/XBufferController.hpp>
34 
35 #include "dx_rendermodule.hxx"
36 #include "dx_surfacebitmap.hxx"
37 #include "dx_devicehelper.hxx"
38 
39 #include <canvas/rendering/isurfaceproxymanager.hxx>
40 
41 #include <boost/utility.hpp>
42 
43 
44 namespace dxcanvas
45 {
46     class SpriteCanvas;
47     class SpriteCanvasHelper;
48 
49     class SpriteDeviceHelper : public DeviceHelper
50     {
51     public:
52         SpriteDeviceHelper();
53 
54         void init( Window&                                  rWindow,
55                    SpriteCanvas&                            rSpriteCanvas,
56                    const ::com::sun::star::awt::Rectangle&	rRect,
57                    bool                                     bFullscreen );
58 
59         /// Dispose all internal references
60         void disposing();
61 
62         // partial override XWindowGraphicDevice
63         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > createCompatibleBitmap(
64             const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& 	rDevice,
65             const ::com::sun::star::geometry::IntegerSize2D& 										size );
66         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XVolatileBitmap > createVolatileBitmap(
67             const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& 	rDevice,
68             const ::com::sun::star::geometry::IntegerSize2D& 										size );
69         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > createCompatibleAlphaBitmap(
70             const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& 	rDevice,
71             const ::com::sun::star::geometry::IntegerSize2D& 										size );
72         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XVolatileBitmap > createVolatileAlphaBitmap(
73             const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& 	rDevice,
74             const ::com::sun::star::geometry::IntegerSize2D& 										size );
75 
76         sal_Bool hasFullScreenMode(  );
77         sal_Bool enterFullScreenMode( sal_Bool bEnter );
78 
79         ::sal_Int32 createBuffers( ::sal_Int32 nBuffers );
80         void 		destroyBuffers(  );
81         ::sal_Bool  showBuffer( bool bIsVisible, ::sal_Bool bUpdateAll );
82         ::sal_Bool  switchBuffer( bool bIsVisible, ::sal_Bool bUpdateAll );
83 
84         const IDXRenderModuleSharedPtr& getRenderModule() const { return mpRenderModule; }
85         const DXSurfaceBitmapSharedPtr&	getBackBuffer() const { return mpBackBuffer; }
86 		const ::canvas::ISurfaceProxyManagerSharedPtr &getSurfaceProxy() const { return mpSurfaceProxyManager; }
87 
88         ::com::sun::star::uno::Any isAccelerated() const;
89 
90         void notifySizeUpdate( const ::com::sun::star::awt::Rectangle& rBounds );
91 
92         /** called when DumpScreenContent property is enabled on
93             XGraphicDevice, and writes out bitmaps of current screen.
94          */
95         void dumpScreenContent() const;
96 
97     private:
98         void resizeBackBuffer( const ::basegfx::B2ISize& rNewSize );
99         HWND getHwnd() const;
100 
101         /// Pointer to sprite canvas (owner of this helper), needed to create bitmaps
102         SpriteCanvas*                           mpSpriteCanvas;
103 
104         DXSurfaceBitmapSharedPtr                mpBackBuffer;
105 
106 		/// Instance passing out HW textures
107         ::canvas::ISurfaceProxyManagerSharedPtr mpSurfaceProxyManager;
108 
109         /// Our encapsulation interface to DirectX
110         IDXRenderModuleSharedPtr                mpRenderModule;
111     };
112 }
113 
114 #endif /* _DXCANVAS_SPRITEDEVICEHELPER_HXX */
115