diff options
author | Miguel de Icaza <miguel@gnome.org> | 2016-02-27 23:38:24 +0300 |
---|---|---|
committer | Miguel de Icaza <miguel@gnome.org> | 2016-02-27 23:38:24 +0300 |
commit | 94d4a298ad560f8674d746dea2d51e26e0a97f2a (patch) | |
tree | ae303637d83843abf98938b07eb9808880cea9fa /openjdk/sun/awt/image | |
parent | c9edfe788667d5777e97e3f2fd195080d06dd32c (diff) |
Remove unused filesmaster-signed
Diffstat (limited to 'openjdk/sun/awt/image')
-rw-r--r-- | openjdk/sun/awt/image/GifImageDecoder.java | 38 | ||||
-rw-r--r-- | openjdk/sun/awt/image/IkvmImageDecoder.java | 150 | ||||
-rw-r--r-- | openjdk/sun/awt/image/ImageRepresentation.java | 421 | ||||
-rw-r--r-- | openjdk/sun/awt/image/ImagingLib.java | 67 | ||||
-rw-r--r-- | openjdk/sun/awt/image/JPEGImageDecoder.java | 38 | ||||
-rw-r--r-- | openjdk/sun/awt/image/SunWritableRaster.java | 139 | ||||
-rw-r--r-- | openjdk/sun/awt/image/ToolkitImage.java | 325 |
7 files changed, 0 insertions, 1178 deletions
diff --git a/openjdk/sun/awt/image/GifImageDecoder.java b/openjdk/sun/awt/image/GifImageDecoder.java deleted file mode 100644 index 80f79e15..00000000 --- a/openjdk/sun/awt/image/GifImageDecoder.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - Copyright (C) 2010 Volker Berlin (i-net software) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jeroen Frijters - jeroen@frijters.net - - */ -package sun.awt.image; - -import java.io.InputStream; - -/** - * Replace the same class from Sun with native parts. - * @author Volker Berlin - */ -public class GifImageDecoder extends IkvmImageDecoder{ - - GifImageDecoder(InputStreamImageSource src, InputStream is){ - super(src, is); - } - -} diff --git a/openjdk/sun/awt/image/IkvmImageDecoder.java b/openjdk/sun/awt/image/IkvmImageDecoder.java deleted file mode 100644 index 17be22b9..00000000 --- a/openjdk/sun/awt/image/IkvmImageDecoder.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - Copyright (C) 2010 Volker Berlin (i-net software) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jeroen Frijters - jeroen@frijters.net - - */ -package sun.awt.image; - -import java.awt.image.*; -import java.io.IOException; -import java.io.InputStream; - -import cli.System.Drawing.Bitmap; -import cli.System.Drawing.Imaging.ImageLockMode; -import cli.System.Drawing.Imaging.PixelFormat; -import cli.System.IO.SeekOrigin; -import cli.System.IO.Stream; -import cli.System.NotSupportedException; -import ikvm.runtime.Util; - -abstract class IkvmImageDecoder extends ImageDecoder { - - IkvmImageDecoder(InputStreamImageSource src, InputStream is){ - super(src, is); - } - - @Override - @cli.System.Security.SecuritySafeCriticalAttribute.Annotation - public void produceImage() throws IOException, ImageFormatException{ - Stream stream = new Stream(){ - - @Override - public void Flush(){ - Util.throwException(new NotSupportedException()); - } - - @Override - public int Read(byte[] bytes, int off, int len){ - try{ - int count = input.read(bytes, off, len); - if( count < 0 ){ - return 0; - } - return count; - }catch(IOException ex){ - throw new RuntimeException(ex); - } - } - - @Override - public long Seek(long arg0, SeekOrigin arg1){ - Util.throwException(new NotSupportedException()); - return 0; - } - - @Override - public void SetLength(long arg0){ - Util.throwException(new NotSupportedException()); - } - - @Override - public void Write(byte[] arg0, int arg1, int arg2){ - Util.throwException(new NotSupportedException()); - } - - @Override - public boolean get_CanRead(){ - return true; - } - - @Override - public boolean get_CanSeek(){ - return false; - } - - @Override - public boolean get_CanWrite(){ - return true; - } - - @Override - public long get_Length(){ - try{ - return input.available(); - }catch(IOException ex){ - throw new RuntimeException(ex); - } - } - - @Override - public long get_Position(){ - Util.throwException(new NotSupportedException()); - return 0; - } - - @Override - public void set_Position(long arg0){ - Util.throwException(new NotSupportedException()); - } - - }; - try{ - Bitmap bitmap = new Bitmap(stream); - int width = bitmap.get_Width(); - int height = bitmap.get_Height(); - int size = width * height; - int[] pixelData = new int[size]; - - cli.System.Drawing.Rectangle rect = new cli.System.Drawing.Rectangle(0, 0, width, height); - cli.System.Drawing.Imaging.BitmapData data = bitmap.LockBits(rect, ImageLockMode.wrap(ImageLockMode.ReadOnly), PixelFormat.wrap(PixelFormat.Format32bppArgb)); - cli.System.IntPtr pixelPtr = data.get_Scan0(); - cli.System.Runtime.InteropServices.Marshal.Copy(pixelPtr, pixelData, 0, size); - bitmap.UnlockBits(data); - - //source. - - setDimensions(width, height); - ColorModel cm = ColorModel.getRGBdefault(); - setColorModel(cm); - //setHints(flags); - headerComplete(); - - setPixels(0,0,width,height, cm, pixelData,0,width); - imageComplete(ImageConsumer.STATICIMAGEDONE, true); - }catch(Throwable th){ - th.printStackTrace(); - imageComplete(ImageConsumer.IMAGEERROR|ImageConsumer.STATICIMAGEDONE, true); - throw new IOException(th); - } finally { - try { close(); } catch(Throwable e){e.printStackTrace();} - } - } -} diff --git a/openjdk/sun/awt/image/ImageRepresentation.java b/openjdk/sun/awt/image/ImageRepresentation.java deleted file mode 100644 index 962d46e0..00000000 --- a/openjdk/sun/awt/image/ImageRepresentation.java +++ /dev/null @@ -1,421 +0,0 @@ -/* - Copyright (C) 2009 Jeroen Frijters - Copyright (C) 2010 Volker Berlin (i-net software) - Copyright (C) 2011 Karsten Heinrich (i-net software) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jeroen Frijters - jeroen@frijters.net - -*/ - -package sun.awt.image; - -import java.awt.image.BufferedImage; -import java.awt.image.ColorModel; -import java.awt.image.ImageConsumer; -import java.awt.image.ImageObserver; -import java.util.Hashtable; - -import cli.System.Drawing.Bitmap; -import cli.System.Drawing.Imaging.BitmapData; -import cli.System.Drawing.Imaging.ImageLockMode; -import cli.System.Drawing.Imaging.PixelFormat; - -public class ImageRepresentation extends ImageWatched implements ImageConsumer{ - - private static final int DEFAULT_PIXEL_FORMAT = PixelFormat.Format32bppArgb; - InputStreamImageSource src; - ToolkitImage image; - - private int width = -1; - private int height = -1; - - private int availinfo; - - private BufferedImage bimage; - private cli.System.Drawing.Bitmap bitmap; - private int pixelFormat = DEFAULT_PIXEL_FORMAT; - - ImageRepresentation(ToolkitImage im){ - image = im; - - if (image.getSource() instanceof InputStreamImageSource) { - src = (InputStreamImageSource) image.getSource(); - } - } - - /* REMIND: Only used for Frame.setIcon - should use ImageWatcher instead */ - public synchronized void reconstruct(int flags) { - if (src != null) { - src.checkSecurity(null, false); - } - int missinginfo = flags & ~availinfo; - if ((availinfo & ImageObserver.ERROR) == 0 && missinginfo != 0) { - numWaiters++; - try { - startProduction(); - missinginfo = flags & ~availinfo; - while ((availinfo & ImageObserver.ERROR) == 0 && - missinginfo != 0) - { - try { - wait(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - return; - } - missinginfo = flags & ~availinfo; - } - } finally { - decrementWaiters(); - } - } - } - - @Override - public void setDimensions(int w, int h){ - if (src != null) { - src.checkSecurity(null, false); - } - - image.setDimensions(w, h); -// bitmap = new cli.System.Drawing.Bitmap(w, h); - - newInfo(image, (ImageObserver.WIDTH | ImageObserver.HEIGHT), - 0, 0, w, h); - - if (w <= 0 || h <= 0) { - imageComplete(ImageConsumer.IMAGEERROR); - return; - } - - width = w; - height = h; - - availinfo |= ImageObserver.WIDTH | ImageObserver.HEIGHT; - } - - private Bitmap getBitmapRef(){ - if( bitmap == null ){ - bitmap = new Bitmap(width, height, PixelFormat.wrap(pixelFormat) ); - } - return bitmap; - } - - public int getWidth(){ - return width; - } - - public int getHeight(){ - return height; - } - - public BufferedImage getBufferedImage(){ - return bimage; - } - - @Override - public void setProperties(Hashtable<?, ?> props){ - // ignore it - - } - - @Override - public synchronized void setColorModel(ColorModel model){ - int newPixelFormat = getPixelFormatForColorModel(model); - if( model.getPixelSize() <= 8 ){ - newPixelFormat = DEFAULT_PIXEL_FORMAT; - } - if( newPixelFormat != pixelFormat && bitmap != null ){ - // force reconstruct of the bitmap due to a color model change - bitmap.Dispose(); - bitmap = null; - } - pixelFormat = newPixelFormat; - } - - @Override - public void setHints(int hintflags){ - // ignore it - } - - @Override - public void setPixels(int x, int y, int w, int h, ColorModel model, byte[] pixels, int off, int scansize){ - int[] pixeli = new int[pixels.length]; - for (int i = 0; i < pixels.length; i++) - { - pixeli[i] = model.getRGB(pixels[i] & 0xff); - } - setPixels(x, y, w, h, model, pixeli, off, scansize); - } - - @Override - @cli.System.Security.SecuritySafeCriticalAttribute.Annotation - public void setPixels(int x, int y, int w, int h, ColorModel model, int[] pixels, int off, int scansize){ - // FIXME this method will fail for scan lines - if( x < 0) { - w -= x; - x = 0; - } - if (y < 0) { - h -= y; - y = 0; - } - if (w <= 0 || h <= 0) { - // nothing to set - return; - } - if ( off < 0 ) { - throw new java.lang.ArrayIndexOutOfBoundsException( "Data offset out of bounds." ); - } - long length = w * h; - if (length > pixels.length - off) - { - throw new java.lang.ArrayIndexOutOfBoundsException("Data offset out of bounds."); - } - synchronized (this) - { - int pixelFormat = getPixelFormatForColorModel( model ); - int bpp = model.getPixelSize(); - if( bpp == 32 ){ // 32 can be copies 1:1 using an int array - copyInt(x, y, w, h, pixels, off, pixelFormat); - }else if( bpp <= 8 ){ - // transform all pixels using the color model (for indexed color models) - int[] newData = new int[pixels.length]; - for( int i=0; i < newData.length; i++ ){ - newData[i] = model.getRGB(pixels[i]); - } - copyInt(x, y, w, h, pixels, off, DEFAULT_PIXEL_FORMAT); - }else { - // byte per scanline, must be a multitude of 4 - // see http://stackoverflow.com/questions/2185944/why-must-stride-in-the-system-drawing-bitmap-constructor-be-a-multiple-of-4 - int bytesPerLine = (bpp * w) / 8; - int scanLine = ((bytesPerLine + 3) / 4) * 4; - int offset = scanLine - bytesPerLine; - byte[] newData = new byte[h * scanLine]; - int position = 0; - int pixel; - for( int i=0; i<pixels.length; i++ ){ - pixel = pixels[i]; - switch( bpp ){ - case 16: newData[position] = (byte)(pixel & 0xFF); - newData[position + 1] = (byte)((pixel >> 8) & 0xFF); break; - case 24: newData[position] = (byte)(pixel & 0xFF); - newData[position + 1] = (byte)((pixel >> 8) & 0xFF); - newData[position + 2] = (byte)((pixel >> 16) & 0xFF); break; - } - position += bpp / 8; - if( position % scanLine == bytesPerLine ){ - position += offset; - } - } - copyByte(x, y, w, h, newData, off, pixelFormat, bpp); - } - } - - availinfo |= ImageObserver.SOMEBITS; - - // Can't do this here since we might need to transform/clip - // the region - if (((availinfo & ImageObserver.FRAMEBITS) == 0)) { - newInfo(image, ImageObserver.SOMEBITS, x, y, w, h); - } - } - - @cli.System.Security.SecurityCriticalAttribute.Annotation - private void copyInt(int x, int y, int w, int h, int[] pixels, int off, int pixelFormat ) { - BitmapData data = getBitmapRef().LockBits(new cli.System.Drawing.Rectangle(x, y, w, h), ImageLockMode.wrap(ImageLockMode.WriteOnly), PixelFormat.wrap(pixelFormat)); - cli.System.Runtime.InteropServices.Marshal.Copy(pixels, off, data.get_Scan0(), data.get_Width() * data.get_Height()); - getBitmapRef().UnlockBits(data); - } - - @cli.System.Security.SecurityCriticalAttribute.Annotation - private void copyByte(int x, int y, int w, int h, byte[] pixels, int off, int pixelFormat, int bpp) { - BitmapData data = getBitmapRef().LockBits(new cli.System.Drawing.Rectangle(x, y, w, h), ImageLockMode.wrap(ImageLockMode.WriteOnly), PixelFormat.wrap(pixelFormat)); - cli.System.Runtime.InteropServices.Marshal.Copy(pixels, off, data.get_Scan0(), pixels.length); - getBitmapRef().UnlockBits(data); - } - - - private int getPixelFormatForColorModel( ColorModel cm ){ - if( cm == null ){ - return DEFAULT_PIXEL_FORMAT; // TODO is PixelFormat.Canonical better here? - } - int bpp = cm.getPixelSize(); - int[] sizes = cm.getComponentSize(); - switch( bpp ){ - case 1: return PixelFormat.Undefined; // Indexed is invalid and there is no 1bpp - case 4: return PixelFormat.Format4bppIndexed; - case 8: return PixelFormat.Format8bppIndexed; - case 16: - if( sizes.length <= 1) { - return PixelFormat.Format16bppGrayScale; - } - if( sizes.length == 3 ){ - if( sizes[0] == 5 && sizes[2] == 5 ){ - return sizes[1] == 5 ? PixelFormat.Format16bppRgb555 : PixelFormat.Format16bppRgb565; - } - } - if( sizes.length == 4 && cm.hasAlpha() ){ - return PixelFormat.Format16bppArgb1555; - } - break; - case 24: - return PixelFormat.Format24bppRgb; - case 32: - if(!cm.hasAlpha()){ - return PixelFormat.Format32bppRgb; - } else { - return cm.isAlphaPremultiplied() ? PixelFormat.Format32bppPArgb : PixelFormat.Format32bppArgb; - } - case 48: - return PixelFormat.Format48bppRgb; - case 64: - return cm.isAlphaPremultiplied() ? PixelFormat.Format64bppPArgb : PixelFormat.Format64bppArgb; - } - return PixelFormat.Undefined; - } - - private boolean consuming = false; - - public void imageComplete(int status) { - if (src != null) { - src.checkSecurity(null, false); - } - boolean done; - int info; - switch (status) { - default: - case ImageConsumer.IMAGEABORTED: - done = true; - info = ImageObserver.ABORT; - break; - case ImageConsumer.IMAGEERROR: - image.addInfo(ImageObserver.ERROR); - done = true; - info = ImageObserver.ERROR; - dispose(); - break; - case ImageConsumer.STATICIMAGEDONE: - done = true; - info = ImageObserver.ALLBITS; - break; - case ImageConsumer.SINGLEFRAMEDONE: - done = false; - info = ImageObserver.FRAMEBITS; - break; - } - synchronized (this) { - if (done) { - image.getSource().removeConsumer(this); - consuming = false; - } - if (bimage == null ) { - bimage = new BufferedImage(getBitmapRef()); - } - availinfo |= info; - notifyAll(); - } - - newInfo(image, info, 0, 0, width, height); - - image.infoDone(status); - } - - /*synchronized*/ void startProduction() { - if (!consuming) { - consuming = true; - image.getSource().startProduction(this); - } - } - - private int numWaiters; - - private synchronized void checkConsumption() { - if (isWatcherListEmpty() && numWaiters == 0 && - ((availinfo & ImageObserver.ALLBITS) == 0)) - { - dispose(); - } - } - - @Override - public synchronized void notifyWatcherListEmpty() { - checkConsumption(); - } - - private synchronized void decrementWaiters() { - --numWaiters; - checkConsumption(); - } - - public boolean prepare(ImageObserver iw) { - if (src != null) { - src.checkSecurity(null, false); - } - if ((availinfo & ImageObserver.ERROR) != 0) { - if (iw != null) { - iw.imageUpdate(image, ImageObserver.ERROR|ImageObserver.ABORT, - -1, -1, -1, -1); - } - return false; - } - boolean done = ((availinfo & ImageObserver.ALLBITS) != 0); - if (!done) { - addWatcher(iw); - startProduction(); - // Some producers deliver image data synchronously - done = ((availinfo & ImageObserver.ALLBITS) != 0); - } - return done; - } - - public int check(ImageObserver iw) { - - if (src != null) { - src.checkSecurity(null, false); - } - if ((availinfo & (ImageObserver.ERROR | ImageObserver.ALLBITS)) == 0) { - addWatcher(iw); - } - - return availinfo; - } - - synchronized void abort() { - image.getSource().removeConsumer(this); - consuming = false; - bimage = null; - bitmap = null; - - newInfo(image, ImageObserver.ABORT, -1, -1, -1, -1); - availinfo &= ~(ImageObserver.SOMEBITS - | ImageObserver.FRAMEBITS - | ImageObserver.ALLBITS - | ImageObserver.ERROR); - } - - synchronized void dispose() { - image.getSource().removeConsumer(this); - consuming = false; - availinfo &= ~(ImageObserver.SOMEBITS - | ImageObserver.FRAMEBITS - | ImageObserver.ALLBITS); - } -} diff --git a/openjdk/sun/awt/image/ImagingLib.java b/openjdk/sun/awt/image/ImagingLib.java deleted file mode 100644 index 104c3c46..00000000 --- a/openjdk/sun/awt/image/ImagingLib.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.awt.image; - -import java.awt.geom.AffineTransform; -import java.awt.image.AffineTransformOp; -import java.awt.image.BufferedImage; -import java.awt.image.BufferedImageOp; -import java.awt.image.ByteLookupTable; -import java.awt.image.ConvolveOp; -import java.awt.image.Kernel; -import java.awt.image.LookupOp; -import java.awt.image.LookupTable; -import java.awt.image.RasterOp; -import java.awt.image.Raster; -import java.awt.image.WritableRaster; -import java.security.AccessController; -import java.security.PrivilegedAction; - -/** - * This class provides a hook to access platform-specific - * imaging code. - * - * If the implementing class cannot handle the op, tile format or - * image format, the method will return null; - * If there is an error when processing the - * data, the implementing class may either return null - * (in which case our java code will be executed) or may throw - * an exception. - */ -public class ImagingLib { - - public static WritableRaster filter(RasterOp op, Raster src, - WritableRaster dst) { - return null; - } - - - public static BufferedImage filter(BufferedImageOp op, BufferedImage src, - BufferedImage dst) - { - return null; - } -} diff --git a/openjdk/sun/awt/image/JPEGImageDecoder.java b/openjdk/sun/awt/image/JPEGImageDecoder.java deleted file mode 100644 index 8a406817..00000000 --- a/openjdk/sun/awt/image/JPEGImageDecoder.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - Copyright (C) 2010 Volker Berlin (i-net software) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jeroen Frijters - jeroen@frijters.net - - */ -package sun.awt.image; - -import java.io.InputStream; - -/** - * Replace the same class from Sun with native parts. - * @author Volker Berlin - */ -public class JPEGImageDecoder extends IkvmImageDecoder{ - - JPEGImageDecoder(InputStreamImageSource src, InputStream is){ - super(src, is); - } - -} diff --git a/openjdk/sun/awt/image/SunWritableRaster.java b/openjdk/sun/awt/image/SunWritableRaster.java deleted file mode 100644 index 6eb92086..00000000 --- a/openjdk/sun/awt/image/SunWritableRaster.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2001, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.awt.image; - -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.Image; -import java.awt.image.DataBuffer; -import java.awt.image.DataBufferByte; -import java.awt.image.DataBufferUShort; -import java.awt.image.DataBufferInt; -import java.awt.image.SampleModel; -import java.awt.image.WritableRaster; - -import sun.java2d.StateTrackable.State; -//import sun.java2d.SurfaceData; -import sun.java2d.StateTrackableDelegate; - -/** - * This class exists as a middle layer between WritableRaster and its - * implementation specific subclasses (ByteComponentRaster, ShortBandedRaster, - * etc). - * It provides utilities to steal the data arrays from the standard DataBuffer - * types and also steals the StateTrackableDelegate from the associated - * DataBuffer so that it can be updated when the data is changed. - */ -public class SunWritableRaster extends WritableRaster { - private static DataStealer stealer; - - public static interface DataStealer { - public byte[] getData(DataBufferByte dbb, int bank); - public short[] getData(DataBufferUShort dbus, int bank); - public int[] getData(DataBufferInt dbi, int bank); - public StateTrackableDelegate getTrackable(DataBuffer db); - public void setTrackable(DataBuffer db, StateTrackableDelegate trackable); - } - - public static void setDataStealer(DataStealer ds) { - if (stealer != null) { - throw new InternalError("Attempt to set DataStealer twice"); - } - stealer = ds; - } - - public static byte[] stealData(DataBufferByte dbb, int bank) { - return stealer.getData(dbb, bank); - } - - public static short[] stealData(DataBufferUShort dbus, int bank) { - return stealer.getData(dbus, bank); - } - - public static int[] stealData(DataBufferInt dbi, int bank) { - return stealer.getData(dbi, bank); - } - - public static StateTrackableDelegate stealTrackable(DataBuffer db) { - return stealer.getTrackable(db); - } - - public static void markDirty(DataBuffer db) { - stealer.getTrackable(db).markDirty(); - } - - public static void setTrackable(DataBuffer db, StateTrackableDelegate trackable) { - stealer.setTrackable(db, trackable); - } - - public static void makeTrackable(DataBuffer db) { - stealer.setTrackable(db, StateTrackableDelegate.createInstance(State.STABLE)); - } - - public static void markDirty(WritableRaster wr) { - if (wr instanceof SunWritableRaster) { - ((SunWritableRaster) wr).markDirty(); - } else { - markDirty(wr.getDataBuffer()); - } - } - - public static void markDirty(Image img) { -// SurfaceData.getPrimarySurfaceData(img).markDirty(); - } - - private StateTrackableDelegate theTrackable; - - public SunWritableRaster(SampleModel sampleModel, Point origin) { - super(sampleModel, origin); - theTrackable = stealTrackable(dataBuffer); - } - - public SunWritableRaster(SampleModel sampleModel, - DataBuffer dataBuffer, - Point origin) - { - super(sampleModel, dataBuffer, origin); - theTrackable = stealTrackable(dataBuffer); - } - - public SunWritableRaster(SampleModel sampleModel, - DataBuffer dataBuffer, - Rectangle aRegion, - Point sampleModelTranslate, - WritableRaster parent) - { - super(sampleModel, dataBuffer, aRegion, sampleModelTranslate, parent); - theTrackable = stealTrackable(dataBuffer); - } - - /** - * Mark the TrackableDelegate of the associated DataBuffer dirty. - */ - public final void markDirty() { - theTrackable.markDirty(); - } -} diff --git a/openjdk/sun/awt/image/ToolkitImage.java b/openjdk/sun/awt/image/ToolkitImage.java deleted file mode 100644 index 8f882f3e..00000000 --- a/openjdk/sun/awt/image/ToolkitImage.java +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Copyright (c) 1995, 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.awt.image; - -import java.util.Hashtable; -import java.util.Enumeration; - -import java.awt.Component; -import java.awt.Color; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.image.BufferedImage; -import java.awt.image.ColorModel; -import java.awt.image.ImageProducer; -import java.awt.image.ImageConsumer; -import java.awt.image.ImageObserver; -import sun.awt.image.ImageRepresentation; - -public class ToolkitImage extends Image { - - /** - * The object which is used to reconstruct the original image data - * as needed. - */ - ImageProducer source; - - InputStreamImageSource src; - - ImageRepresentation imagerep; - - - protected ToolkitImage() { - } - - /** - * Construct an image from an ImageProducer object. - */ - public ToolkitImage(ImageProducer is) { - source = is; - if (is instanceof InputStreamImageSource) { - src = (InputStreamImageSource) is; - } - } - - public ImageProducer getSource() { - if (src != null) { - src.checkSecurity(null, false); - } - return source; - } - - private int width = -1; - private int height = -1; - private Hashtable properties; - - private int availinfo; - - /** - * Return the width of the original image source. - * If the width isn't known, then the image is reconstructed. - */ - public int getWidth() { - if (src != null) { - src.checkSecurity(null, false); - } - if ((availinfo & ImageObserver.WIDTH) == 0) { - reconstruct(ImageObserver.WIDTH); - } - return width; - } - - /** - * Return the width of the original image source. - * If the width isn't known, then the ImageObserver object will be - * notified when the data is available. - */ - public synchronized int getWidth(ImageObserver iw) { - if (src != null) { - src.checkSecurity(null, false); - } - if ((availinfo & ImageObserver.WIDTH) == 0) { - addWatcher(iw, true); - if ((availinfo & ImageObserver.WIDTH) == 0) { - return -1; - } - } - return width; - } - - /** - * Return the height of the original image source. - * If the height isn't known, then the image is reconstructed. - */ - public int getHeight() { - if (src != null) { - src.checkSecurity(null, false); - } - if ((availinfo & ImageObserver.HEIGHT) == 0) { - reconstruct(ImageObserver.HEIGHT); - } - return height; - } - - /** - * Return the height of the original image source. - * If the height isn't known, then the ImageObserver object will be - * notified when the data is available. - */ - public synchronized int getHeight(ImageObserver iw) { - if (src != null) { - src.checkSecurity(null, false); - } - if ((availinfo & ImageObserver.HEIGHT) == 0) { - addWatcher(iw, true); - if ((availinfo & ImageObserver.HEIGHT) == 0) { - return -1; - } - } - return height; - } - - /** - * Return a property of the image by name. Individual property names - * are defined by the various image formats. If a property is not - * defined for a particular image, then this method will return the - * UndefinedProperty object. If the properties for this image are - * not yet known, then this method will return null and the ImageObserver - * object will be notified later. The property name "comment" should - * be used to store an optional comment which can be presented to - * the user as a description of the image, its source, or its author. - */ - public Object getProperty(String name, ImageObserver observer) { - if (name == null) { - throw new NullPointerException("null property name is not allowed"); - } - - if (src != null) { - src.checkSecurity(null, false); - } - if (properties == null) { - addWatcher(observer, true); - if (properties == null) { - return null; - } - } - Object o = properties.get(name); - if (o == null) { - o = Image.UndefinedProperty; - } - return o; - } - - public boolean hasError() { - if (src != null) { - src.checkSecurity(null, false); - } - return (availinfo & ImageObserver.ERROR) != 0; - } - - public int check(ImageObserver iw) { - if (src != null) { - src.checkSecurity(null, false); - } - if ((availinfo & ImageObserver.ERROR) == 0 && - ((~availinfo) & (ImageObserver.WIDTH | - ImageObserver.HEIGHT | - ImageObserver.PROPERTIES)) != 0) { - addWatcher(iw, false); - } - return availinfo; - } - - public void preload(ImageObserver iw) { - if (src != null) { - src.checkSecurity(null, false); - } - if ((availinfo & ImageObserver.ALLBITS) == 0) { - addWatcher(iw, true); - } - } - - private synchronized void addWatcher(ImageObserver iw, boolean load) { - if ((availinfo & ImageObserver.ERROR) != 0) { - if (iw != null) { - iw.imageUpdate(this, ImageObserver.ERROR|ImageObserver.ABORT, - -1, -1, -1, -1); - } - return; - } - ImageRepresentation ir = getImageRep(); - ir.addWatcher(iw); - if (load) { - ir.startProduction(); - } - } - - private synchronized void reconstruct(int flags) { - if ((flags & ~availinfo) != 0) { - if ((availinfo & ImageObserver.ERROR) != 0) { - return; - } - ImageRepresentation ir = getImageRep(); - ir.startProduction(); - while ((flags & ~availinfo) != 0) { - try { - wait(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - return; - } - if ((availinfo & ImageObserver.ERROR) != 0) { - return; - } - } - } - } - - synchronized void addInfo(int newinfo) { - availinfo |= newinfo; - notifyAll(); - } - - void setDimensions(int w, int h) { - width = w; - height = h; - addInfo(ImageObserver.WIDTH | ImageObserver.HEIGHT); - } - - void setProperties(Hashtable props) { - if (props == null) { - props = new Hashtable(); - } - properties = props; - addInfo(ImageObserver.PROPERTIES); - } - - synchronized void infoDone(int status) { - if (status == ImageConsumer.IMAGEERROR || - ((~availinfo) & (ImageObserver.WIDTH | - ImageObserver.HEIGHT)) != 0) { - addInfo(ImageObserver.ERROR); - } else if ((availinfo & ImageObserver.PROPERTIES) == 0) { - setProperties(null); - } - } - - public void flush() { - if (src != null) { - src.checkSecurity(null, false); - } - - ImageRepresentation ir; - synchronized (this) { - availinfo &= ~ImageObserver.ERROR; - ir = imagerep; - imagerep = null; - } - if (ir != null) { - ir.abort(); - } - if (src != null) { - src.flush(); - } - } - - protected ImageRepresentation makeImageRep() { - return new ImageRepresentation(this); - } - - public synchronized ImageRepresentation getImageRep() { - if (src != null) { - src.checkSecurity(null, false); - } - if (imagerep == null) { - imagerep = makeImageRep(); - } - return imagerep; - } - - public Graphics getGraphics() { - throw new UnsupportedOperationException("getGraphics() not valid for images " + - "created with createImage(producer)"); - } - -// /* this method is needed by printing code */ -// public ColorModel getColorModel() { -// ImageRepresentation imageRep = getImageRep(); -// return imageRep.getColorModel(); -// } -// - /* this method is needed by printing code */ - public BufferedImage getBufferedImage() { - ImageRepresentation imageRep = getImageRep(); - return imageRep.getBufferedImage(); - } -// -// public void setAccelerationPriority(float priority) { -// super.setAccelerationPriority(priority); -// ImageRepresentation imageRep = getImageRep(); -// imageRep.setAccelerationPriority(accelerationPriority); -// } -} |