[cairo-commit] cairo-java/src/jni
org_freedesktop_cairo_PdfSurface.c, 1.1,
1.2 org_freedesktop_cairo_Cairo.c, 1.1, 1.2
Jeffrey Morgan
commit at pdx.freedesktop.org
Fri Mar 4 12:34:49 PST 2005
Committed by: kuzman
Update of /cvs/cairo/cairo-java/src/jni
In directory gabe:/tmp/cvs-serv13777/src/jni
Modified Files:
org_freedesktop_cairo_PdfSurface.c
org_freedesktop_cairo_Cairo.c
Log Message:
More updates and start of snippets tests.
Index: org_freedesktop_cairo_PdfSurface.c
===================================================================
RCS file: /cvs/cairo/cairo-java/src/jni/org_freedesktop_cairo_PdfSurface.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- org_freedesktop_cairo_PdfSurface.c 23 Feb 2005 18:17:52 -0000 1.1
+++ org_freedesktop_cairo_PdfSurface.c 4 Mar 2005 20:34:47 -0000 1.2
@@ -8,8 +8,10 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include <jni.h>
#include <cairo.h>
+#include <cairo-pdf.h>
#include <jg_jnu.h>
#ifndef _Included_org_freedesktop_cairo_PdfSurface
@@ -18,20 +20,23 @@
extern "C" {
#endif
+typedef struct jg_pdfsurface {
+ cairo_surface_t *surface;
+ FILE *file;
+} jg_pdfsurface_t;
+
/*
* Class: org_freedesktop_cairo_PdfSurface
* Method: cairo_set_target_pdf
* Signature: (Lorg/gnu/glib/Handle;Ljava/lang/String;DDDD)V
*/
JNIEXPORT void JNICALL Java_org_freedesktop_cairo_PdfSurface_cairo_1set_1target_1pdf
- (JNIEnv *env, jclass cls, jobject cr, jstring filename, jdouble width, jdouble height,
+ (JNIEnv *env, jclass cls, jobject cr, jobject sur, jdouble width, jdouble height,
jdouble x, jdouble y)
{
cairo_t *cr_g = (cairo_t*)getPointerFromHandle(env, cr);
- char *fn = (char*)(*env)->GetStringUTFChars(env, filename, NULL);
- FILE *f = fopen(fn, "w");
- cairo_set_target_pdf(cr_g, f, width, height, x, y);
- (*env)->ReleaseStringUTFChars(env, filename, fn);
+ jg_pdfsurface_t *s = (jg_pdfsurface_t*)getPointerFromHandle(env, sur);
+ cairo_set_target_pdf(cr_g, s->file, width, height, x, y);
}
/*
@@ -43,13 +48,29 @@
(JNIEnv *env, jclass cls, jstring filename, jdouble width, jdouble height,
jdouble x, jdouble y)
{
+ jg_pdfsurface_t *s = malloc(sizeof(jg_pdfsurface_t));
char *fn = (char*)(*env)->GetStringUTFChars(env, filename, NULL);
FILE *f = fopen(fn, "w");
cairo_surface_t *sur = cairo_pdf_surface_create(f, width, height, x, y);
(*env)->ReleaseStringUTFChars(env, filename, fn);
- return getHandleFromPointer(env, sur);
+ s->surface = sur;
+ s->file = f;
+ return getHandleFromPointer(env, s);
+}
+
+/*
+ * Class: org_freedesktop_cairo_PdfSurface
+ * Method: close_file
+ * Signature: (Lorg/gnu/glib/Handle;)V
+ */
+JNIEXPORT void JNICALL Java_org_freedesktop_cairo_PdfSurface_close_1file
+ (JNIEnv *env, jclass cls, jobject sur)
+{
+ jg_pdfsurface_t *s = (jg_pdfsurface_t*)getPointerFromHandle(env, sur);
+ fclose(s->file);
}
+
#ifdef __cplusplus
}
#endif
Index: org_freedesktop_cairo_Cairo.c
===================================================================
RCS file: /cvs/cairo/cairo-java/src/jni/org_freedesktop_cairo_Cairo.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- org_freedesktop_cairo_Cairo.c 23 Feb 2005 18:17:52 -0000 1.1
+++ org_freedesktop_cairo_Cairo.c 4 Mar 2005 20:34:47 -0000 1.2
@@ -461,7 +461,7 @@
(JNIEnv *env, jclass cls, jobject obj, jdouble xc, jdouble yc, jdouble radius, jdouble angle1, jdouble angle2)
{
cairo_t *cr = (cairo_t*)getPointerFromHandle(env, obj);
- cairo_negative(cr, xc, yc, radius, angle1, angle2);
+ cairo_arc_negative(cr, xc, yc, radius, angle1, angle2);
}
/*
More information about the cairo-commit
mailing list