[cairo-commit] cairomm/cairomm Makefile.am, 1.3, 1.4 surface.cc, 1.7, 1.8 surface.h, 1.5, 1.6 win32_surface.cc, NONE, 1.1 win32_surface.h, NONE, 1.1 xlib_surface.cc, NONE, 1.1 xlib_surface.h, NONE, 1.1

Murray Cumming commit at pdx.freedesktop.org
Tue Jan 24 03:48:44 PST 2006


Committed by: murrayc

Update of /cvs/cairo/cairomm/cairomm
In directory gabe:/tmp/cvs-serv15828/cairomm

Modified Files:
	Makefile.am surface.cc surface.h 
Added Files:
	win32_surface.cc win32_surface.h xlib_surface.cc 
	xlib_surface.h 
Log Message:
2006-01-24  Murray Cumming  <murrayc at murrayc.com>

        * cairomm/Makefile.am:
        * cairomm/surface.cc:
        * cairomm/surface.h:
        * cairomm/xlib_surface.cc:
        * cairomm/xlib_surface.h:
        * cairomm/win32_surface.cc:
        * cairomm/win32_surface.h: Moved XlibSurface and
        Win32Surface into separate files, not #included by
        the main cairomm.h file, so that developers do not need to
        suffer the Xlib.h or Windows namespace pollution unless they really need to.
        For instance, this fixes the gtkmm 2.9 build which was broken by the
        Display struct in Xlib.h.


Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/cairomm/cairomm/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Makefile.am	20 Dec 2005 09:17:53 -0000	1.3
+++ Makefile.am	24 Jan 2006 11:48:42 -0000	1.4
@@ -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 exception.h refptr.h
+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
 h_sources_private = private.h
-cc_sources = context.cc fontface.cc fontoptions.cc path.cc pattern.cc surface.cc exception.cc
+cc_sources = context.cc fontface.cc fontoptions.cc path.cc pattern.cc surface.cc xlib_surface.cc win32_surface.cc exception.cc
 cc_sources_private = private.cc
 
 # Support for DLL on cygwin/mingw using libtool > 1.4

Index: surface.cc
===================================================================
RCS file: /cvs/cairo/cairomm/cairomm/surface.cc,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- surface.cc	21 Jan 2006 16:22:40 -0000	1.7
+++ surface.cc	24 Jan 2006 11:48:42 -0000	1.8
@@ -164,67 +164,6 @@
 }
 
 
-#ifdef CAIRO_HAS_XLIB_SURFACE
-
-XlibSurface::XlibSurface(cairo_surface_t* cobject, bool has_reference) :
-    Surface(cobject, has_reference)
-{}
-
-XlibSurface::~XlibSurface()
-{
-  // surface is destroyed in base class
-}
-
-RefPtr<XlibSurface> XlibSurface::create(Display *dpy, Drawable drawable, Visual *visual, int width, int height)
-{
-  cairo_surface_t* cobject = cairo_xlib_surface_create(dpy, drawable, visual, width, height);
-  check_status_and_throw_exception(cairo_surface_status(cobject));
-  return RefPtr<XlibSurface>(new XlibSurface(cobject, true /* has reference */));
-}
-
-RefPtr<XlibSurface> XlibSurface::create(Display *dpy, Pixmap bitmap, Screen *screen, int width, int height)
-{
-  cairo_surface_t* cobject = cairo_xlib_surface_create_for_bitmap(dpy, bitmap, screen, width, height);
-  check_status_and_throw_exception(cairo_surface_status(cobject));
-  return RefPtr<XlibSurface>(new XlibSurface(cobject, true /* has reference */));
-}
-
-void XlibSurface::set_size(int width, int height)
-{
-  cairo_xlib_surface_set_size(m_cobject, width, height);
-  check_object_status_and_throw_exception(*this);
-}
-
-void XlibSurface::set_drawable(Drawable drawable, int width, int height)
-{
-  cairo_xlib_surface_set_drawable(m_cobject, drawable, width, height);
-  check_object_status_and_throw_exception(*this);
-}
-
-#endif // CAIRO_HAS_XLIB_SURFACE
-
-
-
-#ifdef CAIRO_HAS_WIN32_SURFACE
-
-Win32Surface::Win32Surface(cairo_surface_t* cobject, bool has_reference) :
-    Surface(cobject, has_reference)
-{}
-
-Win32Surface::~Win32Surface()
-{
-  // surface is destroyed in base class
-}
-
-RefPtr<Win32Surface> Win32Surface::create(HDC hdc)
-{
-  cairo_surface_t* cobject = cairo_win32_surface_create(hdc);
-  check_status_and_throw_exception(cairo_surface_status(cobject));
-  return RefPtr<Win32Surface>(new Win32Surface(cobject, true /* has reference */));
-}
-
-#endif // CAIRO_HAS_WIN32_SURFACE
-
 
 /*******************************************************************************
  * THE FOLLOWING SURFACE TYPES ARE EXPERIMENTAL AND NOT FULLY SUPPORTED

Index: surface.h
===================================================================
RCS file: /cvs/cairo/cairomm/cairomm/surface.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- surface.h	21 Jan 2006 16:22:40 -0000	1.5
+++ surface.h	24 Jan 2006 11:48:42 -0000	1.6
@@ -24,12 +24,8 @@
 #include <cairomm/fontoptions.h>
 #include <cairomm/refptr.h>
 
-#ifdef CAIRO_HAS_XLIB_SURFACE
-#include <cairo-xlib.h>
-#endif
-#ifdef CAIRO_HAS_WIN32_SURFACE
-#include <cairo-win32.h>
-#endif
+//See xlib_surface.h for XlibSurface.
+//See win32_surface.h for Win32Surface.
 
 // Experimental surfaces
 #ifdef CAIRO_HAS_PDF_SURFACE
@@ -323,123 +319,6 @@
 };
 
 
-#ifdef CAIRO_HAS_XLIB_SURFACE
-
-/** An XlibSurface provides a way to render to the X Window System using XLib.
- * If you want to draw to the screen within an application that uses the X
- * Window system, you should use this Surface type.
- *
- * \note For this surface to be availabe, cairo must have been compiled with
- * support for XLib Surfaces
- */
-class XlibSurface : 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 XlibSurface(cairo_surface_t* cobject, bool has_reference = false);
-  virtual ~XlibSurface();
-
-  /** Creates an Xlib surface that draws to the given drawable. The way that
-   * colors are represented in the drawable is specified by the provided
-   * visual.
-   *
-   * \note If drawable is a Window, then the function
-   * cairo_xlib_surface_set_size must be called whenever the size of the window
-   * changes.
-   *
-   * @param dpy	an X Display
-   * @param drawable	an X Drawable, (a Pixmap or a Window)
-   * @param visual	the visual to use for drawing to drawable. The depth of the visual must match the depth of the drawable. Currently, only TrueColor visuals are fully supported.
-   * @param width	the current width of drawable.
-   * @param height	the current height of drawable.
-   * @return	A RefPtr to the newly created surface
-   */
-  static RefPtr<XlibSurface> create(Display *dpy, Drawable drawable, Visual *visual, int width, int height);
-
-  /** Creates an Xlib surface that draws to the given bitmap. This will be
-   * drawn to as a CAIRO_FORMAT_A1 object.
-   *
-   * @param dpy	an X Display
-   * @param bitmap	an X Drawable, (a depth-1 Pixmap)
-   * @param screen	the X Screen associated with bitmap
-   * @param width	the current width of bitmap.
-   * @param height	the current height of bitmap.
-   * @return	A RefPtr to the newly created surface
-   */
-  static RefPtr<XlibSurface> create(Display *dpy, Pixmap bitmap, Screen *screen, int width, int height);
-
-  /** Informs cairo of the new size of the X Drawable underlying the surface.
-   * For a surface created for a Window (rather than a Pixmap), this function
-   * must be called each time the size of the window changes. (For a subwindow,
-   * you are normally resizing the window yourself, but for a toplevel window,
-   * it is necessary to listen for ConfigureNotify events.)
-   *
-   * A Pixmap can never change size, so it is never necessary to call this
-   * function on a surface created for a Pixmap.
-   *
-   * @param width	the new width of the surface
-   * @param height	the new height of the surface
-   */
-  void set_size(int width, int height);
-
-  /** Informs cairo of a new X Drawable underlying the surface. The drawable
-   * must match the display, screen and format of the existing drawable or the
-   * application will get X protocol errors and will probably terminate. No
-   * checks are done by this function to ensure this compatibility.
-   *
-   * @param drawable	the new drawable for the surface
-   * @param width	the width of the new drawable
-   * @param height	the height of the new drawable
-   */
-  void set_drawable(Drawable drawable, int width, int height);
-
-};
-
-#endif // CAIRO_HAS_XLIB_SURFACE
-
-
-#ifdef CAIRO_HAS_WIN32_SURFACE
-
-/** A Win32Surface provides a way to render within Microsoft Windows.  If you
- * want to draw to the screen within a Microsoft Windows application, you
- * should use this Surface type.
- *
- * \note For this Surface to be available, cairo must have been compiled with
- * Win32 support
- */
-class Win32Surface : 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 Win32Surface(cairo_surface_t* cobject, bool has_reference = false);
-  virtual ~Win32Surface();
-
-  /** Creates a Surface for drawing in Microsoft Windows
-   *
-   * @param hdc
-   * @return    A RefPtr to the newly created surface
-   */
-  static RefPtr<Win32Surface> create(HDC hdc);
-
-};
-
-#endif // CAIRO_HAS_WIN32_SURFACE
-
-
 /*******************************************************************************
  * THE FOLLOWING SURFACE TYPES ARE EXPERIMENTAL AND NOT FULLY SUPPORTED
  ******************************************************************************/

--- NEW FILE: win32_surface.cc ---
/* Copyright (C) 2005 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

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

#ifdef CAIRO_HAS_WIN32_SURFACE
#include <cairo-win32.h>
#endif

namespace Cairo
{

#ifdef CAIRO_HAS_WIN32_SURFACE

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

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

RefPtr<Win32Surface> Win32Surface::create(HDC hdc)
{
  cairo_surface_t* cobject = cairo_win32_surface_create(hdc);
  check_status_and_throw_exception(cairo_surface_status(cobject));
  return RefPtr<Win32Surface>(new Win32Surface(cobject, true /* has reference */));
}

#endif // CAIRO_HAS_WIN32_SURFACE

} //namespace Cairo

--- NEW FILE: win32_surface.h ---
/* Copyright (C) 2005 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __CAIROMM_WIN32_SURFACE_H
#define __CAIROMM_WIN32_SURFACE_H

#include <cairomm/surface.h>

// This header is not included by cairomm.h because it requires Windows headers that 
// tend to pollute the namespace with non-prefixed #defines and typedefs.
// You may include it directly if you need to use this API.

namespace Cairo
{

#ifdef CAIRO_HAS_WIN32_SURFACE

/** A Win32Surface provides a way to render within Microsoft Windows.  If you
 * want to draw to the screen within a Microsoft Windows application, you
 * should use this Surface type.
 *
 * \note For this Surface to be available, cairo must have been compiled with
 * Win32 support
 */
class Win32Surface : 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 Win32Surface(cairo_surface_t* cobject, bool has_reference = false);
  virtual ~Win32Surface();

  /** Creates a Surface for drawing in Microsoft Windows
   *
   * @param hdc
   * @return    A RefPtr to the newly created surface
   */
  static RefPtr<Win32Surface> create(HDC hdc);

};

#endif // CAIRO_HAS_WIN32_SURFACE


} // namespace Cairo

#endif //__CAIROMM_WIN32_SURFACE_H

--- NEW FILE: xlib_surface.cc ---
/* Copyright (C) 2005 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

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


namespace Cairo
{

#ifdef CAIRO_HAS_XLIB_SURFACE

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

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

RefPtr<XlibSurface> XlibSurface::create(Display *dpy, Drawable drawable, Visual *visual, int width, int height)
{
  cairo_surface_t* cobject = cairo_xlib_surface_create(dpy, drawable, visual, width, height);
  check_status_and_throw_exception(cairo_surface_status(cobject));
  return RefPtr<XlibSurface>(new XlibSurface(cobject, true /* has reference */));
}

RefPtr<XlibSurface> XlibSurface::create(Display *dpy, Pixmap bitmap, Screen *screen, int width, int height)
{
  cairo_surface_t* cobject = cairo_xlib_surface_create_for_bitmap(dpy, bitmap, screen, width, height);
  check_status_and_throw_exception(cairo_surface_status(cobject));
  return RefPtr<XlibSurface>(new XlibSurface(cobject, true /* has reference */));
}

void XlibSurface::set_size(int width, int height)
{
  cairo_xlib_surface_set_size(m_cobject, width, height);
  check_object_status_and_throw_exception(*this);
}

void XlibSurface::set_drawable(Drawable drawable, int width, int height)
{
  cairo_xlib_surface_set_drawable(m_cobject, drawable, width, height);
  check_object_status_and_throw_exception(*this);
}

#endif // CAIRO_HAS_XLIB_SURFACE

} //namespace Cairo

--- NEW FILE: xlib_surface.h ---
/* Copyright (C) 2005 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __CAIROMM_XLIB_SURFACE_H
#define __CAIROMM_XLIB_SURFACE_H

#include <cairomm/surface.h>

// This header is not included by cairomm.h because it requires X headers that 
// tend to pollute the namespace with non-prefixed #defines and typedefs.
// You may include it directly if you need to use this API.

#ifdef CAIRO_HAS_XLIB_SURFACE
#include <cairo-xlib.h> //Needed for the X11 "Display" struct (which pollutes the namespace because it has no prefix.)
#endif


namespace Cairo
{

#ifdef CAIRO_HAS_XLIB_SURFACE

/** An XlibSurface provides a way to render to the X Window System using XLib.
 * If you want to draw to the screen within an application that uses the X
 * Window system, you should use this Surface type.
 *
 * \note For this surface to be availabe, cairo must have been compiled with
 * support for XLib Surfaces
 */
class XlibSurface : 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 XlibSurface(cairo_surface_t* cobject, bool has_reference = false);
  virtual ~XlibSurface();

  /** Creates an Xlib surface that draws to the given drawable. The way that
   * colors are represented in the drawable is specified by the provided
   * visual.
   *
   * \note If drawable is a Window, then the function
   * cairo_xlib_surface_set_size must be called whenever the size of the window
   * changes.
   *
   * @param dpy	an X Display
   * @param drawable	an X Drawable, (a Pixmap or a Window)
   * @param visual	the visual to use for drawing to drawable. The depth of the visual must match the depth of the drawable. Currently, only TrueColor visuals are fully supported.
   * @param width	the current width of drawable.
   * @param height	the current height of drawable.
   * @return	A RefPtr to the newly created surface
   */
  static RefPtr<XlibSurface> create(Display *dpy, Drawable drawable, Visual *visual, int width, int height);

  /** Creates an Xlib surface that draws to the given bitmap. This will be
   * drawn to as a CAIRO_FORMAT_A1 object.
   *
   * @param dpy	an X Display
   * @param bitmap	an X Drawable, (a depth-1 Pixmap)
   * @param screen	the X Screen associated with bitmap
   * @param width	the current width of bitmap.
   * @param height	the current height of bitmap.
   * @return	A RefPtr to the newly created surface
   */
  static RefPtr<XlibSurface> create(Display *dpy, Pixmap bitmap, Screen *screen, int width, int height);

  /** Informs cairo of the new size of the X Drawable underlying the surface.
   * For a surface created for a Window (rather than a Pixmap), this function
   * must be called each time the size of the window changes. (For a subwindow,
   * you are normally resizing the window yourself, but for a toplevel window,
   * it is necessary to listen for ConfigureNotify events.)
   *
   * A Pixmap can never change size, so it is never necessary to call this
   * function on a surface created for a Pixmap.
   *
   * @param width	the new width of the surface
   * @param height	the new height of the surface
   */
  void set_size(int width, int height);

  /** Informs cairo of a new X Drawable underlying the surface. The drawable
   * must match the display, screen and format of the existing drawable or the
   * application will get X protocol errors and will probably terminate. No
   * checks are done by this function to ensure this compatibility.
   *
   * @param drawable	the new drawable for the surface
   * @param width	the width of the new drawable
   * @param height	the height of the new drawable
   */
  void set_drawable(Drawable drawable, int width, int height);

};

#endif // CAIRO_HAS_XLIB_SURFACE

} // namespace Cairo

#endif //__CAIROMM_XLIB_SURFACE_H



More information about the cairo-commit mailing list