diff options
author | Mark Wielaard <mark@gcc.gnu.org> | 2006-05-18 17:29:21 +0000 |
---|---|---|
committer | Mark Wielaard <mark@gcc.gnu.org> | 2006-05-18 17:29:21 +0000 |
commit | 4f9533c7722fa07511a94d005227961f4a4dec23 (patch) | |
tree | 9f9c470de62ee62fba1331a396450d728d2b1fad /libjava/classpath/gnu/java/awt/peer/gtk/GtkImage.java | |
parent | eaec4980e139903ae9b274d1abcf3a13946603a8 (diff) | |
download | gcc-4f9533c7722fa07511a94d005227961f4a4dec23.tar.gz |
Imported GNU Classpath 0.90
Imported GNU Classpath 0.90
* scripts/makemake.tcl: LocaleData.java moved to gnu/java/locale.
* sources.am: Regenerated.
* gcj/javaprims.h: Regenerated.
* Makefile.in: Regenerated.
* gcj/Makefile.in: Regenerated.
* include/Makefile.in: Regenerated.
* testsuite/Makefile.in: Regenerated.
* gnu/java/lang/VMInstrumentationImpl.java: New override.
* gnu/java/net/local/LocalSocketImpl.java: Likewise.
* gnu/classpath/jdwp/VMMethod.java: Likewise.
* gnu/classpath/jdwp/VMVirtualMachine.java: Update to latest
interface.
* java/lang/Thread.java: Add UncaughtExceptionHandler.
* java/lang/reflect/Method.java: Implements GenericDeclaration and
isSynthetic(),
* java/lang/reflect/Field.java: Likewise.
* java/lang/reflect/Constructor.java
* java/lang/Class.java: Implements Type, GenericDeclaration,
getSimpleName() and getEnclosing*() methods.
* java/lang/Class.h: Add new public methods.
* java/lang/Math.java: Add signum(), ulp() and log10().
* java/lang/natMath.cc (log10): New function.
* java/security/VMSecureRandom.java: New override.
* java/util/logging/Logger.java: Updated to latest classpath
version.
* java/util/logging/LogManager.java: New override.
From-SVN: r113887
Diffstat (limited to 'libjava/classpath/gnu/java/awt/peer/gtk/GtkImage.java')
-rw-r--r-- | libjava/classpath/gnu/java/awt/peer/gtk/GtkImage.java | 134 |
1 files changed, 100 insertions, 34 deletions
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkImage.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkImage.java index b48a2049e27..5e5f1de0113 100644 --- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkImage.java +++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkImage.java @@ -123,41 +123,50 @@ public class GtkImage extends Image /** * Returns a copy of the pixel data as a java array. + * Should be called with the GdkPixbufDecoder.pixbufLock held. */ private native int[] getPixels(); /** * Sets the pixel data from a java array. + * Should be called with the GdkPixbufDecoder.pixbufLock held. */ private native void setPixels(int[] pixels); /** * Loads an image using gdk-pixbuf from a file. + * Should be called with the GdkPixbufDecoder.pixbufLock held. */ private native boolean loadPixbuf(String name); /** * Loads an image using gdk-pixbuf from data. + * Should be called with the GdkPixbufDecoder.pixbufLock held. */ private native boolean loadImageFromData(byte[] data); /** * Allocates a Gtk Pixbuf or pixmap + * Should be called with the GdkPixbufDecoder.pixbufLock held. */ private native void createPixmap(); /** * Frees the above. + * Should be called with the GdkPixbufDecoder.pixbufLock held. */ private native void freePixmap(); /** * Sets the pixmap to scaled copy of src image. hints are rendering hints. + * Should be called with the GdkPixbufDecoder.pixbufLock held. */ private native void createScaledPixmap(GtkImage src, int hints); /** * Draws the image, optionally scaled and composited. + * Should be called with the GdkPixbufDecoder.pixbufLock held. + * Also acquires global gdk lock for drawing. */ private native void drawPixelsScaled (GdkGraphics gc, int bg_red, int bg_green, int bg_blue, @@ -166,6 +175,8 @@ public class GtkImage extends Image /** * Draws the image, optionally scaled flipped and composited. + * Should be called with the GdkPixbufDecoder.pixbufLock held. + * Also acquires global gdk lock for drawing. */ private native void drawPixelsScaledFlipped (GdkGraphics gc, int bg_red, int bg_green, @@ -219,12 +230,21 @@ public class GtkImage extends Image File f = new File(filename); try { - if (loadPixbuf(f.getCanonicalPath()) != true) - throw new IllegalArgumentException("Couldn't load image: "+filename); + String path = f.getCanonicalPath(); + synchronized(GdkPixbufDecoder.pixbufLock) + { + if (loadPixbuf(f.getCanonicalPath()) != true) + throw new IllegalArgumentException("Couldn't load image: " + + filename); + } } catch(IOException e) { - throw new IllegalArgumentException("Couldn't load image: "+filename); + IllegalArgumentException iae; + iae = new IllegalArgumentException("Couldn't load image: " + + filename); + iae.initCause(e); + throw iae; } isLoaded = true; @@ -241,8 +261,11 @@ public class GtkImage extends Image */ public GtkImage (byte[] data) { - if (loadImageFromData (data) != true) - throw new IllegalArgumentException ("Couldn't load image."); + synchronized(GdkPixbufDecoder.pixbufLock) + { + if (loadImageFromData (data) != true) + throw new IllegalArgumentException ("Couldn't load image."); + } isLoaded = true; observers = null; @@ -277,8 +300,12 @@ public class GtkImage extends Image { throw new IllegalArgumentException ("Couldn't load image."); } - if (loadImageFromData (baos.toByteArray()) != true) - throw new IllegalArgumentException ("Couldn't load image."); + byte[] array = baos.toByteArray(); + synchronized(GdkPixbufDecoder.pixbufLock) + { + if (loadImageFromData(array) != true) + throw new IllegalArgumentException ("Couldn't load image."); + } isLoaded = true; observers = null; @@ -296,7 +323,10 @@ public class GtkImage extends Image isLoaded = true; observers = null; offScreen = true; - createPixmap(); + synchronized(GdkPixbufDecoder.pixbufLock) + { + createPixmap(); + } } /** @@ -312,7 +342,10 @@ public class GtkImage extends Image offScreen = false; // Use the GDK scaling method. - createScaledPixmap(src, hints); + synchronized(GdkPixbufDecoder.pixbufLock) + { + createScaledPixmap(src, hints); + } } /** @@ -322,7 +355,10 @@ public class GtkImage extends Image GtkImage (Pointer pixbuf) { pixmap = pixbuf; - createFromPixbuf(); + synchronized(GdkPixbufDecoder.pixbufLock) + { + createFromPixbuf(); + } isLoaded = true; observers = null; offScreen = false; @@ -349,6 +385,7 @@ public class GtkImage extends Image /** * Native helper function for constructor that takes a pixbuf Pointer. + * Should be called with the GdkPixbufDecoder.pixbufLock held. */ private native void createFromPixbuf(); @@ -370,8 +407,11 @@ public class GtkImage extends Image isLoaded = true; deliver(); - createPixmap(); - setPixels(pixels); + synchronized(GdkPixbufDecoder.pixbufLock) + { + createPixmap(); + setPixels(pixels); + } } // java.awt.Image methods //////////////////////////////////////////////// @@ -408,7 +448,13 @@ public class GtkImage extends Image { if (!isLoaded) return null; - return new MemoryImageSource(width, height, nativeModel, getPixels(), + + int[] pixels; + synchronized(GdkPixbufDecoder.pixbufLock) + { + pixels = getPixels(); + } + return new MemoryImageSource(width, height, nativeModel, pixels, 0, width); } @@ -454,7 +500,10 @@ public class GtkImage extends Image { observers = new Vector(); isLoaded = false; - freePixmap(); + synchronized(GdkPixbufDecoder.pixbufLock) + { + freePixmap(); + } source.startProduction(new GtkImageConsumer(this, source)); } } @@ -462,7 +511,12 @@ public class GtkImage extends Image public void finalize() { if (isLoaded) - freePixmap(); + { + synchronized(GdkPixbufDecoder.pixbufLock) + { + freePixmap(); + } + } } /** @@ -529,23 +583,29 @@ public class GtkImage extends Image srcHeight = height - srcY; } + if ( this.width <= 0 || this.height <= 0 ) + return true; + if ( srcWidth <= 0 || srcHeight <= 0 || dstWidth <= 0 || dstHeight <= 0) return true; - if(bgcolor != null) - drawPixelsScaledFlipped (g, bgcolor.getRed (), bgcolor.getGreen (), - bgcolor.getBlue (), - flipX, flipY, - srcX, srcY, - srcWidth, srcHeight, - dstX, dstY, - dstWidth, dstHeight, - true); - else - drawPixelsScaledFlipped (g, 0, 0, 0, flipX, flipY, - srcX, srcY, srcWidth, srcHeight, - dstX, dstY, dstWidth, dstHeight, - false); + synchronized(GdkPixbufDecoder.pixbufLock) + { + if(bgcolor != null) + drawPixelsScaledFlipped (g, bgcolor.getRed (), bgcolor.getGreen (), + bgcolor.getBlue (), + flipX, flipY, + srcX, srcY, + srcWidth, srcHeight, + dstX, dstY, + dstWidth, dstHeight, + true); + else + drawPixelsScaledFlipped (g, 0, 0, 0, flipX, flipY, + srcX, srcY, srcWidth, srcHeight, + dstX, dstY, dstWidth, dstHeight, + false); + } return true; } @@ -559,11 +619,17 @@ public class GtkImage extends Image if (addObserver(observer)) return false; - if(bgcolor != null) - drawPixelsScaled(g, bgcolor.getRed (), bgcolor.getGreen (), - bgcolor.getBlue (), x, y, width, height, true); - else - drawPixelsScaled(g, 0, 0, 0, x, y, width, height, false); + if ( this.width <= 0 || this.height <= 0 ) + return true; + + synchronized(GdkPixbufDecoder.pixbufLock) + { + if(bgcolor != null) + drawPixelsScaled(g, bgcolor.getRed (), bgcolor.getGreen (), + bgcolor.getBlue (), x, y, width, height, true); + else + drawPixelsScaled(g, 0, 0, 0, x, y, width, height, false); + } return true; } |