提交 e6190ea4 编写于 作者: P prr

6662775: Move imaging and color classes from closed to open

Reviewed-by: tdv, campbell
上级 b62e601e
......@@ -126,44 +126,10 @@ com/sun/media/sound/SimpleInputDeviceProvider\$$1.class \
com/sun/media/sound/SimpleInputDeviceProvider\$$InputDeviceInfo.class \
com/sun/media/sound/SimpleInputDeviceProvider.class
PLUG_AWT_CLASS_NAMES = \
java/awt/color/CMMException.class \
java/awt/color/ColorSpace.class \
java/awt/color/ICC_ColorSpace.class \
java/awt/color/ICC_Profile\$$1.class \
java/awt/color/ICC_Profile\$$2.class \
java/awt/color/ICC_Profile\$$3.class \
java/awt/color/ICC_Profile.class \
java/awt/color/ICC_ProfileGray.class \
java/awt/color/ICC_ProfileRGB.class \
java/awt/image/BandedSampleModel.class \
java/awt/image/ColorConvertOp.class \
java/awt/image/ComponentSampleModel.class \
java/awt/image/DataBuffer\$$1.class \
java/awt/image/DataBuffer.class \
java/awt/image/DataBufferByte.class \
java/awt/image/DataBufferInt.class \
java/awt/image/DataBufferShort.class \
java/awt/image/DataBufferUShort.class \
java/awt/image/MultiPixelPackedSampleModel.class \
java/awt/image/Raster.class \
java/awt/image/RenderedImage.class \
java/awt/image/SampleModel.class \
java/awt/image/SinglePixelPackedSampleModel.class \
java/awt/image/WritableRaster.class \
java/awt/image/WritableRenderedImage.class \
java/awt/image/renderable/ContextualRenderedImageFactory.class \
java/awt/image/renderable/ParameterBlock.class \
java/awt/image/renderable/RenderContext.class \
java/awt/image/renderable/RenderableImage.class \
java/awt/image/renderable/RenderableImageOp.class \
java/awt/image/renderable/RenderableImageProducer.class \
java/awt/image/renderable/RenderedImageFactory.class
# Class list temp files (used by both import and export of plugs)
PLUG_TEMPDIR=$(ABS_TEMPDIR)/plugs
PLUG_CLASS_AREAS = jmf sound awt
PLUG_CLASS_AREAS = jmf sound
PLUG_CLISTS = $(PLUG_CLASS_AREAS:%=$(PLUG_TEMPDIR)/%.clist)
# Create jargs file command
......@@ -186,11 +152,6 @@ $(PLUG_TEMPDIR)/sound.clist:
@for i in $(PLUG_SOUND_CLASS_NAMES) ; do \
$(ECHO) "$$i" >> $@ ; \
done
$(PLUG_TEMPDIR)/awt.clist:
@$(prep-target)
@for i in $(PLUG_AWT_CLASS_NAMES) ; do \
$(ECHO) "$$i" >> $@ ; \
done
$(PLUG_TEMPDIR)/all.clist: $(PLUG_CLISTS)
@$(prep-target)
$(CAT) $(PLUG_CLISTS) > $@
......@@ -198,8 +159,6 @@ $(PLUG_TEMPDIR)/jmf.jargs: $(PLUG_TEMPDIR)/jmf.clist
$(plug-create-jargs)
$(PLUG_TEMPDIR)/sound.jargs: $(PLUG_TEMPDIR)/sound.clist
$(plug-create-jargs)
$(PLUG_TEMPDIR)/awt.jargs: $(PLUG_TEMPDIR)/awt.clist
$(plug-create-jargs)
$(PLUG_TEMPDIR)/all.jargs: $(PLUG_TEMPDIR)/all.clist
$(plug-create-jargs)
......@@ -235,15 +194,12 @@ import-binary-plug-jmf-classes: $(PLUG_IMPORT_JARFILE) $(PLUG_TEMPDIR)/jmf.clist
$(call import-binary-plug-classes,$(PLUG_TEMPDIR)/jmf.clist)
import-binary-plug-sound-classes: $(PLUG_IMPORT_JARFILE) $(PLUG_TEMPDIR)/sound.clist
$(call import-binary-plug-classes,$(PLUG_TEMPDIR)/sound.clist)
import-binary-plug-awt-classes: $(PLUG_IMPORT_JARFILE) $(PLUG_TEMPDIR)/awt.clist
$(call import-binary-plug-classes,$(PLUG_TEMPDIR)/awt.clist)
# Import all classes from the jar file
import-binary-plug-jar: \
import-binary-plug-jmf-classes \
import-binary-plug-sound-classes \
import-binary-plug-awt-classes
import-binary-plug-sound-classes
# Import native libraries
......@@ -286,7 +242,6 @@ import-binary-plugs: \
import-binary-plug-jar \
import-binary-plug-jmf-classes \
import-binary-plug-sound-classes \
import-binary-plug-awt-classes \
import-binary-plug-jsound-library
else # !OPENJDK
......
......@@ -28,24 +28,12 @@ PACKAGE = java.awt
PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk
# WARNING: Make sure the OPENJDK plugs are up-to-date, see make/common/internal/BinaryPlugs.gmk
#
# Files
#
AUTO_FILES_JAVA_DIRS = java/awt sun/awt/geom
#
# Specific to OPENJDK
#
ifdef OPENJDK
build: import-binary-plug-awt-classes
include $(BUILDDIR)/common/internal/BinaryPlugs.gmk
endif
build: properties cursors
#
......
/*
* 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
Created by gbp, October 25, 1997
*
*/
/**********************************************************************
**********************************************************************
**********************************************************************
*** COPYRIGHT (c) Eastman Kodak Company, 1997 ***
*** As an unpublished work pursuant to Title 17 of the United ***
*** States Code. All rights reserved. ***
**********************************************************************
**********************************************************************
**********************************************************************/
package java.awt.color;
/**
* This exception is thrown if the native CMM returns an error.
*/
public class CMMException extends java.lang.RuntimeException {
/**
* Constructs a CMMException with the specified detail message.
* @param s the specified detail message
*/
public CMMException (String s) {
super (s);
}
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
/*
* Portions Copyright 1997-2007 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/**********************************************************************
**********************************************************************
**********************************************************************
*** COPYRIGHT (c) Eastman Kodak Company, 1997 ***
*** As an unpublished work pursuant to Title 17 of the United ***
*** States Code. All rights reserved. ***
**********************************************************************
**********************************************************************
**********************************************************************/
package java.awt.color;
import java.awt.image.LookupTable;
import sun.java2d.cmm.ProfileDeferralInfo;
/**
*
* A subclass of the ICC_Profile class which represents profiles
* which meet the following criteria: the color space type of the
* profile is TYPE_GRAY and the profile includes the grayTRCTag and
* mediaWhitePointTag tags. Examples of this kind of profile are
* monochrome input profiles, monochrome display profiles, and
* monochrome output profiles. The getInstance methods in the
* ICC_Profile class will
* return an ICC_ProfileGray object when the above conditions are
* met. The advantage of this class is that it provides a lookup
* table that Java or native methods may be able to use directly to
* optimize color conversion in some cases.
* <p>
* To transform from a GRAY device profile color space to the CIEXYZ Profile
* Connection Space, the device gray component is transformed by
* a lookup through the tone reproduction curve (TRC). The result is
* treated as the achromatic component of the PCS.
<pre>
&nbsp; PCSY = grayTRC[deviceGray]
</pre>
* The inverse transform is done by converting the PCS Y components to
* device Gray via the inverse of the grayTRC.
* <p>
*/
public class ICC_ProfileGray
extends ICC_Profile {
static final long serialVersionUID = -1124721290732002649L;
/**
* Constructs a new ICC_ProfileGray from a CMM ID.
*/
ICC_ProfileGray(long ID) {
super(ID);
}
/**
* Constructs a new ICC_ProfileGray from a ProfileDeferralInfo object.
*/
ICC_ProfileGray(ProfileDeferralInfo pdi) {
super(pdi);
}
/**
* Returns a float array of length 3 containing the X, Y, and Z
* components of the mediaWhitePointTag in the ICC profile.
* @return an array containing the components of the
* mediaWhitePointTag in the ICC profile.
*/
public float[] getMediaWhitePoint() {
return super.getMediaWhitePoint();
}
/**
* Returns a gamma value representing the tone reproduction
* curve (TRC). If the profile represents the TRC as a table rather
* than a single gamma value, then an exception is thrown. In this
* case the actual table can be obtained via getTRC(). When
* using a gamma value, the PCS Y component is computed as follows:
<pre>
&nbsp; gamma
&nbsp; PCSY = deviceGray
</pre>
* @return the gamma value as a float.
* @exception ProfileDataException if the profile does not specify
* the TRC as a single gamma value.
*/
public float getGamma() {
float theGamma;
theGamma = super.getGamma(ICC_Profile.icSigGrayTRCTag);
return theGamma;
}
/**
* Returns the TRC as an array of shorts. If the profile has
* specified the TRC as linear (gamma = 1.0) or as a simple gamma
* value, this method throws an exception, and the getGamma() method
* should be used to get the gamma value. Otherwise the short array
* returned here represents a lookup table where the input Gray value
* is conceptually in the range [0.0, 1.0]. Value 0.0 maps
* to array index 0 and value 1.0 maps to array index length-1.
* Interpolation may be used to generate output values for
* input values which do not map exactly to an index in the
* array. Output values also map linearly to the range [0.0, 1.0].
* Value 0.0 is represented by an array value of 0x0000 and
* value 1.0 by 0xFFFF, i.e. the values are really unsigned
* short values, although they are returned in a short array.
* @return a short array representing the TRC.
* @exception ProfileDataException if the profile does not specify
* the TRC as a table.
*/
public short[] getTRC() {
short[] theTRC;
theTRC = super.getTRC(ICC_Profile.icSigGrayTRCTag);
return theTRC;
}
}
/*
* Portions Copyright 1997-2007 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/**********************************************************************
**********************************************************************
**********************************************************************
*** COPYRIGHT (c) Eastman Kodak Company, 1997 ***
*** As an unpublished work pursuant to Title 17 of the United ***
*** States Code. All rights reserved. ***
**********************************************************************
**********************************************************************
**********************************************************************/
package java.awt.color;
import java.awt.image.LookupTable;
import sun.java2d.cmm.ProfileDeferralInfo;
/**
*
* The ICC_ProfileRGB class is a subclass of the ICC_Profile class
* that represents profiles which meet the following criteria:
* <ul>
* <li>The profile's color space type is RGB.</li>
* <li>The profile includes the <code>redColorantTag</code>,
* <code>greenColorantTag</code>, <code>blueColorantTag</code>,
* <code>redTRCTag</code>, <code>greenTRCTag</code>,
* <code>blueTRCTag</code>, and <code>mediaWhitePointTag</code> tags.</li>
* </ul>
* The <code>ICC_Profile</code> <code>getInstance</code> method will
* return an <code>ICC_ProfileRGB</code> object when these conditions are met.
* Three-component, matrix-based input profiles and RGB display profiles are
* examples of this type of profile.
* <p>
* This profile class provides color transform matrices and lookup tables
* that Java or native methods can use directly to
* optimize color conversion in some cases.
* <p>
* To transform from a device profile color space to the CIEXYZ Profile
* Connection Space, each device color component is first linearized by
* a lookup through the corresponding tone reproduction curve (TRC).
* The resulting linear RGB components are converted to the CIEXYZ PCS
* using a a 3x3 matrix constructed from the RGB colorants.
* <pre>
*
* &nbsp; linearR = redTRC[deviceR]
*
* &nbsp; linearG = greenTRC[deviceG]
*
* &nbsp; linearB = blueTRC[deviceB]
*
* &nbsp; _ _ _ _ _ _
* &nbsp;[ PCSX ] [ redColorantX greenColorantX blueColorantX ] [ linearR ]
* &nbsp;[ ] [ ] [ ]
* &nbsp;[ PCSY ] = [ redColorantY greenColorantY blueColorantY ] [ linearG ]
* &nbsp;[ ] [ ] [ ]
* &nbsp;[_ PCSZ _] [_ redColorantZ greenColorantZ blueColorantZ _] [_ linearB _]
*
* </pre>
* The inverse transform is performed by converting PCS XYZ components to linear
* RGB components through the inverse of the above 3x3 matrix, and then converting
* linear RGB to device RGB through inverses of the TRCs.
* <p>
*/
public class ICC_ProfileRGB
extends ICC_Profile {
static final long serialVersionUID = 8505067385152579334L;
/**
* Used to get a gamma value or TRC for the red component.
*/
public static final int REDCOMPONENT = 0;
/**
* Used to get a gamma value or TRC for the green component.
*/
public static final int GREENCOMPONENT = 1;
/**
* Used to get a gamma value or TRC for the blue component.
*/
public static final int BLUECOMPONENT = 2;
/**
* Constructs an new <code>ICC_ProfileRGB</code> from a CMM ID.
*
* @param ID The CMM ID for the profile.
*
*/
ICC_ProfileRGB(long ID) {
super(ID);
}
/**
* Constructs a new <code>ICC_ProfileRGB</code> from a
* ProfileDeferralInfo object.
*
* @param pdi
*/
ICC_ProfileRGB(ProfileDeferralInfo pdi) {
super(pdi);
}
/**
* Returns an array that contains the components of the profile's
* <CODE>mediaWhitePointTag</CODE>.
*
* @return A 3-element <CODE>float</CODE> array containing the x, y,
* and z components of the profile's <CODE>mediaWhitePointTag</CODE>.
*/
public float[] getMediaWhitePoint() {
return super.getMediaWhitePoint();
}
/**
* Returns a 3x3 <CODE>float</CODE> matrix constructed from the
* X, Y, and Z components of the profile's <CODE>redColorantTag</CODE>,
* <CODE>greenColorantTag</CODE>, and <CODE>blueColorantTag</CODE>.
* <p>
* This matrix can be used for color transforms in the forward
* direction of the profile--from the profile color space
* to the CIEXYZ PCS.
*
* @return A 3x3 <CODE>float</CODE> array that contains the x, y, and z
* components of the profile's <CODE>redColorantTag</CODE>,
* <CODE>greenColorantTag</CODE>, and <CODE>blueColorantTag</CODE>.
*/
public float[][] getMatrix() {
float[][] theMatrix = new float[3][3];
float[] tmpMatrix;
tmpMatrix = getXYZTag(ICC_Profile.icSigRedColorantTag);
theMatrix[0][0] = tmpMatrix[0];
theMatrix[1][0] = tmpMatrix[1];
theMatrix[2][0] = tmpMatrix[2];
tmpMatrix = getXYZTag(ICC_Profile.icSigGreenColorantTag);
theMatrix[0][1] = tmpMatrix[0];
theMatrix[1][1] = tmpMatrix[1];
theMatrix[2][1] = tmpMatrix[2];
tmpMatrix = getXYZTag(ICC_Profile.icSigBlueColorantTag);
theMatrix[0][2] = tmpMatrix[0];
theMatrix[1][2] = tmpMatrix[1];
theMatrix[2][2] = tmpMatrix[2];
return theMatrix;
}
/**
* Returns a gamma value representing the tone reproduction curve
* (TRC) for a particular component. The component parameter
* must be one of REDCOMPONENT, GREENCOMPONENT, or BLUECOMPONENT.
* <p>
* If the profile
* represents the TRC for the corresponding component
* as a table rather than a single gamma value, an
* exception is thrown. In this case the actual table
* can be obtained through the {@link #getTRC(int)} method.
* When using a gamma value,
* the linear component (R, G, or B) is computed as follows:
* <pre>
*
* &nbsp; gamma
* &nbsp; linearComponent = deviceComponent
*
*</pre>
* @param component The <CODE>ICC_ProfileRGB</CODE> constant that
* represents the component whose TRC you want to retrieve
* @return the gamma value as a float.
* @exception ProfileDataException if the profile does not specify
* the corresponding TRC as a single gamma value.
*/
public float getGamma(int component) {
float theGamma;
int theSignature;
switch (component) {
case REDCOMPONENT:
theSignature = ICC_Profile.icSigRedTRCTag;
break;
case GREENCOMPONENT:
theSignature = ICC_Profile.icSigGreenTRCTag;
break;
case BLUECOMPONENT:
theSignature = ICC_Profile.icSigBlueTRCTag;
break;
default:
throw new IllegalArgumentException("Must be Red, Green, or Blue");
}
theGamma = super.getGamma(theSignature);
return theGamma;
}
/**
* Returns the TRC for a particular component as an array.
* Component must be <code>REDCOMPONENT</code>,
* <code>GREENCOMPONENT</code>, or <code>BLUECOMPONENT</code>.
* Otherwise the returned array
* represents a lookup table where the input component value
* is conceptually in the range [0.0, 1.0]. Value 0.0 maps
* to array index 0 and value 1.0 maps to array index length-1.
* Interpolation might be used to generate output values for
* input values that do not map exactly to an index in the
* array. Output values also map linearly to the range [0.0, 1.0].
* Value 0.0 is represented by an array value of 0x0000 and
* value 1.0 by 0xFFFF. In other words, the values are really unsigned
* <code>short</code> values even though they are returned in a
* <code>short</code> array.
*
* If the profile has specified the corresponding TRC
* as linear (gamma = 1.0) or as a simple gamma value, this method
* throws an exception. In this case, the {@link #getGamma(int)}
* method should be used to get the gamma value.
*
* @param component The <CODE>ICC_ProfileRGB</CODE> constant that
* represents the component whose TRC you want to retrieve:
* <CODE>REDCOMPONENT</CODE>, <CODE>GREENCOMPONENT</CODE>, or
* <CODE>BLUECOMPONENT</CODE>.
*
* @return a short array representing the TRC.
* @exception ProfileDataException if the profile does not specify
* the corresponding TRC as a table.
*/
public short[] getTRC(int component) {
short[] theTRC;
int theSignature;
switch (component) {
case REDCOMPONENT:
theSignature = ICC_Profile.icSigRedTRCTag;
break;
case GREENCOMPONENT:
theSignature = ICC_Profile.icSigGreenTRCTag;
break;
case BLUECOMPONENT:
theSignature = ICC_Profile.icSigBlueTRCTag;
break;
default:
throw new IllegalArgumentException("Must be Red, Green, or Blue");
}
theTRC = super.getTRC(theSignature);
return theTRC;
}
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
/*
* Portions Copyright 1997-2007 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* ****************************************************************
******************************************************************
******************************************************************
*** COPYRIGHT (c) Eastman Kodak Company, 1997
*** As an unpublished work pursuant to Title 17 of the United
*** States Code. All rights reserved.
******************************************************************
******************************************************************
******************************************************************/
package java.awt.image;
import static sun.java2d.StateTrackable.State.*;
/**
* This class extends <CODE>DataBuffer</CODE> and stores data internally as bytes.
* Values stored in the byte array(s) of this <CODE>DataBuffer</CODE> are treated as
* unsigned values.
* <p>
* <a name="optimizations">
* Note that some implementations may function more efficiently
* if they can maintain control over how the data for an image is
* stored.
* For example, optimizations such as caching an image in video
* memory require that the implementation track all modifications
* to that data.
* Other implementations may operate better if they can store the
* data in locations other than a Java array.
* To maintain optimum compatibility with various optimizations
* it is best to avoid constructors and methods which expose the
* underlying storage as a Java array, as noted below in the
* documentation for those methods.
* </a>
*/
public final class DataBufferByte extends DataBuffer
{
/** The default data bank. */
byte data[];
/** All data banks */
byte bankdata[][];
/**
* Constructs a byte-based <CODE>DataBuffer</CODE> with a single bank and the
* specified size.
*
* @param size The size of the <CODE>DataBuffer</CODE>.
*/
public DataBufferByte(int size) {
super(STABLE, TYPE_BYTE, size);
data = new byte[size];
bankdata = new byte[1][];
bankdata[0] = data;
}
/**
* Constructs a byte based <CODE>DataBuffer</CODE> with the specified number of
* banks all of which are the specified size.
*
* @param size The size of the banks in the <CODE>DataBuffer</CODE>.
* @param numBanks The number of banks in the a<CODE>DataBuffer</CODE>.
*/
public DataBufferByte(int size, int numBanks) {
super(STABLE, TYPE_BYTE, size, numBanks);
bankdata = new byte[numBanks][];
for (int i= 0; i < numBanks; i++) {
bankdata[i] = new byte[size];
}
data = bankdata[0];
}
/**
* Constructs a byte-based <CODE>DataBuffer</CODE> with a single bank using the
* specified array.
* Only the first <CODE>size</CODE> elements should be used by accessors of
* this <CODE>DataBuffer</CODE>. <CODE>dataArray</CODE> must be large enough to
* hold <CODE>size</CODE> elements.
* <p>
* Note that {@code DataBuffer} objects created by this constructor
* may be incompatible with <a href="#optimizations">performance
* optimizations</a> used by some implementations (such as caching
* an associated image in video memory).
*
* @param dataArray The byte array for the <CODE>DataBuffer</CODE>.
* @param size The size of the <CODE>DataBuffer</CODE> bank.
*/
public DataBufferByte(byte dataArray[], int size) {
super(UNTRACKABLE, TYPE_BYTE, size);
data = dataArray;
bankdata = new byte[1][];
bankdata[0] = data;
}
/**
* Constructs a byte-based <CODE>DataBuffer</CODE> with a single bank using the
* specified array, size, and offset. <CODE>dataArray</CODE> must have at least
* <CODE>offset</CODE> + <CODE>size</CODE> elements. Only elements <CODE>offset</CODE>
* through <CODE>offset</CODE> + <CODE>size</CODE> - 1
* should be used by accessors of this <CODE>DataBuffer</CODE>.
* <p>
* Note that {@code DataBuffer} objects created by this constructor
* may be incompatible with <a href="#optimizations">performance
* optimizations</a> used by some implementations (such as caching
* an associated image in video memory).
*
* @param dataArray The byte array for the <CODE>DataBuffer</CODE>.
* @param size The size of the <CODE>DataBuffer</CODE> bank.
* @param offset The offset into the <CODE>dataArray</CODE>. <CODE>dataArray</CODE>
* must have at least <CODE>offset</CODE> + <CODE>size</CODE> elements.
*/
public DataBufferByte(byte dataArray[], int size, int offset){
super(UNTRACKABLE, TYPE_BYTE, size, 1, offset);
data = dataArray;
bankdata = new byte[1][];
bankdata[0] = data;
}
/**
* Constructs a byte-based <CODE>DataBuffer</CODE> with the specified arrays.
* The number of banks is equal to <CODE>dataArray.length</CODE>.
* Only the first <CODE>size</CODE> elements of each array should be used by
* accessors of this <CODE>DataBuffer</CODE>.
* <p>
* Note that {@code DataBuffer} objects created by this constructor
* may be incompatible with <a href="#optimizations">performance
* optimizations</a> used by some implementations (such as caching
* an associated image in video memory).
*
* @param dataArray The byte arrays for the <CODE>DataBuffer</CODE>.
* @param size The size of the banks in the <CODE>DataBuffer</CODE>.
*/
public DataBufferByte(byte dataArray[][], int size) {
super(UNTRACKABLE, TYPE_BYTE, size, dataArray.length);
bankdata = (byte[][]) dataArray.clone();
data = bankdata[0];
}
/**
* Constructs a byte-based <CODE>DataBuffer</CODE> with the specified arrays, size,
* and offsets.
* The number of banks is equal to <CODE>dataArray.length</CODE>. Each array must
* be at least as large as <CODE>size</CODE> + the corresponding <CODE>offset</CODE>.
* There must be an entry in the <CODE>offset</CODE> array for each <CODE>dataArray</CODE>
* entry. For each bank, only elements <CODE>offset</CODE> through
* <CODE>offset</CODE> + <CODE>size</CODE> - 1 should be used by accessors of this
* <CODE>DataBuffer</CODE>.
* <p>
* Note that {@code DataBuffer} objects created by this constructor
* may be incompatible with <a href="#optimizations">performance
* optimizations</a> used by some implementations (such as caching
* an associated image in video memory).
*
* @param dataArray The byte arrays for the <CODE>DataBuffer</CODE>.
* @param size The size of the banks in the <CODE>DataBuffer</CODE>.
* @param offsets The offsets into each array.
*/
public DataBufferByte(byte dataArray[][], int size, int offsets[]) {
super(UNTRACKABLE, TYPE_BYTE, size, dataArray.length, offsets);
bankdata = (byte[][]) dataArray.clone();
data = bankdata[0];
}
/**
* Returns the default (first) byte data array.
* <p>
* Note that calling this method may cause this {@code DataBuffer}
* object to be incompatible with <a href="#optimizations">performance
* optimizations</a> used by some implementations (such as caching
* an associated image in video memory).
*
* @return The first byte data array.
*/
public byte[] getData() {
theTrackable.setUntrackable();
return data;
}
/**
* Returns the data array for the specified bank.
* <p>
* Note that calling this method may cause this {@code DataBuffer}
* object to be incompatible with <a href="#optimizations">performance
* optimizations</a> used by some implementations (such as caching
* an associated image in video memory).
*
* @param bank The bank whose data array you want to get.
* @return The data array for the specified bank.
*/
public byte[] getData(int bank) {
theTrackable.setUntrackable();
return bankdata[bank];
}
/**
* Returns the data arrays for all banks.
* <p>
* Note that calling this method may cause this {@code DataBuffer}
* object to be incompatible with <a href="#optimizations">performance
* optimizations</a> used by some implementations (such as caching
* an associated image in video memory).
*
* @return All of the data arrays.
*/
public byte[][] getBankData() {
theTrackable.setUntrackable();
return (byte[][]) bankdata.clone();
}
/**
* Returns the requested data array element from the first (default) bank.
*
* @param i The data array element you want to get.
* @return The requested data array element as an integer.
* @see #setElem(int, int)
* @see #setElem(int, int, int)
*/
public int getElem(int i) {
return (int)(data[i+offset]) & 0xff;
}
/**
* Returns the requested data array element from the specified bank.
*
* @param bank The bank from which you want to get a data array element.
* @param i The data array element you want to get.
* @return The requested data array element as an integer.
* @see #setElem(int, int)
* @see #setElem(int, int, int)
*/
public int getElem(int bank, int i) {
return (int)(bankdata[bank][i+offsets[bank]]) & 0xff;
}
/**
* Sets the requested data array element in the first (default) bank
* to the specified value.
*
* @param i The data array element you want to set.
* @param val The integer value to which you want to set the data array element.
* @see #getElem(int)
* @see #getElem(int, int)
*/
public void setElem(int i, int val) {
data[i+offset] = (byte)val;
theTrackable.markDirty();
}
/**
* Sets the requested data array element in the specified bank
* from the given integer.
* @param bank The bank in which you want to set the data array element.
* @param i The data array element you want to set.
* @param val The integer value to which you want to set the specified data array element.
* @see #getElem(int)
* @see #getElem(int, int)
*/
public void setElem(int bank, int i, int val) {
bankdata[bank][i+offsets[bank]] = (byte)val;
theTrackable.markDirty();
}
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册