summaryrefslogtreecommitdiff
authorM Joonas Pihlaja <jpihlaja@cc.helsinki.fi>2009-09-19 07:31:18 (GMT)
committer M Joonas Pihlaja <jpihlaja@cc.helsinki.fi>2009-09-19 07:40:43 (GMT)
commit79613500f185893bb2d5acb99143e97ece2ebb87 (patch) (side-by-side diff)
tree6d4dd3ed7b3cefd90b1027e05a39abada07748ae
parent4987324ec141f8959bb314a1f2b4173438f4842d (diff)
downloadcairosdl-79613500f185893bb2d5acb99143e97ece2ebb87.zip
cairosdl-79613500f185893bb2d5acb99143e97ece2ebb87.tar.gz
Make it compile with g++.HEADmaster
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cairosdl.c21
-rw-r--r--cairosdl.h7
2 files changed, 23 insertions, 5 deletions
diff --git a/cairosdl.c b/cairosdl.c
index eb9af6e..fcfa8fa 100644
--- a/cairosdl.c
+++ b/cairosdl.c
@@ -26,6 +26,10 @@
#include <assert.h>
#include "cairosdl.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* forward references */
static void
_cairosdl_blit_and_unpremultiply (
@@ -50,8 +54,9 @@ _cairosdl_blit_and_premultiply (
*/
/* We're hanging the SDL_Surface as a user datum on the
- * cairo_surface_t representing it using this key. */
-static cairo_user_data_key_t const CAIROSDL_TARGET_KEY[1];
+ * cairo_surface_t representing it using this key. Turns out we need
+ * to initialise it for C++. */
+static cairo_user_data_key_t const CAIROSDL_TARGET_KEY[1] = {{1}};
static void
sdl_surface_destroy_func (void *param)
@@ -104,7 +109,8 @@ cairosdl_surface_create (
*
* However, it turns out malloc is actually safe on many (all?)
* platforms so we'll just go ahead anyway. */
- target = cairo_image_surface_create_for_data (sdl_surface->pixels,
+ unsigned char *data = (unsigned char*)(sdl_surface->pixels);
+ target = cairo_image_surface_create_for_data (data,
format,
sdl_surface->w,
sdl_surface->h,
@@ -143,7 +149,8 @@ SDL_Surface *
cairosdl_surface_get_target (
cairo_surface_t *surface)
{
- return cairo_surface_get_user_data (surface, CAIROSDL_TARGET_KEY);
+ void *udata = cairo_surface_get_user_data (surface, CAIROSDL_TARGET_KEY);
+ return (SDL_Surface*)(udata);
}
static cairo_status_t
@@ -159,7 +166,7 @@ _cairosdl_surface_obtain_SDL_buffer(
return CAIRO_STATUS_NULL_POINTER;
if (OUT_buffer)
- *OUT_buffer = sdl_surface->pixels;
+ *OUT_buffer = (unsigned char *)(sdl_surface->pixels);
if (OUT_stride)
*OUT_stride = sdl_surface->pitch;
if (OUT_width)
@@ -687,3 +694,7 @@ _cairosdl_blit_and_premultiply (
source_bytes += source_stride;
}
}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/cairosdl.h b/cairosdl.h
index beb190d..53c9430 100644
--- a/cairosdl.h
+++ b/cairosdl.h
@@ -27,6 +27,10 @@
#include <cairo.h>
#include <SDL.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* All cairo and cairosdl functions expect the underlying SDL_Surface
* to be locked or not need locking. The underlying condition is that
* the ->pixels member of the SDL_Surface should be valid and not
@@ -109,4 +113,7 @@ cairosdl_destroy (cairo_t *cr);
#define CAIROSDL_GMASK (255U << CAIROSDL_GSHIFT)
#define CAIROSDL_BMASK (255U << CAIROSDL_BSHIFT)
+#ifdef __cplusplus
+}
+#endif
#endif /* CAIROSDL_H */