diff options
author | M Joonas Pihlaja <jpihlaja@cc.helsinki.fi> | 2009-09-19 10:31:18 +0300 |
---|---|---|
committer | M Joonas Pihlaja <jpihlaja@cc.helsinki.fi> | 2009-09-19 10:40:43 +0300 |
commit | 79613500f185893bb2d5acb99143e97ece2ebb87 (patch) | |
tree | 6d4dd3ed7b3cefd90b1027e05a39abada07748ae | |
parent | 4987324ec141f8959bb314a1f2b4173438f4842d (diff) |
-rw-r--r-- | cairosdl.c | 21 | ||||
-rw-r--r-- | cairosdl.h | 7 |
2 files changed, 23 insertions, 5 deletions
@@ -28,2 +28,6 @@ +#ifdef __cplusplus +extern "C" { +#endif + /* forward references */ @@ -52,4 +56,5 @@ _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}}; @@ -106,3 +111,4 @@ cairosdl_surface_create ( * 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, @@ -145,3 +151,4 @@ cairosdl_surface_get_target ( { - 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); } @@ -161,3 +168,3 @@ _cairosdl_surface_obtain_SDL_buffer( if (OUT_buffer) - *OUT_buffer = sdl_surface->pixels; + *OUT_buffer = (unsigned char *)(sdl_surface->pixels); if (OUT_stride) @@ -689 +696,5 @@ _cairosdl_blit_and_premultiply ( } + +#ifdef __cplusplus +} +#endif @@ -29,2 +29,6 @@ +#ifdef __cplusplus +extern "C" { +#endif + /* All cairo and cairosdl functions expect the underlying SDL_Surface @@ -111,2 +115,5 @@ cairosdl_destroy (cairo_t *cr); +#ifdef __cplusplus +} +#endif #endif /* CAIROSDL_H */ |