Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,168 @@
/*
Copyright (C) 2009 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.java2d;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.HeadlessException;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.util.Locale;
/**
* Placeholder for not supported headless environment
*/
public class HeadlessGraphicsEnvironment extends GraphicsEnvironment{
private final GraphicsEnvironment env;
public HeadlessGraphicsEnvironment(GraphicsEnvironment env){
this.env = env;
}
/**
* {@inheritDoc}
*/
@Override
public Graphics2D createGraphics(BufferedImage img){
return env.createGraphics(img);
}
/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object obj){
return env.equals(obj);
}
/**
* {@inheritDoc}
*/
@Override
public Font[] getAllFonts(){
return env.getAllFonts();
}
/**
* {@inheritDoc}
*/
@Override
public String[] getAvailableFontFamilyNames(){
return env.getAvailableFontFamilyNames();
}
/**
* {@inheritDoc}
*/
@Override
public String[] getAvailableFontFamilyNames(Locale l){
return env.getAvailableFontFamilyNames(l);
}
/**
* {@inheritDoc}
*/
@Override
public Point getCenterPoint() throws HeadlessException{
return env.getCenterPoint();
}
/**
* {@inheritDoc}
*/
@Override
public GraphicsDevice getDefaultScreenDevice() throws HeadlessException{
return env.getDefaultScreenDevice();
}
/**
* {@inheritDoc}
*/
@Override
public Rectangle getMaximumWindowBounds() throws HeadlessException{
return env.getMaximumWindowBounds();
}
/**
* {@inheritDoc}
*/
@Override
public GraphicsDevice[] getScreenDevices() throws HeadlessException{
return env.getScreenDevices();
}
/**
* {@inheritDoc}
*/
@Override
public int hashCode(){
return env.hashCode();
}
/**
* {@inheritDoc}
*/
@Override
public boolean isHeadlessInstance(){
return env.isHeadlessInstance();
}
/**
* {@inheritDoc}
*/
@Override
public void preferLocaleFonts(){
env.preferLocaleFonts();
}
/**
* {@inheritDoc}
*/
@Override
public void preferProportionalFonts(){
env.preferProportionalFonts();
}
/**
* {@inheritDoc}
*/
@Override
public boolean registerFont(Font font){
return env.registerFont(font);
}
/**
* {@inheritDoc}
*/
@Override
public String toString(){
return env.toString();
}
}

View File

@@ -0,0 +1,316 @@
/* AlphaCompositeContext.java -- CompositeContext impl for AlphaComposite
Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath 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 for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package sun.java2d;
import java.awt.AWTError;
import java.awt.AlphaComposite;
import java.awt.CompositeContext;
import java.awt.image.ColorModel;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
/**
* A CompositeContext implementation for {@link AlphaComposite}.
*
* @author Roman Kennke (kennke@aicas.com)
*/
public class SunCompositeContext
implements CompositeContext
{
/**
* The Composite object for which we perform compositing.
*/
private AlphaComposite composite;
/**
* The source color model.
*/
private ColorModel srcColorModel;
/**
* The destination color model.
*/
private ColorModel dstColorModel;
/**
* The blending factor for the source.
*/
private float fs;
/**
* The blending factor for the destination.
*/
private float fd;
/**
* Creates a new AlphaCompositeContext.
*
* @param aComp the AlphaComposite object
* @param srcCM the source color model
* @param dstCM the destination color model
*/
public SunCompositeContext(AlphaComposite aComp, ColorModel srcCM,
ColorModel dstCM)
{
composite = aComp;
srcColorModel = srcCM;
dstColorModel = dstCM;
// Determine the blending factors according to the rule in the
// AlphaComposite. For some rules the factors must be determined
// dynamically because they depend on the actual pixel value.
switch (composite.getRule())
{
case AlphaComposite.CLEAR:
fs = 0.F;
fd= 0.F;
break;
case AlphaComposite.DST:
fs = 0.F;
fd= 1.F;
break;
case AlphaComposite.DST_ATOP:
fs = 1.F; // Determined later as 1 - alpha_dst;
fd = 1.F; // Determined later as alpha_src;
break;
case AlphaComposite.DST_IN:
fs = 0.F;
fd = 0.F; // Determined later as alpha_src;
break;
case AlphaComposite.DST_OUT:
fs = 0.F;
fd = 0.F; // Determined later as 1 - alpha_src;
break;
case AlphaComposite.DST_OVER:
fs = 1.F; // Determined later as 1 - alpha_dst.
fd= 1.F;
break;
case AlphaComposite.SRC:
fs = 1.F;
fd= 0.F;
break;
case AlphaComposite.SRC_ATOP:
fs = 1.F; // Determined later as alpha_dst;
fd = 1.F; // Determined later as 1 - alpha_src;
break;
case AlphaComposite.SRC_IN:
fs = 0.F; // Determined later as alpha_dst;
fd = 0.F;
break;
case AlphaComposite.SRC_OUT:
fs = 0.F; // Determined later as 1 - alpha_dst;
fd = 0.F;
break;
case AlphaComposite.SRC_OVER:
fs = 1.F;
fd= 1.F; // Determined later as 1 - alpha_src.
break;
case AlphaComposite.XOR:
fs = 1.F; // Determined later as 1 - alpha_dst.
fd= 1.F; // Determined later as 1 - alpha_src.
break;
default:
throw new AWTError("Illegal AlphaComposite rule");
}
}
/**
* Releases all resources held by this composite object.
*/
public void dispose()
{
// Nothing to do here yet.
}
/**
* Performs compositing according to the rules specified in the
* AlphaComposite from the constructor.
*/
public void compose(Raster src, Raster dstIn, WritableRaster dstOut)
{
// TODO: This implementation is very general and highly inefficient. There
// are two possible ways to optimize this:
// 1. Special cased implementations for common ColorModels and transfer
// types.
// 2. Native implementation.
int x0 = src.getMinX();
int y0 = src.getMinY();
int width = src.getWidth();
int height = src.getHeight();
int x1 = x0 + width;
int y1 = y0 + height;
Object srcPixel = null;
Object dstPixel = null;
// Prepare the array that holds the color and alpha components of the
// source pixels.
float[] srcComponents;
int srcComponentsLength = srcColorModel.getNumComponents();
if (! srcColorModel.hasAlpha())
srcComponentsLength += 1;
srcComponents = new float[srcComponentsLength];
// Prepare the array that holds the color and alpha components of the
// destination pixels.
float[] dstComponents;
int dstComponentsLength = dstColorModel.getNumComponents();
if (! dstColorModel.hasAlpha())
dstComponentsLength += 1;
dstComponents = new float[dstComponentsLength];
if (srcComponentsLength != dstComponentsLength)
throw new AWTError("The color models of the source and destination have"
+ "incompatible number of color components");
int srcTransferType = srcColorModel.getTransferType();
int dstTransferType = dstColorModel.getTransferType();
for (int y = y0; y < y1; y++)
{
for (int x = x0; x < x1; x++)
{
// Fetch source pixel.
srcPixel = src.getDataElements(x, y, (int[]) srcPixel);
// Fetch destination pixel.
dstPixel = dstIn.getDataElements(x, y, dstPixel);
// Get normalized components. This is the only type that is
// guaranteed to be supported by all ColorModels.
srcComponents =
srcColorModel.getNormalizedComponents(srcPixel, srcComponents, 0);
if (! srcColorModel.hasAlpha())
srcComponents[srcComponentsLength - 1] = 1.0F;
dstComponents =
dstColorModel.getNormalizedComponents(dstPixel, dstComponents, 0);
if (! dstColorModel.hasAlpha())
dstComponents[dstComponentsLength - 1] = 1.0F;
// Prepare the input.
float compositeAlpha = composite.getAlpha();
srcComponents[srcComponentsLength - 1] *= compositeAlpha;
if (srcColorModel.isAlphaPremultiplied())
{
for (int i = srcComponentsLength - 2; i >= 0; i--)
srcComponents[i] *= compositeAlpha;
}
else
{
for (int i = srcComponentsLength - 2; i >= 0; i--)
srcComponents[i] *= srcComponents[srcComponentsLength - 1];
}
if (! dstColorModel.isAlphaPremultiplied())
{
for (int i = dstComponentsLength - 2; i >= 0; i--)
dstComponents[i] *= dstComponents[dstComponents.length - 1];
}
// Determine the blending factors according to the rule in the
// AlphaComposite. For some rules the factors must be determined
// dynamically because they depend on the actual pixel value.
float srcAlpha = srcComponents[srcComponentsLength - 1];
float dstAlpha = dstComponents[dstComponentsLength - 1];
switch (composite.getRule())
{
case AlphaComposite.DST_ATOP:
fs = 1.F - dstAlpha;
fd = srcAlpha;
break;
case AlphaComposite.DST_IN:
fd = srcAlpha;
break;
case AlphaComposite.DST_OUT:
fd = 1.F - srcAlpha;
break;
case AlphaComposite.DST_OVER:
fs = 1.F - dstAlpha;
break;
case AlphaComposite.SRC_ATOP:
fs = srcAlpha;
fd = 1.F - srcAlpha;
break;
case AlphaComposite.SRC_IN:
fs = dstAlpha;
break;
case AlphaComposite.SRC_OUT:
fs = 1.F - dstAlpha;
break;
case AlphaComposite.SRC_OVER:
fd= 1.F - srcAlpha;
break;
case AlphaComposite.XOR:
fs = 1.F - dstAlpha;
fd= 1.F - srcAlpha;
break;
default:
// For the other cases the factors have already been determined
// in the constructor.
}
// Apply the blending equation to the pixels.
for (int i = 0; i < srcComponentsLength; i++)
{
dstComponents[i] = srcComponents[i] * fs
+ dstComponents[i] * fd;
}
// Convert the result back when the destination is not
// alpha-premultiplied.
dstAlpha = dstComponents[dstComponentsLength - 1];
if (!dstColorModel.isAlphaPremultiplied() && dstAlpha != 0.F)
{
for (int i = 0; i < dstComponentsLength - 1; i++)
{
dstComponents[i] = dstComponents[i] / dstAlpha;
}
}
// Store the result in the destination raster.
dstPixel = dstColorModel.getDataElements(dstComponents, 0,
dstPixel);
dstOut.setDataElements(x, y, dstPixel);
} // End X loop.
} // End Y loop.
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,106 @@
/*
Copyright (C) 2009, 2011 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.java2d;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Insets;
import java.awt.peer.ComponentPeer;
import java.awt.Rectangle;
import java.awt.Toolkit;
import sun.awt.DisplayChangedListener;
import sun.awt.SunDisplayChanger;
/**
* A replacement of the Sun implementation that will extends from from NetGraphicsEnvironment
*/
public abstract class SunGraphicsEnvironment extends GraphicsEnvironment{
/**
* Return the bounds of a GraphicsDevice, less its screen insets.
* See also java.awt.GraphicsEnvironment.getUsableBounds();
*/
public static Rectangle getUsableBounds(GraphicsDevice gd) {
GraphicsConfiguration gc = gd.getDefaultConfiguration();
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
Rectangle usableBounds = gc.getBounds();
usableBounds.x += insets.left;
usableBounds.y += insets.top;
usableBounds.width -= (insets.left + insets.right);
usableBounds.height -= (insets.top + insets.bottom);
return usableBounds;
}
/**
* Returns true when the display is local, false for remote displays.
*
* @return true when the display is local, false for remote displays
*/
public abstract boolean isDisplayLocal();
/*
* ----DISPLAY CHANGE SUPPORT----
*/
protected SunDisplayChanger displayChanger = new SunDisplayChanger();
/**
* Add a DisplayChangeListener to be notified when the display settings
* are changed.
*/
public void addDisplayChangedListener(DisplayChangedListener client) {
displayChanger.add(client);
}
/**
* Remove a DisplayChangeListener from Win32GraphicsEnvironment
*/
public void removeDisplayChangedListener(DisplayChangedListener client) {
displayChanger.remove(client);
}
/*
* ----END DISPLAY CHANGE SUPPORT----
*/
/**
* Returns true if FlipBufferStrategy with COPIED buffer contents
* is preferred for this peer's GraphicsConfiguration over
* BlitBufferStrategy, false otherwise.
*
* The reason FlipBS could be preferred is that in some configurations
* an accelerated copy to the screen is supported (like Direct3D 9)
*
* @return true if flip strategy should be used, false otherwise
*/
public boolean isFlipStrategyPreferred(ComponentPeer peer) {
return false;
}
}

View File

@@ -0,0 +1,32 @@
/*
Copyright (C) 2011 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.java2d;
public class SurfaceData {
public boolean isSurfaceLost() {
return false;
}
}

View File

@@ -0,0 +1,185 @@
/*
Copyright (C) 2009 Jeroen Frijters
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.java2d.cmm.lcms;
import gnu.java.awt.color.TagEntry;
import java.awt.color.CMMException;
import java.awt.color.ColorSpace;
import java.awt.color.ICC_Profile;
import java.awt.color.ICC_ProfileGray;
import java.awt.color.ICC_ProfileRGB;
import java.awt.image.BufferedImage;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Hashtable;
import sun.java2d.cmm.ColorTransform;
import sun.java2d.cmm.PCMM;
// dummy color management implementation
public class LCMS implements PCMM {
private static final int HEADER_SIZE = 128;
private final ArrayList<ProfileData> profiles = new ArrayList<ProfileData>();
public synchronized long loadProfile( byte[] data ) {
int free = profiles.indexOf( null );
if( free != -1 ) {
profiles.set( free, new ProfileData( data.clone()) );
return free;
} else {
long id = profiles.size();
profiles.add( new ProfileData( data.clone()) );
return id;
}
}
public synchronized void freeProfile( long profileID ) {
profiles.set( (int)profileID, null );
}
public synchronized int getProfileSize( long profileID ) {
return profiles.get( (int)profileID ).data.length;
}
public synchronized void getProfileData( long profileID, byte[] data ) {
byte[] src = profiles.get( (int)profileID ).data;
System.arraycopy( src, 0, data, 0, src.length );
}
public void getTagData( long profileID, int tagSignature, byte[] data ) {
ProfileData profile = profiles.get( (int)profileID );
if( tagSignature == ICC_Profile.icSigHead ) {
byte[] src = profile.data;
System.arraycopy( src, 0, data, 0, HEADER_SIZE );
} else {
TagEntry entry = profile.tags.get( tagSignature );
if( entry == null ){
throw new CMMException( "tag does not exist: " + tagSignature );
}
byte[] src = entry.getData();
System.arraycopy( src, 0, data, 0, src.length );
}
}
public int getTagSize( long profileID, int tagSignature ) {
if( tagSignature == ICC_Profile.icSigHead ) {
return HEADER_SIZE;
}
ProfileData profile = profiles.get( (int)profileID );
TagEntry entry = profile.tags.get( tagSignature );
if( entry == null ){
throw new CMMException( "tag does not exist: " + tagSignature );
}
return entry.getData().length;
}
public void setTagData(long profileID, int tagSignature, byte[] data)
{
throw new CMMException("Not implemented");
}
public ColorTransform createTransform(ICC_Profile profile, int renderType, int transformType)
{
return new DummyColorTransform();
}
public ColorTransform createTransform(ColorTransform[] transforms)
{
return new DummyColorTransform();
}
private static class ProfileData{
private final byte[] data;
private final Hashtable<Integer, TagEntry> tags;
private ProfileData(byte[] data){
this.data = data;
this.tags = createTagTable( data );
}
private static Hashtable<Integer, TagEntry> createTagTable( byte[] data ) throws IllegalArgumentException {
ByteBuffer buf = ByteBuffer.wrap( data );
int nTags = buf.getInt( HEADER_SIZE );
Hashtable<Integer, TagEntry> tagTable = new Hashtable<Integer, TagEntry>();
for( int i = 0; i < nTags; i++ ) {
int sig = buf.getInt( HEADER_SIZE + i * TagEntry.entrySize + 4 );
int offset = buf.getInt( HEADER_SIZE + i * TagEntry.entrySize + 8 );
int size = buf.getInt( HEADER_SIZE + i * TagEntry.entrySize + 12 );
TagEntry te = new TagEntry( sig, offset, size, data );
if( tagTable.put( sig, te ) != null )
throw new IllegalArgumentException( "Duplicate tag in profile:" + te );
}
return tagTable;
}
}
static class DummyColorTransform implements ColorTransform
{
public int getNumInComponents()
{
throw new CMMException("Not implemented");
}
public int getNumOutComponents()
{
throw new CMMException("Not implemented");
}
public void colorConvert(BufferedImage src, BufferedImage dst)
{
throw new CMMException("Not implemented");
}
public void colorConvert(Raster src, WritableRaster dst, float[] srcMinVal, float[] srcMaxVal, float[] dstMinVal, float[]dstMaxVal)
{
throw new CMMException("Not implemented");
}
public void colorConvert(Raster src, WritableRaster dst)
{
throw new CMMException("Not implemented");
}
public short[] colorConvert(short[] src, short[] dest)
{
throw new CMMException("Not implemented");
}
public byte[] colorConvert(byte[] src, byte[] dest)
{
throw new CMMException("Not implemented");
}
}
}

View File

@@ -0,0 +1,82 @@
/*
Copyright (C) 2009 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.java2d.pipe;
import java.awt.geom.PathIterator;
import ikvm.internal.NotYetImplementedError;
/**
* Replacement for compiling only
*/
public class ShapeSpanIterator implements SpanIterator{
public ShapeSpanIterator(boolean normalize){
throw new NotYetImplementedError();
}
public void setOutputArea(Region devBounds){
// TODO Auto-generated method stub
}
public void appendPath(PathIterator pathIterator){
// TODO Auto-generated method stub
}
public void getPathBox(int[] box){
// TODO Auto-generated method stub
}
@Override
public long getNativeIterator(){
// TODO Auto-generated method stub
return 0;
}
@Override
public void intersectClipBox(int lox, int loy, int hix, int hiy){
// TODO Auto-generated method stub
}
@Override
public boolean nextSpan(int[] spanbox){
// TODO Auto-generated method stub
return false;
}
@Override
public void skipDownTo(int y){
// TODO Auto-generated method stub
}
public void dispose(){
// TODO Auto-generated method stub
}
}