1*91c99ff4SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*91c99ff4SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*91c99ff4SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*91c99ff4SAndrew Rist  * distributed with this work for additional information
6*91c99ff4SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*91c99ff4SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*91c99ff4SAndrew Rist  * "License"); you may not use this file except in compliance
9*91c99ff4SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*91c99ff4SAndrew Rist  *
11*91c99ff4SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*91c99ff4SAndrew Rist  *
13*91c99ff4SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*91c99ff4SAndrew Rist  * software distributed under the License is distributed on an
15*91c99ff4SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*91c99ff4SAndrew Rist  * KIND, either express or implied.  See the License for the
17*91c99ff4SAndrew Rist  * specific language governing permissions and limitations
18*91c99ff4SAndrew Rist  * under the License.
19*91c99ff4SAndrew Rist  *
20*91c99ff4SAndrew Rist  *************************************************************/
21*91c99ff4SAndrew Rist 
22*91c99ff4SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _CAIROCANVAS_CAIRO_HXX
25cdf0e10cSrcweir #define _CAIROCANVAS_CAIRO_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <sal/config.h>
28cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir struct SystemEnvData;
31cdf0e10cSrcweir struct BitmapSystemData;
32cdf0e10cSrcweir struct SystemGraphicsData;
33cdf0e10cSrcweir class  VirtualDevice;
34cdf0e10cSrcweir class  OutputDevice;
35cdf0e10cSrcweir class  Window;
36cdf0e10cSrcweir class  Size;
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #include <cairo.h>  //cannot be inside a namespace, otherwise Quartz fails to compile.
39cdf0e10cSrcweir 
40cdf0e10cSrcweir namespace cairo {
41cdf0e10cSrcweir 	typedef cairo_t Cairo;
42cdf0e10cSrcweir 	typedef cairo_matrix_t Matrix;
43cdf0e10cSrcweir 	typedef cairo_format_t Format;
44cdf0e10cSrcweir 	typedef cairo_content_t Content;
45cdf0e10cSrcweir 	typedef cairo_pattern_t Pattern;
46cdf0e10cSrcweir 
47cdf0e10cSrcweir     typedef boost::shared_ptr<cairo_surface_t> CairoSurfaceSharedPtr;
48cdf0e10cSrcweir     typedef boost::shared_ptr<Cairo>           CairoSharedPtr;
49cdf0e10cSrcweir 
50cdf0e10cSrcweir     const SystemEnvData* GetSysData(const Window *pOutputWindow);
51cdf0e10cSrcweir 
52cdf0e10cSrcweir     /** Cairo surface interface
53cdf0e10cSrcweir 
54cdf0e10cSrcweir         For each cairo-supported platform, there's an implementation of
55cdf0e10cSrcweir         this interface
56cdf0e10cSrcweir      */
57cdf0e10cSrcweir 	struct Surface
58cdf0e10cSrcweir     {
59cdf0e10cSrcweir 	public:
~Surfacecairo::Surface60cdf0e10cSrcweir         virtual ~Surface() {}
61cdf0e10cSrcweir 
62cdf0e10cSrcweir         // Query methods
63cdf0e10cSrcweir 		virtual CairoSharedPtr getCairo() const = 0;
64cdf0e10cSrcweir 		virtual CairoSurfaceSharedPtr getCairoSurface() const = 0;
65cdf0e10cSrcweir 		virtual boost::shared_ptr<Surface> getSimilar( Content aContent, int width, int height ) const = 0;
66cdf0e10cSrcweir 
67cdf0e10cSrcweir         /// factory for VirDev on this surface
68cdf0e10cSrcweir         virtual boost::shared_ptr<VirtualDevice> createVirtualDevice() const = 0;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir         /// Resize the surface (possibly destroying content)
71cdf0e10cSrcweir 		virtual void Resize( int width, int height ) = 0;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir         /// Flush all pending output to surface
74cdf0e10cSrcweir         virtual void flush() const = 0;
75cdf0e10cSrcweir 	};
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     typedef boost::shared_ptr<Surface> SurfaceSharedPtr;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     /// Create Surface from given cairo surface
80cdf0e10cSrcweir     SurfaceSharedPtr createSurface( const CairoSurfaceSharedPtr& rSurface );
81cdf0e10cSrcweir     /// Create surface with given dimensions
82cdf0e10cSrcweir     SurfaceSharedPtr createSurface( const OutputDevice& rRefDevice,
83cdf0e10cSrcweir                                     int x, int y, int width, int height );
84cdf0e10cSrcweir     /// Create Surface for given bitmap data
85cdf0e10cSrcweir     SurfaceSharedPtr createBitmapSurface( const OutputDevice& rRefDevice,
86cdf0e10cSrcweir                                           const BitmapSystemData& rData,
87cdf0e10cSrcweir                                           const Size&             rSize );
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     /// Check whether cairo will work on given window
90cdf0e10cSrcweir     bool IsCairoWorking( OutputDevice* );
91cdf0e10cSrcweir }
92cdf0e10cSrcweir 
93cdf0e10cSrcweir #endif
94