summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--gnu/java/awt/peer/gtk/ComponentGraphics.java76
-rw-r--r--include/gnu_java_awt_peer_gtk_ComponentGraphics.h2
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c10
4 files changed, 60 insertions, 38 deletions
diff --git a/ChangeLog b/ChangeLog
index 1c4f62a8e..e308e00f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2006-06-19 Roman Kennke <kennke@aicas.com>
+
+ * 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.
+
2006-06-19 Audrius Meskauskas <AudriusA@Bioinformatics.org>
PR 28035
diff --git a/gnu/java/awt/peer/gtk/ComponentGraphics.java b/gnu/java/awt/peer/gtk/ComponentGraphics.java
index e49c95f01..cb8350265 100644
--- a/gnu/java/awt/peer/gtk/ComponentGraphics.java
+++ b/gnu/java/awt/peer/gtk/ComponentGraphics.java
@@ -39,7 +39,6 @@ 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;
@@ -47,15 +46,12 @@ 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;
/**
@@ -170,7 +166,8 @@ public class ComponentGraphics extends CairoGraphics2D
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
@@ -285,21 +282,24 @@ public class ComponentGraphics extends CairoGraphics2D
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);
}
@@ -323,24 +323,28 @@ public class ComponentGraphics extends CairoGraphics2D
// 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);
diff --git a/include/gnu_java_awt_peer_gtk_ComponentGraphics.h b/include/gnu_java_awt_peer_gtk_ComponentGraphics.h
index 4fd597eff..2e1633452 100644
--- a/include/gnu_java_awt_peer_gtk_ComponentGraphics.h
+++ b/include/gnu_java_awt_peer_gtk_ComponentGraphics.h
@@ -17,7 +17,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_start_1gdk_1
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
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
index d85ba326f..5927b21fa 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
@@ -279,12 +279,13 @@ Java_gnu_java_awt_peer_gtk_ComponentGraphics_copyAreaNative
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);
@@ -296,6 +297,13 @@ Java_gnu_java_awt_peer_gtk_ComponentGraphics_drawVolatile
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,