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_QUARTZ_CAIRO_HXX
25 #define _CAIROCANVAS_QUARTZ_CAIRO_HXX
26 
27 #include "cairo_cairo.hxx"
28 
29 #include "premac.h"
30 #include <Cocoa/Cocoa.h>
31 #include <cairo-quartz.h>
32 #include "postmac.h"
33 
34 namespace cairo {
35 
36 	class QuartzSurface : public Surface
37     {
38         NSView*               mpView; // if NULL - bg surface
39 		CairoSurfaceSharedPtr mpSurface;
40 
41 	public:
42         /// takes over ownership of passed cairo_surface
43 		explicit QuartzSurface( const CairoSurfaceSharedPtr& pSurface );
44 
45         /// create surface on subarea of given CGContext
46 		explicit QuartzSurface( CGContextRef rContext, int x, int y, int width, int height );
47 
48         /// create a offscreen surface for given NSView
49 		QuartzSurface( NSView* pView, int x, int y, int width, int height );
50 
51         // Surface interface
52 		virtual CairoSharedPtr getCairo() const;
getCairoSurface() const53 		virtual CairoSurfaceSharedPtr getCairoSurface() const { return mpSurface; }
54 		virtual SurfaceSharedPtr getSimilar( Content aContent, int width, int height ) const;
55 
56         virtual boost::shared_ptr<VirtualDevice> createVirtualDevice() const;
57 
58 		virtual void Resize( int width, int height );
59 
60         virtual void flush() const;
61 
62 		int getDepth() const;
63 
64         CGContextRef getCGContext() const;
65 
66 	};
67 }
68 
69 #endif
70