[cairo-commit] cairo-java/src/jni org_freedesktop_cairo_PngSurface.c, 1.6, 1.7 org_freedesktop_cairo_Cairo.c, 1.17, 1.18 org_freedesktop_cairo_Pattern.c, 1.1, 1.2

Jeffrey Morgan commit at pdx.freedesktop.org
Sat Apr 23 09:48:30 PDT 2005


Committed by: kuzman

Update of /cvs/cairo/cairo-java/src/jni
In directory gabe:/tmp/cvs-serv27983/src/jni

Modified Files:
	org_freedesktop_cairo_PngSurface.c 
	org_freedesktop_cairo_Cairo.c org_freedesktop_cairo_Pattern.c 
Log Message:
updated methods to reflect upstream API changes.

Index: org_freedesktop_cairo_PngSurface.c
===================================================================
RCS file: /cvs/cairo/cairo-java/src/jni/org_freedesktop_cairo_PngSurface.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- org_freedesktop_cairo_PngSurface.c	11 Apr 2005 00:47:22 -0000	1.6
+++ org_freedesktop_cairo_PngSurface.c	23 Apr 2005 16:48:28 -0000	1.7
@@ -11,7 +11,6 @@
 #include <stdlib.h>
 #include <jni.h>
 #include <cairo.h>
-#include <cairo-png.h>
 #include <jg_jnu.h>
 
 #ifndef _Included_org_freedesktop_cairo_PngSurface
@@ -26,17 +25,11 @@
  * Signature: (Ljava/lang/String;III)Lorg/gnu/glib/Handle;
  */
 JNIEXPORT jobject JNICALL Java_org_freedesktop_cairo_PngSurface_cairo_1image_1surface_1create_1for_1png
-  (JNIEnv *env, jclass cls, jstring filename, jintArray width, jintArray height)
+  (JNIEnv *env, jclass cls, jstring filename)
 {
 	char *fn = (char*)(*env)->GetStringUTFChars(env, filename, NULL);
-	FILE *f = fopen(fn, "rb");
-	int* w = (int*)(*env)->GetIntArrayElements(env, width, NULL);
-	int* h = (int*)(*env)->GetIntArrayElements(env, height, NULL);
-	cairo_surface_t *sur = cairo_image_surface_create_for_png(f, w, h);
+	cairo_surface_t *sur = cairo_image_surface_create_from_png(fn);
 	(*env)->ReleaseStringUTFChars(env, filename, fn);
-	(*env)->ReleaseIntArrayElements(env, width, w, 0);
-	(*env)->ReleaseIntArrayElements(env, height, h, 0);
-	fclose(f);
 	return getHandleFromPointer(env, sur);
 }
 
@@ -50,9 +43,7 @@
 {
 	cairo_surface_t *surface_g = (cairo_surface_t*)getPointerFromHandle(env, surface);
 	char *fn = (char*)(*env)->GetStringUTFChars(env, filename, NULL);
-	FILE *f = fopen(fn, "w");
-	int result = cairo_surface_write_png(surface_g, f);
-	fclose(f);
+	int result = cairo_surface_write_png(surface_g, fn);
 	(*env)->ReleaseStringUTFChars(env, filename, fn);
 	return result;
 }

Index: org_freedesktop_cairo_Cairo.c
===================================================================
RCS file: /cvs/cairo/cairo-java/src/jni/org_freedesktop_cairo_Cairo.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- org_freedesktop_cairo_Cairo.c	11 Apr 2005 00:47:22 -0000	1.17
+++ org_freedesktop_cairo_Cairo.c	23 Apr 2005 16:48:28 -0000	1.18
@@ -116,39 +116,41 @@
 
 /*
  * Class:     org_freedesktop_cairo_Cairo
- * Method:    cairo_set_rgb_color
- * Signature: (Lorg/gnu/glib/Handle;DDD)V
+ * Method:    cairo_set_source
+ * Signature: (Lorg/gnu/javagnome/Handle;Lorg/gnu/javagnome/Handle;)V
  */
-JNIEXPORT void JNICALL Java_org_freedesktop_cairo_Cairo_cairo_1set_1rgb_1color
-  (JNIEnv *env, jclass cls, jobject obj, jdouble red, jdouble green, jdouble blue)
+JNIEXPORT void JNICALL Java_org_freedesktop_cairo_Cairo_cairo_1set_1source
+  (JNIEnv *env, jclass cls, jobject obj, jobject pat)
 {
 	cairo_t *cr = (cairo_t*)getPointerFromHandle(env, obj);
-	cairo_set_rgb_color(cr, red, green, blue);	
+	cairo_pattern_t *p = (cairo_pattern_t*)getPointerFromHandle(env, pat);
+	cairo_set_source(cr, p);
 }
 
+
 /*
  * Class:     org_freedesktop_cairo_Cairo
- * Method:    cairo_set_pattern
- * Signature: (Lorg/gnu/glib/Handle;Lorg/gnu/glib/Handle;)V
+ * Method:    cairo_set_source_rgb
+ * Signature: (Lorg/gnu/glib/Handle;DDD)V
  */
-JNIEXPORT void JNICALL Java_org_freedesktop_cairo_Cairo_cairo_1set_1pattern
-  (JNIEnv *env, jclass cls, jobject obj, jobject pat)
+JNIEXPORT void JNICALL Java_org_freedesktop_cairo_Cairo_cairo_1set_1source_1rgb
+  (JNIEnv *env, jclass cls, jobject obj, jdouble red, jdouble green, jdouble blue)
 {
 	cairo_t *cr = (cairo_t*)getPointerFromHandle(env, obj);
-	cairo_pattern_t *pat_g = (cairo_pattern_t*)getPointerFromHandle(env, pat);
-	cairo_set_pattern(cr, pat_g);
+	cairo_set_source_rgb(cr, red, green, blue);	
 }
 
 /*
  * Class:     org_freedesktop_cairo_Cairo
- * Method:    cairo_set_alpha
- * Signature: (Lorg/gnu/glib/Handle;D)V
+ * Method:    cairo_set_source_rgba
+ * Signature: (Lorg/gnu/javagnome/Handle;DDDD)V
  */
-JNIEXPORT void JNICALL Java_org_freedesktop_cairo_Cairo_cairo_1set_1alpha
-  (JNIEnv *env, jclass cls, jobject obj, jdouble alpha)
+JNIEXPORT void JNICALL Java_org_freedesktop_cairo_Cairo_cairo_1set_1source_1rgba
+  (JNIEnv *env, jclass cls, jobject obj, jdouble red, jdouble green, 
+  	jdouble blue, jdouble alpha)
 {
 	cairo_t *cr = (cairo_t*)getPointerFromHandle(env, obj);
-	cairo_set_alpha(cr, alpha);
+	cairo_set_source_rgba(cr, red, green, blue, alpha);	
 }
 
 /*
@@ -511,6 +513,18 @@
 
 /*
  * Class:     org_freedesktop_cairo_Cairo
+ * Method:    cairo_paint
+ * Signature: (Lorg/gnu/javagnome/Handle;)V
+ */
+JNIEXPORT void JNICALL Java_org_freedesktop_cairo_Cairo_cairo_1paint
+  (JNIEnv *env, jclass cls, jobject obj)
+{
+	cairo_t *cr = (cairo_t*)getPointerFromHandle(env, obj);
+	cairo_paint(cr);
+}
+
+/*
+ * Class:     org_freedesktop_cairo_Cairo
  * Method:    cairo_stroke
  * Signature: (Lorg/gnu/glib/Handle;)V
  */
@@ -861,14 +875,14 @@
 
 /*
  * Class:     org_freedesktop_cairo_Cairo
- * Method:    cairo_get_pattern
+ * Method:    cairo_get_source
  * Signature: (Lorg/gnu/glib/Handle;)Lorg/gnu/glib/Handle;
  */
-JNIEXPORT jobject JNICALL Java_org_freedesktop_cairo_Cairo_cairo_1get_1pattern
+JNIEXPORT jobject JNICALL Java_org_freedesktop_cairo_Cairo_cairo_1get_1source
   (JNIEnv *env, jclass cls, jobject obj)
 {
 	cairo_t *cr = (cairo_t*)getPointerFromHandle(env, obj);
-	return getHandleFromPointer(env, cairo_get_pattern(cr));
+	return getHandleFromPointer(env, cairo_get_source(cr));
 }
 
 /*

Index: org_freedesktop_cairo_Pattern.c
===================================================================
RCS file: /cvs/cairo/cairo-java/src/jni/org_freedesktop_cairo_Pattern.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- org_freedesktop_cairo_Pattern.c	23 Feb 2005 18:17:52 -0000	1.1
+++ org_freedesktop_cairo_Pattern.c	23 Apr 2005 16:48:28 -0000	1.2
@@ -79,15 +79,28 @@
 
 /*
  * Class:     org_freedesktop_cairo_Pattern
- * Method:    cairo_pattern_add_color_stop
+ * Method:    cairo_pattern_add_color_stop_rgb
  * Signature: (Lorg/gnu/glib/Handle;DDDDD)I
  */
-JNIEXPORT jint JNICALL Java_org_freedesktop_cairo_Pattern_cairo_1pattern_1add_1color_1stop
+JNIEXPORT jint JNICALL Java_org_freedesktop_cairo_Pattern_cairo_1pattern_1add_1color_1stop_1rgb
+  (JNIEnv *env, jclass cls, jobject obj, jdouble offset, jdouble red, jdouble green, 
+  		jdouble blue)
+{
+	cairo_pattern_t *pat = (cairo_pattern_t*)getPointerFromHandle(env, obj);
+	return cairo_pattern_add_color_stop_rgb(pat, offset, red, green, blue);
+}
+
+/*
+ * Class:     org_freedesktop_cairo_Pattern
+ * Method:    cairo_pattern_add_color_stop_rgba
+ * Signature: (Lorg/gnu/glib/Handle;DDDDD)I
+ */
+JNIEXPORT jint JNICALL Java_org_freedesktop_cairo_Pattern_cairo_1pattern_1add_1color_1stop_1rgba
   (JNIEnv *env, jclass cls, jobject obj, jdouble offset, jdouble red, jdouble green, 
   		jdouble blue, jdouble alpha)
 {
 	cairo_pattern_t *pat = (cairo_pattern_t*)getPointerFromHandle(env, obj);
-	return cairo_pattern_add_color_stop(pat, offset, red, green, blue, alpha);
+	return cairo_pattern_add_color_stop_rgba(pat, offset, red, green, blue, alpha);
 }
 
 /*




More information about the cairo-commit mailing list