diff options
Diffstat (limited to 'libjava/classpath/gnu/java/awt/peer/gtk/GtkVolatileImage.java')
-rw-r--r-- | libjava/classpath/gnu/java/awt/peer/gtk/GtkVolatileImage.java | 81 |
1 files changed, 58 insertions, 23 deletions
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkVolatileImage.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkVolatileImage.java index 496090a0940..53bcd739d9e 100644 --- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkVolatileImage.java +++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkVolatileImage.java @@ -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 @@ exception statement from your version. */ 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,44 +47,68 @@ import java.awt.image.VolatileImage; 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. + */ + long nativePointer; - public GtkVolatileImage(int width, int height, ImageCapabilities caps) + native long init(GtkComponentPeer component, int width, int height); + + native void destroy(); + + native int[] getPixels(); + + native void copyArea( int x, int y, int w, int h, int dx, int dy ); + + native void drawVolatile( long ptr, int x, int y, int w, int h ); + + public GtkVolatileImage(GtkComponentPeer component, + int width, int height, ImageCapabilities caps) { this.width = width; this.height = height; this.caps = caps; + nativePointer = init( component, 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(); + } + + 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; + return new VolatileImageGraphics( this ); } public int validate(GraphicsConfiguration gc) @@ -101,18 +126,28 @@ public class GtkVolatileImage extends VolatileImage return caps; } - public synchronized Object getProperty (String name, ImageObserver observer) + public int getWidth() { - return null; + return width; + } + + public int getHeight() + { + return height; } - public synchronized int getWidth (ImageObserver observer) + 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; + } } |