From e1bea0c0687c5f4551b3a6058ec37ce3705fa6cc Mon Sep 17 00:00:00 2001 From: Matthias Klose Date: Sun, 3 Jun 2007 23:18:43 +0000 Subject: libjava/classpath/ChangeLog.gcj: 2007-05-31 Matthias Klose * javax/management/NotificationBroadcasterSupport.java (getNotificationInfo): Add cast. * native/jni/qt-peer/Makefile.am (AM_CXXFLAGS): Add libstdc++ include directories. * native/jni/qt-peer/Makefile.in: Regenerate. libjava/ChangeLog: 2007-06-03 Matthias Klose * java/io/natFileWin32.cc (setFilePermissions): New (stub only). _access: Handle EXEC query, stub only. 2007-06-03 Matthias Klose Merged from classpath: * gnu/java/nio/SelectorProviderImpl.java: Whitespace merge. * java/lang/System.java(inheritedChannel): New. * java/lang/Character.java: Remove stray`;'. * java/net/MulticastSocket.java: Merged. * java/text/DateFormatSymbols.java(getInstance): New, comment updates. * java/text/Collator.java(getInstance): Merged. * java/util/Calendar.java: New attributes ALL_STYLES, SHORT, LONG. getDisplayName, getDisplayNames: New. * java/util/logging/Logger.java: Merged. * Regenerate .class and .h files. 2007-06-03 Matthias Klose * java/io/File.java: Merge with classpath-0.95, new method setFilePermissions, new attribute EXEC. * java/io/natFilePosix.cc (setFilePermissions): New. _access: Handle EXEC query. * classpath/lib/java/io/File.class, java/io/File.h: Regenerate. 2007-06-03 Matthias Klose Imported GNU Classpath 0.95. * classpath/Makefile.in, classpath/native/jni/midi-dssi/Makefile.in, classpath/native/jni/classpath/Makefile.in, classpath/native/jni/Makefile.in, classpath/native/jni/gconf-peer/Makefile.in, classpath/native/jni/java-io/Makefile.in, classpath/native/jni/native-lib/Makefile.in, classpath/native/jni/java-util/Makefile.in, classpath/native/jni/midi-alsa/Makefile.in, classpath/native/jni/java-lang/Makefile.in, classpath/native/jni/java-nio/Makefile.in, classpath/native/jni/java-net/Makefile.in, classpath/native/jni/xmlj/Makefile.in, classpath/native/jni/qt-peer/Makefile.in, classpath/native/jni/gtk-peer/Makefile.in, classpath/native/Makefile.in, classpath/native/jawt/Makefile.in, classpath/native/fdlibm/Makefile.in, classpath/native/plugin/Makefile.in, classpath/resource/Makefile.in, classpath/scripts/Makefile.in, classpath/tools/Makefile.in, classpath/doc/Makefile.in, classpath/doc/api/Makefile.in, classpath/lib/Makefile.in, classpath/external/Makefile.in, classpath/external/jsr166/Makefile.in, classpath/external/sax/Makefile.in, classpath/external/w3c_dom/Makefile.in, classpath/external/relaxngDatatype/Makefile.in, classpath/include/Makefile.in, classpath/examples/Makefile.in: Regenerate. * classpath/config.guess, classpath/config.sub, classpath/ltmain.sh : Update. * classpath/configure, classpath/depcomp, classpath/missing, classpath/aclocal.m4, classpath/install-sh: Regenerate. * gnu/classpath/Configuration.java (CLASSPATH_VERSION): Now 0.95. * sources.am: Regenerate. * Makefile.in: Regenerate. * Update the .class files and generated CNI header files, add new .class and generated CNI header files. * Remove generated files for removed java source files: classpath/gnu/java/net/BASE64.java, classpath/gnu/java/security/util/Base64.java, classpath/gnu/java/awt/peer/gtk/GThreadMutex.java, classpath/gnu/java/awt/peer/gtk/GThreadNativeMethodRunner.java, classpath/gnu/java/awt/font/autofit/Scaler.java, classpath/gnu/classpath/jdwp/util/Value.java, classpath/gnu/javax/net/ssl/Base64.java. * Remove empty directories. * Makefile.am(nat_source_files): Add natVMOperatingSystemMXBeanImpl.cc. * java/lang/Class.java(setAccessible): Merge from classpath. * java/util/Locale.java: Remove. * gnu/java/lang/management/VMOperatingSystemMXBeanImpl.java, gnu/java/lang/management/natVMOperatingSystemMXBeanImpl.cc: New. * gcj/javaprims.h: Update class declarations. * scripts/classes.pl: Update usage. * HACKING: Mention to build all peers. From-SVN: r125302 --- .../awt/image/SinglePixelPackedSampleModel.java | 150 +++++++++------------ 1 file changed, 62 insertions(+), 88 deletions(-) (limited to 'libjava/classpath/java/awt/image/SinglePixelPackedSampleModel.java') diff --git a/libjava/classpath/java/awt/image/SinglePixelPackedSampleModel.java b/libjava/classpath/java/awt/image/SinglePixelPackedSampleModel.java index 9ed948c..1b0ac3f 100644 --- a/libjava/classpath/java/awt/image/SinglePixelPackedSampleModel.java +++ b/libjava/classpath/java/awt/image/SinglePixelPackedSampleModel.java @@ -39,7 +39,6 @@ package java.awt.image; import java.util.Arrays; import gnu.java.awt.BitMaskExtent; -import gnu.java.awt.Buffers; /** * A SampleModel used when all samples are stored in a single @@ -151,14 +150,25 @@ public class SinglePixelPackedSampleModel extends SampleModel */ public DataBuffer createDataBuffer() { - int size; - // We can save (scanlineStride - width) pixels at the very end of // the buffer. The Sun reference implementation (J2SE 1.3.1 and // 1.4.1_01) seems to do this; tested with Mauve test code. - size = scanlineStride * (height - 1) + width; + int size = scanlineStride * (height - 1) + width; - return Buffers.createBuffer(getDataType(), size); + DataBuffer buffer = null; + switch (getTransferType()) + { + case DataBuffer.TYPE_BYTE: + buffer = new DataBufferByte(size); + break; + case DataBuffer.TYPE_USHORT: + buffer = new DataBufferUShort(size); + break; + case DataBuffer.TYPE_INT: + buffer = new DataBufferInt(size); + break; + } + return buffer; } /** @@ -253,73 +263,39 @@ public class SinglePixelPackedSampleModel extends SampleModel public Object getDataElements(int x, int y, Object obj, DataBuffer data) { - int offset = scanlineStride*y + x + data.getOffset(); - - return Buffers.getData(data, offset, obj, - 0, // destination offset, - 1 // length - ); - } - - /** - * This is a more efficient implementation of the default implementation in - * the super class. - * @param x The x-coordinate of the pixel rectangle to store in - * obj. - * @param y The y-coordinate of the pixel rectangle to store in - * obj. - * @param w The width of the pixel rectangle to store in obj. - * @param h The height of the pixel rectangle to store in obj. - * @param obj The primitive array to store the pixels into or null to force - * creation. - * @param data The DataBuffer that is the source of the pixel data. - * @return The primitive array containing the pixel data. - * @see java.awt.image.SampleModel#getDataElements(int, int, int, int, - * java.lang.Object, java.awt.image.DataBuffer) - */ - public Object getDataElements(int x, int y, int w, int h, Object obj, - DataBuffer data) - { - int size = w*h; - int dataSize = size; - Object pixelData = null; - switch (getTransferType()) - { + int type = getTransferType(); + Object ret = null; + switch (type) + { case DataBuffer.TYPE_BYTE: - pixelData = ((DataBufferByte) data).getData(); - if (obj == null) obj = new byte[dataSize]; + { + byte[] in = (byte[]) obj; + if (in == null) + in = new byte[1]; + in[0] = (byte) data.getElem(x + y * scanlineStride); + ret = in; + } break; - case DataBuffer.TYPE_USHORT: - pixelData = ((DataBufferUShort) data).getData(); - if (obj == null) obj = new short[dataSize]; - break; - case DataBuffer.TYPE_INT: - pixelData = ((DataBufferInt) data).getData(); - if (obj == null) obj = new int[dataSize]; - break; - default: - // Seems like the only sensible thing to do. - throw new ClassCastException(); - } - if(x == 0 && scanlineStride == w) - { - // The full width need to be copied therefore we can copy in one shot. - System.arraycopy(pixelData, scanlineStride*y + data.getOffset(), obj, - 0, size); - } - else - { - // Since we do not need the full width we need to copy line by line. - int outOffset = 0; - int dataOffset = scanlineStride*y + x + data.getOffset(); - for (int yy = y; yy<(y+h); yy++) + case DataBuffer.TYPE_USHORT: + { + short[] in = (short[]) obj; + if (in == null) + in = new short[1]; + in[0] = (short) data.getElem(x + y * scanlineStride); + ret = in; + } + break; + case DataBuffer.TYPE_INT: { - System.arraycopy(pixelData, dataOffset, obj, outOffset, w); - dataOffset += scanlineStride; - outOffset += w; + int[] in = (int[]) obj; + if (in == null) + in = new int[1]; + in[0] = data.getElem(x + y * scanlineStride); + ret = in; } + break; } - return obj; + return ret; } /** @@ -414,30 +390,29 @@ public class SinglePixelPackedSampleModel extends SampleModel public void setDataElements(int x, int y, Object obj, DataBuffer data) { - int transferType = getTransferType(); - switch (transferType) - { - case DataBuffer.TYPE_BYTE: - { - byte[] in = (byte[]) obj; - data.setElem(y * scanlineStride + x, ((int) in[0]) & 0xff); - break; - } - case DataBuffer.TYPE_USHORT: - { - short[] in = (short[]) obj; + switch (transferType) + { + case DataBuffer.TYPE_BYTE: + { + byte[] in = (byte[]) obj; + data.setElem(y * scanlineStride + x, ((int) in[0]) & 0xff); + } + break; + case DataBuffer.TYPE_USHORT: + { + short[] in = (short[]) obj; data.setElem(y * scanlineStride + x, ((int) in[0]) & 0xffff); - break; - } - case DataBuffer.TYPE_INT: - { - int[] in = (int[]) obj; + } + break; + case DataBuffer.TYPE_INT: + { + int[] in = (int[]) obj; data.setElem(y * scanlineStride + x, in[0]); break; - } - } - } + } + } + } /** * Sets the samples for the pixel at (x, y) in the specified data buffer to @@ -479,7 +454,6 @@ public class SinglePixelPackedSampleModel extends SampleModel DataBuffer data) { int inOffset = 0; - int[] pixel = new int[numBands]; for (int yy=y; yy<(y+h); yy++) { int offset = scanlineStride*yy + x; -- cgit v1.1