[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commit-cp] classpath ChangeLog gnu/java/awt/peer/gtk/Compo...
From: |
Sven de Marothy |
Subject: |
[commit-cp] classpath ChangeLog gnu/java/awt/peer/gtk/Compo... |
Date: |
Sat, 03 Jun 2006 22:41:41 +0000 |
CVSROOT: /sources/classpath
Module name: classpath
Changes by: Sven de Marothy <smarothy> 06/06/03 22:41:41
Modified files:
. : ChangeLog
gnu/java/awt/peer/gtk: ComponentGraphics.java
GtkVolatileImage.java
include : Makefile.am
gnu_java_awt_peer_gtk_ComponentGraphics.h
native/jni/gtk-peer: Makefile.am
gnu_java_awt_peer_gtk_ComponentGraphics.c
gtkpeer.h
Added files:
gnu/java/awt/peer/gtk: VolatileImageGraphics.java
include : gnu_java_awt_peer_gtk_GtkVolatileImage.h
native/jni/gtk-peer: gnu_java_awt_peer_gtk_GtkVolatileImage.c
Log message:
2006-06-02 Sven de Marothy <address@hidden>
* gnu/java/awt/peer/gtk/VolatileImageGraphics.java
* include/gnu_java_awt_peer_gtk_GtkVolatileImage.h
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
New files.
* gnu/java/awt/peer/gtk/ComponentGraphics.java
(drawImage): Overloads for VolatileImage drawing.
(drawVolatile): New method.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
* include/gnu_java_awt_peer_gtk_ComponentGraphics.h
(drawVolatile): New method.
* gnu/java/awt/peer/gtk/GtkVolatileImage.java
Unstub implementation.
* include/Makefile.am
* native/jni/gtk-peer/Makefile.am
Add new files.
* native/jni/gtk-peer/gtkpeer.h
New prototype.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&r1=1.7640&r2=1.7641
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/ComponentGraphics.java?cvsroot=classpath&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/GtkVolatileImage.java?cvsroot=classpath&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/VolatileImageGraphics.java?cvsroot=classpath&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/classpath/include/Makefile.am?cvsroot=classpath&r1=1.61&r2=1.62
http://cvs.savannah.gnu.org/viewcvs/classpath/include/gnu_java_awt_peer_gtk_ComponentGraphics.h?cvsroot=classpath&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/classpath/include/gnu_java_awt_peer_gtk_GtkVolatileImage.h?cvsroot=classpath&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/classpath/native/jni/gtk-peer/Makefile.am?cvsroot=classpath&r1=1.42&r2=1.43
http://cvs.savannah.gnu.org/viewcvs/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c?cvsroot=classpath&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/classpath/native/jni/gtk-peer/gtkpeer.h?cvsroot=classpath&r1=1.46&r2=1.47
http://cvs.savannah.gnu.org/viewcvs/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c?cvsroot=classpath&rev=1.1
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/classpath/classpath/ChangeLog,v
retrieving revision 1.7640
retrieving revision 1.7641
diff -u -b -r1.7640 -r1.7641
--- ChangeLog 3 Jun 2006 16:07:58 -0000 1.7640
+++ ChangeLog 3 Jun 2006 22:41:40 -0000 1.7641
@@ -1,3 +1,23 @@
+2006-06-02 Sven de Marothy <address@hidden>
+
+ * gnu/java/awt/peer/gtk/VolatileImageGraphics.java
+ * include/gnu_java_awt_peer_gtk_GtkVolatileImage.h
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
+ New files.
+ * gnu/java/awt/peer/gtk/ComponentGraphics.java
+ (drawImage): Overloads for VolatileImage drawing.
+ (drawVolatile): New method.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
+ * include/gnu_java_awt_peer_gtk_ComponentGraphics.h
+ (drawVolatile): New method.
+ * gnu/java/awt/peer/gtk/GtkVolatileImage.java
+ Unstub implementation.
+ * include/Makefile.am
+ * native/jni/gtk-peer/Makefile.am
+ Add new files.
+ * native/jni/gtk-peer/gtkpeer.h
+ New prototype.
+
2006-06-03 Roman Kennke <address@hidden>
PR 27418
Index: gnu/java/awt/peer/gtk/ComponentGraphics.java
===================================================================
RCS file:
/sources/classpath/classpath/gnu/java/awt/peer/gtk/ComponentGraphics.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- gnu/java/awt/peer/gtk/ComponentGraphics.java 2 Jun 2006 22:57:31
-0000 1.7
+++ gnu/java/awt/peer/gtk/ComponentGraphics.java 3 Jun 2006 22:41:41
-0000 1.8
@@ -110,6 +110,10 @@
private native void copyAreaNative(GtkComponentPeer component, int x, int y,
int width, int height, int dx, int dy);
+ private native void drawVolatile(GtkComponentPeer component,
+ Image vimg, int x, int y,
+ int width, int height);
+
/**
* Returns a Graphics2D object for a component, either an instance of this
* class (if xrender is supported), or a context which copies.
@@ -183,4 +187,32 @@
super.drawGlyphVector(gv, x, y);
end_gdk_drawing();
}
+
+ public boolean drawImage(Image img, int x, int y, ImageObserver observer)
+ {
+ if( img instanceof GtkVolatileImage )
+ {
+ ((GtkVolatileImage)img).validate( null );
+ drawVolatile( component, img, x, y-20 ,
+ ((GtkVolatileImage)img).width,
+ ((GtkVolatileImage)img).height );
+ return true;
+ }
+ return super.drawImage( img, x, y, observer );
+ }
+
+ public boolean drawImage(Image img, int x, int y, int width, int height,
+ ImageObserver observer)
+ {
+ if( img instanceof GtkVolatileImage )
+ {
+ ((GtkVolatileImage)img).validate( null );
+ drawVolatile( component, img, x, y-20,
+ width, height );
+ return true;
+ }
+ return super.drawImage( img, x, y, width, height, observer );
+ }
+
}
+
Index: gnu/java/awt/peer/gtk/GtkVolatileImage.java
===================================================================
RCS file:
/sources/classpath/classpath/gnu/java/awt/peer/gtk/GtkVolatileImage.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- gnu/java/awt/peer/gtk/GtkVolatileImage.java 2 Jul 2005 20:32:12 -0000
1.3
+++ gnu/java/awt/peer/gtk/GtkVolatileImage.java 3 Jun 2006 22:41:41 -0000
1.4
@@ -1,4 +1,4 @@
-/* GtkVolatileImage.java -- a hardware-accelerated image buffer
+/* GtkVolatileImage.java -- wraps an X pixmap
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,7 @@
package gnu.java.awt.peer.gtk;
import java.awt.ImageCapabilities;
+import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.image.BufferedImage;
@@ -46,54 +47,96 @@
public class GtkVolatileImage extends VolatileImage
{
- private int width;
- private int height;
+ int width, height;
private ImageCapabilities caps;
- public GtkVolatileImage(int width, int height)
- {
- this(width, height, null);
- }
+ /**
+ * Don't touch, accessed from native code.
+ */
+ private long nativePointer;
- public GtkVolatileImage(int width, int height, ImageCapabilities caps)
+ /**
+ * Offscreen image we draw to.
+ */
+ CairoSurface offScreen;
+
+ private boolean needsUpdate = false;
+
+ native long init(GtkComponentPeer component, int width, int height);
+
+ native void destroy();
+
+ native int[] getPixels();
+
+ native void update(GtkImage image);
+
+ public GtkVolatileImage(GtkComponentPeer component,
+ int width, int height, ImageCapabilities caps)
{
this.width = width;
this.height = height;
this.caps = caps;
+ nativePointer = init( component, width, height );
+ offScreen = new CairoSurface( width, height );
}
- // FIXME: should return a buffered image snapshot of the accelerated
- // visual
- public BufferedImage getSnapshot()
+ public GtkVolatileImage(int width, int height, ImageCapabilities caps)
{
- return null;
+ this(null, width, height, caps);
}
- public int getWidth()
+ public GtkVolatileImage(int width, int height)
{
- return width;
+ this(null, width, height, null);
}
- public int getHeight()
+ public void finalize()
{
- return height;
+ dispose();
+ }
+
+ public void dispose()
+ {
+ destroy();
+ }
+
+ void invalidate()
+ {
+ needsUpdate = true;
+ }
+
+ public BufferedImage getSnapshot()
+ {
+ CairoSurface cs = new CairoSurface( width, height );
+ cs.setPixels( getPixels() );
+ return CairoSurface.getBufferedImage( cs );
+ }
+
+ public Graphics getGraphics()
+ {
+ return createGraphics();
}
- // FIXME: should return a graphics wrapper around this image's
- // visual
public Graphics2D createGraphics()
{
- return null;
+ invalidate();
+ return offScreen.getGraphics();
}
public int validate(GraphicsConfiguration gc)
{
+ if( needsUpdate )
+ {
+ update( offScreen.getSharedGtkImage() );
+ needsUpdate = false;
+ return VolatileImage.IMAGE_RESTORED;
+ }
return VolatileImage.IMAGE_OK;
}
public boolean contentsLost()
{
- return false;
+ return needsUpdate;
}
public ImageCapabilities getCapabilities()
@@ -101,18 +144,28 @@
return caps;
}
- public synchronized Object getProperty (String name, ImageObserver observer)
+ public int getWidth()
{
- return null;
+ return width;
}
- public synchronized int getWidth (ImageObserver observer)
+ public int getHeight()
+ {
+ return height;
+ }
+
+ public int getWidth(java.awt.image.ImageObserver observer)
{
return width;
}
- public synchronized int getHeight (ImageObserver observer)
+ public int getHeight(java.awt.image.ImageObserver observer)
{
return height;
}
+
+ public Object getProperty(String name, ImageObserver observer)
+ {
+ return null;
+ }
}
Index: include/Makefile.am
===================================================================
RCS file: /sources/classpath/classpath/include/Makefile.am,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -b -r1.61 -r1.62
--- include/Makefile.am 30 May 2006 10:14:12 -0000 1.61
+++ include/Makefile.am 3 Jun 2006 22:41:41 -0000 1.62
@@ -74,6 +74,7 @@
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkTextFieldPeer.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkToolkit.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkWindowPeer.h \
+$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkVolatileImage.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.h
QTPEER_H_FILES = \
Index: include/gnu_java_awt_peer_gtk_ComponentGraphics.h
===================================================================
RCS file:
/sources/classpath/classpath/include/gnu_java_awt_peer_gtk_ComponentGraphics.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- include/gnu_java_awt_peer_gtk_ComponentGraphics.h 30 May 2006 19:16:56
-0000 1.2
+++ include/gnu_java_awt_peer_gtk_ComponentGraphics.h 3 Jun 2006 22:41:41
-0000 1.3
@@ -15,6 +15,7 @@
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_ComponentGraphics_end_1gdk_1drawing (JNIEnv *env,
jobject);
JNIEXPORT jboolean JNICALL
Java_gnu_java_awt_peer_gtk_ComponentGraphics_hasXRender (JNIEnv *env, jclass);
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_ComponentGraphics_copyAreaNative (JNIEnv *env,
jobject, jobject, jint, jint, jint, jint, jint, jint);
+JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_ComponentGraphics_drawVolatile (JNIEnv *env,
jobject, jobject, jobject, jint, jint, jint, jint);
#ifdef __cplusplus
}
Index: native/jni/gtk-peer/Makefile.am
===================================================================
RCS file: /sources/classpath/classpath/native/jni/gtk-peer/Makefile.am,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -b -r1.42 -r1.43
--- native/jni/gtk-peer/Makefile.am 2 Jun 2006 20:47:05 -0000 1.42
+++ native/jni/gtk-peer/Makefile.am 3 Jun 2006 22:41:41 -0000 1.43
@@ -39,6 +39,7 @@
gnu_java_awt_peer_gtk_GtkTextFieldPeer.c \
gnu_java_awt_peer_gtk_GtkToolkit.c \
gnu_java_awt_peer_gtk_GtkWindowPeer.c \
+ gnu_java_awt_peer_gtk_GtkVolatileImage.c \
cairographics2d.h \
gthread-jni.c \
gdkfont.h \
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
===================================================================
RCS file:
/sources/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c 2 Jun
2006 18:29:14 -0000 1.9
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c 3 Jun
2006 22:41:41 -0000 1.10
@@ -94,8 +94,6 @@
*draw = *win;
gdk_window_get_internal_paint_info (*win, draw, 0, 0);
- /* g_object_ref (*draw); */
- /* FIXME: Unref this. */
}
/**
@@ -211,3 +209,38 @@
gdk_threads_leave();
}
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_ComponentGraphics_drawVolatile
+(JNIEnv *env, jobject obj __attribute__ ((unused)), jobject peer,
+ jobject img, jint x, jint y, jint w, jint h)
+{
+ GdkPixmap *pixmap;
+ GtkWidget *widget = NULL;
+ void *ptr = NULL;
+ GdkGC *gc;
+
+ gdk_threads_enter();
+
+ ptr = NSA_GET_PTR (env, peer);
+ g_assert (ptr != NULL);
+
+ widget = GTK_WIDGET (ptr);
+ g_assert (widget != NULL);
+
+ while(widget->window != NULL)
+ widget = widget->window;
+ pixmap = cp_gtk_get_pixmap( env, img );
+
+
+ gc = gdk_gc_new( widget );
+ gdk_draw_drawable(widget,
+ gc,
+ pixmap,
+ 0, 0,
+ x, y,
+ w, h);
+
+ schedule_flush ();
+
+ gdk_threads_leave();
+}
Index: native/jni/gtk-peer/gtkpeer.h
===================================================================
RCS file: /sources/classpath/classpath/native/jni/gtk-peer/gtkpeer.h,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -b -r1.46 -r1.47
--- native/jni/gtk-peer/gtkpeer.h 31 May 2006 21:29:48 -0000 1.46
+++ native/jni/gtk-peer/gtkpeer.h 3 Jun 2006 22:41:41 -0000 1.47
@@ -209,6 +209,8 @@
/* Debugging */
void cp_gtk_print_current_thread (void);
+GdkPixmap *cp_gtk_get_pixmap( JNIEnv *env, jobject obj);
+
#define SYNCHRONIZE_GDK 0
#define DEBUG_LOCKING 0
Index: gnu/java/awt/peer/gtk/VolatileImageGraphics.java
===================================================================
RCS file: gnu/java/awt/peer/gtk/VolatileImageGraphics.java
diff -N gnu/java/awt/peer/gtk/VolatileImageGraphics.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/java/awt/peer/gtk/VolatileImageGraphics.java 3 Jun 2006 22:41:41
-0000 1.1
@@ -0,0 +1,129 @@
+/* VolatileImageGraphics.java
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.awt.peer.gtk;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.Image;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.font.GlyphVector;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferInt;
+import java.awt.image.ColorModel;
+import java.awt.image.DirectColorModel;
+import java.awt.image.RenderedImage;
+import java.awt.image.ImageObserver;
+import java.util.WeakHashMap;
+
+public class VolatileImageGraphics extends CairoSurfaceGraphics
+{
+ private GtkVolatileImage owner;
+
+ public VolatileImageGraphics(GtkVolatileImage owner)
+ {
+ super( owner.offScreen );
+ this.owner = owner;
+ }
+
+ VolatileImageGraphics(VolatileImageGraphics copyFrom)
+ {
+ super( copyFrom.owner.offScreen );
+ owner = copyFrom.owner;
+ }
+
+ /**
+ * Abstract methods.
+ */
+ public Graphics create()
+ {
+ return new VolatileImageGraphics( this );
+ }
+
+ public void copyAreaImpl(int x, int y, int width, int height, int dx, int dy)
+ {
+ surface.copyAreaNative(x, y, width, height, dx, dy, surface.width);
+ owner.invalidate();
+ }
+
+ /**
+ * Overloaded methods that do actual drawing need to enter the gdk threads
+ * and also do certain things before and after.
+ */
+ public void draw(Shape s)
+ {
+ super.draw(s);
+ Rectangle r = s.getBounds();
+ owner.invalidate();
+ }
+
+ public void fill(Shape s)
+ {
+ super.fill(s);
+ Rectangle r = s.getBounds();
+ owner.invalidate();
+ }
+
+ public void drawRenderedImage(RenderedImage image, AffineTransform xform)
+ {
+ super.drawRenderedImage(image, xform);
+ owner.invalidate();
+ }
+
+ protected boolean drawImage(Image img, AffineTransform xform,
+ Color bgcolor, ImageObserver obs)
+ {
+ boolean rv = super.drawImage(img, xform, bgcolor, obs);
+ owner.invalidate();
+ return rv;
+ }
+
+ public void drawGlyphVector(GlyphVector gv, float x, float y)
+ {
+ super.drawGlyphVector(gv, x, y);
+ owner.invalidate();
+ }
+}
+
Index: include/gnu_java_awt_peer_gtk_GtkVolatileImage.h
===================================================================
RCS file: include/gnu_java_awt_peer_gtk_GtkVolatileImage.h
diff -N include/gnu_java_awt_peer_gtk_GtkVolatileImage.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ include/gnu_java_awt_peer_gtk_GtkVolatileImage.h 3 Jun 2006 22:41:41
-0000 1.1
@@ -0,0 +1,22 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_gtk_GtkVolatileImage__
+#define __gnu_java_awt_peer_gtk_GtkVolatileImage__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_gtk_GtkVolatileImage_init
(JNIEnv *env, jobject, jobject, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkVolatileImage_destroy
(JNIEnv *env, jobject);
+JNIEXPORT jintArray JNICALL
Java_gnu_java_awt_peer_gtk_GtkVolatileImage_getPixels (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkVolatileImage_update
(JNIEnv *env, jobject, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_gtk_GtkVolatileImage__ */
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
===================================================================
RCS file: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
diff -N native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c 3 Jun
2006 22:41:41 -0000 1.1
@@ -0,0 +1,188 @@
+/* gnu_java_awt_peer_gtk_VolatileImage.c
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+#include "jcl.h"
+#include "gtkpeer.h"
+#include <gdk/gdkx.h>
+#include <gdk/gdktypes.h>
+#include <gdk/gdkprivate.h>
+#include <gdk/gdkx.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gdk-pixbuf/gdk-pixdata.h>
+
+#include "gnu_java_awt_peer_gtk_GtkVolatileImage.h"
+#include "cairographics2d.h"
+
+/* prototypes */
+static void *getNativeObject( JNIEnv *env, jobject obj );
+static void setNativeObject( JNIEnv *env, jobject obj, void *ptr );
+
+GdkPixmap *cp_gtk_get_pixmap( JNIEnv *env, jobject obj);
+
+/**
+ * Creates a cairo surface, ARGB32, native ordering, premultiplied alpha.
+ */
+JNIEXPORT jlong JNICALL
+Java_gnu_java_awt_peer_gtk_GtkVolatileImage_init (JNIEnv *env, jobject obj,
+ jobject peer,
+ jint width, jint height)
+{
+ GtkWidget *widget = NULL;
+ GdkPixmap* pixmap;
+ void *ptr = NULL;
+
+ gdk_threads_enter();
+
+ if( peer != NULL )
+ {
+ ptr = NSA_GET_PTR (env, peer);
+ g_assert (ptr != NULL);
+
+ widget = GTK_WIDGET (ptr);
+ g_assert (widget != NULL);
+ pixmap = gdk_pixmap_new( widget->window, width, height, -1 );
+ }
+ else
+ pixmap = gdk_pixmap_new( NULL, width, height, 16 );
+
+ gdk_threads_leave();
+
+ g_assert( pixmap != NULL );
+
+ return PTR_TO_JLONG( pixmap );
+}
+
+/**
+ * Destroy the surface
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkVolatileImage_destroy (JNIEnv *env, jobject obj)
+{
+ GdkPixmap* pixmap = getNativeObject(env, obj);
+ if( pixmap != NULL )
+ {
+ gdk_threads_enter();
+ g_object_unref( pixmap );
+ gdk_threads_leave();
+ }
+}
+
+/**
+ * Gets all pixels in an array
+ */
+JNIEXPORT jintArray JNICALL
+Java_gnu_java_awt_peer_gtk_GtkVolatileImage_getPixels
+(JNIEnv *env, jobject obj)
+{
+ jint *pixeldata, *jpixdata;
+ GdkPixmap *pixmap;
+ jintArray jpixels;
+ int width, height, depth, size;
+ jclass cls;
+ jfieldID field;
+
+ cls = (*env)->GetObjectClass (env, obj);
+ field = (*env)->GetFieldID (env, cls, "width", "I");
+ g_assert (field != 0);
+ width = (*env)->GetIntField (env, obj, field);
+
+ field = (*env)->GetFieldID (env, cls, "height", "I");
+ g_assert (field != 0);
+ height = (*env)->GetIntField (env, obj, field);
+
+ pixmap = (jint *)getNativeObject(env, obj);
+ g_assert(pixmap != NULL);
+
+ gdk_threads_enter();
+
+ /* get depth in bytes */
+ depth = gdk_drawable_get_depth( pixmap ) >> 3;
+ size = width * height * 4;
+ jpixels = (*env)->NewIntArray ( env, size );
+ jpixdata = (*env)->GetIntArrayElements (env, jpixels, NULL);
+ /* memcpy (jpixdata, pixeldata, size * sizeof( jint )); */
+
+ (*env)->ReleaseIntArrayElements (env, jpixels, jpixdata, 0);
+
+ gdk_threads_leave();
+
+ return jpixels;
+}
+
+/**
+ * Update the pixels.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkVolatileImage_update
+(JNIEnv *env, jobject obj, jobject gtkimage)
+{
+ GdkPixmap *pixmap = getNativeObject(env, obj);
+ GdkPixbuf *pixbuf;
+
+ gdk_threads_enter();
+ g_assert( pixmap != NULL );
+
+ pixbuf = cp_gtk_image_get_pixbuf (env, gtkimage);
+ g_assert( pixbuf != NULL );
+
+ gdk_draw_pixbuf (pixmap, NULL, pixbuf,
+ 0, 0, 0, 0, /* src and dest x, y */
+ -1, -1, /* full width, height */
+ GDK_RGB_DITHER_NORMAL, 0, 0);
+ gdk_threads_leave();
+}
+
+GdkPixmap *cp_gtk_get_pixmap( JNIEnv *env, jobject obj)
+{
+ return (GdkPixmap *)getNativeObject(env, obj);
+}
+
+/**
+ * Gets the native object field.
+ */
+static void *
+getNativeObject( JNIEnv *env, jobject obj )
+{
+ jclass cls;
+ jlong value;
+ jfieldID nofid;
+ cls = (*env)->GetObjectClass( env, obj );
+ nofid = (*env)->GetFieldID( env, cls, "nativePointer", "J" );
+ value = (*env)->GetLongField( env, obj, nofid );
+ (*env)->DeleteLocalRef( env, cls );
+ return JLONG_TO_PTR(void, value);
+}
- [commit-cp] classpath ChangeLog gnu/java/awt/peer/gtk/Compo...,
Sven de Marothy <=