[cairo-commit] cairo-java/src/java/org/freedesktop/cairo Matrix.java, 1.13, 1.14 Pattern.java, 1.11, 1.12

Dan Williams commit at pdx.freedesktop.org
Thu Mar 23 10:32:03 PST 2006


Committed by: dcbw

Update of /cvs/cairo/cairo-java/src/java/org/freedesktop/cairo
In directory kemper:/tmp/cvs-serv22452/src/java/org/freedesktop/cairo

Modified Files:
	Matrix.java Pattern.java 
Log Message:
2006-03-23  Dan Williams  <dcbw at redhat.com>

    * src/java/org/freedesktop/cairo/Matrix.java
        - Add Matrix() constructor
        - Add finalize() for Matrix objects
        - Fix Matrix.multiply() to not crash

    * src/java/org/freedesktop/cairo/Pattern.java
        - Fix getMatrix() to not crash

    * src/jni/org_freedesktop_cairo_Matrix.c
        - Fix JNI function Signatures
        - (new_identity_matrix): new function; return a new
            allocated identity matrix
        - (free_matrix): new function; free memory associated with
            a matrix object
        - (cairo_matrix_multiply): allocate result matrix object, since
            cairo needs an allocated matrix, not NULL

    * src/jni/org_freedesktop_cairo_Pattern.c
        - (cairo_pattern_get_matrix): allocate result matrix object,
            since cairo needs an allocated matrix, not NULL



Index: Matrix.java
===================================================================
RCS file: /cvs/cairo/cairo-java/src/java/org/freedesktop/cairo/Matrix.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- Matrix.java	12 Feb 2006 09:05:44 -0000	1.13
+++ Matrix.java	23 Mar 2006 18:32:01 -0000	1.14
@@ -21,6 +21,21 @@
     }
 
     /**
+     * Creates a new matrix initialized with a noop transform.
+     */
+	public Matrix() {
+		super(new_identity_matrix());
+	}
+
+    /**
+     * Disposes all the native resources used by the matrix.
+     */
+    protected void finalize() throws Throwable {
+        free_matrix(getHandle());
+        super.finalize();
+    }
+
+    /**
      * Sets the matrix to be the affine transformation given by xx, yx, xy, yy,
      * x0, y0. The transformation is given by: <code> 
      *  x_new = xx * x + xy * y + x0;
@@ -132,8 +147,7 @@
      * @return The product
      */
     static public Matrix multiply(Matrix a, Matrix b) {
-        Handle hndl = Struct.getNullHandle();
-        cairo_matrix_multiply(hndl, a.getHandle(), b.getHandle());
+        Handle hndl = cairo_matrix_multiply(a.getHandle(), b.getHandle());
         return new Matrix(hndl);
     }
 
@@ -232,6 +246,10 @@
 
     native static final private void setY0(Handle matrix, double y0);
 
+    native static final private Handle new_identity_matrix();
+
+    native static final private void free_matrix(Handle matrix);
+
     native static final private void cairo_matrix_init(Handle matrix,
             double xx, double yx, double xy, double yy, double x0, double y0);
 
@@ -257,8 +275,8 @@
 
     native static final private void cairo_matrix_invert(Handle matrix);
 
-    native static final private void cairo_matrix_multiply(Handle result,
-            Handle a, Handle b);
+    native static final private Handle cairo_matrix_multiply(Handle a,
+            Handle b);
 
     native static final private void cairo_matrix_transform_distance(
             Handle handle, double[] dx, double[] dy);

Index: Pattern.java
===================================================================
RCS file: /cvs/cairo/cairo-java/src/java/org/freedesktop/cairo/Pattern.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- Pattern.java	12 Feb 2006 09:05:44 -0000	1.11
+++ Pattern.java	23 Mar 2006 18:32:01 -0000	1.12
@@ -69,8 +69,7 @@
      * @return The transformation matrix for the pattern.
      */
     public Matrix getMatrix() {
-        Handle hndl = Struct.getNullHandle();
-        cairo_pattern_get_matrix(getHandle(), hndl);
+        Handle hndl = cairo_pattern_get_matrix(getHandle());
         return new Matrix(hndl);
     }
 
@@ -82,8 +81,7 @@
     native static final private void cairo_pattern_set_matrix(Handle pat,
             Handle matrix);
 
-    native static final private void cairo_pattern_get_matrix(Handle pat,
-            Handle matrix);
+    native static final private Handle cairo_pattern_get_matrix(Handle pat);
 
     native static final private Handle cairo_pattern_create_rgb(double red,
             double green, double blue);



More information about the cairo-commit mailing list