[cairo-commit] cairomm/cairomm Makefile.am, 1.5, 1.6 quartz_surface.cc, NONE, 1.1 quartz_surface.h, NONE, 1.1 surface.h, 1.18, 1.19

Murray Cumming commit at pdx.freedesktop.org
Mon Apr 16 01:40:09 PDT 2007


Committed by: murrayc

Update of /cvs/cairo/cairomm/cairomm
In directory kemper:/tmp/cvs-serv20487/cairomm

Modified Files:
	Makefile.am surface.h 
Added Files:
	quartz_surface.cc quartz_surface.h 
Log Message:
2007-04-16  Hugo Vincent  <hugo.vincent at gmail.com>

        * Added QuartzSurface for MacOS X (when cairo is built with Quartz support),
        similar to the existing Win32Surface and XlibSurface. These allow use of 
        platform-specific features and data structures.


Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/cairomm/cairomm/Makefile.am,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Makefile.am	4 Jul 2006 23:06:07 -0000	1.5
+++ Makefile.am	16 Apr 2007 08:39:59 -0000	1.6
@@ -2,9 +2,9 @@
 
 INCLUDES = -I$(top_srcdir) @CAIROMM_CFLAGS@
 
-h_sources_public = cairomm.h context.h enums.h fontface.h fontoptions.h path.h pattern.h surface.h xlib_surface.h win32_surface.h exception.h refptr.h scaledfont.h
+h_sources_public = cairomm.h context.h enums.h fontface.h fontoptions.h path.h pattern.h quartz_surface.h surface.h xlib_surface.h win32_surface.h exception.h refptr.h scaledfont.h
 h_sources_private = private.h
-cc_sources = context.cc fontface.cc fontoptions.cc path.cc pattern.cc surface.cc xlib_surface.cc win32_surface.cc exception.cc scaledfont.cc
+cc_sources = context.cc fontface.cc fontoptions.cc path.cc pattern.cc quartz_surface.cc surface.cc xlib_surface.cc win32_surface.cc exception.cc scaledfont.cc
 cc_sources_private = private.cc
 
 # Support for DLL on cygwin/mingw using libtool > 1.4

--- NEW FILE: quartz_surface.cc ---
/* Copyright (C) 2007 The cairomm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 */

#include <cairomm/quartz_surface.h>
#include <cairomm/private.h>

namespace Cairo
{

#ifdef CAIRO_HAS_QUARTZ_SURFACE

QuartzSurface::QuartzSurface(cairo_surface_t* cobject, bool has_reference) :
    Surface(cobject, has_reference)
{}

QuartzSurface::~QuartzSurface()
{
  // surface is destroyed in base class
}

CGContextRef QuartzSurface::get_cg_context() const
{
  return cairo_quartz_surface_get_cg_context(m_cobject);
}

RefPtr<QuartzSurface> QuartzSurface::create(CGContextRef cg_context, int width, int height)
{
  cairo_surface_t* cobject = cairo_quartz_surface_create_for_cg_context(cg_context, 
          width, height);
  check_status_and_throw_exception(cairo_surface_status(cobject));
  return RefPtr<QuartzSurface>(new QuartzSurface(cobject, true /* has reference */));
}

RefPtr<QuartzSurface> QuartzSurface::create(Format format, int width, int height)
{
  cairo_surface_t* cobject = cairo_quartz_surface_create((cairo_format_t)format, width, height);
  check_status_and_throw_exception(cairo_surface_status(cobject));
  return RefPtr<QuartzSurface>(new QuartzSurface(cobject, true /* has reference */));
}

#endif // CAIRO_HAS_QUARTZ_SURFACE

} //namespace Cairo

// vim: ts=2 sw=2 et

--- NEW FILE: quartz_surface.h ---
/* Copyright (C) 2007 The cairomm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 */

#ifndef __CAIROMM_QUARTZ_SURFACE_H
#define __CAIROMM_QUARTZ_SURFACE_H

#include <cairomm/surface.h>

#ifdef CAIRO_HAS_QUARTZ_SURFACE
#include <cairo-quartz.h>
#endif

namespace Cairo
{

#ifdef CAIRO_HAS_QUARTZ_SURFACE

/** A QuartzSurface provides a way to render within Apple Mac OS X.  If you
 * want to draw to the screen within a Mac OS X application, you
 * should use this Surface type.
 *
 * @note For this Surface to be available, cairo must have been compiled with
 * (native) Quartz support (requires Cairo > 1.4.0)
 */
class QuartzSurface : public Surface
{
public:

  /** Create a C++ wrapper for the C instance. This C++ instance should then be
   * given to a RefPtr.
   *
   * @param cobject The C instance.
   * @param has_reference whether we already have a reference. Otherwise, the
   * constructor will take an extra reference.
   */
  explicit QuartzSurface(cairo_surface_t* cobject, bool has_reference = false);
  virtual ~QuartzSurface();

  /** Returns the CGContextRef associated with this surface, or NULL if none. Also
   * returns NULL if the surface is not a Quartz surface.
   *
   * @return CGContextRef or NULL if no CGContextRef available.
   */
  CGContextRef get_cg_context() const;

  /** Creates a cairo surface that targets the given CGContext.
   *
   * @param cg_context the CGContext to create a surface for
   * @return the newly created surface
   */
  static RefPtr<QuartzSurface> create(CGContextRef cg_context, int width, int height);

  /** Creates a device-independent-bitmap surface not associated with any
   * particular existing surface or device context. The created bitmap will be
   * unititialized.
   *
   * @param format format of pixels in the surface to create
   * @param width width of the surface, in pixels
   * @param height height of the surface, in pixels
   * @return the newly created surface
   */
  static RefPtr<QuartzSurface> create(Format format, int width, int height);

};

#endif // CAIRO_HAS_QUARTZ_SURFACE


} // namespace Cairo

#endif //__CAIROMM_QUARTZ_SURFACE_H

// vim: ts=2 sw=2 et

Index: surface.h
===================================================================
RCS file: /cvs/cairo/cairomm/cairomm/surface.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- surface.h	5 Jul 2006 15:37:12 -0000	1.18
+++ surface.h	16 Apr 2007 08:39:59 -0000	1.19
@@ -28,6 +28,7 @@
 
 //See xlib_surface.h for XlibSurface.
 //See win32_surface.h for Win32Surface.
+//See quartz_surface.h for QuartzSurface (Mac OS X).
 
 #ifdef CAIRO_HAS_PDF_SURFACE
 #include <cairo-pdf.h>



More information about the cairo-commit mailing list