xref: /trunk/main/canvas/source/cairo/cairo_cairo.hxx (revision 91c99ff4)
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_CAIRO_HXX
25 #define _CAIROCANVAS_CAIRO_HXX
26 
27 #include <sal/config.h>
28 #include <boost/shared_ptr.hpp>
29 
30 struct SystemEnvData;
31 struct BitmapSystemData;
32 struct SystemGraphicsData;
33 class  VirtualDevice;
34 class  OutputDevice;
35 class  Window;
36 class  Size;
37 
38 #include <cairo.h>  //cannot be inside a namespace, otherwise Quartz fails to compile.
39 
40 namespace cairo {
41 	typedef cairo_t Cairo;
42 	typedef cairo_matrix_t Matrix;
43 	typedef cairo_format_t Format;
44 	typedef cairo_content_t Content;
45 	typedef cairo_pattern_t Pattern;
46 
47     typedef boost::shared_ptr<cairo_surface_t> CairoSurfaceSharedPtr;
48     typedef boost::shared_ptr<Cairo>           CairoSharedPtr;
49 
50     const SystemEnvData* GetSysData(const Window *pOutputWindow);
51 
52     /** Cairo surface interface
53 
54         For each cairo-supported platform, there's an implementation of
55         this interface
56      */
57 	struct Surface
58     {
59 	public:
~Surfacecairo::Surface60         virtual ~Surface() {}
61 
62         // Query methods
63 		virtual CairoSharedPtr getCairo() const = 0;
64 		virtual CairoSurfaceSharedPtr getCairoSurface() const = 0;
65 		virtual boost::shared_ptr<Surface> getSimilar( Content aContent, int width, int height ) const = 0;
66 
67         /// factory for VirDev on this surface
68         virtual boost::shared_ptr<VirtualDevice> createVirtualDevice() const = 0;
69 
70         /// Resize the surface (possibly destroying content)
71 		virtual void Resize( int width, int height ) = 0;
72 
73         /// Flush all pending output to surface
74         virtual void flush() const = 0;
75 	};
76 
77     typedef boost::shared_ptr<Surface> SurfaceSharedPtr;
78 
79     /// Create Surface from given cairo surface
80     SurfaceSharedPtr createSurface( const CairoSurfaceSharedPtr& rSurface );
81     /// Create surface with given dimensions
82     SurfaceSharedPtr createSurface( const OutputDevice& rRefDevice,
83                                     int x, int y, int width, int height );
84     /// Create Surface for given bitmap data
85     SurfaceSharedPtr createBitmapSurface( const OutputDevice& rRefDevice,
86                                           const BitmapSystemData& rData,
87                                           const Size&             rSize );
88 
89     /// Check whether cairo will work on given window
90     bool IsCairoWorking( OutputDevice* );
91 }
92 
93 #endif
94