Merged revisions 6293,6296-6306,6308 via svnmerge from
[ardour.git] / libs / cairomm / cairomm / quartz_surface.h
1 /* Copyright (C) 2007 The cairomm Development Team
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Library General Public
5  * License as published by the Free Software Foundation; either
6  * version 2 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * Library General Public License for more details.
12  *
13  * You should have received a copy of the GNU Library General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16  * 02110-1301, USA.
17  */
18
19 #ifndef __CAIROMM_QUARTZ_SURFACE_H
20 #define __CAIROMM_QUARTZ_SURFACE_H
21
22 #include <cairomm/surface.h>
23
24 #ifdef CAIRO_HAS_QUARTZ_SURFACE
25 #include <cairo-quartz.h>
26 #endif
27
28 namespace Cairo
29 {
30
31 #ifdef CAIRO_HAS_QUARTZ_SURFACE
32
33 /** A QuartzSurface provides a way to render within Apple Mac OS X.  If you
34  * want to draw to the screen within a Mac OS X application, you
35  * should use this Surface type.
36  *
37  * @note For this Surface to be available, cairo must have been compiled with
38  * (native) Quartz support (requires Cairo > 1.4.0)
39  */
40 class QuartzSurface : public Surface
41 {
42 public:
43
44   /** Create a C++ wrapper for the C instance. This C++ instance should then be
45    * given to a RefPtr.
46    *
47    * @param cobject The C instance.
48    * @param has_reference whether we already have a reference. Otherwise, the
49    * constructor will take an extra reference.
50    */
51   explicit QuartzSurface(cairo_surface_t* cobject, bool has_reference = false);
52   virtual ~QuartzSurface();
53
54   /** Returns the CGContextRef associated with this surface, or NULL if none. Also
55    * returns NULL if the surface is not a Quartz surface.
56    *
57    * @return CGContextRef or NULL if no CGContextRef available.
58    */
59   CGContextRef get_cg_context() const;
60
61   /** Creates a cairo surface that targets the given CGContext.
62    *
63    * @param cg_context the CGContext to create a surface for
64    * @return the newly created surface
65    */
66   static RefPtr<QuartzSurface> create(CGContextRef cg_context, int width, int height);
67
68   /** Creates a device-independent-bitmap surface not associated with any
69    * particular existing surface or device context. The created bitmap will be
70    * unititialized.
71    *
72    * @param format format of pixels in the surface to create
73    * @param width width of the surface, in pixels
74    * @param height height of the surface, in pixels
75    * @return the newly created surface
76    */
77   static RefPtr<QuartzSurface> create(Format format, int width, int height);
78
79 };
80
81 #endif // CAIRO_HAS_QUARTZ_SURFACE
82
83
84 } // namespace Cairo
85
86 #endif //__CAIROMM_QUARTZ_SURFACE_H
87
88 // vim: ts=2 sw=2 et