I did a slight improvement to ComponentGraphics.drawImage() for
VolatileImages, which is to apply the clip correctly. This brings Swing
painting performance back to the snappiness of the last release, or even
better.

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

        * gnu/java/awt/peer/gtk/ComponentGraphics.java
        (drawImage): Clip volatile image correctly.
        (drawVolatileImage): Added arguments for clipping.
        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
        (drawVolatileImage): Added arguments for clipping. Clip image
        correctly.
        * include/gnu_java_awt_peer_gtk_ComponentGraphics.h: Regenerated.

-- 
“Improvement makes straight roads, but the crooked roads, without
Improvement, are roads of Genius.” - William Blake
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c,v
retrieving revision 1.16
diff -u -1 -0 -r1.16 gnu_java_awt_peer_gtk_ComponentGraphics.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c	10 Jun 2006 10:33:17 -0000	1.16
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c	19 Jun 2006 11:47:42 -0000
@@ -272,37 +272,45 @@
   gdk_draw_pixbuf (drawable, NULL, pixbuf,
 		   0, 0, x + dx, y + dy, 
 		   w, h, 
 		   GDK_RGB_DITHER_NORMAL, 0, 0);
   gdk_threads_leave();
 }
 
 JNIEXPORT void JNICALL 
 Java_gnu_java_awt_peer_gtk_ComponentGraphics_drawVolatile
 (JNIEnv *env, jobject obj __attribute__ ((unused)), jobject peer, 
- jlong img, jint x, jint y, jint w, jint h)
+ jlong img, jint x, jint y, jint w, jint h, jint cx, jint cy, jint cw, jint ch)
 {
   GdkPixmap *pixmap;
   GtkWidget *widget = NULL;
   void *ptr = NULL;
   GdkGC *gc;
+  GdkRectangle clip;
 
   gdk_threads_enter();
   ptr = NSA_GET_PTR (env, peer);
   g_assert (ptr != NULL);
 
   widget = GTK_WIDGET (ptr);
   g_assert (widget != NULL);
 
   pixmap = JLONG_TO_PTR(GdkPixmap, img);
  
   gc = gdk_gc_new(widget->window);
+
+  clip.x = cx;
+  clip.y = cy;
+  clip.width = cw;
+  clip.height = ch;
+  gdk_gc_set_clip_rectangle(gc, &clip);
+
   gdk_draw_drawable(widget->window,
 		    gc,
 		    pixmap,
 		    0, 0,
 		    x, y,
 		    w, h);
 
   g_object_unref( gc );
 
   schedule_flush ();
Index: include/gnu_java_awt_peer_gtk_ComponentGraphics.h
===================================================================
RCS file: /cvsroot/classpath/classpath/include/gnu_java_awt_peer_gtk_ComponentGraphics.h,v
retrieving revision 1.7
diff -u -1 -0 -r1.7 gnu_java_awt_peer_gtk_ComponentGraphics.h
--- include/gnu_java_awt_peer_gtk_ComponentGraphics.h	10 Jun 2006 14:16:10 -0000	1.7
+++ include/gnu_java_awt_peer_gtk_ComponentGraphics.h	19 Jun 2006 11:47:42 -0000
@@ -10,17 +10,17 @@
 {
 #endif
 
 JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_initState (JNIEnv *env, jobject, jobject);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_disposeSurface (JNIEnv *env, jobject, jlong);
 JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_initFromVolatile (JNIEnv *env, jobject, jlong, jint, jint);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_start_1gdk_1drawing (JNIEnv *env, jobject);
 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, jlong, jint, jint, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_drawVolatile (JNIEnv *env, jobject, jobject, jlong, jint, jint, jint, jint, jint, jint, jint, jint);
 
 #ifdef __cplusplus
 }
 #endif
 
 #endif /* __gnu_java_awt_peer_gtk_ComponentGraphics__ */
Index: gnu/java/awt/peer/gtk/ComponentGraphics.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/ComponentGraphics.java,v
retrieving revision 1.17
diff -u -1 -0 -r1.17 ComponentGraphics.java
--- gnu/java/awt/peer/gtk/ComponentGraphics.java	14 Jun 2006 17:23:07 -0000	1.17
+++ gnu/java/awt/peer/gtk/ComponentGraphics.java	19 Jun 2006 11:47:42 -0000
@@ -32,37 +32,33 @@
 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.Font;
 import java.awt.Graphics;
 import java.awt.Graphics2D;
 import java.awt.GraphicsConfiguration;
 import java.awt.Image;
 import java.awt.Rectangle;
 import java.awt.Shape;
 import java.awt.Toolkit;
-import java.awt.Point;
-import java.awt.font.FontRenderContext;
 import java.awt.font.GlyphVector;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Rectangle2D;
 import java.awt.image.BufferedImage;
 import java.awt.image.ImageObserver;
 import java.awt.image.ImageProducer;
-import java.awt.image.ImagingOpException;
 import java.awt.image.RenderedImage;
 
 /**
  * ComponentGraphics - context for drawing directly to a component,
  * as this is an X drawable, it requires that we use GTK locks.
  *
  * This context draws directly to the drawable and requires xrender.
  */
 public class ComponentGraphics extends CairoGraphics2D
 {
@@ -163,21 +159,22 @@
    * Query if the system has the XRender extension.
    */
   public static native boolean hasXRender();
 
 
   private native void copyAreaNative(GtkComponentPeer component, int x, int y, 
 				     int width, int height, int dx, int dy);
 
   private native void drawVolatile(GtkComponentPeer component,
 				   long vimg, int x, int y, 
-				   int width, int height);
+				   int width, int height, int cx, int cy,
+                                   int cw, int ch);
 
   /**
    * Returns a Graphics2D object for a component, either an instance of this 
    * class (if xrender is supported), or a context which copies.
    */
   public static Graphics2D getComponentGraphics(GtkComponentPeer component)
   {
     if( hasXRender() )
       return new ComponentGraphics(component);
 
@@ -278,35 +275,38 @@
   }
   
   public boolean drawImage(Image img, int x, int y, ImageObserver observer)
   {
     // If it is a GtkVolatileImage with an "easy" transform then
     // draw directly. Always pass a BufferedImage to super to avoid
     // deadlock (see Note in CairoGraphics.drawImage()).
     if (img instanceof GtkVolatileImage)
       {
         GtkVolatileImage vimg = (GtkVolatileImage) img;
-	int type = transform.getType();
-	if (type == AffineTransform.TYPE_IDENTITY)
-	  {
-	    drawVolatile(component, vimg.nativePointer,
-			 x, y, vimg.width, vimg.height);
-	    return true;
-	  }
-	  else if (type == AffineTransform.TYPE_TRANSLATION)
-	  {
-	    x += transform.getTranslateX();
-	    y += transform.getTranslateY();
-	    drawVolatile(component, vimg.nativePointer,
-			 x, y, vimg.width, vimg.height);
-	    return true;
-	  }
+        int type = transform.getType();
+        if ((type == AffineTransform.TYPE_IDENTITY
+             || type == AffineTransform.TYPE_TRANSLATION)
+             && (clip == null || clip instanceof Rectangle2D))
+          {
+            Rectangle2D r = (Rectangle2D) clip;
+            if (r == null)
+              r = getRealBounds();
+            x += transform.getTranslateX();
+            y += transform.getTranslateY();
+            drawVolatile(component, vimg.nativePointer,
+                         x, y, vimg.width, vimg.height,
+                         (int) (r.getX() + transform.getTranslateX()),
+                         (int) (r.getY() + transform.getTranslateY()),
+                         (int) r.getWidth(),
+                         (int) r.getHeight());
+            return true;
+          }
 	else
 	  return super.drawImage(vimg.getSnapshot(), x, y, observer);
       }
 
     BufferedImage bimg;
     if (img instanceof BufferedImage)
       bimg = (BufferedImage) img;
     else
       {
 	ImageProducer source = img.getSource();
@@ -316,38 +316,42 @@
       }
     return super.drawImage(bimg, x, y, observer);
   }
   
   public boolean drawImage(Image img, int x, int y, int width, int height,
                            ImageObserver observer)
   {
     // If it is a GtkVolatileImage with an "easy" transform then
     // draw directly. Always pass a BufferedImage to super to avoid
     // deadlock (see Note in CairoGraphics.drawImage()).
-    if (img instanceof GtkVolatileImage)
+    if (img instanceof GtkVolatileImage
+        && (clip == null || clip instanceof Rectangle2D))
       {
         GtkVolatileImage vimg = (GtkVolatileImage) img;
-	int type = transform.getType();
-	if (type == AffineTransform.TYPE_IDENTITY)
-	  {
-	    drawVolatile(component, vimg.nativePointer,
-			 x, y, width, height);
-	    return true;
-	  }
-	  else if (type == AffineTransform.TYPE_TRANSLATION)
-	  {
-	    x += transform.getTranslateX();
-	    y += transform.getTranslateY();
-	    drawVolatile(component, vimg.nativePointer,
-			 x, y, width, height);
-	    return true;
-	  }
+        int type = transform.getType();
+        if ((type == AffineTransform.TYPE_IDENTITY
+             || type == AffineTransform.TYPE_TRANSLATION)
+             && (clip == null || clip instanceof Rectangle2D))
+          {
+            Rectangle2D r = (Rectangle2D) clip;
+            if (r == null)
+              r = getRealBounds();
+            x += transform.getTranslateX();
+            y += transform.getTranslateY();
+            drawVolatile(component, vimg.nativePointer,
+                         x, y, width, height,
+                         (int) (r.getX() + transform.getTranslateX()),
+                         (int) (r.getY() + transform.getTranslateY()),
+                         (int) r.getWidth(),
+                         (int) r.getHeight());
+            return true;
+          }
 	else
 	  return super.drawImage(vimg.getSnapshot(), x, y,
 				 width, height, observer);
       }
 
     BufferedImage bimg;
     if (img instanceof BufferedImage)
       bimg = (BufferedImage) img;
     else
       {

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

Reply via email to