This fixes two problems with VolatileImageGraphics:

- when doing create() the native context wasn't initialized properly.
- copyArea() didn't work because getRealBounds() from ComponentGraphics
tried to access the component field, which isn't set in
VolatileImageGraphics. This is overridden to return the bounds of the
image.

With this, I am now able to use a VolatileImage as back buffer for
Swing.

2006-06-10  Roman Kennke  <[EMAIL PROTECTED]>

        * gnu/java/awt/peer/gtk/VolatileImageGraphics.java
        (VolatileImageGraphics(VolatileImageGraphics)): Initialize
native
        context correctly.
        (getRealBounds): Overridden to return the correct bounds.

/Roman
-- 
“Improvement makes straight roads, but the crooked roads, without
Improvement, are roads of Genius.” - William Blake
Index: gnu/java/awt/peer/gtk/VolatileImageGraphics.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/VolatileImageGraphics.java,v
retrieving revision 1.2
diff -u -1 -0 -r1.2 VolatileImageGraphics.java
--- gnu/java/awt/peer/gtk/VolatileImageGraphics.java	6 Jun 2006 02:22:28 -0000	1.2
+++ gnu/java/awt/peer/gtk/VolatileImageGraphics.java	10 Jun 2006 07:51:53 -0000
@@ -66,23 +66,23 @@
   {
     this.owner = img;
     cairo_t = initFromVolatile( owner.nativePointer, img.width, img.height );
     setup( cairo_t );
     setClip( new Rectangle( 0, 0, img.width, img.height) );
   }
 
   private VolatileImageGraphics(VolatileImageGraphics copy)
   {
     this.owner = copy.owner;
-    initFromVolatile( owner.nativePointer, owner.width, owner.height );
-    setClip( new Rectangle( 0, 0, owner.width, owner.height) );
+    cairo_t = initFromVolatile(owner.nativePointer, owner.width, owner.height);
     copy( copy, cairo_t );
+    setClip(0, 0, owner.width, owner.height);
   }
 
   public void copyAreaImpl(int x, int y, int width, int height, int dx, int dy)
   {
     owner.copyArea(x, y, width, height, dx, dy);
   }
 
   public GraphicsConfiguration getDeviceConfiguration()
   {
     return null;
@@ -111,12 +111,17 @@
                            ImageObserver observer)
   {
     if( img instanceof GtkVolatileImage )
       {
 	owner.drawVolatile( ((GtkVolatileImage)img).nativePointer, 
 			    x, y, width, height );
 	return true;
       }      
     return super.drawImage( img, x, y, width, height, observer );
   }
+
+  protected Rectangle2D getRealBounds()
+  {
+    return new Rectangle2D.Double(0, 0, owner.width, owner.height);
+  }
 }
 

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil

Reply via email to