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 _CAIROCANVAS_SPRITEDEVICEHELPER_HXX
29 #define _CAIROCANVAS_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 <boost/utility.hpp>
36 
37 #include <vcl/window.hxx>
38 #include <vcl/bitmap.hxx>
39 
40 #include "cairo_cairo.hxx"
41 #include "cairo_devicehelper.hxx"
42 
43 /* Definition of DeviceHelper class */
44 
45 namespace cairocanvas
46 {
47     class SpriteCanvas;
48     class SpriteCanvasHelper;
49 
50     class SpriteDeviceHelper : public DeviceHelper
51     {
52     public:
53         SpriteDeviceHelper();
54 
55         void init( Window&                   rOutputWindow,
56                    SpriteCanvas&			 rSpriteCanvas,
57                    const ::basegfx::B2ISize& rSize,
58                    bool                      bFullscreen );
59 
60         /// Dispose all internal references
61         void disposing();
62 
63         // XWindowGraphicDevice
64         ::sal_Int32 createBuffers( ::sal_Int32 nBuffers );
65         void 		destroyBuffers(  );
66         ::sal_Bool  showBuffer( bool, ::sal_Bool );
67         ::sal_Bool  switchBuffer( bool, ::sal_Bool bUpdateAll );
68 
69         ::com::sun::star::uno::Any isAccelerated() const;
70         ::com::sun::star::uno::Any getDeviceHandle() const;
71         ::com::sun::star::uno::Any getSurfaceHandle() const;
72 
73         void notifySizeUpdate( const ::com::sun::star::awt::Rectangle& rBounds );
74         void setSize( const ::basegfx::B2ISize&	rSize );
75 
76         ::cairo::SurfaceSharedPtr getSurface();
77         ::cairo::SurfaceSharedPtr getBufferSurface();
78         ::cairo::SurfaceSharedPtr getWindowSurface();
79         ::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, ::cairo::Content aContent = CAIRO_CONTENT_COLOR_ALPHA );
80         ::cairo::SurfaceSharedPtr createSurface( BitmapSystemData& rData, const Size& rSize );
81         const ::basegfx::B2ISize& getSizePixel();
82         void flush();
83 
84     private:
85         /// Pointer to sprite canvas (owner of this helper), needed to create bitmaps
86         SpriteCanvas*		      mpSpriteCanvas;
87 
88         ::cairo::SurfaceSharedPtr mpBufferSurface;
89 
90         ::basegfx::B2ISize        maSize;
91         bool                      mbFullScreen;
92     };
93 }
94 
95 #endif
96