[cairo-commit] CairoJava/jni CairoSurfacePattern.cpp, NONE, 1.1 CairoMatrix.cpp, NONE, 1.1 CairoException.cpp, NONE, 1.1 CairoSurface.cpp, NONE, 1.1 CairoFont.cpp, NONE, 1.1 CairoSWTSurface.cpp, NONE, 1.1 utils.h, NONE, 1.1 Cairo.cpp, NONE, 1.1

Soorya Kuloor commit at pdx.freedesktop.org
Fri Apr 30 10:47:41 PDT 2004


Committed by: skuloor

Update of /cvs/cairo/CairoJava/jni
In directory pdx:/tmp/cvs-serv13905/jni

Added Files:
	CairoSurfacePattern.cpp CairoMatrix.cpp CairoException.cpp 
	CairoSurface.cpp CairoFont.cpp CairoSWTSurface.cpp utils.h 
	Cairo.cpp 
Log Message:
Initial version

--- NEW FILE: CairoSurfacePattern.cpp ---
/*
 * $Id: Cairo.java,v 1.5 2003/12/23 17:36:01 skuloor Exp $
 * 
 * Copyright (C) 2003 Verano
 * 
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of Verano not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 * Verano makes no representations about the suitability of this software for
 * any purpose. It is provided "as is" without express or implied warranty.
 * 
 * VERANO MAKES NO REPRESENTATIONS OR WARRANTIES OR COVENANTS, EITHER EXPRESS OR
 * IMPLIED, WITH RESPECT TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION,
 * STATUTORY OR IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR
 * A PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR ARISING FROM CUSTOM, COURSE
 * OF DEALING, USAGE OF TRADE OR COURSE OF PERFORMANCE, ALL OF WHICH ARE
 * EXPRESSLY DISCLAIMED TO THE FULLEST EXTENT ALLOWABLE BY APPLICABLE LAW. IN NO
 * EVENT SHALL VERANO BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */
 
#include <cairo.h>
#include "CairoSurfacePattern.h"
#include "utils.h"

/*
 * Class:     org_cairographics_cairo_CairoSurfacePattern
 * Method:    cairo_pattern_create_for_surface
 * Signature: (J)J
 */
JNIEXPORT jlong JNICALL Java_org_cairographics_cairo_CairoSurfacePattern_cairo_1pattern_1create_1for_1surface
(JNIEnv *env, jclass me, jlong surfacep)
{
    return TO_LONG(cairo_pattern_create_for_surface(TO_PTR(cairo_surface_t, surfacep)));
}


--- NEW FILE: CairoMatrix.cpp ---
/*
 * $Id: Cairo.java,v 1.5 2003/12/23 17:36:01 skuloor Exp $
 * 
 * Copyright (C) 2003 Verano
 * 
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of Verano not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 * Verano makes no representations about the suitability of this software for
 * any purpose. It is provided "as is" without express or implied warranty.
 * 
 * VERANO MAKES NO REPRESENTATIONS OR WARRANTIES OR COVENANTS, EITHER EXPRESS OR
 * IMPLIED, WITH RESPECT TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION,
 * STATUTORY OR IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR
 * A PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR ARISING FROM CUSTOM, COURSE
 * OF DEALING, USAGE OF TRADE OR COURSE OF PERFORMANCE, ALL OF WHICH ARE
 * EXPRESSLY DISCLAIMED TO THE FULLEST EXTENT ALLOWABLE BY APPLICABLE LAW. IN NO
 * EVENT SHALL VERANO BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */
 
#include <cairo.h>
#include "CairoMatrix.h"
#include "utils.h"

/*
 * Class:     org_cairographics_cairo_CairoMatrix
 * Method:    cairo_matrix_create
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_org_cairographics_cairo_CairoMatrix_cairo_1matrix_1create
(JNIEnv *env, jclass me)
{
    return TO_LONG(cairo_matrix_create());
}   

/*
 * Class:     org_cairographics_cairo_CairoMatrix
 * Method:    cairo_matrix_destroy
 * Signature: (J)V
 */
JNIEXPORT void JNICALL Java_org_cairographics_cairo_CairoMatrix_cairo_1matrix_1destroy
(JNIEnv *env, jclass me, jlong matrix)
{
    cairo_matrix_destroy(TO_PTR(cairo_matrix_t, matrix));
}

/*
 * Class:     org_cairographics_cairo_CairoMatrix
 * Method:    cairo_matrix_copy
 * Signature: (JJ)V
 */
JNIEXPORT void JNICALL Java_org_cairographics_cairo_CairoMatrix_cairo_1matrix_1copy
(JNIEnv *env, jclass me, jlong matrix, jlong other)
{
    cairo_matrix_copy(TO_PTR(cairo_matrix_t, matrix), TO_PTR(cairo_matrix_t, other));
}

/*
 * Class:     org_cairographics_cairo_CairoMatrix
 * Method:    cairo_matrix_set_identity
 * Signature: (J)V
 */
JNIEXPORT void JNICALL Java_org_cairographics_cairo_CairoMatrix_cairo_1matrix_1set_1identity
  (JNIEnv *env, jclass me, jlong matrix)
{
    cairo_matrix_set_identity(TO_PTR(cairo_matrix_t, matrix));
}

/*
 * Class:     org_cairographics_cairo_CairoMatrix
 * Method:    cairo_matrix_set_affine
 * Signature: (JDDDDDD)V
 */
JNIEXPORT void JNICALL Java_org_cairographics_cairo_CairoMatrix_cairo_1matrix_1set_1affine__JDDDDDD
  (JNIEnv *env, jclass me, jlong matrix,
    jdouble a, jdouble b,
    jdouble c, jdouble d,
    jdouble tx, jdouble ty)
{
    cairo_matrix_set_affine(TO_PTR(cairo_matrix_t, matrix), a, b, c, d, tx, ty);
}

/*
 * Class:     org_cairographics_cairo_CairoMatrix
 * Method:    cairo_matrix_set_affine
 * Signature: (J[D)V
 */
JNIEXPORT void JNICALL Java_org_cairographics_cairo_CairoMatrix_cairo_1matrix_1set_1affine__J_3D
(JNIEnv *env, jclass me, jlong matrix, jdoubleArray vec)
{
    double *elems = env->GetDoubleArrayElements(vec, NULL);
    cairo_matrix_set_affine(TO_PTR(cairo_matrix_t, matrix), 
                            elems[0], elems[1], elems[2], elems[3], elems[4], elems[5]);
    env->ReleaseDoubleArrayElements(vec, elems, 0);
}

/*
 * Class:     org_cairographics_cairo_CairoMatrix
 * Method:    cairo_matrix_get_affine
 * Signature: (J)[D
 */
JNIEXPORT jdoubleArray JNICALL Java_org_cairographics_cairo_CairoMatrix_cairo_1matrix_1get_1affine
  (JNIEnv *env, jclass me, jlong matrixp)
{
    jdoubleArray affine = env->NewDoubleArray(6);
    double *elems = env->GetDoubleArrayElements(affine, NULL);

    cairo_matrix_get_affine(TO_PTR(cairo_matrix_t, matrixp),
                      &elems[0], &elems[1],
                      &elems[2], &elems[3],
                      &elems[4], &elems[5]);

    env->ReleaseDoubleArrayElements(affine, elems, 0);
    
    return affine;
}

/*
 * Class:     org_cairographics_cairo_CairoMatrix
 * Method:    cairo_matrix_translate
 * Signature: (JDD)V
 */
JNIEXPORT void JNICALL Java_org_cairographics_cairo_CairoMatrix_cairo_1matrix_1translate
  (JNIEnv *env, jclass me, jlong matrix, jdouble dx, jdouble dy)
{
    cairo_matrix_translate(TO_PTR(cairo_matrix_t, matrix), dx, dy);
}

/*
 * Class:     org_cairographics_cairo_CairoMatrix
 * Method:    cairo_matrix_scale
 * Signature: (JDD)V
 */
JNIEXPORT void JNICALL Java_org_cairographics_cairo_CairoMatrix_cairo_1matrix_1scale
  (JNIEnv *env, jclass me, jlong matrix, jdouble sx, jdouble sy)
{
    cairo_matrix_scale(TO_PTR(cairo_matrix_t, matrix), sx, sy);
}

/*
 * Class:     org_cairographics_cairo_CairoMatrix
 * Method:    cairo_matrix_rotate
 * Signature: (JD)V
 */
JNIEXPORT void JNICALL Java_org_cairographics_cairo_CairoMatrix_cairo_1matrix_1rotate
  (JNIEnv *env, jclass me, jlong matrix, jdouble angle)
{
    cairo_matrix_rotate(TO_PTR(cairo_matrix_t, matrix), angle);
}

/*
 * Class:     org_cairographics_cairo_CairoMatrix
 * Method:    cairo_matrix_invert
 * Signature: (J)V
 */
JNIEXPORT void JNICALL Java_org_cairographics_cairo_CairoMatrix_cairo_1matrix_1invert
  (JNIEnv *env, jclass me, jlong matrix)
{
    cairo_matrix_invert(TO_PTR(cairo_matrix_t, matrix));
}

/*
 * Class:     org_cairographics_cairo_CairoMatrix
 * Method:    cairo_matrix_multiply
 * Signature: (JJJ)V
 */
JNIEXPORT void JNICALL Java_org_cairographics_cairo_CairoMatrix_cairo_1matrix_1multiply
  (JNIEnv *env, jclass me, jlong result, jlong a, jlong b)
{
    cairo_matrix_multiply(TO_PTR(cairo_matrix_t, result),
                            TO_PTR(cairo_matrix_t, a),
                            TO_PTR(cairo_matrix_t, b));
}

/*
 * Class:     org_cairographics_cairo_CairoMatrix
 * Method:    cairo_matrix_transform_distance
 * Signature: (JDD)[D
 */
JNIEXPORT jdoubleArray JNICALL Java_org_cairographics_cairo_CairoMatrix_cairo_1matrix_1transform_1distance
  (JNIEnv *env, jclass me, jlong matrixp, jdouble dx, jdouble dy)
{
    cairo_matrix_transform_distance(TO_PTR(cairo_matrix_t, matrixp), &dx, &dy);
    return newPoint(env, dx, dy);
}

/*
 * Class:     org_cairographics_cairo_CairoMatrix
 * Method:    cairo_matrix_transform_point
 * Signature: (JDD)[D
 */
JNIEXPORT jdoubleArray JNICALL Java_org_cairographics_cairo_CairoMatrix_cairo_1matrix_1transform_1point
  (JNIEnv *env, jclass me, jlong matrixp, jdouble x, jdouble y)
{
    cairo_matrix_transform_point(TO_PTR(cairo_matrix_t, matrixp), &x, &y);
    return newPoint(env, x, y);
}

--- NEW FILE: CairoException.cpp ---
/*
 * $Id: Cairo.java,v 1.5 2003/12/23 17:36:01 skuloor Exp $
 * 
 * Copyright (C) 2003 Verano
 * 
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of Verano not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 * Verano makes no representations about the suitability of this software for
 * any purpose. It is provided "as is" without express or implied warranty.
 * 
 * VERANO MAKES NO REPRESENTATIONS OR WARRANTIES OR COVENANTS, EITHER EXPRESS OR
 * IMPLIED, WITH RESPECT TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION,
 * STATUTORY OR IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR
 * A PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR ARISING FROM CUSTOM, COURSE
 * OF DEALING, USAGE OF TRADE OR COURSE OF PERFORMANCE, ALL OF WHICH ARE
 * EXPRESSLY DISCLAIMED TO THE FULLEST EXTENT ALLOWABLE BY APPLICABLE LAW. IN NO
 * EVENT SHALL VERANO BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */
#include <cairo.h>
#include "CairoException.h"
#include "utils.h"

/*
 * Class:     org_cairographics_cairo_CairoException
 * Method:    cairo_status_string
 * Signature: (J)Ljava/lang/String;
 */
JNIEXPORT jstring JNICALL Java_org_cairographics_cairo_CairoException_cairo_1status_1string
(JNIEnv * env, jclass me, jlong crp)
{
    return env->NewStringUTF(cairo_status_string(TO_PTR(cairo_t, crp)));
}


--- NEW FILE: CairoSurface.cpp ---
/*
 * $Id: Cairo.java,v 1.5 2003/12/23 17:36:01 skuloor Exp $
 * 
 * Copyright (C) 2003 Verano
 * 
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of Verano not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 * Verano makes no representations about the suitability of this software for
 * any purpose. It is provided "as is" without express or implied warranty.
 * 
 * VERANO MAKES NO REPRESENTATIONS OR WARRANTIES OR COVENANTS, EITHER EXPRESS OR
 * IMPLIED, WITH RESPECT TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION,
 * STATUTORY OR IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR
 * A PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR ARISING FROM CUSTOM, COURSE
 * OF DEALING, USAGE OF TRADE OR COURSE OF PERFORMANCE, ALL OF WHICH ARE
 * EXPRESSLY DISCLAIMED TO THE FULLEST EXTENT ALLOWABLE BY APPLICABLE LAW. IN NO
 * EVENT SHALL VERANO BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */
#include <cairo.h>
#include "CairoSurface.h"
#include "utils.h"

/*
 * Class:     org_cairographics_cairo_CairoSurface
 * Method:    cairo_surface_create_similar
 * Signature: (JSII)J
 */
JNIEXPORT jlong JNICALL Java_org_cairographics_cairo_CairoSurface_cairo_1surface_1create_1similar
  (JNIEnv *env, jclass me, jlong neighbor,
    jshort format, jint width, jint height)
{
    cairo_surface_t* surface = TO_PTR(cairo_surface_t, neighbor);
    return TO_LONG(cairo_surface_create_similar(surface, (cairo_format_t) format,
                                         width, height));
}

/*
 * Class:     org_cairographics_cairo_CairoSurface
 * Method:    cairo_surface_reference
 * Signature: (J)V
 */
JNIEXPORT void JNICALL Java_org_cairographics_cairo_CairoSurface_cairo_1surface_1reference
  (JNIEnv *env, jclass me, jlong surface)
{
    cairo_surface_reference(TO_PTR(cairo_surface_t, surface));
}

/*
 * Class:     org_cairographics_cairo_CairoSurface
 * Method:    cairo_surface_destroy
 * Signature: (J)V
 */
JNIEXPORT void JNICALL Java_org_cairographics_cairo_CairoSurface_cairo_1surface_1destroy
  (JNIEnv *env, jclass me, jlong surface)
{
    cairo_surface_destroy(TO_PTR(cairo_surface_t, surface));
}


/*
 * Class:     org_cairographics_cairo_CairoSurface
 * Method:    cairo_surface_set_repeat
 * Signature: (JI)V
 */
JNIEXPORT void JNICALL Java_org_cairographics_cairo_CairoSurface_cairo_1surface_1set_1repeat
  (JNIEnv *env, jclass me, jlong surface, jint repeat)
{
    (jshort) cairo_surface_set_repeat(TO_PTR(cairo_surface_t, surface), repeat);
}

/*
 * Class:     org_cairographics_cairo_CairoSurface
 * Method:    cairo_surface_set_matrix
 * Signature: (JJ)V
 */
JNIEXPORT void JNICALL Java_org_cairographics_cairo_CairoSurface_cairo_1surface_1set_1matrix
  (JNIEnv *env, jclass me, jlong surface, jlong matrix) 
{
    cairo_surface_set_matrix(TO_PTR(cairo_surface_t, surface),
                              TO_PTR(cairo_matrix_t, matrix));
}

/*
 * Class:     org_cairographics_cairo_CairoSurface
 * Method:    cairo_surface_get_matrix
 * Signature: (JJ)V
 */
JNIEXPORT void JNICALL Java_org_cairographics_cairo_CairoSurface_cairo_1surface_1get_1matrix
  (JNIEnv *env, jclass me, jlong surface, jlong matrix)
{
    
    cairo_surface_get_matrix(TO_PTR(cairo_surface_t, surface),
                                    TO_PTR(cairo_matrix_t, matrix));
}

/*
 * Class:     org_cairographics_cairo_CairoSurface
 * Method:    cairo_surface_set_filter
 * Signature: (JS)V
 */
JNIEXPORT void JNICALL Java_org_cairographics_cairo_CairoSurface_cairo_1surface_1set_1filter
  (JNIEnv *env, jclass me, jlong surface, jshort filter)
{
    cairo_surface_set_filter(TO_PTR(cairo_surface_t, surface), (cairo_filter_t) filter);
}

/*
 * Class:     org_cairographics_cairo_CairoSurface
 * Method:    cairo_surface_get_filter
 * Signature: (J)S
 */
JNIEXPORT jshort JNICALL Java_org_cairographics_cairo_CairoSurface_cairo_1surface_1get_1filter
  (JNIEnv *env, jclass me, jlong surface)
{
    return cairo_surface_get_filter(TO_PTR(cairo_surface_t, surface));
}

--- NEW FILE: CairoFont.cpp ---
/*
 * $Id: Cairo.java,v 1.5 2003/12/23 17:36:01 skuloor Exp $
 * 
 * Copyright (C) 2003 Verano
 * 
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of Verano not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 * Verano makes no representations about the suitability of this software for
 * any purpose. It is provided "as is" without express or implied warranty.
 * 
 * VERANO MAKES NO REPRESENTATIONS OR WARRANTIES OR COVENANTS, EITHER EXPRESS OR
 * IMPLIED, WITH RESPECT TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION,
 * STATUTORY OR IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR
 * A PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR ARISING FROM CUSTOM, COURSE
 * OF DEALING, USAGE OF TRADE OR COURSE OF PERFORMANCE, ALL OF WHICH ARE
 * EXPRESSLY DISCLAIMED TO THE FULLEST EXTENT ALLOWABLE BY APPLICABLE LAW. IN NO
 * EVENT SHALL VERANO BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */

#include <cairo.h>
#include "CairoFont.h"
#include "utils.h"

/*
 * Class:     org_cairographics_cairo_CairoFont
 * Method:    cairo_font_reference
 * Signature: (J)V
 */
JNIEXPORT void JNICALL Java_org_cairographics_cairo_CairoFont_cairo_1font_1reference
(JNIEnv *env, jclass me, jlong fontp) 
{
    cairo_font_reference(TO_PTR(cairo_font_t, fontp));
}

/*
 * Class:     org_cairographics_cairo_CairoFont
 * Method:    cairo_font_destroy
 * Signature: (J)V
 */
JNIEXPORT void JNICALL Java_org_cairographics_cairo_CairoFont_cairo_1font_1destroy
  (JNIEnv *env, jclass me, jlong fontp)
{
    cairo_font_destroy(TO_PTR(cairo_font_t, fontp));
}

/*
 * Class:     org_cairographics_cairo_CairoFont
 * Method:    cairo_font_set_transform
 * Signature: (JJ)V
 */
JNIEXPORT void JNICALL Java_org_cairographics_cairo_CairoFont_cairo_1font_1set_1transform
(JNIEnv *env, jclass me, jlong fontp, jlong matrixp)
{
    cairo_font_set_transform(TO_PTR(cairo_font_t, fontp),
                             TO_PTR(cairo_matrix_t, matrixp));
}

/*
 * Class:     org_cairographics_cairo_CairoFont
 * Method:    cairo_font_current_transform
 * Signature: (J)J
 */
JNIEXPORT void JNICALL Java_org_cairographics_cairo_CairoFont_cairo_1font_1current_1transform
(JNIEnv *env, jclass me, jlong fontp, jlong matrixp)
{
    cairo_font_current_transform(TO_PTR(cairo_font_t, fontp),
                                 TO_PTR(cairo_matrix_t, matrixp));
}

--- NEW FILE: CairoSWTSurface.cpp ---
/*
 * $Id: Cairo.java,v 1.5 2003/12/23 17:36:01 skuloor Exp $
 * 
 * Copyright (C) 2003 Verano
 * 
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of Verano not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 * Verano makes no representations about the suitability of this software for
 * any purpose. It is provided "as is" without express or implied warranty.
 * 
 * VERANO MAKES NO REPRESENTATIONS OR WARRANTIES OR COVENANTS, EITHER EXPRESS OR
 * IMPLIED, WITH RESPECT TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION,
 * STATUTORY OR IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR
 * A PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR ARISING FROM CUSTOM, COURSE
 * OF DEALING, USAGE OF TRADE OR COURSE OF PERFORMANCE, ALL OF WHICH ARE
 * EXPRESSLY DISCLAIMED TO THE FULLEST EXTENT ALLOWABLE BY APPLICABLE LAW. IN NO
 * EVENT SHALL VERANO BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */
#include <cairo.h>
#include "CairoSWTSurface.h"
#include "utils.h"
#include <gdk/gdkx.h>
#include <gtk/gtkwidget.h>

/*
 * Class:     org_cairographics_cairo_CairoSWTSurface
 * Method:    cairo_swt_image_surface_create
 * Signature: (I)J
 */
JNIEXPORT jlong JNICALL Java_org_cairographics_cairo_CairoSWTSurface_cairo_1swt_1image_1surface_1create
(JNIEnv *env, jclass me, jlong image) 
{
    GdkPixmap *drawable = (GdkPixmap *) (long) image;

    Display *dpy = GDK_PIXMAP_XDISPLAY(drawable);
    cairo_surface_t *surface = cairo_xlib_surface_create (
        dpy, 
        GDK_PIXMAP_XID(drawable),
        DefaultVisual (dpy, DefaultScreen (dpy)),
        (cairo_format) 0,
        DefaultColormap (dpy, DefaultScreen (dpy)));
    
    return TO_LONG(surface);
}

/*
 * Class:     org_cairographics_cairo_CairoSWTSurface
 * Method:    cairo_swt_widget_surface_create
 * Signature: (I)J
 */
JNIEXPORT jlong JNICALL Java_org_cairographics_cairo_CairoSWTSurface_cairo_1swt_1widget_1surface_1create
  (JNIEnv *env, jclass me, jlong widget)
{
    GdkDrawable *drawable;
    gint x_offset, y_offset;
    
    gdk_window_get_internal_paint_info (((GtkWidget *) (long) widget)->window,
                                        &drawable, &x_offset, &y_offset);

    Display *dpy = GDK_WINDOW_XDISPLAY(drawable);
    cairo_surface_t *surface = cairo_xlib_surface_create(
        dpy,
        GDK_DRAWABLE_XID(drawable),
        DefaultVisual (dpy, DefaultScreen (dpy)),
        CAIRO_FORMAT_ARGB32,
        DefaultColormap (dpy, DefaultScreen (dpy)));
    
    return TO_LONG(surface);
}

--- NEW FILE: utils.h ---
/*
 * $Id: Cairo.java,v 1.5 2003/12/23 17:36:01 skuloor Exp $
 * 
 * Copyright (C) 2003 Verano
 * 
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of Verano not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 * Verano makes no representations about the suitability of this software for
 * any purpose. It is provided "as is" without express or implied warranty.
 * 
 * VERANO MAKES NO REPRESENTATIONS OR WARRANTIES OR COVENANTS, EITHER EXPRESS OR
 * IMPLIED, WITH RESPECT TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION,
 * STATUTORY OR IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR
 * A PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR ARISING FROM CUSTOM, COURSE
 * OF DEALING, USAGE OF TRADE OR COURSE OF PERFORMANCE, ALL OF WHICH ARE
 * EXPRESSLY DISCLAIMED TO THE FULLEST EXTENT ALLOWABLE BY APPLICABLE LAW. IN NO
 * EVENT SHALL VERANO BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */
 
#ifndef libcairo_utils_h_
#define libcairo_utils_h_

#include <jni.h>

#define TO_PTR(type, longvalue) ((type *) (long) longvalue)
#define TO_LONG(ptr) (jlong) (long) ptr

jdoubleArray newPoint(JNIEnv *env, double x, double y);

/*
 * Internal cairo_image structure
 */
typedef struct {
    cairo_format_t format;
    char *bytes;
    int width, height, stride;
} cairo_image_buffer_t;

#endif

--- NEW FILE: Cairo.cpp ---
/*
 * $Id: Cairo.java,v 1.5 2003/12/23 17:36:01 skuloor Exp $
 * 
 * Copyright (C) 2003 Verano
 * 
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of Verano not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 * Verano makes no representations about the suitability of this software for
 * any purpose. It is provided "as is" without express or implied warranty.
 * 
 * VERANO MAKES NO REPRESENTATIONS OR WARRANTIES OR COVENANTS, EITHER EXPRESS OR
 * IMPLIED, WITH RESPECT TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION,
 * STATUTORY OR IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR
 * A PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR ARISING FROM CUSTOM, COURSE
 * OF DEALING, USAGE OF TRADE OR COURSE OF PERFORMANCE, ALL OF WHICH ARE
[...1173 lines suppressed...]
 * Class:     org_cairographics_cairo_Cairo
 * Method:    cairo_current_path
 * Signature: (JLorg/cairographics/cairo/PathTracer;)V
 */
JNIEXPORT void JNICALL Java_org_cairographics_cairo_Cairo_cairo_1current_1path
(JNIEnv *env, jclass me, jlong crp, jobject tracer)
{
    // TODO: Finish this properly
}

/*
 * Class:     org_cairographics_cairo_Cairo
 * Method:    cairo_current_path_flat
 * Signature: (JLorg/cairographics/cairo/FlatPathTracer;)V
 */
JNIEXPORT void JNICALL Java_org_cairographics_cairo_Cairo_cairo_1current_1path_1flat
(JNIEnv *env, jclass me, jlong crp, jobject tracer)
{
    // TODO: Finish this properly
}





More information about the cairo-commit mailing list