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