Commit fc56f7ac by Michael Koch

[multiple changes]

2003-09-26  Sascha Brawer  <brawer@dandelis.ch>

	* java/awt/image/SinglePixelPackedSampleModel.java (createDataBuffer):
	Save space for some pixels at the buffer end.  Added Javadoc.

2003-09-26  Tom Tromey  <tromey@redhat.com>

	* java/io/ObjectOutputStream.java (writeFields): Fixed
	indentation.
	(putFields): Likewise.

From-SVN: r71829
parent 8aa43dd0
2003-09-26 Sascha Brawer <brawer@dandelis.ch>
* java/awt/image/SinglePixelPackedSampleModel.java (createDataBuffer):
Save space for some pixels at the buffer end. Added Javadoc.
2003-09-26 Tom Tromey <tromey@redhat.com>
* java/io/ObjectOutputStream.java (writeFields): Fixed
indentation.
(putFields): Likewise.
2003-09-26 Michael Koch <konqueror@gmx.de> 2003-09-26 Michael Koch <konqueror@gmx.de>
* java/nio/ByteBufferHelper.java: * java/nio/ByteBufferHelper.java:
......
/* Copyright (C) 2000, 2002 Free Software Foundation /* Copyright (C) 2000, 2002, 2003 Free Software Foundation
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -88,13 +88,25 @@ public class SinglePixelPackedSampleModel extends SampleModel ...@@ -88,13 +88,25 @@ public class SinglePixelPackedSampleModel extends SampleModel
return new SinglePixelPackedSampleModel(dataType, w, h, bitMasks); return new SinglePixelPackedSampleModel(dataType, w, h, bitMasks);
} }
/**
* Creates a DataBuffer for holding pixel data in the format and
* layout described by this SampleModel. The returned buffer will
* consist of one single bank.
*/
public DataBuffer createDataBuffer() public DataBuffer createDataBuffer()
{ {
// Important: use scanlineStride here, not width! int size;
int size = scanlineStride*height;
// 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;
return Buffers.createBuffer(getDataType(), size); return Buffers.createBuffer(getDataType(), size);
} }
public int[] getSampleSize() public int[] getSampleSize()
{ {
return sampleSize; return sampleSize;
......
...@@ -868,140 +868,139 @@ public class ObjectOutputStream extends OutputStream ...@@ -868,140 +868,139 @@ public class ObjectOutputStream extends OutputStream
{ {
if (currentPutField == null) if (currentPutField == null)
{ {
currentPutField = new PutField () currentPutField = new PutField ()
{ {
private byte[] prim_field_data private byte[] prim_field_data =
= new byte[currentObjectStreamClass.primFieldSize]; new byte[currentObjectStreamClass.primFieldSize];
private Object[] objs private Object[] objs =
= new Object[currentObjectStreamClass.objectFieldCount]; new Object[currentObjectStreamClass.objectFieldCount];
public void put (String name, boolean value) public void put (String name, boolean value)
{ {
ObjectStreamField field ObjectStreamField field
= currentObjectStreamClass.getField (name); = currentObjectStreamClass.getField (name);
checkType (field, 'Z'); checkType (field, 'Z');
prim_field_data[field.getOffset ()] = (byte)(value ? 1 : 0); prim_field_data[field.getOffset ()] = (byte)(value ? 1 : 0);
} }
public void put (String name, byte value) public void put (String name, byte value)
{ {
ObjectStreamField field ObjectStreamField field
= currentObjectStreamClass.getField (name); = currentObjectStreamClass.getField (name);
checkType (field, 'B'); checkType (field, 'B');
prim_field_data[field.getOffset ()] = value; prim_field_data[field.getOffset ()] = value;
} }
public void put (String name, char value) public void put (String name, char value)
{ {
ObjectStreamField field ObjectStreamField field
= currentObjectStreamClass.getField (name); = currentObjectStreamClass.getField (name);
checkType (field, 'C'); checkType (field, 'C');
int off = field.getOffset (); int off = field.getOffset ();
prim_field_data[off++] = (byte)(value >>> 8); prim_field_data[off++] = (byte)(value >>> 8);
prim_field_data[off] = (byte)value; prim_field_data[off] = (byte)value;
} }
public void put (String name, double value) public void put (String name, double value)
{ {
ObjectStreamField field ObjectStreamField field
= currentObjectStreamClass.getField (name); = currentObjectStreamClass.getField (name);
checkType (field, 'D'); checkType (field, 'D');
int off = field.getOffset (); int off = field.getOffset ();
long l_value = Double.doubleToLongBits (value); long l_value = Double.doubleToLongBits (value);
prim_field_data[off++] = (byte)(l_value >>> 52); prim_field_data[off++] = (byte)(l_value >>> 52);
prim_field_data[off++] = (byte)(l_value >>> 48); prim_field_data[off++] = (byte)(l_value >>> 48);
prim_field_data[off++] = (byte)(l_value >>> 40); prim_field_data[off++] = (byte)(l_value >>> 40);
prim_field_data[off++] = (byte)(l_value >>> 32); prim_field_data[off++] = (byte)(l_value >>> 32);
prim_field_data[off++] = (byte)(l_value >>> 24); prim_field_data[off++] = (byte)(l_value >>> 24);
prim_field_data[off++] = (byte)(l_value >>> 16); prim_field_data[off++] = (byte)(l_value >>> 16);
prim_field_data[off++] = (byte)(l_value >>> 8); prim_field_data[off++] = (byte)(l_value >>> 8);
prim_field_data[off] = (byte)l_value; prim_field_data[off] = (byte)l_value;
} }
public void put (String name, float value) public void put (String name, float value)
{ {
ObjectStreamField field ObjectStreamField field
= currentObjectStreamClass.getField (name); = currentObjectStreamClass.getField (name);
checkType (field, 'F'); checkType (field, 'F');
int off = field.getOffset (); int off = field.getOffset ();
int i_value = Float.floatToIntBits (value); int i_value = Float.floatToIntBits (value);
prim_field_data[off++] = (byte)(i_value >>> 24); prim_field_data[off++] = (byte)(i_value >>> 24);
prim_field_data[off++] = (byte)(i_value >>> 16); prim_field_data[off++] = (byte)(i_value >>> 16);
prim_field_data[off++] = (byte)(i_value >>> 8); prim_field_data[off++] = (byte)(i_value >>> 8);
prim_field_data[off] = (byte)i_value; prim_field_data[off] = (byte)i_value;
} }
public void put (String name, int value) public void put (String name, int value)
{ {
ObjectStreamField field ObjectStreamField field
= currentObjectStreamClass.getField (name); = currentObjectStreamClass.getField (name);
checkType (field, 'I'); checkType (field, 'I');
int off = field.getOffset (); int off = field.getOffset ();
prim_field_data[off++] = (byte)(value >>> 24); prim_field_data[off++] = (byte)(value >>> 24);
prim_field_data[off++] = (byte)(value >>> 16); prim_field_data[off++] = (byte)(value >>> 16);
prim_field_data[off++] = (byte)(value >>> 8); prim_field_data[off++] = (byte)(value >>> 8);
prim_field_data[off] = (byte)value; prim_field_data[off] = (byte)value;
} }
public void put (String name, long value) public void put (String name, long value)
{ {
ObjectStreamField field ObjectStreamField field
= currentObjectStreamClass.getField (name); = currentObjectStreamClass.getField (name);
checkType (field, 'J'); checkType (field, 'J');
int off = field.getOffset (); int off = field.getOffset ();
prim_field_data[off++] = (byte)(value >>> 52); prim_field_data[off++] = (byte)(value >>> 52);
prim_field_data[off++] = (byte)(value >>> 48); prim_field_data[off++] = (byte)(value >>> 48);
prim_field_data[off++] = (byte)(value >>> 40); prim_field_data[off++] = (byte)(value >>> 40);
prim_field_data[off++] = (byte)(value >>> 32); prim_field_data[off++] = (byte)(value >>> 32);
prim_field_data[off++] = (byte)(value >>> 24); prim_field_data[off++] = (byte)(value >>> 24);
prim_field_data[off++] = (byte)(value >>> 16); prim_field_data[off++] = (byte)(value >>> 16);
prim_field_data[off++] = (byte)(value >>> 8); prim_field_data[off++] = (byte)(value >>> 8);
prim_field_data[off] = (byte)value; prim_field_data[off] = (byte)value;
} }
public void put (String name, short value) public void put (String name, short value)
{ {
ObjectStreamField field ObjectStreamField field
= currentObjectStreamClass.getField (name); = currentObjectStreamClass.getField (name);
checkType (field, 'S'); checkType (field, 'S');
int off = field.getOffset (); int off = field.getOffset ();
prim_field_data[off++] = (byte)(value >>> 8); prim_field_data[off++] = (byte)(value >>> 8);
prim_field_data[off] = (byte)value; prim_field_data[off] = (byte)value;
} }
public void put (String name, Object value) public void put (String name, Object value)
{ {
ObjectStreamField field ObjectStreamField field
= currentObjectStreamClass.getField (name); = currentObjectStreamClass.getField (name);
if (field == null) if (field == null)
throw new IllegalArgumentException (); throw new IllegalArgumentException ();
if (value != null && if (value != null &&
! field.getType ().isAssignableFrom (value.getClass ())) ! field.getType ().isAssignableFrom (value.getClass ()))
throw new IllegalArgumentException (); throw new IllegalArgumentException ();
objs[field.getOffset ()] = value; objs[field.getOffset ()] = value;
} }
public void write (ObjectOutput out) throws IOException public void write (ObjectOutput out) throws IOException
{ {
// Apparently Block data is not used with PutField as per // Apparently Block data is not used with PutField as per
// empirical evidence against JDK 1.2. Also see Mauve test // empirical evidence against JDK 1.2. Also see Mauve test
// java.io.ObjectInputOutput.Test.GetPutField. // java.io.ObjectInputOutput.Test.GetPutField.
boolean oldmode = setBlockDataMode (false); boolean oldmode = setBlockDataMode (false);
out.write (prim_field_data); out.write (prim_field_data);
for (int i = 0; i < objs.length; ++ i) for (int i = 0; i < objs.length; ++ i)
out.writeObject (objs[i]); out.writeObject (objs[i]);
setBlockDataMode (oldmode); setBlockDataMode (oldmode);
} }
private void checkType (ObjectStreamField field, char type) private void checkType (ObjectStreamField field, char type)
throws IllegalArgumentException throws IllegalArgumentException
{ {
if (TypeSignature.getEncodingOfClass (field.getType ()).charAt (0) if (TypeSignature.getEncodingOfClass(field.getType ()).charAt(0)
!= type) != type)
throw new IllegalArgumentException (); throw new IllegalArgumentException ();
} }
}; };
// end PutFieldImpl
} }
return currentPutField; return currentPutField;
...@@ -1013,10 +1012,9 @@ public class ObjectOutputStream extends OutputStream ...@@ -1013,10 +1012,9 @@ public class ObjectOutputStream extends OutputStream
if (currentPutField == null) if (currentPutField == null)
throw new NotActiveException ("writeFields can only be called after putFields has been called"); throw new NotActiveException ("writeFields can only be called after putFields has been called");
// moved here from putFields since putFields // putFields may be called more than once, but not writeFields.
// may be called more than once, but not writeFields markFieldsWritten();
markFieldsWritten();
currentPutField.write (this); currentPutField.write (this);
currentPutField = null; currentPutField = null;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment