From bdaf6ef334461948076de056b0d76b05e516e974 Mon Sep 17 00:00:00 2001 From: Benjamin Reed Date: Fri, 25 Apr 2008 13:46:06 -0400 Subject: [PATCH] separate calls to possibly-conflicting surface calls On Mac OS X, if you have both the xlib and quartz backends enabled in cairo, cairomm fails to build with conflicting headers: /bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -DPNG_NO_MMX_CODE -I/sw/lib/freetype219/include/freetype2 -I/sw/lib/freetype219/include -I/sw/lib/fontconfig2/include -I/sw/include/pixman-1 -I/sw/include/libpng12 -I/sw/include -I/sw/include/cairo -I/usr/X11R6/include -I/usr/X11/include -I/sw/lib/freetype219/include -I/sw/lib/freetype219/include/freetype2 -I/sw/lib/fontconfig2/include -I/sw/include -I/usr/X11R6/include -g -O2 -c -o context.lo context.cc g++ -DHAVE_CONFIG_H -I. -I.. -DPNG_NO_MMX_CODE -I/sw/lib/freetype219/include/freetype2 -I/sw/lib/freetype219/include -I/sw/lib/fontconfig2/include -I/sw/include/pixman-1 -I/sw/include/libpng12 -I/sw/include -I/sw/include/cairo -I/usr/X11R6/include -I/usr/X11/include -I/sw/lib/freetype219/include -I/sw/lib/freetype219/include/freetype2 -I/sw/lib/fontconfig2/include -I/sw/include -I/usr/X11R6/include -g -O2 -c context.cc -fno-common -DPIC -o .libs/context.o /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/MachineExceptions.h:255: error: declaration does not declare anything /System/Library/Frameworks/ApplicationServices.framework/Frameworks/QD.framework/Headers/QuickdrawTypes.h:264: error: using typedef-name 'Cursor' after 'struct' /usr/X11R6/include/X11/X.h:108: error: 'Cursor' has a previous declaration here /System/Library/Frameworks/ApplicationServices.framework/Frameworks/QD.framework/Headers/QuickdrawTypes.h:269: error: using typedef-name 'Cursor' after 'struct' /usr/X11R6/include/X11/X.h:108: error: 'Cursor' has a previous declaration here /System/Library/Frameworks/ApplicationServices.framework/Frameworks/QD.framework/Headers/QuickdrawTypes.h:269: error: invalid type in declaration before ';' token /System/Library/Frameworks/ApplicationServices.framework/Frameworks/QD.framework/Headers/QuickdrawTypes.h:269: error: conflicting declaration 'typedef int Cursor' /usr/X11R6/include/X11/X.h:108: error: 'Cursor' has a previous declaration as 'typedef XID Cursor' /System/Library/Frameworks/ApplicationServices.framework/Frameworks/QD.framework/Headers/QuickdrawTypes.h:296: error: using typedef-name 'Picture' after 'struct' /usr/X11R6/include/X11/extensions/render.h:31: error: 'Picture' has a previous declaration here /System/Library/Frameworks/ApplicationServices.framework/Frameworks/QD.framework/Headers/QuickdrawTypes.h:300: error: using typedef-name 'Picture' after 'struct' /usr/X11R6/include/X11/extensions/render.h:31: error: 'Picture' has a previous declaration here /System/Library/Frameworks/ApplicationServices.framework/Frameworks/QD.framework/Headers/QuickdrawTypes.h:300: error: invalid type in declaration before ';' token /System/Library/Frameworks/ApplicationServices.framework/Frameworks/QD.framework/Headers/QuickdrawTypes.h:300: error: conflicting declaration 'typedef int Picture' /usr/X11R6/include/X11/extensions/render.h:31: error: 'Picture' has a previous declaration as 'typedef XID Picture' This patch fixes this by separating out the calls in the get_surface_wrapper call to individual .cc files which are then compiled with only the headers they need. --- .gitignore | 4 +++ cairomm/Makefile.am | 4 +- cairomm/context.cc | 12 +++++----- cairomm/context.h | 4 +++ cairomm/context_private.h | 41 ++++++++++++++++++++++++++++++++++++ cairomm/context_surface_quartz.cc | 42 +++++++++++++++++++++++++++++++++++++ cairomm/context_surface_win32.cc | 42 +++++++++++++++++++++++++++++++++++++ cairomm/context_surface_xlib.cc | 42 +++++++++++++++++++++++++++++++++++++ 8 files changed, 183 insertions(+), 8 deletions(-) create mode 100644 cairomm/context_private.h create mode 100644 cairomm/context_surface_quartz.cc create mode 100644 cairomm/context_surface_win32.cc create mode 100644 cairomm/context_surface_xlib.cc diff --git a/.gitignore b/.gitignore index 50f889b..a68e659 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,7 @@ examples/ps-surface/example_ps_file examples/svg-surface/example_svg_file examples/text-rotate/text_rotate tests/test-context +cairomm/cairommconfig.h* +cairomm/stamp-* +m4/libtool.m4 +m4/lt*.m4 diff --git a/cairomm/Makefile.am b/cairomm/Makefile.am index ad2b535..cb476cc 100644 --- a/cairomm/Makefile.am +++ b/cairomm/Makefile.am @@ -3,9 +3,9 @@ SUBDIRS = INCLUDES = -I$(top_srcdir) @CAIROMM_CFLAGS@ 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 cairommconfig.h -h_sources_private = private.h +h_sources_private = private.h context_private.h 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 +cc_sources_private = private.cc context_surface_quartz.cc context_surface_win32.cc context_surface_xlib.cc # Support for DLL on cygwin/mingw using libtool > 1.4 if PLATFORM_WIN32 diff --git a/cairomm/context.cc b/cairomm/context.cc index 8964dd5..f5f17f6 100644 --- a/cairomm/context.cc +++ b/cairomm/context.cc @@ -18,11 +18,9 @@ #include #include +#include #include #include -#include -#include -#include /* M_PI is defined in math.h in the case of Microsoft Visual C++ */ #if defined(_MSC_VER) @@ -34,6 +32,8 @@ # include #endif +using namespace Cairo::Private; + namespace Cairo { @@ -684,7 +684,7 @@ RefPtr get_surface_wrapper (cairo_surface_t* surface) #endif #if CAIRO_HAS_XLIB_SURFACE case CAIRO_SURFACE_TYPE_XLIB: - return RefPtr(new XlibSurface(surface, false /* does not have reference */)); + return wrap_surface_xlib(surface); break; #endif #if CAIRO_HAS_GLITZ_SURFACE @@ -694,12 +694,12 @@ RefPtr get_surface_wrapper (cairo_surface_t* surface) #endif #if CAIRO_HAS_QUARTZ_SURFACE case CAIRO_SURFACE_TYPE_QUARTZ: - return RefPtr(new QuartzSurface(surface, false /* does not have reference */)); + return wrap_surface_quartz(surface); break; #endif #if CAIRO_HAS_WIN32_SURFACE case CAIRO_SURFACE_TYPE_WIN32: - return RefPtr(new Win32Surface(surface, false /* does not have reference */)); + return wrap_surface_win32(surface); break; #endif #if CAIRO_HAS_SVG_SURFACE diff --git a/cairomm/context.h b/cairomm/context.h index 711309e..ceac161 100644 --- a/cairomm/context.h +++ b/cairomm/context.h @@ -1003,6 +1003,10 @@ protected: cobject* m_cobject; }; + RefPtr get_surface_quartz(cairo_surface_t*); + RefPtr get_surface_win32(cairo_surface_t*); + RefPtr get_surface_xlib(cairo_surface_t*); + } // namespace Cairo #endif //__CAIROMM_CONTEXT_H diff --git a/cairomm/context_private.h b/cairomm/context_private.h new file mode 100644 index 0000000..3081dca --- /dev/null +++ b/cairomm/context_private.h @@ -0,0 +1,41 @@ +/* Copyright (C) 2008 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_CONTEXT_PRIVATE_H +#define __CAIROMM_CONTEXT_PRIVATE_H + +#include +#include + +namespace Cairo +{ + +namespace Private +{ + +RefPtr wrap_surface_quartz(cairo_surface_t*); +RefPtr wrap_surface_win32(cairo_surface_t*); +RefPtr wrap_surface_xlib(cairo_surface_t*); + +} // namespace Private + +} // namespace Cairo + +#endif // __CAIROMM_CONTEXT_PRIVATE_H + +// vim: ts=2 sw=2 et diff --git a/cairomm/context_surface_quartz.cc b/cairomm/context_surface_quartz.cc new file mode 100644 index 0000000..540dca3 --- /dev/null +++ b/cairomm/context_surface_quartz.cc @@ -0,0 +1,42 @@ +/* Copyright (C) 2008 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 +#include +#include + +namespace Cairo +{ + +namespace Private +{ + +RefPtr wrap_surface_quartz(cairo_surface_t* surface) +{ +#if CAIRO_HAS_QUARTZ_SURFACE + return RefPtr(new QuartzSurface(surface, false /* does not have reference */)); +#else + return RefPtr(new Surface(surface, false /* does not have reference */)); +#endif +} + +} // namespace Private + +} // namespace Cairo + +// vim: ts=2 sw=2 et diff --git a/cairomm/context_surface_win32.cc b/cairomm/context_surface_win32.cc new file mode 100644 index 0000000..61837bd --- /dev/null +++ b/cairomm/context_surface_win32.cc @@ -0,0 +1,42 @@ +/* Copyright (C) 2008 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 +#include +#include + +namespace Cairo +{ + +namespace Private +{ + +RefPtr wrap_surface_win32(cairo_surface_t* surface) +{ +#if CAIRO_HAS_WIN32_SURFACE + return RefPtr(new Win32Surface(surface, false /* does not have reference */)); +#else + return RefPtr(new Surface(surface, false /* does not have reference */)); +#endif +} + +} // namespace Private + +} // namespace Cairo + +// vim: ts=2 sw=2 et diff --git a/cairomm/context_surface_xlib.cc b/cairomm/context_surface_xlib.cc new file mode 100644 index 0000000..0f57bc7 --- /dev/null +++ b/cairomm/context_surface_xlib.cc @@ -0,0 +1,42 @@ +/* Copyright (C) 2008 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 +#include +#include + +namespace Cairo +{ + +namespace Private +{ + +RefPtr wrap_surface_xlib(cairo_surface_t* surface) +{ +#if CAIRO_HAS_WIN32_SURFACE + return RefPtr(new XlibSurface(surface, false /* does not have reference */)); +#else + return RefPtr(new Surface(surface, false /* does not have reference */)); +#endif +} + +} // namespace Private + +} // namespace Cairo + +// vim: ts=2 sw=2 et -- 1.5.3.7