[cairo-commit] rcairo/src rb_cairo.h, 1.5, 1.6 rb_cairo_surface.c, 1.7, 1.8

Kouhei Sutou commit at pdx.freedesktop.org
Sat May 19 20:03:14 PDT 2007


Committed by: kou

Update of /cvs/cairo/rcairo/src
In directory kemper:/tmp/cvs-serv25403/src

Modified Files:
	rb_cairo.h rb_cairo_surface.c 
Log Message:
* src/rb_cairo.h, src/rb_cairo_surface.c: improved win32 surface
  support. Thanks to Yoshinao Muramatsu!


Index: rb_cairo.h
===================================================================
RCS file: /cvs/cairo/rcairo/src/rb_cairo.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- rb_cairo.h	20 May 2007 02:45:40 -0000	1.5
+++ rb_cairo.h	20 May 2007 03:03:02 -0000	1.6
@@ -31,7 +31,9 @@
 #endif
 
 #if CAIRO_HAS_WIN32_SURFACE
+#  define OpenFile OpenFile_win32
 #  include <cairo-win32.h>
+#  undef OpenFile
 #endif
 
 #define CAIRO_CHECK_VERSION(major, minor, micro)    \

Index: rb_cairo_surface.c
===================================================================
RCS file: /cvs/cairo/rcairo/src/rb_cairo_surface.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- rb_cairo_surface.c	20 May 2007 02:45:40 -0000	1.7
+++ rb_cairo_surface.c	20 May 2007 03:03:02 -0000	1.8
@@ -750,45 +750,45 @@
 static VALUE
 cr_win32_surface_initialize (int argc, VALUE *argv, VALUE self)
 {
-  const char[] invalid_argument_message =
-    "invalid argument (expect "
-    "(hdc), "
-    "(hdc, width, height), "
-    "(hdc, format, width, height), "
-    "(width, height) or "
-    "(format, width, height)";
-  cairo_surface_t *surface;
+  cairo_surface_t *surface = NULL;
   cairo_format_t cr_format;
+  VALUE arg1, arg2, arg3, arg4;
   VALUE hdc, format, width, height;
 
-  rb_scan_args (argc, argv, "13", &hdc, &format, &width, &height);
+  rb_scan_args (argc, argv, "13", &arg1, &arg2, &arg3, &arg4);
 
   switch (argc)
     {
     case 1:
+      hdc = arg1;
       surface = cairo_win32_surface_create ((HDC) NUM2UINT (hdc));
       break;
     case 2:
-      surface = cairo_win32_surface_create_with_dib (CAIRO_FORMAT_RGB24,
+      width = arg1;
+      height = arg3;
+      surface = cairo_win32_surface_create_with_dib (CAIRO_FORMAT_ARGB32,
                                                      NUM2INT (width),
                                                      NUM2INT (height));
       break;
     case 3:
-      if (NIL_P (hdc) ||
-          (rb_cairo__is_kind_of (hdc, rb_cNumeric) &&
-           NUM2INT (hdc) != CAIRO_FORMAT_RGB24))
+      if (NIL_P (arg1) ||
+          (rb_cairo__is_kind_of (arg1, rb_cNumeric) &&
+           NUM2INT (arg1) != CAIRO_FORMAT_RGB24))
         {
+          hdc = arg1;
+          width = arg2;
+          height = arg3;
           HDC win32_hdc = NIL_P (hdc) ? NULL : (HDC) NUM2UINT (hdc);
-          surface = cairo_win32_surface_create_with_ddb (hdc,
-                                                         CAIRO_FORMAT_ARGB32,
+          surface = cairo_win32_surface_create_with_ddb (win32_hdc,
+                                                         CAIRO_FORMAT_RGB24,
                                                          NUM2INT (width),
                                                          NUM2INT (height));
         }
       else
         {
-          height = width;
-          width = format;
-          format = hdc;
+          format = arg1;
+          width = arg2;
+          height = arg3;
           surface = cairo_win32_surface_create_with_dib (RVAL2CRFORMAT (format),
                                                          NUM2INT (width),
                                                          NUM2INT (height));
@@ -796,12 +796,18 @@
       break;
     case 4:
       {
-        HDC win32_hdc = NIL_P (hdc) ? NULL : (HDC) NUM2UINT (hdc);
-        surface = cairo_win32_surface_create_with_ddb (hdc,
-                                                       CAIRO_FORMAT_ARGB32,
+        HDC win32_hdc;
+        hdc = arg1;
+        format = arg2;
+        width = arg3;
+        height = arg4;
+        win32_hdc = NIL_P (hdc) ? NULL : (HDC) NUM2UINT (hdc);
+        surface = cairo_win32_surface_create_with_ddb (win32_hdc,
+                                                       RVAL2CRFORMAT (format),
                                                        NUM2INT (width),
                                                        NUM2INT (height));
       }
+      break;
     }
 
   if (!surface)
@@ -830,7 +836,6 @@
 cr_win32_surface_get_image (VALUE self)
 {
   cairo_surface_t *surface;
-  VALUE rb_surface;
 
   surface = cairo_win32_surface_get_image (_SELF);
   if (!surface)



More information about the cairo-commit mailing list