[cairo-commit] cairo-demo/sdl ChangeLog,1.1,1.2 main.c,1.1,1.2

Carl Worth commit at pdx.freedesktop.org
Tue Jul 12 20:54:03 PDT 2005


Committed by: cworth

Update of /cvs/cairo/cairo-demo/sdl
In directory gabe:/tmp/cvs-serv1091

Modified Files:
	ChangeLog main.c 
Log Message:

        * main.c: (load_svg): Port things forward to the latest cairo API.


Index: ChangeLog
===================================================================
RCS file: /cvs/cairo/cairo-demo/sdl/ChangeLog,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ChangeLog	19 Mar 2004 21:58:05 -0000	1.1
+++ ChangeLog	13 Jul 2005 03:54:01 -0000	1.2
@@ -1,3 +1,7 @@
+2005-07-12  Carl Worth  <cworth at cworth.org>
+
+	* main.c: (load_svg): Port things forward to the latest cairo API.
+
 2004-03-18  Eric Windisch  <nospam at bwbohh.net>
 
 	* sdl: initial version.

Index: main.c
===================================================================
RCS file: /cvs/cairo/cairo-demo/sdl/main.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- main.c	19 Mar 2004 21:58:05 -0000	1.1
+++ main.c	13 Jul 2005 03:54:01 -0000	1.2
@@ -23,6 +23,7 @@
 */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <sys/types.h>
 
 #include <SDL.h>
@@ -48,14 +49,25 @@
     svg_cairo_t *scr;
     int bpp;
     int btpp;
-    int rwidth;
-    int rheight;
+    unsigned int rwidth;
+    unsigned int rheight;
 
     // Get some info from SDL.
     bpp=SDL_GetVideoInfo()->vfmt->BitsPerPixel;
     btpp=SDL_GetVideoInfo()->vfmt->BytesPerPixel;
 
-    cairo_t *cr=cairo_create();
+    // scanline width
+    int stride=width * btpp;
+
+    // Allocate an image
+    unsigned char *image=calloc(stride*height, 4);
+
+    cairo_surface_t *cairo_surface;
+    cairo_surface = cairo_image_surface_create_for_data (image,
+							 CAIRO_FORMAT_ARGB32,
+							 width, height, stride);
+
+    cairo_t *cr=cairo_create(cairo_surface);
 
     // Create the Cairo stuff.
     svg_cairo_create(&scr);
@@ -96,22 +108,17 @@
     }
     cairo_scale (cr, wscale, hscale);
 
-    // scanline width
-    int stride=width * btpp;
-
-    // Allocate an image
-    char *image=(char *)calloc(stride*height, 4);
-
-    //printf ("Setting target.\n");
-    cairo_set_target_image (cr, image, CAIRO_FORMAT_ARGB32, width, height, stride);
     svg_cairo_render (scr, cr);
 
+    cairo_surface_destroy (cairo_surface);
+    cairo_destroy (cr);
+
     // This is the most important part of the code.
     // Make sure to shift the alpha channel.
-    SDL_Surface *surface=SDL_CreateRGBSurfaceFrom( (void *) image, width, height, bpp, stride, 0x00, 0x00, 0x00, 0xFF<<24);
+    SDL_Surface *sdl_surface=SDL_CreateRGBSurfaceFrom( (void *) image, width, height, bpp, stride, 0x00, 0x00, 0x00, 0xFF<<24);
 
     //printf ("Returning..\n");
-    return surface;
+    return sdl_surface;
 }
 
 SDL_Surface*




More information about the cairo-commit mailing list