gnu_java_awt_peer_gtk_gdkgraphics.c
来自「Mac OS X 10.4.9 for x86 Source Code gcc」· C语言 代码 · 共 693 行 · 第 1/2 页
C
693 行
{ g_memmove (buf, left, channels); g_memmove (left, right, channels); g_memmove (right, buf, channels); left += channels; right -= channels; } } } if (flip_y) { guchar *top = src_pix; guchar *bottom = top + (height - 1) * src_rs; gpointer buf = g_malloc (src_rs); while (top < bottom) { g_memmove (buf, top, src_rs); g_memmove (top, bottom, src_rs); g_memmove (bottom, buf, src_rs); top += src_rs; bottom -= src_rs; } g_free (buf); }} JNIEXPORT void JNICALLJava_gnu_java_awt_peer_gtk_GdkGraphics_copyAndScalePixmap (JNIEnv *env, jobject obj, jobject offscreen, jboolean flip_x, jboolean flip_y, jint src_x, jint src_y, jint src_width, jint src_height, jint dest_x, jint dest_y, jint dest_width, jint dest_height){ struct graphics *g1, *g2; GdkPixbuf *buf_src, *buf_dest; g1 = (struct graphics *) NSA_GET_PTR (env, obj); g2 = (struct graphics *) NSA_GET_PTR (env, offscreen); gdk_threads_enter (); buf_src = gdk_pixbuf_get_from_drawable (NULL, g2->drawable, g2->cm, src_x, src_y, 0, 0, src_width, src_height); buf_dest = gdk_pixbuf_scale_simple (buf_src, dest_width, dest_height, GDK_INTERP_BILINEAR); if (flip_x || flip_y) { flip_pixbuf (buf_dest, flip_x, flip_y, dest_width, dest_height); } gdk_pixbuf_render_to_drawable (buf_dest, g1->drawable, g1->gc, 0, 0, dest_x, dest_y, dest_width, dest_height, GDK_RGB_DITHER_NORMAL, 0, 0); g_object_unref (G_OBJECT (buf_src)); g_object_unref (G_OBJECT (buf_dest)); gdk_threads_leave ();}JNIEXPORT void JNICALLJava_gnu_java_awt_peer_gtk_GdkGraphics_clearRect (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height){ struct graphics *g; GdkGCValues saved; GtkWidget *widget; union widget_union w; g = (struct graphics *) NSA_GET_PTR (env, obj); gdk_threads_enter (); if (!g) { gdk_threads_leave (); return; } if (GDK_IS_WINDOW (g->drawable)) { w.widget = &widget; gdk_window_get_user_data (GDK_WINDOW (g->drawable), w.void_widget); if (widget == NULL || !GTK_IS_EVENT_BOX (widget)) gdk_window_clear_area ((GdkWindow *) g->drawable, x + g->x_offset, y + g->y_offset, width, height); } else { gdk_gc_get_values (g->gc, &saved); gdk_gc_set_foreground (g->gc, &(saved.background)); gdk_draw_rectangle (g->drawable, g->gc, TRUE, x + g->x_offset, y + g->y_offset, width, height); gdk_gc_set_foreground (g->gc, &(saved.foreground)); } gdk_flush (); gdk_threads_leave ();}JNIEXPORT void JNICALLJava_gnu_java_awt_peer_gtk_GdkGraphics_setFunction (JNIEnv *env, jobject obj, jint func){ struct graphics *g; g = (struct graphics *) NSA_GET_PTR (env, obj); gdk_threads_enter (); gdk_gc_set_function (g->gc, func); gdk_threads_leave ();}JNIEXPORT void JNICALLJava_gnu_java_awt_peer_gtk_GdkGraphics_setFGColor (JNIEnv *env, jobject obj, jint red, jint green, jint blue){ GdkColor color; struct graphics *g; color.red = red << 8; color.green = green << 8; color.blue = blue << 8; g = (struct graphics *) NSA_GET_PTR (env, obj); gdk_threads_enter (); gdk_color_alloc (g->cm, &color); gdk_gc_set_foreground (g->gc, &color); gdk_threads_leave ();}JNIEXPORT void JNICALLJava_gnu_java_awt_peer_gtk_GdkGraphics_drawArc (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height, jint angle1, jint angle2){ struct graphics *g; g = (struct graphics *) NSA_GET_PTR (env, obj); gdk_threads_enter (); gdk_draw_arc (g->drawable, g->gc, FALSE, x + g->x_offset, y + g->y_offset, width, height, angle1 << 6, angle2 << 6); gdk_flush (); gdk_threads_leave ();} GdkPoint *translate_points (JNIEnv *env, jintArray xpoints, jintArray ypoints, jint npoints, jint x_offset, jint y_offset){ GdkPoint *points; jint *x, *y; int i; /* allocate one more point than necessary, in case we need to tack on an extra due to the semantics of Java polygons. */ points = g_malloc (sizeof (GdkPoint) * (npoints + 1)); x = (*env)->GetIntArrayElements (env, xpoints, NULL); y = (*env)->GetIntArrayElements (env, ypoints, NULL); for (i = 0; i < npoints; i++) { points[i].x = x[i] + x_offset; points[i].y = y[i] + y_offset; } (*env)->ReleaseIntArrayElements (env, xpoints, x, JNI_ABORT); (*env)->ReleaseIntArrayElements (env, ypoints, y, JNI_ABORT); return points;}JNIEXPORT void JNICALLJava_gnu_java_awt_peer_gtk_GdkGraphics_drawPolyline (JNIEnv *env, jobject obj, jintArray xpoints, jintArray ypoints, jint npoints){ struct graphics *g; GdkPoint *points; g = (struct graphics *) NSA_GET_PTR (env, obj); points = translate_points (env, xpoints, ypoints, npoints, g->x_offset, g->y_offset); gdk_threads_enter (); gdk_draw_lines (g->drawable, g->gc, points, npoints); gdk_flush (); gdk_threads_leave (); g_free (points);}JNIEXPORT void JNICALLJava_gnu_java_awt_peer_gtk_GdkGraphics_drawPolygon (JNIEnv *env, jobject obj, jintArray xpoints, jintArray ypoints, jint npoints){ struct graphics *g; GdkPoint *points; g = (struct graphics *) NSA_GET_PTR (env, obj); points = translate_points (env, xpoints, ypoints, npoints, g->x_offset, g->y_offset); /* make sure the polygon is closed, per Java semantics. if it's not, we close it. */ if (points[0].x != points[npoints-1].x || points[0].y != points[npoints-1].y) points[npoints++] = points[0]; gdk_threads_enter (); gdk_draw_lines (g->drawable, g->gc, points, npoints); gdk_flush (); gdk_threads_leave (); g_free (points);}JNIEXPORT void JNICALLJava_gnu_java_awt_peer_gtk_GdkGraphics_fillPolygon (JNIEnv *env, jobject obj, jintArray xpoints, jintArray ypoints, jint npoints){ struct graphics *g; GdkPoint *points; g = (struct graphics *) NSA_GET_PTR (env, obj); points = translate_points (env, xpoints, ypoints, npoints, g->x_offset, g->y_offset); gdk_threads_enter (); gdk_draw_polygon (g->drawable, g->gc, TRUE, points, npoints); gdk_flush (); gdk_threads_leave (); g_free (points);}JNIEXPORT void JNICALLJava_gnu_java_awt_peer_gtk_GdkGraphics_fillArc (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height, jint angle1, jint angle2){ struct graphics *g; g = (struct graphics *) NSA_GET_PTR (env, obj); gdk_threads_enter (); gdk_draw_arc (g->drawable, g->gc, TRUE, x + g->x_offset, y + g->y_offset, width, height, angle1 << 6, angle2 << 6); gdk_flush (); gdk_threads_leave ();} JNIEXPORT void JNICALLJava_gnu_java_awt_peer_gtk_GdkGraphics_drawOval (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height){ struct graphics *g; g = (struct graphics *) NSA_GET_PTR (env, obj); gdk_threads_enter (); gdk_draw_arc (g->drawable, g->gc, FALSE, x + g->x_offset, y + g->y_offset, width, height, 0, 23040); gdk_flush (); gdk_threads_leave ();} JNIEXPORT void JNICALLJava_gnu_java_awt_peer_gtk_GdkGraphics_fillOval (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height){ struct graphics *g; g = (struct graphics *) NSA_GET_PTR (env, obj); gdk_threads_enter (); gdk_draw_arc (g->drawable, g->gc, TRUE, x + g->x_offset, y + g->y_offset, width, height, 0, 23040); gdk_flush (); gdk_threads_leave ();}JNIEXPORT void JNICALLJava_gnu_java_awt_peer_gtk_GdkGraphics_setClipRectangle (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height){ struct graphics *g; GdkRectangle rectangle; g = (struct graphics *) NSA_GET_PTR (env, obj); rectangle.x = x + g->x_offset; rectangle.y = y + g->y_offset; rectangle.width = width; rectangle.height = height; gdk_threads_enter (); gdk_gc_set_clip_rectangle (g->gc, &rectangle); gdk_threads_leave ();}static void realize_cb (GtkWidget *widget __attribute__ ((unused)), jobject peer){ gdk_threads_leave (); (*gdk_env())->CallVoidMethod (gdk_env(), peer, initComponentGraphicsID); NSA_DEL_GLOBAL_REF (gdk_env(), peer); gdk_threads_enter ();}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?