Merge
This commit is contained in:
commit
791e25aabf
@ -407,6 +407,7 @@ SUNWprivate_1.1 {
|
||||
Java_sun_java2d_x11_X11SurfaceData_initSurface;
|
||||
Java_sun_java2d_x11_X11SurfaceData_isDrawableValid;
|
||||
Java_sun_java2d_x11_X11SurfaceData_isDgaAvailable;
|
||||
Java_sun_java2d_x11_X11SurfaceData_isShmPMAvailable;
|
||||
Java_sun_java2d_x11_X11SurfaceData_setInvalid;
|
||||
Java_sun_java2d_x11_X11SurfaceData_flushNativeSurface;
|
||||
Java_sun_java2d_x11_X11SurfaceData_XCreateGC;
|
||||
|
@ -337,6 +337,7 @@ SUNWprivate_1.1 {
|
||||
Java_sun_java2d_x11_X11SurfaceData_initIDs;
|
||||
Java_sun_java2d_x11_X11SurfaceData_isDrawableValid;
|
||||
Java_sun_java2d_x11_X11SurfaceData_isDgaAvailable;
|
||||
Java_sun_java2d_x11_X11SurfaceData_isShmPMAvailable;
|
||||
Java_sun_java2d_x11_X11SurfaceData_initOps;
|
||||
Java_sun_java2d_x11_X11SurfaceData_initSurface;
|
||||
Java_sun_java2d_x11_X11SurfaceData_flushNativeSurface;
|
||||
|
@ -44,7 +44,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.zip.Inflater;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
import javax.imageio.IIOException;
|
||||
@ -57,6 +56,7 @@ import javax.imageio.stream.ImageInputStream;
|
||||
import com.sun.imageio.plugins.common.InputStreamAdapter;
|
||||
import com.sun.imageio.plugins.common.ReaderUtil;
|
||||
import com.sun.imageio.plugins.common.SubImageInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import sun.awt.image.ByteInterleavedRaster;
|
||||
|
||||
class PNGImageDataEnumeration implements Enumeration {
|
||||
@ -207,6 +207,15 @@ public class PNGImageReader extends ImageReader {
|
||||
resetStreamSettings();
|
||||
}
|
||||
|
||||
private String readNullTerminatedString(String charset) throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
int b;
|
||||
while ((b = stream.read()) != 0) {
|
||||
baos.write(b);
|
||||
}
|
||||
return new String(baos.toByteArray(), charset);
|
||||
}
|
||||
|
||||
private String readNullTerminatedString() throws IOException {
|
||||
StringBuilder b = new StringBuilder();
|
||||
int c;
|
||||
@ -445,26 +454,27 @@ public class PNGImageReader extends ImageReader {
|
||||
metadata.iTXt_keyword.add(keyword);
|
||||
|
||||
int compressionFlag = stream.readUnsignedByte();
|
||||
metadata.iTXt_compressionFlag.add(new Integer(compressionFlag));
|
||||
metadata.iTXt_compressionFlag.add(Boolean.valueOf(compressionFlag == 1));
|
||||
|
||||
int compressionMethod = stream.readUnsignedByte();
|
||||
metadata.iTXt_compressionMethod.add(new Integer(compressionMethod));
|
||||
metadata.iTXt_compressionMethod.add(Integer.valueOf(compressionMethod));
|
||||
|
||||
String languageTag = readNullTerminatedString();
|
||||
String languageTag = readNullTerminatedString("UTF8");
|
||||
metadata.iTXt_languageTag.add(languageTag);
|
||||
|
||||
String translatedKeyword = stream.readUTF();
|
||||
String translatedKeyword =
|
||||
readNullTerminatedString("UTF8");
|
||||
metadata.iTXt_translatedKeyword.add(translatedKeyword);
|
||||
stream.skipBytes(1); // Null separator
|
||||
|
||||
String text;
|
||||
long pos = stream.getStreamPosition();
|
||||
byte[] b = new byte[(int)(chunkStart + chunkLength - pos)];
|
||||
stream.readFully(b);
|
||||
|
||||
if (compressionFlag == 1) { // Decompress the text
|
||||
long pos = stream.getStreamPosition();
|
||||
byte[] b = new byte[(int)(chunkStart + chunkLength - pos)];
|
||||
stream.readFully(b);
|
||||
text = inflate(b);
|
||||
text = new String(inflate(b), "UTF8");
|
||||
} else {
|
||||
text = stream.readUTF();
|
||||
text = new String(b, "UTF8");
|
||||
}
|
||||
metadata.iTXt_text.add(text);
|
||||
}
|
||||
@ -613,15 +623,20 @@ public class PNGImageReader extends ImageReader {
|
||||
metadata.tRNS_present = true;
|
||||
}
|
||||
|
||||
private static String inflate(byte[] b) throws IOException {
|
||||
private static byte[] inflate(byte[] b) throws IOException {
|
||||
InputStream bais = new ByteArrayInputStream(b);
|
||||
InputStream iis = new InflaterInputStream(bais);
|
||||
StringBuilder sb = new StringBuilder(80);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
int c;
|
||||
while ((c = iis.read()) != -1) {
|
||||
sb.append((char)c);
|
||||
try {
|
||||
while ((c = iis.read()) != -1) {
|
||||
baos.write(c);
|
||||
}
|
||||
} finally {
|
||||
iis.close();
|
||||
}
|
||||
return sb.toString();
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
private void parse_zTXt_chunk(int chunkLength) throws IOException {
|
||||
@ -633,7 +648,7 @@ public class PNGImageReader extends ImageReader {
|
||||
|
||||
byte[] b = new byte[chunkLength - keyword.length() - 2];
|
||||
stream.readFully(b);
|
||||
metadata.zTXt_text.add(inflate(b));
|
||||
metadata.zTXt_text.add(new String(inflate(b)));
|
||||
}
|
||||
|
||||
private void readMetadata() throws IIOException {
|
||||
@ -1244,13 +1259,26 @@ public class PNGImageReader extends ImageReader {
|
||||
destinationBands = param.getDestinationBands();
|
||||
destinationOffset = param.getDestinationOffset();
|
||||
}
|
||||
|
||||
Inflater inf = null;
|
||||
try {
|
||||
stream.seek(imageStartPosition);
|
||||
|
||||
Enumeration e = new PNGImageDataEnumeration(stream);
|
||||
InputStream is = new SequenceInputStream(e);
|
||||
is = new InflaterInputStream(is, new Inflater());
|
||||
|
||||
/* InflaterInputStream uses an Inflater instance which consumes
|
||||
* native (non-GC visible) resources. This is normally implicitly
|
||||
* freed when the stream is closed. However since the
|
||||
* InflaterInputStream wraps a client-supplied input stream,
|
||||
* we cannot close it.
|
||||
* But the app may depend on GC finalization to close the stream.
|
||||
* Therefore to ensure timely freeing of native resources we
|
||||
* explicitly create the Inflater instance and free its resources
|
||||
* when we are done with the InflaterInputStream by calling
|
||||
* inf.end();
|
||||
*/
|
||||
inf = new Inflater();
|
||||
is = new InflaterInputStream(is, inf);
|
||||
is = new BufferedInputStream(is);
|
||||
this.pixelStream = new DataInputStream(is);
|
||||
|
||||
@ -1283,6 +1311,10 @@ public class PNGImageReader extends ImageReader {
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new IIOException("Error reading PNG image data", e);
|
||||
} finally {
|
||||
if (inf != null) {
|
||||
inf.end();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,13 +244,17 @@ final class IDATOutputStream extends ImageOutputStreamImpl {
|
||||
}
|
||||
|
||||
public void finish() throws IOException {
|
||||
if (!def.finished()) {
|
||||
def.finish();
|
||||
while (!def.finished()) {
|
||||
deflate();
|
||||
try {
|
||||
if (!def.finished()) {
|
||||
def.finish();
|
||||
while (!def.finished()) {
|
||||
deflate();
|
||||
}
|
||||
}
|
||||
finishChunk();
|
||||
} finally {
|
||||
def.end();
|
||||
}
|
||||
finishChunk();
|
||||
}
|
||||
|
||||
protected void finalize() throws Throwable {
|
||||
@ -667,13 +671,13 @@ public class PNGImageWriter extends ImageWriter {
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] deflate(String s) throws IOException {
|
||||
private byte[] deflate(byte[] b) throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
DeflaterOutputStream dos = new DeflaterOutputStream(baos);
|
||||
|
||||
int len = s.length();
|
||||
int len = b.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
dos.write((int)s.charAt(i));
|
||||
dos.write((int)(0xff & b[i]));
|
||||
}
|
||||
dos.close();
|
||||
|
||||
@ -681,38 +685,37 @@ public class PNGImageWriter extends ImageWriter {
|
||||
}
|
||||
|
||||
private void write_iTXt() throws IOException {
|
||||
Iterator keywordIter = metadata.iTXt_keyword.iterator();
|
||||
Iterator flagIter = metadata.iTXt_compressionFlag.iterator();
|
||||
Iterator methodIter = metadata.iTXt_compressionMethod.iterator();
|
||||
Iterator languageIter = metadata.iTXt_languageTag.iterator();
|
||||
Iterator translatedKeywordIter =
|
||||
Iterator<String> keywordIter = metadata.iTXt_keyword.iterator();
|
||||
Iterator<Boolean> flagIter = metadata.iTXt_compressionFlag.iterator();
|
||||
Iterator<Integer> methodIter = metadata.iTXt_compressionMethod.iterator();
|
||||
Iterator<String> languageIter = metadata.iTXt_languageTag.iterator();
|
||||
Iterator<String> translatedKeywordIter =
|
||||
metadata.iTXt_translatedKeyword.iterator();
|
||||
Iterator textIter = metadata.iTXt_text.iterator();
|
||||
Iterator<String> textIter = metadata.iTXt_text.iterator();
|
||||
|
||||
while (keywordIter.hasNext()) {
|
||||
ChunkStream cs = new ChunkStream(PNGImageReader.iTXt_TYPE, stream);
|
||||
String keyword = (String)keywordIter.next();
|
||||
cs.writeBytes(keyword);
|
||||
|
||||
cs.writeBytes(keywordIter.next());
|
||||
cs.writeByte(0);
|
||||
|
||||
int flag = ((Integer)flagIter.next()).intValue();
|
||||
cs.writeByte(flag);
|
||||
int method = ((Integer)methodIter.next()).intValue();
|
||||
cs.writeByte(method);
|
||||
Boolean compressed = flagIter.next();
|
||||
cs.writeByte(compressed ? 1 : 0);
|
||||
|
||||
String languageTag = (String)languageIter.next();
|
||||
cs.writeBytes(languageTag);
|
||||
cs.writeByte(methodIter.next().intValue());
|
||||
|
||||
cs.writeBytes(languageIter.next());
|
||||
cs.writeByte(0);
|
||||
|
||||
String translatedKeyword = (String)translatedKeywordIter.next();
|
||||
cs.writeBytes(translatedKeyword);
|
||||
|
||||
cs.write(translatedKeywordIter.next().getBytes("UTF8"));
|
||||
cs.writeByte(0);
|
||||
|
||||
String text = (String)textIter.next();
|
||||
if (flag == 1) {
|
||||
cs.write(deflate(text));
|
||||
String text = textIter.next();
|
||||
if (compressed) {
|
||||
cs.write(deflate(text.getBytes("UTF8")));
|
||||
} else {
|
||||
cs.writeUTF(text);
|
||||
cs.write(text.getBytes("UTF8"));
|
||||
}
|
||||
cs.finish();
|
||||
}
|
||||
@ -733,7 +736,7 @@ public class PNGImageWriter extends ImageWriter {
|
||||
cs.writeByte(compressionMethod);
|
||||
|
||||
String text = (String)textIter.next();
|
||||
cs.write(deflate(text));
|
||||
cs.write(deflate(text.getBytes()));
|
||||
cs.finish();
|
||||
}
|
||||
}
|
||||
@ -928,23 +931,24 @@ public class PNGImageWriter extends ImageWriter {
|
||||
// Use sourceXOffset, etc.
|
||||
private void write_IDAT(RenderedImage image) throws IOException {
|
||||
IDATOutputStream ios = new IDATOutputStream(stream, 32768);
|
||||
|
||||
if (metadata.IHDR_interlaceMethod == 1) {
|
||||
for (int i = 0; i < 7; i++) {
|
||||
encodePass(ios, image,
|
||||
PNGImageReader.adam7XOffset[i],
|
||||
PNGImageReader.adam7YOffset[i],
|
||||
PNGImageReader.adam7XSubsampling[i],
|
||||
PNGImageReader.adam7YSubsampling[i]);
|
||||
if (abortRequested()) {
|
||||
break;
|
||||
try {
|
||||
if (metadata.IHDR_interlaceMethod == 1) {
|
||||
for (int i = 0; i < 7; i++) {
|
||||
encodePass(ios, image,
|
||||
PNGImageReader.adam7XOffset[i],
|
||||
PNGImageReader.adam7YOffset[i],
|
||||
PNGImageReader.adam7XSubsampling[i],
|
||||
PNGImageReader.adam7YSubsampling[i]);
|
||||
if (abortRequested()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
encodePass(ios, image, 0, 0, 1, 1);
|
||||
}
|
||||
} else {
|
||||
encodePass(ios, image, 0, 0, 1, 1);
|
||||
} finally {
|
||||
ios.finish();
|
||||
}
|
||||
|
||||
ios.finish();
|
||||
}
|
||||
|
||||
private void writeIEND() throws IOException {
|
||||
|
@ -174,12 +174,12 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
|
||||
public byte[] iCCP_compressedProfile;
|
||||
|
||||
// iTXt chunk
|
||||
public ArrayList iTXt_keyword = new ArrayList(); // Strings
|
||||
public ArrayList iTXt_compressionFlag = new ArrayList(); // Integers
|
||||
public ArrayList iTXt_compressionMethod = new ArrayList(); // Integers
|
||||
public ArrayList iTXt_languageTag = new ArrayList(); // Strings
|
||||
public ArrayList iTXt_translatedKeyword = new ArrayList(); // Strings
|
||||
public ArrayList iTXt_text = new ArrayList(); // Strings
|
||||
public ArrayList<String> iTXt_keyword = new ArrayList<String>();
|
||||
public ArrayList<Boolean> iTXt_compressionFlag = new ArrayList<Boolean>();
|
||||
public ArrayList<Integer> iTXt_compressionMethod = new ArrayList<Integer>();
|
||||
public ArrayList<String> iTXt_languageTag = new ArrayList<String>();
|
||||
public ArrayList<String> iTXt_translatedKeyword = new ArrayList<String>();
|
||||
public ArrayList<String> iTXt_text = new ArrayList<String>();
|
||||
|
||||
// pHYs chunk
|
||||
public boolean pHYs_present;
|
||||
@ -597,19 +597,17 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
|
||||
if (iTXt_keyword.size() > 0) {
|
||||
IIOMetadataNode iTXt_parent = new IIOMetadataNode("iTXt");
|
||||
for (int i = 0; i < iTXt_keyword.size(); i++) {
|
||||
Integer val;
|
||||
|
||||
IIOMetadataNode iTXt_node = new IIOMetadataNode("iTXtEntry");
|
||||
iTXt_node.setAttribute("keyword", (String)iTXt_keyword.get(i));
|
||||
val = (Integer)iTXt_compressionFlag.get(i);
|
||||
iTXt_node.setAttribute("compressionFlag", val.toString());
|
||||
val = (Integer)iTXt_compressionMethod.get(i);
|
||||
iTXt_node.setAttribute("compressionMethod", val.toString());
|
||||
iTXt_node.setAttribute("keyword", iTXt_keyword.get(i));
|
||||
iTXt_node.setAttribute("compressionFlag",
|
||||
iTXt_compressionFlag.get(i) ? "1" : "0");
|
||||
iTXt_node.setAttribute("compressionMethod",
|
||||
iTXt_compressionMethod.get(i).toString());
|
||||
iTXt_node.setAttribute("languageTag",
|
||||
(String)iTXt_languageTag.get(i));
|
||||
iTXt_languageTag.get(i));
|
||||
iTXt_node.setAttribute("translatedKeyword",
|
||||
(String)iTXt_translatedKeyword.get(i));
|
||||
iTXt_node.setAttribute("text", (String)iTXt_text.get(i));
|
||||
iTXt_translatedKeyword.get(i));
|
||||
iTXt_node.setAttribute("text", iTXt_text.get(i));
|
||||
|
||||
iTXt_parent.appendChild(iTXt_node);
|
||||
}
|
||||
@ -1037,11 +1035,11 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
|
||||
|
||||
for (int i = 0; i < iTXt_keyword.size(); i++) {
|
||||
node = new IIOMetadataNode("TextEntry");
|
||||
node.setAttribute("keyword", (String)iTXt_keyword.get(i));
|
||||
node.setAttribute("value", (String)iTXt_text.get(i));
|
||||
node.setAttribute("keyword", iTXt_keyword.get(i));
|
||||
node.setAttribute("value", iTXt_text.get(i));
|
||||
node.setAttribute("language",
|
||||
(String)iTXt_languageTag.get(i));
|
||||
if (((Integer)iTXt_compressionFlag.get(i)).intValue() == 1) {
|
||||
iTXt_languageTag.get(i));
|
||||
if (iTXt_compressionFlag.get(i)) {
|
||||
node.setAttribute("compression", "deflate");
|
||||
} else {
|
||||
node.setAttribute("compression", "none");
|
||||
@ -1427,11 +1425,11 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
|
||||
|
||||
boolean compressionFlag =
|
||||
getBooleanAttribute(iTXt_node, "compressionFlag");
|
||||
iTXt_compressionFlag.add(new Boolean(compressionFlag));
|
||||
iTXt_compressionFlag.add(Boolean.valueOf(compressionFlag));
|
||||
|
||||
String compressionMethod =
|
||||
getAttribute(iTXt_node, "compressionMethod");
|
||||
iTXt_compressionMethod.add(compressionMethod);
|
||||
iTXt_compressionMethod.add(Integer.valueOf(compressionMethod));
|
||||
|
||||
String languageTag =
|
||||
getAttribute(iTXt_node, "languageTag");
|
||||
@ -1950,13 +1948,10 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
|
||||
tEXt_text.add(value);
|
||||
}
|
||||
} else {
|
||||
int flag = compression.equals("zip") ?
|
||||
1 : 0;
|
||||
|
||||
// Use an iTXt node
|
||||
iTXt_keyword.add(keyword);
|
||||
iTXt_compressionFlag.add(new Integer(flag));
|
||||
iTXt_compressionMethod.add(new Integer(0));
|
||||
iTXt_compressionFlag.add(Boolean.valueOf(compression.equals("zip")));
|
||||
iTXt_compressionMethod.add(Integer.valueOf(0));
|
||||
iTXt_languageTag.add(language);
|
||||
iTXt_translatedKeyword.add(keyword); // fake it
|
||||
iTXt_text.add(value);
|
||||
@ -1993,12 +1988,12 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
|
||||
gAMA_present = false;
|
||||
hIST_present = false;
|
||||
iCCP_present = false;
|
||||
iTXt_keyword = new ArrayList();
|
||||
iTXt_compressionFlag = new ArrayList();
|
||||
iTXt_compressionMethod = new ArrayList();
|
||||
iTXt_languageTag = new ArrayList();
|
||||
iTXt_translatedKeyword = new ArrayList();
|
||||
iTXt_text = new ArrayList();
|
||||
iTXt_keyword = new ArrayList<String>();
|
||||
iTXt_compressionFlag = new ArrayList<Boolean>();
|
||||
iTXt_compressionMethod = new ArrayList<Integer>();
|
||||
iTXt_languageTag = new ArrayList<String>();
|
||||
iTXt_translatedKeyword = new ArrayList<String>();
|
||||
iTXt_text = new ArrayList<String>();
|
||||
pHYs_present = false;
|
||||
sBIT_present = false;
|
||||
sPLT_present = false;
|
||||
|
@ -117,15 +117,18 @@ public abstract class PrinterJob {
|
||||
* FileOutputStream outstream;
|
||||
* StreamPrintService psPrinter;
|
||||
* String psMimeType = "application/postscript";
|
||||
* PrinterJob pj = PrinterJob.getPrinterJob();
|
||||
*
|
||||
* StreamPrintServiceFactory[] factories =
|
||||
* PrinterJob.lookupStreamPrintServices(psMimeType);
|
||||
* if (factories.length > 0) {
|
||||
* try {
|
||||
* outstream = new File("out.ps");
|
||||
* psPrinter = factories[0].getPrintService(fos);
|
||||
* psPrinter = factories[0].getPrintService(outstream);
|
||||
* // psPrinter can now be set as the service on a PrinterJob
|
||||
* } catch (FileNotFoundException e) {
|
||||
* pj.setPrintService(psPrinter)
|
||||
* } catch (Exception e) {
|
||||
* e.printStackTrace();
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
|
@ -28,9 +28,7 @@ package javax.print;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import javax.print.attribute.AttributeSet;
|
||||
import javax.print.attribute.DocAttributeSet;
|
||||
|
||||
|
||||
|
@ -30,7 +30,6 @@ import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Class <code>DocFlavor</code> encapsulates an object that specifies the
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
package javax.print;
|
||||
|
||||
import javax.print.attribute.AttributeSet;
|
||||
import javax.print.attribute.PrintJobAttributeSet;
|
||||
import javax.print.attribute.PrintRequestAttributeSet;
|
||||
import javax.print.event.PrintJobAttributeListener;
|
||||
|
@ -25,11 +25,6 @@
|
||||
|
||||
package javax.print;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.event.PrintServiceAttributeListener;
|
||||
|
||||
|
||||
/** Interface MultiPrintService is the factory for a MultiDocPrintJob.
|
||||
* A MultiPrintService
|
||||
|
@ -28,7 +28,6 @@ package javax.print;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import javax.print.attribute.AttributeSet;
|
||||
|
||||
import sun.awt.AppContext;
|
||||
|
@ -28,7 +28,6 @@ package javax.print.attribute;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
/**
|
||||
* Class URISyntax is an abstract base class providing the common
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
package javax.print.event;
|
||||
|
||||
import java.util.List;
|
||||
import javax.print.PrintService;
|
||||
import javax.print.attribute.AttributeSetUtilities;
|
||||
import javax.print.attribute.PrintServiceAttributeSet;
|
||||
|
@ -267,7 +267,9 @@ public class Decoration {
|
||||
CoreMetrics cm = label.getCoreMetrics();
|
||||
if (strikethrough) {
|
||||
Stroke savedStroke = g2d.getStroke();
|
||||
g2d.setStroke(new BasicStroke(cm.strikethroughThickness));
|
||||
g2d.setStroke(new BasicStroke(cm.strikethroughThickness,
|
||||
BasicStroke.CAP_BUTT,
|
||||
BasicStroke.JOIN_MITER));
|
||||
float strikeY = y + cm.strikethroughOffset;
|
||||
g2d.draw(new Line2D.Float(x1, strikeY, x2, strikeY));
|
||||
g2d.setStroke(savedStroke);
|
||||
@ -341,7 +343,7 @@ public class Decoration {
|
||||
|
||||
Rectangle2D visBounds = label.handleGetVisualBounds();
|
||||
|
||||
if (swapColors || bgPaint != null
|
||||
if (swapColors || bgPaint != null || strikethrough
|
||||
|| stdUnderline != null || imUnderline != null) {
|
||||
|
||||
float minX = 0;
|
||||
@ -377,6 +379,7 @@ public class Decoration {
|
||||
// NOTE: The performace of the following code may
|
||||
// be very poor.
|
||||
float ulThickness = cm.underlineThickness;
|
||||
float ulOffset = cm.underlineOffset;
|
||||
|
||||
Rectangle2D lb = label.getLogicalBounds();
|
||||
float x1 = x;
|
||||
@ -385,12 +388,15 @@ public class Decoration {
|
||||
Area area = null;
|
||||
|
||||
if (stdUnderline != null) {
|
||||
Shape ul = stdUnderline.getUnderlineShape(ulThickness, x1, x2, y);
|
||||
Shape ul = stdUnderline.getUnderlineShape(ulThickness,
|
||||
x1, x2, y+ulOffset);
|
||||
area = new Area(ul);
|
||||
}
|
||||
|
||||
if (strikethrough) {
|
||||
Stroke stStroke = new BasicStroke(cm.strikethroughThickness);
|
||||
Stroke stStroke = new BasicStroke(cm.strikethroughThickness,
|
||||
BasicStroke.CAP_BUTT,
|
||||
BasicStroke.JOIN_MITER);
|
||||
float shiftY = y + cm.strikethroughOffset;
|
||||
Line2D line = new Line2D.Float(x1, shiftY, x2, shiftY);
|
||||
Area slArea = new Area(stStroke.createStrokedShape(line));
|
||||
@ -402,7 +408,8 @@ public class Decoration {
|
||||
}
|
||||
|
||||
if (imUnderline != null) {
|
||||
Shape ul = imUnderline.getUnderlineShape(ulThickness, x1, x2, y);
|
||||
Shape ul = imUnderline.getUnderlineShape(ulThickness,
|
||||
x1, x2, y+ulOffset);
|
||||
Area ulArea = new Area(ul);
|
||||
if (area == null) {
|
||||
area = ulArea;
|
||||
|
@ -3344,7 +3344,7 @@ public final class FontManager {
|
||||
int fontFormat = FONTFORMAT_NONE;
|
||||
int fontRank = Font2D.UNKNOWN_RANK;
|
||||
|
||||
if (ext.equals(".ttf") || isTTC) {
|
||||
if (ext.equals(".ttf") || ext.equals(".otf") || isTTC) {
|
||||
fontFormat = FONTFORMAT_TRUETYPE;
|
||||
fontRank = Font2D.TTF_RANK;
|
||||
} else if (ext.equals(".pfa") || ext.equals(".pfb")) {
|
||||
|
@ -90,6 +90,7 @@ public class TrueTypeFont extends FileFont {
|
||||
public static final int ttcfTag = 0x74746366; // 'ttcf' - TTC file
|
||||
public static final int v1ttTag = 0x00010000; // 'v1tt' - Version 1 TT font
|
||||
public static final int trueTag = 0x74727565; // 'true' - Version 2 TT font
|
||||
public static final int ottoTag = 0x4f54544f; // 'otto' - OpenType font
|
||||
|
||||
/* -- ID's used in the 'name' table */
|
||||
public static final int MS_PLATFORM_ID = 3;
|
||||
@ -490,6 +491,7 @@ public class TrueTypeFont extends FileFont {
|
||||
|
||||
case v1ttTag:
|
||||
case trueTag:
|
||||
case ottoTag:
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -126,7 +126,9 @@ abstract class Underline {
|
||||
private BasicStroke createStroke(float lineThickness) {
|
||||
|
||||
if (dashPattern == null) {
|
||||
return new BasicStroke(lineThickness);
|
||||
return new BasicStroke(lineThickness,
|
||||
BasicStroke.CAP_BUTT,
|
||||
BasicStroke.JOIN_MITER);
|
||||
}
|
||||
else {
|
||||
return new BasicStroke(lineThickness,
|
||||
|
@ -812,7 +812,9 @@ public abstract class SunGraphicsEnvironment extends GraphicsEnvironment
|
||||
return(name.startsWith(".ttf", offset) ||
|
||||
name.startsWith(".TTF", offset) ||
|
||||
name.startsWith(".ttc", offset) ||
|
||||
name.startsWith(".TTC", offset));
|
||||
name.startsWith(".TTC", offset) ||
|
||||
name.startsWith(".otf", offset) ||
|
||||
name.startsWith(".OTF", offset));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -835,31 +837,11 @@ public abstract class SunGraphicsEnvironment extends GraphicsEnvironment
|
||||
}
|
||||
}
|
||||
|
||||
public static class TTorT1Filter implements FilenameFilter {
|
||||
public boolean accept(File dir, String name) {
|
||||
|
||||
/* all conveniently have the same suffix length */
|
||||
int offset = name.length()-4;
|
||||
if (offset <= 0) { /* must be at least A.ttf or A.pfa */
|
||||
return false;
|
||||
} else {
|
||||
boolean isTT =
|
||||
name.startsWith(".ttf", offset) ||
|
||||
name.startsWith(".TTF", offset) ||
|
||||
name.startsWith(".ttc", offset) ||
|
||||
name.startsWith(".TTC", offset);
|
||||
if (isTT) {
|
||||
return true;
|
||||
} else if (noType1Font) {
|
||||
return false;
|
||||
} else {
|
||||
return(name.startsWith(".pfa", offset) ||
|
||||
name.startsWith(".pfb", offset) ||
|
||||
name.startsWith(".PFA", offset) ||
|
||||
name.startsWith(".PFB", offset));
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class TTorT1Filter implements FilenameFilter {
|
||||
public boolean accept(File dir, String name) {
|
||||
return SunGraphicsEnvironment.ttFilter.accept(dir, name) ||
|
||||
SunGraphicsEnvironment.t1Filter.accept(dir, name);
|
||||
}
|
||||
}
|
||||
|
||||
/* No need to keep consing up new instances - reuse a singleton.
|
||||
@ -1290,6 +1272,13 @@ public abstract class SunGraphicsEnvironment extends GraphicsEnvironment
|
||||
displayChanger.notifyPaletteChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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----
|
||||
*/
|
||||
|
@ -449,7 +449,8 @@ public abstract class SurfaceData
|
||||
// For now the answer can only be true in the following cases:
|
||||
if (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY &&
|
||||
sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR &&
|
||||
sg2d.clipState <= SunGraphics2D.CLIP_RECTANGULAR)
|
||||
sg2d.clipState <= SunGraphics2D.CLIP_RECTANGULAR &&
|
||||
sg2d.surfaceData.getTransparency() == Transparency.OPAQUE)
|
||||
{
|
||||
if (haveLCDLoop == LCDLOOP_UNKNOWN) {
|
||||
DrawGlyphListLCD loop =
|
||||
|
@ -25,17 +25,13 @@
|
||||
|
||||
package sun.java2d.opengl;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Transparency;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.AffineTransformOp;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.BufferedImageOp;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.lang.ref.WeakReference;
|
||||
import sun.awt.image.BufImgSurfaceData;
|
||||
import sun.java2d.SurfaceData;
|
||||
import sun.java2d.loops.Blit;
|
||||
import sun.java2d.loops.CompositeType;
|
||||
@ -84,6 +80,8 @@ class OGLBlitLoops {
|
||||
OGLSurfaceData.PF_INT_BGR),
|
||||
new OGLSwToSurfaceBlit(SurfaceType.IntBgrx,
|
||||
OGLSurfaceData.PF_INT_BGRX),
|
||||
new OGLSwToSurfaceBlit(SurfaceType.ThreeByteBgr,
|
||||
OGLSurfaceData.PF_3BYTE_BGR),
|
||||
new OGLSwToSurfaceBlit(SurfaceType.Ushort565Rgb,
|
||||
OGLSurfaceData.PF_USHORT_565_RGB),
|
||||
new OGLSwToSurfaceBlit(SurfaceType.Ushort555Rgb,
|
||||
@ -106,6 +104,8 @@ class OGLBlitLoops {
|
||||
OGLSurfaceData.PF_INT_BGR),
|
||||
new OGLSwToSurfaceScale(SurfaceType.IntBgrx,
|
||||
OGLSurfaceData.PF_INT_BGRX),
|
||||
new OGLSwToSurfaceScale(SurfaceType.ThreeByteBgr,
|
||||
OGLSurfaceData.PF_3BYTE_BGR),
|
||||
new OGLSwToSurfaceScale(SurfaceType.Ushort565Rgb,
|
||||
OGLSurfaceData.PF_USHORT_565_RGB),
|
||||
new OGLSwToSurfaceScale(SurfaceType.Ushort555Rgb,
|
||||
@ -127,6 +127,8 @@ class OGLBlitLoops {
|
||||
OGLSurfaceData.PF_INT_BGR),
|
||||
new OGLSwToSurfaceTransform(SurfaceType.IntBgrx,
|
||||
OGLSurfaceData.PF_INT_BGRX),
|
||||
new OGLSwToSurfaceTransform(SurfaceType.ThreeByteBgr,
|
||||
OGLSurfaceData.PF_3BYTE_BGR),
|
||||
new OGLSwToSurfaceTransform(SurfaceType.Ushort565Rgb,
|
||||
OGLSurfaceData.PF_USHORT_565_RGB),
|
||||
new OGLSwToSurfaceTransform(SurfaceType.Ushort555Rgb,
|
||||
@ -155,6 +157,8 @@ class OGLBlitLoops {
|
||||
OGLSurfaceData.PF_INT_BGR),
|
||||
new OGLSwToTextureBlit(SurfaceType.IntBgrx,
|
||||
OGLSurfaceData.PF_INT_BGRX),
|
||||
new OGLSwToTextureBlit(SurfaceType.ThreeByteBgr,
|
||||
OGLSurfaceData.PF_3BYTE_BGR),
|
||||
new OGLSwToTextureBlit(SurfaceType.Ushort565Rgb,
|
||||
OGLSurfaceData.PF_USHORT_565_RGB),
|
||||
new OGLSwToTextureBlit(SurfaceType.Ushort555Rgb,
|
||||
|
@ -120,6 +120,7 @@ public abstract class OGLSurfaceData extends SurfaceData
|
||||
public static final int PF_USHORT_555_RGBX = 8;
|
||||
public static final int PF_BYTE_GRAY = 9;
|
||||
public static final int PF_USHORT_GRAY = 10;
|
||||
public static final int PF_3BYTE_BGR = 11;
|
||||
|
||||
/**
|
||||
* SurfaceTypes
|
||||
@ -401,6 +402,7 @@ public abstract class OGLSurfaceData extends SurfaceData
|
||||
* - the fragment shader extension is available, and
|
||||
* - blending is disabled, and
|
||||
* - the source color is opaque
|
||||
* - and the destination is opaque
|
||||
*
|
||||
* Eventually, we could enhance the native OGL text rendering code
|
||||
* and remove the above restrictions, but that would require significantly
|
||||
@ -410,7 +412,8 @@ public abstract class OGLSurfaceData extends SurfaceData
|
||||
return
|
||||
graphicsConfig.isCapPresent(CAPS_EXT_LCD_SHADER) &&
|
||||
sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY &&
|
||||
sg2d.paintState <= SunGraphics2D.PAINT_OPAQUECOLOR;
|
||||
sg2d.paintState <= SunGraphics2D.PAINT_OPAQUECOLOR &&
|
||||
sg2d.surfaceData.getTransparency() == Transparency.OPAQUE;
|
||||
}
|
||||
|
||||
public void validatePipe(SunGraphics2D sg2d) {
|
||||
|
@ -90,7 +90,8 @@ public abstract class BufferedContext {
|
||||
private Region validatedClip;
|
||||
private Composite validatedComp;
|
||||
private Paint validatedPaint;
|
||||
private boolean isValidatedPaintAColor;
|
||||
// renamed from isValidatedPaintAColor as part of a work around for 6764257
|
||||
private boolean isValidatedPaintJustAColor;
|
||||
private int validatedRGB;
|
||||
private int validatedFlags;
|
||||
private boolean xformInUse;
|
||||
@ -182,7 +183,7 @@ public abstract class BufferedContext {
|
||||
if (paint instanceof Color) {
|
||||
// REMIND: not 30-bit friendly
|
||||
int newRGB = ((Color)paint).getRGB();
|
||||
if (isValidatedPaintAColor) {
|
||||
if (isValidatedPaintJustAColor) {
|
||||
if (newRGB != validatedRGB) {
|
||||
validatedRGB = newRGB;
|
||||
updatePaint = true;
|
||||
@ -190,13 +191,13 @@ public abstract class BufferedContext {
|
||||
} else {
|
||||
validatedRGB = newRGB;
|
||||
updatePaint = true;
|
||||
isValidatedPaintAColor = true;
|
||||
isValidatedPaintJustAColor = true;
|
||||
}
|
||||
} else if (validatedPaint != paint) {
|
||||
updatePaint = true;
|
||||
// this should be set when we are switching from paint to color
|
||||
// in which case this condition will be true
|
||||
isValidatedPaintAColor = false;
|
||||
isValidatedPaintJustAColor = false;
|
||||
}
|
||||
|
||||
if ((currentContext != this) ||
|
||||
@ -281,7 +282,7 @@ public abstract class BufferedContext {
|
||||
txChanged = true;
|
||||
}
|
||||
// non-Color paints may require paint revalidation
|
||||
if (!isValidatedPaintAColor && txChanged) {
|
||||
if (!isValidatedPaintJustAColor && txChanged) {
|
||||
updatePaint = true;
|
||||
}
|
||||
|
||||
@ -427,10 +428,12 @@ public abstract class BufferedContext {
|
||||
resetTransform();
|
||||
resetComposite();
|
||||
resetClip();
|
||||
BufferedPaints.resetPaint(rq);
|
||||
invalidateSurfaces();
|
||||
validatedComp = null;
|
||||
validatedClip = null;
|
||||
validatedPaint = null;
|
||||
isValidatedPaintJustAColor = false;
|
||||
xformInUse = false;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,6 @@ import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.Paint;
|
||||
import java.awt.Shape;
|
||||
import java.awt.Transparency;
|
||||
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
package sun.print;
|
||||
|
||||
import javax.print.DocFlavor;
|
||||
import javax.print.AttributeException;
|
||||
import javax.print.PrintException;
|
||||
import javax.print.attribute.Attribute;
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
package sun.print;
|
||||
|
||||
import javax.print.attribute.EnumSyntax;
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
|
||||
/*
|
||||
|
@ -26,7 +26,6 @@
|
||||
package sun.print;
|
||||
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
import javax.print.attribute.standard.Media;
|
||||
|
||||
/*
|
||||
* A class used to determine the range of pages to be printed.
|
||||
|
@ -55,6 +55,7 @@ import java.io.*;
|
||||
import java.util.*;
|
||||
import sun.font.FontDesignMetrics;
|
||||
import sun.font.FontManager;
|
||||
import sun.java2d.SunGraphicsEnvironment;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
@ -1478,22 +1479,14 @@ public class SwingUtilities2 {
|
||||
* appear capable of performing gamma correction needed for LCD text.
|
||||
*/
|
||||
public static boolean isLocalDisplay() {
|
||||
try {
|
||||
// On Windows just return true. Permission to read os.name
|
||||
// is granted to all code but wrapped in try to be safe.
|
||||
if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) {
|
||||
return true;
|
||||
}
|
||||
// Else probably Solaris or Linux in which case may be remote X11
|
||||
Class<?> x11Class = Class.forName("sun.awt.X11GraphicsEnvironment");
|
||||
Method isDisplayLocalMethod = x11Class.getMethod(
|
||||
"isDisplayLocal", new Class[0]);
|
||||
return (Boolean)isDisplayLocalMethod.invoke(null, (Object[])null);
|
||||
} catch (Throwable t) {
|
||||
boolean isLocal;
|
||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
if (ge instanceof SunGraphicsEnvironment) {
|
||||
isLocal = ((SunGraphicsEnvironment) ge).isDisplayLocal();
|
||||
} else {
|
||||
isLocal = true;
|
||||
}
|
||||
// If we get here we're most likely being run on some other O/S
|
||||
// or we didn't properly detect Windows.
|
||||
return true;
|
||||
return isLocal;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,6 +60,9 @@ import java.awt.image.VolatileImage;
|
||||
import java.awt.image.WritableRaster;
|
||||
import java.awt.Transparency;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.DataBufferByte;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.awt.image.DataBufferShort;
|
||||
import java.util.ArrayList;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
@ -84,6 +87,7 @@ public abstract class ImageTests extends GraphicsTests {
|
||||
static Group.EnableSet bufimgsrcroot;
|
||||
|
||||
static Group imgtestroot;
|
||||
static Group imgoptionsroot;
|
||||
|
||||
static Group imageOpRoot;
|
||||
static Group imageOpOptRoot;
|
||||
@ -92,6 +96,7 @@ public abstract class ImageTests extends GraphicsTests {
|
||||
static Group bufImgOpTestRoot;
|
||||
static Group rasterOpTestRoot;
|
||||
static Option opList;
|
||||
static Option doTouchSrc;
|
||||
|
||||
static String transNodeNames[] = {
|
||||
null, "opaque", "bitmask", "translucent",
|
||||
@ -105,9 +110,19 @@ public abstract class ImageTests extends GraphicsTests {
|
||||
imageroot = new Group(graphicsroot, "imaging",
|
||||
"Imaging Benchmarks");
|
||||
imageroot.setTabbed();
|
||||
|
||||
imgsrcroot = new Group.EnableSet(imageroot, "src",
|
||||
"Image Rendering Sources");
|
||||
imgsrcroot.setBordered(true);
|
||||
|
||||
imgoptionsroot = new Group(imgsrcroot, "options",
|
||||
"Image Source Options");
|
||||
imgoptionsroot.setBordered(true);
|
||||
doTouchSrc =
|
||||
new Option.Toggle(imgoptionsroot, "touchsrc",
|
||||
"Touch src image before every operation",
|
||||
Option.Toggle.Off);
|
||||
|
||||
imgtestroot = new Group(imageroot, "tests",
|
||||
"Image Rendering Tests");
|
||||
imgtestroot.setBordered(true);
|
||||
@ -131,7 +146,11 @@ public abstract class ImageTests extends GraphicsTests {
|
||||
new BufImg(BufferedImage.TYPE_INT_RGB);
|
||||
new BufImg(BufferedImage.TYPE_INT_ARGB);
|
||||
new BufImg(BufferedImage.TYPE_BYTE_GRAY);
|
||||
new BufImg(BufferedImage.TYPE_3BYTE_BGR);
|
||||
new BmByteIndexBufImg();
|
||||
new BufImg(BufferedImage.TYPE_INT_RGB, true);
|
||||
new BufImg(BufferedImage.TYPE_INT_ARGB, true);
|
||||
new BufImg(BufferedImage.TYPE_3BYTE_BGR, true);
|
||||
|
||||
imageOpRoot = new Group(imageroot, "imageops",
|
||||
"Image Op Benchmarks");
|
||||
@ -193,6 +212,7 @@ public abstract class ImageTests extends GraphicsTests {
|
||||
}
|
||||
|
||||
public static class Context extends GraphicsTests.Context {
|
||||
boolean touchSrc;
|
||||
Image src;
|
||||
AffineTransform tx;
|
||||
}
|
||||
@ -206,6 +226,7 @@ public abstract class ImageTests extends GraphicsTests {
|
||||
{
|
||||
super(parent, nodeName, description);
|
||||
addDependency(imgsrcroot, srcFilter);
|
||||
addDependency(doTouchSrc);
|
||||
}
|
||||
|
||||
public GraphicsTests.Context createContext() {
|
||||
@ -217,6 +238,7 @@ public abstract class ImageTests extends GraphicsTests {
|
||||
ImageTests.Context ictx = (ImageTests.Context) ctx;
|
||||
|
||||
ictx.src = env.getSrcImage();
|
||||
ictx.touchSrc = env.isEnabled(doTouchSrc);
|
||||
}
|
||||
|
||||
public abstract static class TriStateImageType extends Group {
|
||||
@ -272,13 +294,6 @@ public abstract class ImageTests extends GraphicsTests {
|
||||
public static class CompatImg extends TriStateImageType {
|
||||
int transparency;
|
||||
|
||||
public static String Descriptions[] = {
|
||||
"Default Compatible Image",
|
||||
"Opaque Compatible Image",
|
||||
"Bitmask Compatible Image",
|
||||
"Translucent Compatible Image",
|
||||
};
|
||||
|
||||
public CompatImg(int transparency) {
|
||||
super(imgsrcroot,
|
||||
Destinations.CompatImg.ShortNames[transparency],
|
||||
@ -296,6 +311,7 @@ public abstract class ImageTests extends GraphicsTests {
|
||||
|
||||
public static class BufImg extends TriStateImageType {
|
||||
int type;
|
||||
boolean unmanaged;
|
||||
|
||||
static int Transparencies[] = {
|
||||
Transparency.TRANSLUCENT, // "custom",
|
||||
@ -315,15 +331,37 @@ public abstract class ImageTests extends GraphicsTests {
|
||||
};
|
||||
|
||||
public BufImg(int type) {
|
||||
this(type, false);
|
||||
}
|
||||
|
||||
public BufImg(int type, boolean unmanaged) {
|
||||
super(bufimgsrcroot,
|
||||
(unmanaged ? "unmanaged" : "") +
|
||||
Destinations.BufImg.ShortNames[type],
|
||||
(unmanaged ? "Unmanaged " : "") +
|
||||
Destinations.BufImg.Descriptions[type],
|
||||
Transparencies[type]);
|
||||
this.type = type;
|
||||
this.unmanaged = unmanaged;
|
||||
}
|
||||
|
||||
public Image makeImage(TestEnvironment env, int w, int h) {
|
||||
return new BufferedImage(w, h, type);
|
||||
BufferedImage img = new BufferedImage(w, h, type);
|
||||
if (unmanaged) {
|
||||
DataBuffer db = img.getRaster().getDataBuffer();
|
||||
if (db instanceof DataBufferInt) {
|
||||
((DataBufferInt)db).getData();
|
||||
} else if (db instanceof DataBufferShort) {
|
||||
((DataBufferShort)db).getData();
|
||||
} else if (db instanceof DataBufferByte) {
|
||||
((DataBufferByte)db).getData();
|
||||
} else {
|
||||
try {
|
||||
img.setAccelerationPriority(0.0f);
|
||||
} catch (Throwable e) {}
|
||||
}
|
||||
}
|
||||
return img;
|
||||
}
|
||||
}
|
||||
|
||||
@ -471,15 +509,33 @@ public abstract class ImageTests extends GraphicsTests {
|
||||
g.translate(ictx.orgX, ictx.orgY);
|
||||
Image src = ictx.src;
|
||||
if (ictx.animate) {
|
||||
do {
|
||||
g.drawImage(src, x, y, null);
|
||||
if ((x -= 3) < 0) x += ictx.maxX;
|
||||
if ((y -= 1) < 0) y += ictx.maxY;
|
||||
} while (--numReps > 0);
|
||||
if (ictx.touchSrc) {
|
||||
Graphics srcG = src.getGraphics();
|
||||
do {
|
||||
srcG.fillRect(0, 0, 1, 1);
|
||||
g.drawImage(src, x, y, null);
|
||||
if ((x -= 3) < 0) x += ictx.maxX;
|
||||
if ((y -= 1) < 0) y += ictx.maxY;
|
||||
} while (--numReps > 0);
|
||||
} else {
|
||||
do {
|
||||
g.drawImage(src, x, y, null);
|
||||
if ((x -= 3) < 0) x += ictx.maxX;
|
||||
if ((y -= 1) < 0) y += ictx.maxY;
|
||||
} while (--numReps > 0);
|
||||
}
|
||||
} else {
|
||||
do {
|
||||
g.drawImage(src, x, y, null);
|
||||
} while (--numReps > 0);
|
||||
if (ictx.touchSrc) {
|
||||
Graphics srcG = src.getGraphics();
|
||||
do {
|
||||
srcG.fillRect(0, 0, 1, 1);
|
||||
g.drawImage(src, x, y, null);
|
||||
} while (--numReps > 0);
|
||||
} else {
|
||||
do {
|
||||
g.drawImage(src, x, y, null);
|
||||
} while (--numReps > 0);
|
||||
}
|
||||
}
|
||||
g.translate(-ictx.orgX, -ictx.orgY);
|
||||
}
|
||||
@ -505,15 +561,33 @@ public abstract class ImageTests extends GraphicsTests {
|
||||
Image src = ictx.src;
|
||||
Color bg = Color.orange;
|
||||
if (ictx.animate) {
|
||||
do {
|
||||
g.drawImage(src, x, y, bg, null);
|
||||
if ((x -= 3) < 0) x += ictx.maxX;
|
||||
if ((y -= 1) < 0) y += ictx.maxY;
|
||||
} while (--numReps > 0);
|
||||
if (ictx.touchSrc) {
|
||||
Graphics srcG = src.getGraphics();
|
||||
do {
|
||||
srcG.fillRect(0, 0, 1, 1);
|
||||
g.drawImage(src, x, y, bg, null);
|
||||
if ((x -= 3) < 0) x += ictx.maxX;
|
||||
if ((y -= 1) < 0) y += ictx.maxY;
|
||||
} while (--numReps > 0);
|
||||
} else {
|
||||
do {
|
||||
g.drawImage(src, x, y, bg, null);
|
||||
if ((x -= 3) < 0) x += ictx.maxX;
|
||||
if ((y -= 1) < 0) y += ictx.maxY;
|
||||
} while (--numReps > 0);
|
||||
}
|
||||
} else {
|
||||
do {
|
||||
g.drawImage(src, x, y, bg, null);
|
||||
} while (--numReps > 0);
|
||||
if (ictx.touchSrc) {
|
||||
Graphics srcG = src.getGraphics();
|
||||
do {
|
||||
srcG.fillRect(0, 0, 1, 1);
|
||||
g.drawImage(src, x, y, bg, null);
|
||||
} while (--numReps > 0);
|
||||
} else {
|
||||
do {
|
||||
g.drawImage(src, x, y, bg, null);
|
||||
} while (--numReps > 0);
|
||||
}
|
||||
}
|
||||
g.translate(-ictx.orgX, -ictx.orgY);
|
||||
}
|
||||
@ -524,7 +598,7 @@ public abstract class ImageTests extends GraphicsTests {
|
||||
|
||||
public DrawImageScale(String dir, float scale) {
|
||||
super(imgtestroot, "drawimagescale"+dir,
|
||||
"drawImage(img, x, y, w*"+scale+", h*"+scale+", obs);");
|
||||
"drawImage(img, x, y, w*"+scale+", h*"+scale+", obs);");
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
@ -546,15 +620,33 @@ public abstract class ImageTests extends GraphicsTests {
|
||||
g.translate(ictx.orgX, ictx.orgY);
|
||||
Image src = ictx.src;
|
||||
if (ictx.animate) {
|
||||
do {
|
||||
g.drawImage(src, x, y, w, h, null);
|
||||
if ((x -= 3) < 0) x += ictx.maxX;
|
||||
if ((y -= 1) < 0) y += ictx.maxY;
|
||||
} while (--numReps > 0);
|
||||
if (ictx.touchSrc) {
|
||||
Graphics srcG = src.getGraphics();
|
||||
do {
|
||||
srcG.fillRect(0, 0, 1, 1);
|
||||
g.drawImage(src, x, y, w, h, null);
|
||||
if ((x -= 3) < 0) x += ictx.maxX;
|
||||
if ((y -= 1) < 0) y += ictx.maxY;
|
||||
} while (--numReps > 0);
|
||||
} else {
|
||||
do {
|
||||
g.drawImage(src, x, y, w, h, null);
|
||||
if ((x -= 3) < 0) x += ictx.maxX;
|
||||
if ((y -= 1) < 0) y += ictx.maxY;
|
||||
} while (--numReps > 0);
|
||||
}
|
||||
} else {
|
||||
do {
|
||||
g.drawImage(src, x, y, w, h, null);
|
||||
} while (--numReps > 0);
|
||||
Graphics srcG = src.getGraphics();
|
||||
if (ictx.touchSrc) {
|
||||
do {
|
||||
srcG.fillRect(0, 0, 1, 1);
|
||||
g.drawImage(src, x, y, w, h, null);
|
||||
} while (--numReps > 0);
|
||||
} else {
|
||||
do {
|
||||
g.drawImage(src, x, y, w, h, null);
|
||||
} while (--numReps > 0);
|
||||
}
|
||||
}
|
||||
g.translate(-ictx.orgX, -ictx.orgY);
|
||||
}
|
||||
@ -588,17 +680,36 @@ public abstract class ImageTests extends GraphicsTests {
|
||||
Image src = ictx.src;
|
||||
AffineTransform tx = ictx.tx;
|
||||
if (ictx.animate) {
|
||||
do {
|
||||
tx.setTransform(1.0, 0.1, 0.1, 1.0, x, y);
|
||||
g.drawImage(src, tx, null);
|
||||
if ((x -= 3) < 0) x += ictx.maxX;
|
||||
if ((y -= 1) < 0) y += ictx.maxY;
|
||||
} while (--numReps > 0);
|
||||
if (ictx.touchSrc) {
|
||||
Graphics srcG = src.getGraphics();
|
||||
do {
|
||||
tx.setTransform(1.0, 0.1, 0.1, 1.0, x, y);
|
||||
srcG.fillRect(0, 0, 1, 1);
|
||||
g.drawImage(src, tx, null);
|
||||
if ((x -= 3) < 0) x += ictx.maxX;
|
||||
if ((y -= 1) < 0) y += ictx.maxY;
|
||||
} while (--numReps > 0);
|
||||
} else {
|
||||
do {
|
||||
tx.setTransform(1.0, 0.1, 0.1, 1.0, x, y);
|
||||
g.drawImage(src, tx, null);
|
||||
if ((x -= 3) < 0) x += ictx.maxX;
|
||||
if ((y -= 1) < 0) y += ictx.maxY;
|
||||
} while (--numReps > 0);
|
||||
}
|
||||
} else {
|
||||
tx.setTransform(1.0, 0.1, 0.1, 1.0, x, y);
|
||||
do {
|
||||
g.drawImage(src, tx, null);
|
||||
} while (--numReps > 0);
|
||||
if (ictx.touchSrc) {
|
||||
Graphics srcG = src.getGraphics();
|
||||
do {
|
||||
srcG.fillRect(0, 0, 1, 1);
|
||||
g.drawImage(src, tx, null);
|
||||
} while (--numReps > 0);
|
||||
} else {
|
||||
do {
|
||||
g.drawImage(src, tx, null);
|
||||
} while (--numReps > 0);
|
||||
}
|
||||
}
|
||||
g.translate(-ictx.orgX, -ictx.orgY);
|
||||
}
|
||||
@ -736,15 +847,33 @@ public abstract class ImageTests extends GraphicsTests {
|
||||
Graphics2D g2 = (Graphics2D)ictx.graphics;
|
||||
g2.translate(ictx.orgX, ictx.orgY);
|
||||
if (ictx.animate) {
|
||||
do {
|
||||
g2.drawImage(src, op, x, y);
|
||||
if ((x -= 3) < 0) x += ictx.maxX;
|
||||
if ((y -= 1) < 0) y += ictx.maxY;
|
||||
} while (--numReps > 0);
|
||||
if (ictx.touchSrc) {
|
||||
Graphics gSrc = src.getGraphics();
|
||||
do {
|
||||
gSrc.fillRect(0, 0, 1, 1);
|
||||
g2.drawImage(src, op, x, y);
|
||||
if ((x -= 3) < 0) x += ictx.maxX;
|
||||
if ((y -= 1) < 0) y += ictx.maxY;
|
||||
} while (--numReps > 0);
|
||||
} else {
|
||||
do {
|
||||
g2.drawImage(src, op, x, y);
|
||||
if ((x -= 3) < 0) x += ictx.maxX;
|
||||
if ((y -= 1) < 0) y += ictx.maxY;
|
||||
} while (--numReps > 0);
|
||||
}
|
||||
} else {
|
||||
do {
|
||||
g2.drawImage(src, op, x, y);
|
||||
} while (--numReps > 0);
|
||||
if (ictx.touchSrc) {
|
||||
Graphics gSrc = src.getGraphics();
|
||||
do {
|
||||
gSrc.fillRect(0, 0, 1, 1);
|
||||
g2.drawImage(src, op, x, y);
|
||||
} while (--numReps > 0);
|
||||
} else {
|
||||
do {
|
||||
g2.drawImage(src, op, x, y);
|
||||
} while (--numReps > 0);
|
||||
}
|
||||
}
|
||||
g2.translate(-ictx.orgX, -ictx.orgY);
|
||||
}
|
||||
@ -778,9 +907,17 @@ public abstract class ImageTests extends GraphicsTests {
|
||||
BufferedImageOp op = ictx.bufImgOp;
|
||||
BufferedImage src = ictx.bufSrc;
|
||||
BufferedImage dst = ictx.bufDst;
|
||||
do {
|
||||
op.filter(src, dst);
|
||||
} while (--numReps > 0);
|
||||
if (ictx.touchSrc) {
|
||||
Graphics gSrc = src.getGraphics();
|
||||
do {
|
||||
gSrc.fillRect(0, 0, 1, 1);
|
||||
op.filter(src, dst);
|
||||
} while (--numReps > 0);
|
||||
} else {
|
||||
do {
|
||||
op.filter(src, dst);
|
||||
} while (--numReps > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -814,9 +951,17 @@ public abstract class ImageTests extends GraphicsTests {
|
||||
RasterOp op = ictx.rasterOp;
|
||||
Raster src = ictx.rasSrc;
|
||||
WritableRaster dst = ictx.rasDst;
|
||||
do {
|
||||
op.filter(src, dst);
|
||||
} while (--numReps > 0);
|
||||
if (ictx.touchSrc) {
|
||||
Graphics gSrc = ictx.bufSrc.getGraphics();
|
||||
do {
|
||||
gSrc.fillRect(0, 0, 1, 1);
|
||||
op.filter(src, dst);
|
||||
} while (--numReps > 0);
|
||||
} else {
|
||||
do {
|
||||
op.filter(src, dst);
|
||||
} while (--numReps > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1281,7 +1281,7 @@ Java_sun_font_FreetypeFontScaler_getGlyphOutlineBoundsNative(
|
||||
sunFontIDs.rect2DFloatClass,
|
||||
sunFontIDs.rect2DFloatCtr4,
|
||||
F26Dot6ToFloat(bbox.xMin),
|
||||
F26Dot6ToFloat(bbox.yMax),
|
||||
F26Dot6ToFloat(-bbox.yMax),
|
||||
F26Dot6ToFloat(bbox.xMax-bbox.xMin),
|
||||
F26Dot6ToFloat(bbox.yMax-bbox.yMin));
|
||||
}
|
||||
|
@ -203,7 +203,24 @@ OGLBlitSwToSurface(OGLContext *oglc, SurfaceDataRasInfo *srcInfo,
|
||||
j2d_glBitmap(0, 0, 0, 0, (GLfloat)dx1, (GLfloat)-dy1, NULL);
|
||||
|
||||
j2d_glPixelZoom(scalex, -scaley);
|
||||
j2d_glDrawPixels(sx2-sx1, sy2-sy1, pf->format, pf->type, srcInfo->rasBase);
|
||||
|
||||
// in case pixel stride is not a multiple of scanline stride the copy
|
||||
// has to be done line by line (see 6207877)
|
||||
if (srcInfo->scanStride % srcInfo->pixelStride != 0) {
|
||||
jint width = sx2-sx1;
|
||||
jint height = sy2-sy1;
|
||||
GLvoid *pSrc = srcInfo->rasBase;
|
||||
|
||||
while (height > 0) {
|
||||
j2d_glDrawPixels(width, 1, pf->format, pf->type, pSrc);
|
||||
j2d_glBitmap(0, 0, 0, 0, (GLfloat)0, (GLfloat)-1, NULL);
|
||||
pSrc = PtrAddBytes(pSrc, srcInfo->scanStride);
|
||||
height--;
|
||||
}
|
||||
} else {
|
||||
j2d_glDrawPixels(sx2-sx1, sy2-sy1, pf->format, pf->type, srcInfo->rasBase);
|
||||
}
|
||||
|
||||
j2d_glPixelZoom(1.0, 1.0);
|
||||
|
||||
if (oglc->extraAlpha != 1.0f) {
|
||||
@ -250,6 +267,7 @@ OGLBlitToSurfaceViaTexture(OGLContext *oglc, SurfaceDataRasInfo *srcInfo,
|
||||
jint sx, sy, sw, sh;
|
||||
GLint glhint = (hint == OGLSD_XFORM_BILINEAR) ? GL_LINEAR : GL_NEAREST;
|
||||
jboolean adjustAlpha = (pf != NULL && !pf->hasAlpha);
|
||||
jboolean slowPath;
|
||||
|
||||
if (oglc->blitTextureID == 0) {
|
||||
if (!OGLContext_InitBlitTileTexture(oglc)) {
|
||||
@ -279,6 +297,10 @@ OGLBlitToSurfaceViaTexture(OGLContext *oglc, SurfaceDataRasInfo *srcInfo,
|
||||
j2d_glPixelTransferf(GL_ALPHA_BIAS, 1.0f);
|
||||
}
|
||||
|
||||
// in case pixel stride is not a multiple of scanline stride the copy
|
||||
// has to be done line by line (see 6207877)
|
||||
slowPath = srcInfo->scanStride % srcInfo->pixelStride != 0;
|
||||
|
||||
for (sy = sy1, dy = dy1; sy < sy2; sy += th, dy += cdh) {
|
||||
sh = ((sy + th) > sy2) ? (sy2 - sy) : th;
|
||||
dh = ((dy + cdh) > dy2) ? (dy2 - dy) : cdh;
|
||||
@ -291,13 +313,29 @@ OGLBlitToSurfaceViaTexture(OGLContext *oglc, SurfaceDataRasInfo *srcInfo,
|
||||
ty2 = ((GLdouble)sh) / th;
|
||||
|
||||
if (swsurface) {
|
||||
j2d_glPixelStorei(GL_UNPACK_SKIP_PIXELS, sx);
|
||||
j2d_glPixelStorei(GL_UNPACK_SKIP_ROWS, sy);
|
||||
if (slowPath) {
|
||||
jint tmph = sh;
|
||||
GLvoid *pSrc = PtrCoord(srcInfo->rasBase,
|
||||
sx, srcInfo->pixelStride,
|
||||
sy, srcInfo->scanStride);
|
||||
|
||||
j2d_glTexSubImage2D(GL_TEXTURE_2D, 0,
|
||||
0, 0, sw, sh,
|
||||
pf->format, pf->type,
|
||||
srcInfo->rasBase);
|
||||
while (tmph > 0) {
|
||||
j2d_glTexSubImage2D(GL_TEXTURE_2D, 0,
|
||||
0, sh - tmph, sw, 1,
|
||||
pf->format, pf->type,
|
||||
pSrc);
|
||||
pSrc = PtrAddBytes(pSrc, srcInfo->scanStride);
|
||||
tmph--;
|
||||
}
|
||||
} else {
|
||||
j2d_glPixelStorei(GL_UNPACK_SKIP_PIXELS, sx);
|
||||
j2d_glPixelStorei(GL_UNPACK_SKIP_ROWS, sy);
|
||||
|
||||
j2d_glTexSubImage2D(GL_TEXTURE_2D, 0,
|
||||
0, 0, sw, sh,
|
||||
pf->format, pf->type,
|
||||
srcInfo->rasBase);
|
||||
}
|
||||
|
||||
// the texture image is "right side up", so we align the
|
||||
// upper-left texture corner with the upper-left quad corner
|
||||
@ -356,9 +394,25 @@ OGLBlitSwToTexture(SurfaceDataRasInfo *srcInfo, OGLPixelFormat *pf,
|
||||
jint dx1, jint dy1, jint dx2, jint dy2)
|
||||
{
|
||||
j2d_glBindTexture(dstOps->textureTarget, dstOps->textureID);
|
||||
j2d_glTexSubImage2D(dstOps->textureTarget, 0,
|
||||
dx1, dy1, dx2-dx1, dy2-dy1,
|
||||
pf->format, pf->type, srcInfo->rasBase);
|
||||
// in case pixel stride is not a multiple of scanline stride the copy
|
||||
// has to be done line by line (see 6207877)
|
||||
if (srcInfo->scanStride % srcInfo->pixelStride != 0) {
|
||||
jint width = dx2 - dx1;
|
||||
jint height = dy2 - dy1;
|
||||
GLvoid *pSrc = srcInfo->rasBase;
|
||||
|
||||
while (height > 0) {
|
||||
j2d_glTexSubImage2D(dstOps->textureTarget, 0,
|
||||
dx1, dy2 - height, width, 1,
|
||||
pf->format, pf->type, pSrc);
|
||||
pSrc = PtrAddBytes(pSrc, srcInfo->scanStride);
|
||||
height--;
|
||||
}
|
||||
} else {
|
||||
j2d_glTexSubImage2D(dstOps->textureTarget, 0,
|
||||
dx1, dy1, dx2-dx1, dy2-dy1,
|
||||
pf->format, pf->type, srcInfo->rasBase);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,7 +73,8 @@ OGLPixelFormat PixelFormats[] = {
|
||||
1, 0, 1, }, /* 9 - ByteGray */
|
||||
{ GL_LUMINANCE, GL_UNSIGNED_SHORT,
|
||||
2, 0, 1, }, /*10 - UshortGray */
|
||||
};
|
||||
{ GL_BGR, GL_UNSIGNED_BYTE,
|
||||
1, 0, 1, }, /*11 - ThreeByteBgr */};
|
||||
|
||||
/**
|
||||
* Given a starting value and a maximum limit, returns the first power-of-two
|
||||
|
@ -209,7 +209,7 @@ public class X11GraphicsEnvironment
|
||||
private static native int checkShmExt();
|
||||
|
||||
private static native String getDisplayString();
|
||||
private static Boolean isDisplayLocal;
|
||||
private Boolean isDisplayLocal;
|
||||
|
||||
/**
|
||||
* This should only be called from the static initializer, so no need for
|
||||
@ -234,7 +234,8 @@ public class X11GraphicsEnvironment
|
||||
return getScreenDevices()[getDefaultScreenNum()];
|
||||
}
|
||||
|
||||
public static boolean isDisplayLocal() {
|
||||
@Override
|
||||
public boolean isDisplayLocal() {
|
||||
if (isDisplayLocal == null) {
|
||||
SunToolkit.awtLock();
|
||||
try {
|
||||
|
@ -120,12 +120,14 @@ public class GLXGraphicsConfig
|
||||
new GLXGetConfigInfo(device.getScreen(), visualnum);
|
||||
rq.flushAndInvokeNow(action);
|
||||
cfginfo = action.getConfigInfo();
|
||||
OGLContext.setScratchSurface(cfginfo);
|
||||
rq.flushAndInvokeNow(new Runnable() {
|
||||
public void run() {
|
||||
ids[0] = OGLContext.getOGLIdString();
|
||||
}
|
||||
});
|
||||
if (cfginfo != 0L) {
|
||||
OGLContext.setScratchSurface(cfginfo);
|
||||
rq.flushAndInvokeNow(new Runnable() {
|
||||
public void run() {
|
||||
ids[0] = OGLContext.getOGLIdString();
|
||||
}
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
rq.unlock();
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ import sun.awt.image.PixelConverter;
|
||||
import sun.font.X11TextRenderer;
|
||||
import sun.java2d.InvalidPipeException;
|
||||
import sun.java2d.SunGraphics2D;
|
||||
import sun.java2d.SunGraphicsEnvironment;
|
||||
import sun.java2d.SurfaceData;
|
||||
import sun.java2d.SurfaceDataProxy;
|
||||
import sun.java2d.loops.SurfaceType;
|
||||
@ -240,6 +241,11 @@ public abstract class X11SurfaceData extends SurfaceData {
|
||||
*/
|
||||
public static native boolean isDgaAvailable();
|
||||
|
||||
/**
|
||||
* Returns true if shared memory pixmaps are available
|
||||
*/
|
||||
private static native boolean isShmPMAvailable();
|
||||
|
||||
public static boolean isAccelerationEnabled() {
|
||||
if (accelerationEnabled == null) {
|
||||
|
||||
@ -253,8 +259,17 @@ public abstract class X11SurfaceData extends SurfaceData {
|
||||
// true iff prop==true, false otherwise
|
||||
accelerationEnabled = Boolean.valueOf(prop);
|
||||
} else {
|
||||
// use pixmaps if there is no dga, no matter local or remote
|
||||
accelerationEnabled = Boolean.valueOf(!isDgaAvailable());
|
||||
boolean isDisplayLocal = false;
|
||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
if (ge instanceof SunGraphicsEnvironment) {
|
||||
isDisplayLocal = ((SunGraphicsEnvironment) ge).isDisplayLocal();
|
||||
}
|
||||
|
||||
// EXA based drivers tend to place pixmaps in VRAM, slowing down readbacks.
|
||||
// Don't use pixmaps if dga is available,
|
||||
// or we are local and shared memory Pixmaps are not available.
|
||||
accelerationEnabled =
|
||||
!(isDgaAvailable() || (isDisplayLocal && !isShmPMAvailable()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,9 +46,9 @@ import javax.print.attribute.standard.PrinterName;
|
||||
|
||||
|
||||
public class CUPSPrinter {
|
||||
|
||||
private static final String debugPrefix = "CUPSPrinter>> ";
|
||||
private static final double PRINTER_DPI = 72.0;
|
||||
private static boolean initialized;
|
||||
private boolean initialized;
|
||||
private static native String getCupsServer();
|
||||
private static native int getCupsPort();
|
||||
private static native boolean canConnect(String server, int port);
|
||||
@ -156,7 +156,7 @@ public class CUPSPrinter {
|
||||
/**
|
||||
* Initialize media by translating PPD info to PrintService attributes.
|
||||
*/
|
||||
private void initMedia() {
|
||||
private synchronized void initMedia() {
|
||||
if (initialized) {
|
||||
return;
|
||||
} else {
|
||||
@ -392,9 +392,9 @@ public class CUPSPrinter {
|
||||
* Detects if CUPS is running.
|
||||
*/
|
||||
public static boolean isCupsRunning() {
|
||||
IPPPrintService.debug_println("libFound "+libFound);
|
||||
IPPPrintService.debug_println(debugPrefix+"libFound "+libFound);
|
||||
if (libFound) {
|
||||
IPPPrintService.debug_println("CUPS server "+getServer()+
|
||||
IPPPrintService.debug_println(debugPrefix+"CUPS server "+getServer()+
|
||||
" port "+getPort());
|
||||
return canConnect(getServer(), getPort());
|
||||
} else {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2003-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
|
||||
@ -57,18 +57,28 @@ import java.io.InputStreamReader;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.HashSet;
|
||||
|
||||
|
||||
public class IPPPrintService implements PrintService, SunPrinterJobService {
|
||||
|
||||
public static boolean debugPrint = false;
|
||||
private static String debugPrefix = "IPPPrintService>> ";
|
||||
public static final boolean debugPrint;
|
||||
private static final String debugPrefix = "IPPPrintService>> ";
|
||||
protected static void debug_println(String str) {
|
||||
if (debugPrint) {
|
||||
System.out.println(str);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String FORCE_PIPE_PROP = "sun.print.ippdebug";
|
||||
|
||||
static {
|
||||
String debugStr =
|
||||
(String)java.security.AccessController.doPrivileged(
|
||||
new sun.security.action.GetPropertyAction(FORCE_PIPE_PROP));
|
||||
|
||||
debugPrint = "true".equalsIgnoreCase(debugStr);
|
||||
}
|
||||
|
||||
private String printer;
|
||||
private URI myURI;
|
||||
@ -382,7 +392,7 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
|
||||
if ((urlConnection = getIPPConnection(myURL)) == null) {
|
||||
mediaSizeNames = new MediaSizeName[0];
|
||||
mediaTrays = new MediaTray[0];
|
||||
debug_println("NULL urlConnection ");
|
||||
debug_println(debugPrefix+"initAttributes, NULL urlConnection ");
|
||||
init = true;
|
||||
return;
|
||||
}
|
||||
@ -407,7 +417,7 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
IPPPrintService.debug_println(debugPrefix+
|
||||
" error creating CUPSPrinter e="+e);
|
||||
"initAttributes, error creating CUPSPrinter e="+e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -486,28 +496,26 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
|
||||
/* Test if the flavor is compatible with the category */
|
||||
if ((category == Copies.class) ||
|
||||
(category == CopiesSupported.class)) {
|
||||
CopiesSupported cs = new CopiesSupported(1, MAXCOPIES);
|
||||
AttributeClass attribClass = (getAttMap != null) ?
|
||||
(AttributeClass)getAttMap.get(cs.getName()) : null;
|
||||
if (attribClass != null) {
|
||||
int[] range = attribClass.getIntRangeValue();
|
||||
cs = new CopiesSupported(range[0], range[1]);
|
||||
if (flavor == null ||
|
||||
!(flavor.equals(DocFlavor.INPUT_STREAM.POSTSCRIPT) ||
|
||||
flavor.equals(DocFlavor.URL.POSTSCRIPT) ||
|
||||
flavor.equals(DocFlavor.BYTE_ARRAY.POSTSCRIPT))) {
|
||||
CopiesSupported cs = new CopiesSupported(1, MAXCOPIES);
|
||||
AttributeClass attribClass = (getAttMap != null) ?
|
||||
(AttributeClass)getAttMap.get(cs.getName()) : null;
|
||||
if (attribClass != null) {
|
||||
int[] range = attribClass.getIntRangeValue();
|
||||
cs = new CopiesSupported(range[0], range[1]);
|
||||
}
|
||||
return cs;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return cs;
|
||||
} else if (category == Chromaticity.class) {
|
||||
if (flavor == null ||
|
||||
flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
|
||||
flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE) ||
|
||||
flavor.equals(DocFlavor.BYTE_ARRAY.GIF) ||
|
||||
flavor.equals(DocFlavor.INPUT_STREAM.GIF) ||
|
||||
flavor.equals(DocFlavor.URL.GIF) ||
|
||||
flavor.equals(DocFlavor.BYTE_ARRAY.JPEG) ||
|
||||
flavor.equals(DocFlavor.INPUT_STREAM.JPEG) ||
|
||||
flavor.equals(DocFlavor.URL.JPEG) ||
|
||||
flavor.equals(DocFlavor.BYTE_ARRAY.PNG) ||
|
||||
flavor.equals(DocFlavor.INPUT_STREAM.PNG) ||
|
||||
flavor.equals(DocFlavor.URL.PNG)) {
|
||||
|
||||
!isIPPSupportedImages(flavor.getMimeType())) {
|
||||
Chromaticity[]arr = new Chromaticity[1];
|
||||
arr[0] = Chromaticity.COLOR;
|
||||
return (arr);
|
||||
@ -822,7 +830,7 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
|
||||
boolean psSupported = false;
|
||||
String[] docFlavors = attribClass.getArrayOfStringValues();
|
||||
DocFlavor[] flavors;
|
||||
ArrayList docList = new ArrayList();
|
||||
HashSet docList = new HashSet();
|
||||
int j;
|
||||
String hostEnc = DocFlavor.hostEncoding.
|
||||
toLowerCase(Locale.ENGLISH);
|
||||
@ -839,18 +847,6 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
|
||||
|
||||
docList.addAll(Arrays.asList(flavors));
|
||||
|
||||
if (isCupsPrinter) {
|
||||
/*
|
||||
Always add Pageable and Printable for CUPS
|
||||
since it uses Filters to convert from Postscript
|
||||
to device printer language.
|
||||
*/
|
||||
docList.add(
|
||||
DocFlavor.SERVICE_FORMATTED.PAGEABLE);
|
||||
docList.add(
|
||||
DocFlavor.SERVICE_FORMATTED.PRINTABLE);
|
||||
}
|
||||
|
||||
if (mimeType.equals("text/plain") &&
|
||||
addHostEncoding) {
|
||||
docList.add(Arrays.asList(textPlainHost));
|
||||
@ -880,16 +876,19 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
|
||||
}
|
||||
|
||||
// check if we need to add image DocFlavors
|
||||
// and Pageable/Printable flavors
|
||||
if (psSupported || isCupsPrinter) {
|
||||
if (!jpgImagesAdded) {
|
||||
docList.addAll(Arrays.asList(imageJPG));
|
||||
}
|
||||
if (!pngImagesAdded) {
|
||||
docList.addAll(Arrays.asList(imagePNG));
|
||||
}
|
||||
if (!gifImagesAdded) {
|
||||
docList.addAll(Arrays.asList(imageGIF));
|
||||
}
|
||||
/*
|
||||
Always add Pageable and Printable for CUPS
|
||||
since it uses Filters to convert from Postscript
|
||||
to device printer language.
|
||||
*/
|
||||
docList.add(DocFlavor.SERVICE_FORMATTED.PAGEABLE);
|
||||
docList.add(DocFlavor.SERVICE_FORMATTED.PRINTABLE);
|
||||
|
||||
docList.addAll(Arrays.asList(imageJPG));
|
||||
docList.addAll(Arrays.asList(imagePNG));
|
||||
docList.addAll(Arrays.asList(imageGIF));
|
||||
}
|
||||
supportedDocFlavors = new DocFlavor[docList.size()];
|
||||
docList.toArray(supportedDocFlavors);
|
||||
@ -922,6 +921,9 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
|
||||
* Finds matching CustomMediaSizeName of given media.
|
||||
*/
|
||||
public CustomMediaSizeName findCustomMedia(MediaSizeName media) {
|
||||
if (customMediaSizeNames == null) {
|
||||
return null;
|
||||
}
|
||||
for (int i=0; i< customMediaSizeNames.length; i++) {
|
||||
CustomMediaSizeName custom =
|
||||
(CustomMediaSizeName)customMediaSizeNames[i];
|
||||
@ -1203,7 +1205,7 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
|
||||
return true;
|
||||
}
|
||||
for (int i=0; i<mediaSizeNames.length; i++) {
|
||||
debug_println("mediaSizeNames[i] "+mediaSizeNames[i]);
|
||||
debug_println(debugPrefix+"isSupportedMedia, mediaSizeNames[i] "+mediaSizeNames[i]);
|
||||
if (msn.equals(mediaSizeNames[i])) {
|
||||
return true;
|
||||
}
|
||||
@ -1228,7 +1230,7 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
|
||||
}
|
||||
|
||||
|
||||
public boolean isAttributeValueSupported(Attribute attr,
|
||||
public boolean isAttributeValueSupported(Attribute attr,
|
||||
DocFlavor flavor,
|
||||
AttributeSet attributes) {
|
||||
if (attr == null) {
|
||||
@ -1257,21 +1259,18 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
|
||||
if ((flavor == null) ||
|
||||
flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
|
||||
flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE) ||
|
||||
flavor.equals(DocFlavor.BYTE_ARRAY.GIF) ||
|
||||
flavor.equals(DocFlavor.INPUT_STREAM.GIF) ||
|
||||
flavor.equals(DocFlavor.URL.GIF) ||
|
||||
flavor.equals(DocFlavor.BYTE_ARRAY.JPEG) ||
|
||||
flavor.equals(DocFlavor.INPUT_STREAM.JPEG) ||
|
||||
flavor.equals(DocFlavor.URL.JPEG) ||
|
||||
flavor.equals(DocFlavor.BYTE_ARRAY.PNG) ||
|
||||
flavor.equals(DocFlavor.INPUT_STREAM.PNG) ||
|
||||
flavor.equals(DocFlavor.URL.PNG)) {
|
||||
!isIPPSupportedImages(flavor.getMimeType())) {
|
||||
return attr == Chromaticity.COLOR;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else if (attr.getCategory() == Copies.class) {
|
||||
return isSupportedCopies((Copies)attr);
|
||||
return (flavor == null ||
|
||||
!(flavor.equals(DocFlavor.INPUT_STREAM.POSTSCRIPT) ||
|
||||
flavor.equals(DocFlavor.URL.POSTSCRIPT) ||
|
||||
flavor.equals(DocFlavor.BYTE_ARRAY.POSTSCRIPT))) &&
|
||||
isSupportedCopies((Copies)attr);
|
||||
|
||||
} else if (attr.getCategory() == Destination.class) {
|
||||
if (flavor == null ||
|
||||
flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
|
||||
@ -1667,9 +1666,10 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
|
||||
try {
|
||||
osw = new OutputStreamWriter(os, "UTF-8");
|
||||
} catch (java.io.UnsupportedEncodingException exc) {
|
||||
debug_println("UTF-8 not supported? Exception: "+exc);
|
||||
debug_println(debugPrefix+"writeIPPRequest, UTF-8 not supported? Exception: "+exc);
|
||||
return false;
|
||||
}
|
||||
debug_println(debugPrefix+"writeIPPRequest, op code= "+operCode);
|
||||
char[] opCode = new char[2];
|
||||
opCode[0] = (char)Byte.parseByte(operCode.substring(0,2), 16);
|
||||
opCode[1] = (char)Byte.parseByte(operCode.substring(2,4), 16);
|
||||
@ -1710,7 +1710,7 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
|
||||
osw.flush();
|
||||
osw.close();
|
||||
} catch (java.io.IOException ioe) {
|
||||
debug_println(debugPrefix+"IPPPrintService Exception in writeIPPRequest: "+ioe);
|
||||
debug_println(debugPrefix+"writeIPPRequest, IPPPrintService Exception in writeIPPRequest: "+ioe);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -1747,7 +1747,7 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
|
||||
while ((response[0] >= GRPTAG_OP_ATTRIBUTES) &&
|
||||
(response[0] <= GRPTAG_PRINTER_ATTRIBUTES)
|
||||
&& (response[0] != GRPTAG_END_ATTRIBUTES)) {
|
||||
debug_println(debugPrefix+"checking group tag, response[0]= "+
|
||||
debug_println(debugPrefix+"readIPPResponse, checking group tag, response[0]= "+
|
||||
response[0]);
|
||||
|
||||
outObj = new ByteArrayOutputStream();
|
||||
@ -1786,6 +1786,7 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
|
||||
outArray);
|
||||
|
||||
responseMap.put(ac.getName(), ac);
|
||||
debug_println(debugPrefix+ "readIPPResponse "+ac);
|
||||
}
|
||||
|
||||
outObj = new ByteArrayOutputStream();
|
||||
@ -1858,6 +1859,9 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
|
||||
|
||||
} catch (java.io.IOException e) {
|
||||
debug_println(debugPrefix+"readIPPResponse: "+e);
|
||||
if (debugPrint) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -1872,4 +1876,8 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
|
||||
(obj instanceof IPPPrintService &&
|
||||
((IPPPrintService)obj).getName().equals(getName())));
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.getClass().hashCode()+getName().hashCode();
|
||||
}
|
||||
}
|
||||
|
@ -686,19 +686,7 @@ public class UnixPrintService implements PrintService, AttributeUpdater,
|
||||
}
|
||||
|
||||
if (category == Chromaticity.class) {
|
||||
if (flavor == null ||
|
||||
flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
|
||||
flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE) ||
|
||||
flavor.equals(DocFlavor.BYTE_ARRAY.GIF) ||
|
||||
flavor.equals(DocFlavor.INPUT_STREAM.GIF) ||
|
||||
flavor.equals(DocFlavor.URL.GIF) ||
|
||||
flavor.equals(DocFlavor.BYTE_ARRAY.JPEG) ||
|
||||
flavor.equals(DocFlavor.INPUT_STREAM.JPEG) ||
|
||||
flavor.equals(DocFlavor.URL.JPEG) ||
|
||||
flavor.equals(DocFlavor.BYTE_ARRAY.PNG) ||
|
||||
flavor.equals(DocFlavor.INPUT_STREAM.PNG) ||
|
||||
flavor.equals(DocFlavor.URL.PNG)) {
|
||||
|
||||
if (flavor == null || isServiceFormattedFlavor(flavor)) {
|
||||
Chromaticity[]arr = new Chromaticity[1];
|
||||
arr[0] = Chromaticity.COLOR;
|
||||
return (arr);
|
||||
@ -730,18 +718,7 @@ public class UnixPrintService implements PrintService, AttributeUpdater,
|
||||
}
|
||||
return new RequestingUserName(userName, null);
|
||||
} else if (category == OrientationRequested.class) {
|
||||
if (flavor == null ||
|
||||
flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
|
||||
flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE) ||
|
||||
flavor.equals(DocFlavor.INPUT_STREAM.GIF) ||
|
||||
flavor.equals(DocFlavor.INPUT_STREAM.JPEG) ||
|
||||
flavor.equals(DocFlavor.INPUT_STREAM.PNG) ||
|
||||
flavor.equals(DocFlavor.BYTE_ARRAY.GIF) ||
|
||||
flavor.equals(DocFlavor.BYTE_ARRAY.JPEG) ||
|
||||
flavor.equals(DocFlavor.BYTE_ARRAY.PNG) ||
|
||||
flavor.equals(DocFlavor.URL.GIF) ||
|
||||
flavor.equals(DocFlavor.URL.JPEG) ||
|
||||
flavor.equals(DocFlavor.URL.PNG)) {
|
||||
if (flavor == null || isServiceFormattedFlavor(flavor)) {
|
||||
OrientationRequested []arr = new OrientationRequested[3];
|
||||
arr[0] = OrientationRequested.PORTRAIT;
|
||||
arr[1] = OrientationRequested.LANDSCAPE;
|
||||
@ -752,7 +729,14 @@ public class UnixPrintService implements PrintService, AttributeUpdater,
|
||||
}
|
||||
} else if ((category == Copies.class) ||
|
||||
(category == CopiesSupported.class)) {
|
||||
return new CopiesSupported(1, MAXCOPIES);
|
||||
if (flavor == null ||
|
||||
!(flavor.equals(DocFlavor.INPUT_STREAM.POSTSCRIPT) ||
|
||||
flavor.equals(DocFlavor.URL.POSTSCRIPT) ||
|
||||
flavor.equals(DocFlavor.BYTE_ARRAY.POSTSCRIPT))) {
|
||||
return new CopiesSupported(1, MAXCOPIES);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else if (category == Media.class) {
|
||||
Media []arr = new Media[mediaSizes.length];
|
||||
System.arraycopy(mediaSizes, 0, arr, 0, mediaSizes.length);
|
||||
@ -917,8 +901,10 @@ public class UnixPrintService implements PrintService, AttributeUpdater,
|
||||
}
|
||||
}
|
||||
else if (attr.getCategory() == Copies.class) {
|
||||
return
|
||||
(flavor == null || isServiceFormattedFlavor(flavor)) &&
|
||||
return (flavor == null ||
|
||||
!(flavor.equals(DocFlavor.INPUT_STREAM.POSTSCRIPT) ||
|
||||
flavor.equals(DocFlavor.URL.POSTSCRIPT) ||
|
||||
flavor.equals(DocFlavor.BYTE_ARRAY.POSTSCRIPT))) &&
|
||||
isSupportedCopies((Copies)attr);
|
||||
} else if (attr.getCategory() == Destination.class) {
|
||||
URI uri = ((Destination)attr).getURI();
|
||||
|
@ -156,7 +156,7 @@ jboolean isDisplayLocal(JNIEnv *env) {
|
||||
|
||||
isLocal = JNU_CallStaticMethodByName(env, NULL,
|
||||
"sun/awt/X11GraphicsEnvironment",
|
||||
"isDisplayLocal",
|
||||
"_isDisplayLocal",
|
||||
"()Z").z;
|
||||
isLocalSet = True;
|
||||
return isLocal;
|
||||
@ -1233,7 +1233,7 @@ Java_sun_font_FontManager_getFontConfig
|
||||
for (j=0; j<nfonts; j++) {
|
||||
FcPattern *fontPattern = fontset->fonts[j];
|
||||
FcChar8 *fontformat;
|
||||
FcCharSet *unionCharset, *charset;
|
||||
FcCharSet *unionCharset = NULL, *charset;
|
||||
|
||||
fontformat = NULL;
|
||||
(*FcPatternGetString)(fontPattern, FC_FONTFORMAT, 0, &fontformat);
|
||||
@ -1256,7 +1256,7 @@ Java_sun_font_FontManager_getFontConfig
|
||||
if (nfonts==10) {
|
||||
minGlyphs = 50;
|
||||
}
|
||||
if (j == 0) {
|
||||
if (unionCharset == NULL) {
|
||||
unionCharset = charset;
|
||||
} else {
|
||||
if ((*FcCharSetSubtractCount)(charset, unionCharset)
|
||||
|
@ -208,6 +208,23 @@ Java_sun_java2d_x11_X11SurfaceData_isDgaAvailable(JNIEnv *env, jobject this)
|
||||
#endif /* HEADLESS */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: sun_java2d_x11_X11SurfaceData
|
||||
* Method: isShmPMAvailable
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_sun_java2d_x11_X11SurfaceData_isShmPMAvailable(JNIEnv *env, jobject this)
|
||||
{
|
||||
#if defined(HEADLESS) || !defined(MITSHM)
|
||||
return JNI_FALSE;
|
||||
#else
|
||||
return useMitShmPixmaps;
|
||||
#endif /* HEADLESS, MITSHM */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: sun_java2d_x11_X11SurfaceData
|
||||
* Method: initOps
|
||||
|
@ -393,4 +393,9 @@ public class Win32GraphicsEnvironment
|
||||
private static void dwmCompositionChanged(boolean enabled) {
|
||||
isDWMCompositionEnabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisplayLocal() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -85,6 +85,8 @@ class D3DBlitLoops {
|
||||
D3DSurfaceData.ST_INT_RGB),
|
||||
new D3DSwToSurfaceBlit(SurfaceType.IntBgr,
|
||||
D3DSurfaceData.ST_INT_BGR),
|
||||
new D3DSwToSurfaceBlit(SurfaceType.ThreeByteBgr,
|
||||
D3DSurfaceData.ST_3BYTE_BGR),
|
||||
new D3DSwToSurfaceBlit(SurfaceType.Ushort565Rgb,
|
||||
D3DSurfaceData.ST_USHORT_565_RGB),
|
||||
new D3DSwToSurfaceBlit(SurfaceType.Ushort555Rgb,
|
||||
@ -106,6 +108,8 @@ class D3DBlitLoops {
|
||||
D3DSurfaceData.ST_INT_RGB),
|
||||
new D3DSwToSurfaceScale(SurfaceType.IntBgr,
|
||||
D3DSurfaceData.ST_INT_BGR),
|
||||
new D3DSwToSurfaceScale(SurfaceType.ThreeByteBgr,
|
||||
D3DSurfaceData.ST_3BYTE_BGR),
|
||||
new D3DSwToSurfaceScale(SurfaceType.Ushort565Rgb,
|
||||
D3DSurfaceData.ST_USHORT_565_RGB),
|
||||
new D3DSwToSurfaceScale(SurfaceType.Ushort555Rgb,
|
||||
@ -124,6 +128,8 @@ class D3DBlitLoops {
|
||||
D3DSurfaceData.ST_INT_RGB),
|
||||
new D3DSwToSurfaceTransform(SurfaceType.IntBgr,
|
||||
D3DSurfaceData.ST_INT_BGR),
|
||||
new D3DSwToSurfaceTransform(SurfaceType.ThreeByteBgr,
|
||||
D3DSurfaceData.ST_3BYTE_BGR),
|
||||
new D3DSwToSurfaceTransform(SurfaceType.Ushort565Rgb,
|
||||
D3DSurfaceData.ST_USHORT_565_RGB),
|
||||
new D3DSwToSurfaceTransform(SurfaceType.Ushort555Rgb,
|
||||
@ -147,6 +153,8 @@ class D3DBlitLoops {
|
||||
D3DSurfaceData.ST_INT_ARGB),
|
||||
new D3DSwToTextureBlit(SurfaceType.IntBgr,
|
||||
D3DSurfaceData.ST_INT_BGR),
|
||||
new D3DSwToTextureBlit(SurfaceType.ThreeByteBgr,
|
||||
D3DSurfaceData.ST_3BYTE_BGR),
|
||||
new D3DSwToTextureBlit(SurfaceType.Ushort565Rgb,
|
||||
D3DSurfaceData.ST_USHORT_565_RGB),
|
||||
new D3DSwToTextureBlit(SurfaceType.Ushort555Rgb,
|
||||
|
@ -135,6 +135,7 @@ public class D3DSurfaceData extends SurfaceData implements AccelSurface {
|
||||
public static final int ST_USHORT_555_RGB = 6;
|
||||
public static final int ST_BYTE_INDEXED = 7;
|
||||
public static final int ST_BYTE_INDEXED_BM = 8;
|
||||
public static final int ST_3BYTE_BGR = 9;
|
||||
|
||||
/** Equals to D3DSWAPEFFECT_DISCARD */
|
||||
public static final int SWAP_DISCARD = 1;
|
||||
@ -501,12 +502,14 @@ public class D3DSurfaceData extends SurfaceData implements AccelSurface {
|
||||
* - the pixel shaders are available, and
|
||||
* - blending is disabled, and
|
||||
* - the source color is opaque
|
||||
* - and the destination is opaque
|
||||
*/
|
||||
public boolean canRenderLCDText(SunGraphics2D sg2d) {
|
||||
return
|
||||
graphicsDevice.isCapPresent(CAPS_LCD_SHADER) &&
|
||||
sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY &&
|
||||
sg2d.paintState <= SunGraphics2D.PAINT_OPAQUECOLOR;
|
||||
sg2d.paintState <= SunGraphics2D.PAINT_OPAQUECOLOR &&
|
||||
sg2d.surfaceData.getTransparency() == Transparency.OPAQUE;
|
||||
}
|
||||
|
||||
public void validatePipe(SunGraphics2D sg2d) {
|
||||
|
@ -127,12 +127,14 @@ public class WGLGraphicsConfig
|
||||
new WGLGetConfigInfo(device.getScreen(), pixfmt);
|
||||
rq.flushAndInvokeNow(action);
|
||||
cfginfo = action.getConfigInfo();
|
||||
OGLContext.setScratchSurface(cfginfo);
|
||||
rq.flushAndInvokeNow(new Runnable() {
|
||||
public void run() {
|
||||
ids[0] = OGLContext.getOGLIdString();
|
||||
}
|
||||
});
|
||||
if (cfginfo != 0L) {
|
||||
OGLContext.setScratchSurface(cfginfo);
|
||||
rq.flushAndInvokeNow(new Runnable() {
|
||||
public void run() {
|
||||
ids[0] = OGLContext.getOGLIdString();
|
||||
}
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
rq.unlock();
|
||||
}
|
||||
|
@ -153,7 +153,8 @@ static int CALLBACK EnumFontFacesInFamilyProcA(
|
||||
JNIEnv *env = fmi->env;
|
||||
jstring fullname, fullnameLC;
|
||||
|
||||
if (FontType != TRUETYPE_FONTTYPE) {
|
||||
/* Both Vista and XP return DEVICE_FONTTYPE for OTF fonts */
|
||||
if (FontType != TRUETYPE_FONTTYPE && FontType != DEVICE_FONTTYPE) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -227,7 +228,8 @@ static int CALLBACK EnumFontFacesInFamilyProcW(
|
||||
JNIEnv *env = fmi->env;
|
||||
jstring fullname, fullnameLC;
|
||||
|
||||
if (FontType != TRUETYPE_FONTTYPE) {
|
||||
/* Both Vista and XP return DEVICE_FONTTYPE for OTF fonts */
|
||||
if (FontType != TRUETYPE_FONTTYPE && FontType != DEVICE_FONTTYPE) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -274,7 +276,8 @@ static int CALLBACK EnumFamilyNamesA(
|
||||
jstring familyLC;
|
||||
LOGFONTA lfa;
|
||||
|
||||
if (FontType != TRUETYPE_FONTTYPE) {
|
||||
/* Both Vista and XP return DEVICE_FONTTYPE for OTF fonts */
|
||||
if (FontType != TRUETYPE_FONTTYPE && FontType != DEVICE_FONTTYPE) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -323,7 +326,8 @@ static int CALLBACK EnumFamilyNamesW(
|
||||
int slen;
|
||||
LOGFONTW lfw;
|
||||
|
||||
if (FontType != TRUETYPE_FONTTYPE) {
|
||||
/* Both Vista and XP return DEVICE_FONTTYPE for OTF fonts */
|
||||
if (FontType != TRUETYPE_FONTTYPE && FontType != DEVICE_FONTTYPE) {
|
||||
return 1;
|
||||
}
|
||||
/* wprintf(L"FAMILY=%s charset=%d FULL=%s\n", */
|
||||
@ -383,15 +387,16 @@ static int CALLBACK EnumFamilyNamesW(
|
||||
* Also if a Font has a name for this locale that name also
|
||||
* exists in the registry using the appropriate platform encoding.
|
||||
* What do we do then?
|
||||
*
|
||||
* Note: OpenType fonts seems to have " (TrueType)" suffix on Vista
|
||||
* but " (OpenType)" on XP.
|
||||
*/
|
||||
|
||||
/* static const wchar_t W_TTSUFFIX[] = L" (TrueType)"; */
|
||||
/* static const char C_TTSUFFIX[] = " (TrueType)"; */
|
||||
/* static int TTSLEN = 11; hard-coded - be careful */
|
||||
static BOOL RegistryToBaseTTNameA(LPCSTR name) {
|
||||
static BOOL RegistryToBaseTTNameA(LPSTR name) {
|
||||
static const char TTSUFFIX[] = " (TrueType)";
|
||||
static const char OTSUFFIX[] = " (OpenType)";
|
||||
int TTSLEN = strlen(TTSUFFIX);
|
||||
char *match;
|
||||
char *suffix;
|
||||
|
||||
int len = strlen(name);
|
||||
if (len == 0) {
|
||||
@ -403,19 +408,21 @@ static BOOL RegistryToBaseTTNameA(LPCSTR name) {
|
||||
if (len <= TTSLEN) {
|
||||
return FALSE;
|
||||
}
|
||||
match = strstr(name, TTSUFFIX);
|
||||
if ((match != NULL) && (match == name+(len-TTSLEN))) {
|
||||
match[0] = '\0'; /* truncate name */
|
||||
|
||||
/* suffix length is the same for truetype and opentype fonts */
|
||||
suffix = name + len - TTSLEN;
|
||||
if (strcmp(suffix, TTSUFFIX) == 0 || strcmp(suffix, OTSUFFIX) == 0) {
|
||||
suffix[0] = '\0'; /* truncate name */
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static BOOL RegistryToBaseTTNameW(LPWSTR name) {
|
||||
static const wchar_t TTSUFFIX[] = L" (TrueType)";
|
||||
static const wchar_t OTSUFFIX[] = L" (OpenType)";
|
||||
int TTSLEN = wcslen(TTSUFFIX);
|
||||
wchar_t *match;
|
||||
wchar_t *suffix;
|
||||
|
||||
int len = wcslen(name);
|
||||
if (len == 0) {
|
||||
@ -427,13 +434,13 @@ static BOOL RegistryToBaseTTNameW(LPWSTR name) {
|
||||
if (len <= TTSLEN) {
|
||||
return FALSE;
|
||||
}
|
||||
match = wcsstr(name, TTSUFFIX);
|
||||
if ((match != NULL) && (match == name+(len-TTSLEN))) {
|
||||
match[0] = L'\0'; /* truncate name */
|
||||
/* suffix length is the same for truetype and opentype fonts */
|
||||
suffix = name + (len - TTSLEN);
|
||||
if (wcscmp(suffix, TTSUFFIX) == 0 || wcscmp(suffix, OTSUFFIX) == 0) {
|
||||
suffix[0] = L'\0'; /* truncate name */
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void registerFontA(GdiFontMapInfo *fmi, jobject fontToFileMap,
|
||||
@ -675,18 +682,19 @@ Java_sun_font_FontManager_populateFontFileNameMap
|
||||
}
|
||||
if (IS_NT) {
|
||||
if (!RegistryToBaseTTNameW((LPWSTR)wname) ) {
|
||||
/* If the filename ends with ".ttf" also accept it.
|
||||
/* If the filename ends with ".ttf" or ".otf" also accept it.
|
||||
* Not expecting to need to do this for .ttc files.
|
||||
* Also note this code is not mirrored in the "A" (win9x) path.
|
||||
*/
|
||||
LPWSTR dot = wcsrchr((LPWSTR)data, L'.');
|
||||
if (dot == NULL || (wcsicmp(dot, L".ttf") != 0)) {
|
||||
if (dot == NULL || ((wcsicmp(dot, L".ttf") != 0)
|
||||
&& (wcsicmp(dot, L".otf") != 0))) {
|
||||
continue; /* not a TT font... */
|
||||
}
|
||||
}
|
||||
registerFontW(&fmi, fontToFileMap, (LPWSTR)wname, (LPWSTR)data);
|
||||
} else {
|
||||
if (!RegistryToBaseTTNameA(cname) ) {
|
||||
if (!RegistryToBaseTTNameA((LPSTR)cname)) {
|
||||
continue; /* not a TT font... */
|
||||
}
|
||||
registerFontA(&fmi, fontToFileMap, cname, (LPCSTR)data);
|
||||
|
@ -85,6 +85,19 @@ static const ADAPTER_INFO badHardware[] = {
|
||||
{ 0x1002, 0x71C5, D_VERSION(6,14,10,6706), OS_WINXP },
|
||||
{ 0x1002, 0x71C5, D_VERSION(7,14,10,0567), OS_VISTA },
|
||||
|
||||
// ATI Mobility Radeon 9700
|
||||
// Reason: workaround for 6773336
|
||||
{ 0x1002, 0x4E50, D_VERSION(6,14,10,6561), OS_WINXP },
|
||||
|
||||
// Nvidia FX 5200
|
||||
// Reason: workaround for 6717988
|
||||
{ 0x10DE, 0x0322, D_VERSION(6,14,11,6921), OS_WINXP },
|
||||
|
||||
// Nvidia FX Go5600, Go5700
|
||||
// Reason: workaround for 6714579
|
||||
{ 0x10DE, 0x031A, D_VERSION(6,14,11,6921), OS_WINXP },
|
||||
{ 0x10DE, 0x0347, D_VERSION(6,14,11,6921), OS_WINXP },
|
||||
|
||||
// Nvidia Quadro NVS 110M
|
||||
// Reason: workaround for 6629891
|
||||
{ 0x10DE, 0x01D7, D_VERSION(6,14,11,5665), OS_WINXP },
|
||||
@ -93,6 +106,32 @@ static const ADAPTER_INFO badHardware[] = {
|
||||
// Reason: workaround for 6653860
|
||||
{ 0x10DE, 0x00FD, D_VERSION(6,14,10,6573), OS_WINXP },
|
||||
|
||||
// Nvidia Quadro FX family
|
||||
// Reason: workaround for 6772137
|
||||
{ 0x10DE, 0x00F8, D_VERSION(6,14,10,9381), OS_WINXP },
|
||||
{ 0x10DE, 0x009D, D_VERSION(6,14,10,9381), OS_WINXP },
|
||||
{ 0x10DE, 0x029C, D_VERSION(6,14,10,9381), OS_WINXP },
|
||||
{ 0x10DE, 0x029D, D_VERSION(6,14,10,9381), OS_WINXP },
|
||||
{ 0x10DE, 0x029E, D_VERSION(6,14,10,9381), OS_WINXP },
|
||||
{ 0x10DE, 0x029F, D_VERSION(6,14,10,9381), OS_WINXP },
|
||||
{ 0x10DE, 0x01DE, D_VERSION(6,14,10,9381), OS_WINXP },
|
||||
{ 0x10DE, 0x039E, D_VERSION(6,14,10,9381), OS_WINXP },
|
||||
{ 0x10DE, 0x019D, D_VERSION(6,14,10,9381), OS_WINXP },
|
||||
{ 0x10DE, 0x019E, D_VERSION(6,14,10,9381), OS_WINXP },
|
||||
{ 0x10DE, 0x040A, D_VERSION(6,14,10,9381), OS_WINXP },
|
||||
{ 0x10DE, 0x040E, D_VERSION(6,14,10,9381), OS_WINXP },
|
||||
{ 0x10DE, 0x040F, D_VERSION(6,14,10,9381), OS_WINXP },
|
||||
{ 0x10DE, 0x061A, D_VERSION(6,14,10,9381), OS_WINXP },
|
||||
{ 0x10DE, 0x06F9, D_VERSION(6,14,10,9381), OS_WINXP },
|
||||
{ 0x10DE, 0x05FD, D_VERSION(6,14,10,9381), OS_WINXP },
|
||||
{ 0x10DE, 0x05FE, D_VERSION(6,14,10,9381), OS_WINXP },
|
||||
{ 0x10DE, 0x004E, D_VERSION(6,14,10,9381), OS_WINXP },
|
||||
{ 0x10DE, 0x00CD, D_VERSION(6,14,10,9381), OS_WINXP },
|
||||
{ 0x10DE, 0x00CE, D_VERSION(6,14,10,9381), OS_WINXP },
|
||||
{ 0x10DE, 0x014C, D_VERSION(6,14,10,9381), OS_WINXP },
|
||||
{ 0x10DE, 0x014D, D_VERSION(6,14,10,9381), OS_WINXP },
|
||||
{ 0x10DE, 0x014E, D_VERSION(6,14,10,9381), OS_WINXP },
|
||||
|
||||
// Nvidia GeForce 6200 TurboCache(TM)
|
||||
// Reason: workaround for 6588384
|
||||
{ 0x10DE, 0x0161, NO_VERSION, OS_VISTA },
|
||||
|
@ -47,6 +47,7 @@ extern "C" BlitFunc IntArgbToIntArgbPreConvert;
|
||||
extern "C" BlitFunc IntArgbPreToIntArgbConvert;
|
||||
extern "C" BlitFunc IntArgbBmToIntArgbConvert;
|
||||
extern "C" BlitFunc IntRgbToIntArgbConvert;
|
||||
extern "C" BlitFunc ThreeByteBgrToIntArgbConvert;
|
||||
extern "C" BlitFunc Ushort565RgbToIntArgbConvert;
|
||||
extern "C" BlitFunc Ushort555RgbToIntArgbConvert;
|
||||
extern "C" BlitFunc IntBgrToIntArgbConvert;
|
||||
@ -220,12 +221,17 @@ D3DBL_CopyImageToIntXrgbSurface(SurfaceDataRasInfo *pSrcInfo,
|
||||
" srctype=%d rect={%-4d, %-4d, %-4d, %-4d}",
|
||||
srctype, r.left, r.top, r.right, r.bottom);
|
||||
|
||||
if (pDesc->Usage == D3DUSAGE_DYNAMIC &&
|
||||
dstx == 0 && dstx == 0 &&
|
||||
srcWidth == pDesc->Width && srcHeight == pDesc->Height)
|
||||
{
|
||||
if (pDesc->Usage == D3DUSAGE_DYNAMIC) {
|
||||
// it is safe to lock with discard because we don't care about the
|
||||
// contents of dynamic textures, and some drivers are happier if
|
||||
// dynamic textures are always locked with DISCARD
|
||||
dwLockFlags |= D3DLOCK_DISCARD;
|
||||
pR = NULL;
|
||||
} else {
|
||||
// in non-DYNAMIC case we lock the exact rect so there's no need to
|
||||
// offset the destination pointer
|
||||
dstx = 0;
|
||||
dsty = 0;
|
||||
}
|
||||
|
||||
res = pDstSurface->LockRect(&lockedRect, pR, dwLockFlags);
|
||||
@ -242,7 +248,9 @@ D3DBL_CopyImageToIntXrgbSurface(SurfaceDataRasInfo *pSrcInfo,
|
||||
void *pSrcBase = PtrCoord(pSrcInfo->rasBase,
|
||||
srcx, pSrcInfo->pixelStride,
|
||||
srcy, pSrcInfo->scanStride);
|
||||
void *pDstBase = lockedRect.pBits;
|
||||
void *pDstBase = PtrCoord(lockedRect.pBits,
|
||||
dstx, dstInfo.pixelStride,
|
||||
dsty, dstInfo.scanStride);
|
||||
|
||||
switch (srctype) {
|
||||
case ST_INT_ARGB:
|
||||
@ -251,11 +259,15 @@ D3DBL_CopyImageToIntXrgbSurface(SurfaceDataRasInfo *pSrcInfo,
|
||||
pSrcInfo, &dstInfo, NULL, NULL);
|
||||
break;
|
||||
case ST_INT_ARGB_PRE:
|
||||
case ST_INT_RGB:
|
||||
AnyIntIsomorphicCopy(pSrcBase, pDstBase,
|
||||
srcWidth, srcHeight,
|
||||
pSrcInfo, &dstInfo, NULL, NULL);
|
||||
break;
|
||||
case ST_INT_RGB:
|
||||
IntRgbToIntArgbConvert(pSrcBase, pDstBase,
|
||||
srcWidth, srcHeight,
|
||||
pSrcInfo, &dstInfo, NULL, NULL);
|
||||
break;
|
||||
case ST_INT_ARGB_BM:
|
||||
// REMIND: we don't have such sw loop
|
||||
// so this path is disabled for now on java level
|
||||
@ -268,6 +280,11 @@ D3DBL_CopyImageToIntXrgbSurface(SurfaceDataRasInfo *pSrcInfo,
|
||||
srcWidth, srcHeight,
|
||||
pSrcInfo, &dstInfo, NULL, NULL);
|
||||
break;
|
||||
case ST_3BYTE_BGR:
|
||||
ThreeByteBgrToIntArgbConvert(pSrcBase, pDstBase,
|
||||
srcWidth, srcHeight,
|
||||
pSrcInfo, &dstInfo, NULL, NULL);
|
||||
break;
|
||||
case ST_USHORT_555_RGB:
|
||||
Ushort555RgbToIntArgbConvert(pSrcBase, pDstBase,
|
||||
srcWidth, srcHeight,
|
||||
|
@ -1174,11 +1174,10 @@ D3DContext::UploadTileToTexture(D3DResource *pTextureRes, void *pixels,
|
||||
" rect={%-4d, %-4d, %-4d, %-4d}",
|
||||
r.left, r.top, r.right, r.bottom);
|
||||
|
||||
// REMIND: we should also check for dstx, dsty being 0 here,
|
||||
// but they're always 0 in dynamic texture case
|
||||
if (pDesc->Usage == D3DUSAGE_DYNAMIC &&
|
||||
srcWidth == pDesc->Width && srcHeight == pDesc->Height)
|
||||
{
|
||||
if (pDesc->Usage == D3DUSAGE_DYNAMIC) {
|
||||
// it is safe to lock with discard because we don't care about the
|
||||
// contents of dynamic textures and dstx,dsty for this case is
|
||||
// always 0,0 because we are uploading into a tile texture
|
||||
dwLockFlags |= D3DLOCK_DISCARD;
|
||||
pR = NULL;
|
||||
}
|
||||
|
@ -68,6 +68,7 @@ struct _D3DSDOps {
|
||||
#define ST_USHORT_555_RGB sun_java2d_d3d_D3DSurfaceData_ST_USHORT_555_RGB
|
||||
#define ST_BYTE_INDEXED sun_java2d_d3d_D3DSurfaceData_ST_BYTE_INDEXED
|
||||
#define ST_BYTE_INDEXED_BM sun_java2d_d3d_D3DSurfaceData_ST_BYTE_INDEXED_BM
|
||||
#define ST_3BYTE_BGR sun_java2d_d3d_D3DSurfaceData_ST_3BYTE_BGR
|
||||
|
||||
/**
|
||||
* These are defined to be the same as ExtendedBufferCapabilities.VSyncType
|
||||
|
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright 2006-2008 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.awt.DisplayMode;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Frame;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
/**
|
||||
* Used by the UninitializedDisplayModeChangeTest to change the
|
||||
* display mode.
|
||||
*/
|
||||
public class DisplayModeChanger {
|
||||
|
||||
public static void main(String[] args)
|
||||
throws InterruptedException, InvocationTargetException
|
||||
{
|
||||
final GraphicsDevice gd =
|
||||
GraphicsEnvironment.getLocalGraphicsEnvironment().
|
||||
getDefaultScreenDevice();
|
||||
|
||||
EventQueue.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
Frame f = null;
|
||||
if (gd.isFullScreenSupported()) {
|
||||
try {
|
||||
f = new Frame("DisplayChanger Frame");
|
||||
gd.setFullScreenWindow(f);
|
||||
if (gd.isDisplayChangeSupported()) {
|
||||
DisplayMode dm = findDisplayMode(gd);
|
||||
if (gd != null) {
|
||||
gd.setDisplayMode(dm);
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
gd.setFullScreenWindow(null);
|
||||
} finally {
|
||||
if (f != null) {
|
||||
f.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a display mode that is different from the current display
|
||||
* mode and is likely to cause a display change event.
|
||||
*/
|
||||
private static DisplayMode findDisplayMode(GraphicsDevice gd) {
|
||||
DisplayMode dms[] = gd.getDisplayModes();
|
||||
DisplayMode currentDM = gd.getDisplayMode();
|
||||
for (DisplayMode dm : dms) {
|
||||
if (!dm.equals(currentDM) &&
|
||||
dm.getRefreshRate() == currentDM.getRefreshRate())
|
||||
{
|
||||
// different from the current dm and refresh rate is the same
|
||||
// means that something else is different => more likely to
|
||||
// cause a DM change event
|
||||
return dm;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
98
jdk/test/java/awt/font/TextLayout/DecorationBoundsTest.java
Normal file
98
jdk/test/java/awt/font/TextLayout/DecorationBoundsTest.java
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright 2008 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @summary verify bounds enclose rendering of decorations.
|
||||
* @bug 6751621
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.font.*;
|
||||
import java.awt.geom.*;
|
||||
import java.awt.image.*;
|
||||
import java.util.*;
|
||||
|
||||
public class DecorationBoundsTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
BufferedImage bi =
|
||||
new BufferedImage(600, 300, BufferedImage.TYPE_INT_RGB);
|
||||
Graphics2D g2d = bi.createGraphics();
|
||||
g2d.setColor(Color.white);
|
||||
g2d.fillRect(0, 0, 600, 300);
|
||||
|
||||
float x = 10;
|
||||
float y = 90;
|
||||
Map map = new HashMap();
|
||||
map.put(TextAttribute.STRIKETHROUGH,
|
||||
TextAttribute.STRIKETHROUGH_ON);
|
||||
map.put(TextAttribute.SIZE, new Float(80));
|
||||
|
||||
FontRenderContext frc = g2d.getFontRenderContext();
|
||||
|
||||
String text = "Welcome to ";
|
||||
TextLayout tl = new TextLayout(text, map, frc);
|
||||
g2d.translate(x, y);
|
||||
g2d.setColor(Color.RED);
|
||||
tl.draw(g2d, 0, 0);
|
||||
g2d.setColor(Color.GREEN);
|
||||
Rectangle2D bds = tl.getBounds();
|
||||
/* Since due to pixelisation the glyphs may touch above
|
||||
* or below the theoretical outline bounds, pad in the
|
||||
* y direction to avoid spurious failures.
|
||||
*/
|
||||
bds.setRect(bds.getX(), bds.getY()-1,
|
||||
bds.getWidth(), bds.getHeight()+2);
|
||||
g2d.fill(bds);
|
||||
|
||||
map = new HashMap();
|
||||
map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
|
||||
map.put(TextAttribute.SIZE, new Float(80));
|
||||
tl = new TextLayout(text, map, frc);
|
||||
g2d.translate(0, 100);
|
||||
g2d.setColor(Color.RED);
|
||||
tl.draw(g2d, 0, 0);
|
||||
|
||||
g2d.setColor(Color.GREEN);
|
||||
bds = tl.getBounds();
|
||||
bds.setRect(bds.getX(), bds.getY()-1,
|
||||
bds.getWidth(), bds.getHeight()+2);
|
||||
g2d.fill(bds);
|
||||
|
||||
checkBI(bi, Color.RED);
|
||||
}
|
||||
|
||||
static void checkBI(BufferedImage bi, Color badColor) {
|
||||
int badrgb = badColor.getRGB();
|
||||
int w = bi.getWidth(null);
|
||||
int h = bi.getHeight(null);
|
||||
for (int x=0; x<w; x++) {
|
||||
for (int y=0; y<h; y++) {
|
||||
int col = bi.getRGB(x, y);
|
||||
if (col == badrgb) {
|
||||
throw new RuntimeException("Got " + col);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
/* @test
|
||||
* @summary verify TextLayout.getBounds() return visual bounds
|
||||
* @bug 6323611
|
||||
* @bug 6323611 6761856
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
@ -39,10 +39,15 @@ public class TextLayoutBounds {
|
||||
Rectangle2D tlBounds = tl.getBounds();
|
||||
GlyphVector gv = f.createGlyphVector(frc, s);
|
||||
Rectangle2D gvvBounds = gv.getVisualBounds();
|
||||
Rectangle2D oBounds = tl.getOutline(null).getBounds2D();
|
||||
System.out.println("tlbounds="+tlBounds);
|
||||
System.out.println("gvbounds="+gvvBounds);
|
||||
System.out.println("outlineBounds="+oBounds);
|
||||
if (!gvvBounds.equals(tlBounds)) {
|
||||
throw new RuntimeException("Bounds differ");
|
||||
throw new RuntimeException("Bounds differ [gvv != tl]");
|
||||
}
|
||||
if (!tlBounds.equals(oBounds)) {
|
||||
throw new RuntimeException("Bounds differ [tl != outline]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
88
jdk/test/java/awt/font/TextLayout/UnderlinePositionTest.java
Normal file
88
jdk/test/java/awt/font/TextLayout/UnderlinePositionTest.java
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright 2008 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @summary verify outline and stroking of underline match.
|
||||
* @bug 6751616
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.font.*;
|
||||
import java.awt.geom.*;
|
||||
import java.awt.image.*;
|
||||
import java.util.*;
|
||||
|
||||
public class UnderlinePositionTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
BufferedImage bi =
|
||||
new BufferedImage(600, 150, BufferedImage.TYPE_INT_RGB);
|
||||
Graphics2D g2d = bi.createGraphics();
|
||||
g2d.setColor(Color.white);
|
||||
g2d.fillRect(0, 0, 600, 150);
|
||||
|
||||
float x = 10;
|
||||
float y = 90;
|
||||
Map map = new HashMap();
|
||||
map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
|
||||
map.put(TextAttribute.SIZE, new Float(80));
|
||||
|
||||
FontRenderContext frc = g2d.getFontRenderContext();
|
||||
|
||||
// Use all spaces for the text so we know we are dealing
|
||||
// only with pixels from the underline.
|
||||
String text = " ";
|
||||
TextLayout tl = new TextLayout(text, map, frc);
|
||||
Shape outline = tl.getOutline(null);
|
||||
Rectangle2D bounds = outline.getBounds();
|
||||
|
||||
g2d.translate(x, y);
|
||||
g2d.setColor(Color.RED);
|
||||
tl.draw(g2d, 0, 0);
|
||||
|
||||
/* By getting the outline, then its bounds, then filling
|
||||
* according to the same pixelisation rules, this ought to
|
||||
* match the position of the original underline. If any
|
||||
* red pixels are left, then the test will fail.
|
||||
*/
|
||||
g2d.setColor(Color.BLUE);
|
||||
g2d.fill(bounds);
|
||||
g2d.dispose();
|
||||
|
||||
checkBI(bi, Color.RED);
|
||||
}
|
||||
|
||||
static void checkBI(BufferedImage bi, Color badColor) {
|
||||
int badrgb = badColor.getRGB();
|
||||
int w = bi.getWidth(null);
|
||||
int h = bi.getHeight(null);
|
||||
for (int x=0; x<w; x++) {
|
||||
for (int y=0; y<h; y++) {
|
||||
int col = bi.getRGB(x, y);
|
||||
if (col == badrgb) {
|
||||
throw new RuntimeException("Got " + col);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
46
jdk/test/java/awt/print/PrinterJob/GetMediasTest.java
Normal file
46
jdk/test/java/awt/print/PrinterJob/GetMediasTest.java
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2008 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 6653384
|
||||
* @summary No exception should be thrown.
|
||||
* @run main GetMediasTest
|
||||
*/
|
||||
import javax.print.PrintService;
|
||||
import javax.print.PrintServiceLookup;
|
||||
import javax.print.attribute.standard.Media;
|
||||
|
||||
public class GetMediasTest {
|
||||
public static void main(String[] args) {
|
||||
PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
|
||||
for(final PrintService service: services) {
|
||||
Thread thread = new Thread() {
|
||||
public void run() {
|
||||
service.getSupportedAttributeValues(Media.class, null, null);
|
||||
}
|
||||
};
|
||||
thread.start();
|
||||
}
|
||||
}
|
||||
}
|
236
jdk/test/javax/imageio/plugins/png/ITXtTest.java
Normal file
236
jdk/test/javax/imageio/plugins/png/ITXtTest.java
Normal file
@ -0,0 +1,236 @@
|
||||
/*
|
||||
* Copyright 2008 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 6541476
|
||||
* @summary Test verifies that ImageIO PNG plugin correcly handles the
|
||||
* iTxt chunk (International textual data).
|
||||
*
|
||||
* @run main ITXtTest
|
||||
*/
|
||||
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.imageio.ImageReader;
|
||||
import javax.imageio.IIOImage;
|
||||
import javax.imageio.ImageTypeSpecifier;
|
||||
import javax.imageio.ImageWriter;
|
||||
import javax.imageio.metadata.IIOMetadata;
|
||||
import javax.imageio.metadata.IIOMetadataNode;
|
||||
import javax.imageio.stream.ImageOutputStream;
|
||||
import javax.imageio.stream.ImageInputStream;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
public class ITXtTest {
|
||||
static public void main(String args[]) {
|
||||
ITXtTest t_en = new ITXtTest();
|
||||
t_en.description = "xml - en";
|
||||
t_en.keyword = "XML:com.adobe.xmp";
|
||||
t_en.isCompressed = false;
|
||||
t_en.compression = 0;
|
||||
t_en.language = "en";
|
||||
t_en.trasKeyword = "XML:com.adobe.xmp";
|
||||
t_en.text = "<xml>Something</xml>";
|
||||
|
||||
doTest(t_en);
|
||||
|
||||
// check compression case
|
||||
t_en.isCompressed = true;
|
||||
t_en.description = "xml - en - compressed";
|
||||
|
||||
doTest(t_en);
|
||||
|
||||
ITXtTest t_ru = new ITXtTest();
|
||||
t_ru.description = "xml - ru";
|
||||
t_ru.keyword = "XML:com.adobe.xmp";
|
||||
t_ru.isCompressed = false;
|
||||
t_ru.compression = 0;
|
||||
t_ru.language = "ru";
|
||||
t_ru.trasKeyword = "\u0410\u0410\u0410\u0410\u0410 XML";
|
||||
t_ru.text = "<xml>\u042A\u042F\u042F\u042F\u042F\u042F\u042F</xml>";
|
||||
|
||||
doTest(t_ru);
|
||||
|
||||
t_ru.isCompressed = true;
|
||||
t_ru.description = "xml - ru - compressed";
|
||||
|
||||
doTest(t_ru);
|
||||
}
|
||||
|
||||
|
||||
String description;
|
||||
|
||||
String keyword;
|
||||
boolean isCompressed;
|
||||
int compression;
|
||||
String language;
|
||||
String trasKeyword;
|
||||
String text;
|
||||
|
||||
|
||||
public IIOMetadataNode getNode() {
|
||||
IIOMetadataNode iTXt = new IIOMetadataNode("iTXt");
|
||||
IIOMetadataNode iTXtEntry = new IIOMetadataNode("iTXtEntry");
|
||||
iTXtEntry.setAttribute("keyword", keyword);
|
||||
iTXtEntry.setAttribute("compressionFlag",
|
||||
isCompressed ? "true" : "false");
|
||||
iTXtEntry.setAttribute("compressionMethod",
|
||||
Integer.toString(compression));
|
||||
iTXtEntry.setAttribute("languageTag", language);
|
||||
iTXtEntry.setAttribute("translatedKeyword",
|
||||
trasKeyword);
|
||||
iTXtEntry.setAttribute("text", text);
|
||||
iTXt.appendChild(iTXtEntry);
|
||||
return iTXt;
|
||||
}
|
||||
|
||||
public static ITXtTest getFromNode(IIOMetadataNode n) {
|
||||
ITXtTest t = new ITXtTest();
|
||||
|
||||
if (!"iTXt".equals(n.getNodeName())) {
|
||||
throw new RuntimeException("Invalid node");
|
||||
}
|
||||
IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
|
||||
if (!"iTXtEntry".equals(e.getNodeName())) {
|
||||
throw new RuntimeException("Invalid entry node");
|
||||
}
|
||||
t.keyword = e.getAttribute("keyword");
|
||||
t.isCompressed =
|
||||
(Integer.valueOf(e.getAttribute("compressionFlag")).intValue() == 1);
|
||||
t.compression =
|
||||
Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
|
||||
t.language = e.getAttribute("languageTag");
|
||||
t.trasKeyword = e.getAttribute("translatedKeyword");
|
||||
t.text = e.getAttribute("text");
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (! (o instanceof ITXtTest)) {
|
||||
return false;
|
||||
}
|
||||
ITXtTest t = (ITXtTest)o;
|
||||
if (!keyword.equals(t.keyword)) { return false; }
|
||||
if (isCompressed != t.isCompressed) { return false; }
|
||||
if (compression != t.compression) { return false; }
|
||||
if (!language.equals(t.language)) { return false; }
|
||||
if (!trasKeyword.equals(t.trasKeyword)) { return false; }
|
||||
if (!text.equals(t.text)) { return false; }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static void doTest(ITXtTest src) {
|
||||
|
||||
System.out.println("Test: " + src.description);
|
||||
|
||||
File file = new File("test.png");
|
||||
|
||||
writeTo(file, src);
|
||||
ITXtTest dst = readFrom(file);
|
||||
|
||||
if (dst == null || !dst.equals(src)) {
|
||||
throw new RuntimeException("Test failed.");
|
||||
}
|
||||
|
||||
System.out.println("Test passed.");
|
||||
}
|
||||
|
||||
private static void writeTo(File f, ITXtTest t) {
|
||||
BufferedImage src = createBufferedImage();
|
||||
try {
|
||||
ImageOutputStream imageOutputStream =
|
||||
ImageIO.createImageOutputStream(f);
|
||||
|
||||
ImageTypeSpecifier imageTypeSpecifier =
|
||||
new ImageTypeSpecifier(src);
|
||||
ImageWriter imageWriter =
|
||||
ImageIO.getImageWritersByFormatName("PNG").next();
|
||||
|
||||
imageWriter.setOutput(imageOutputStream);
|
||||
|
||||
IIOMetadata m =
|
||||
imageWriter.getDefaultImageMetadata(imageTypeSpecifier, null);
|
||||
|
||||
String format = m.getNativeMetadataFormatName();
|
||||
Node root = m.getAsTree(format);
|
||||
|
||||
IIOMetadataNode iTXt = t.getNode();
|
||||
root.appendChild(iTXt);
|
||||
m.setFromTree(format, root);
|
||||
|
||||
imageWriter.write(new IIOImage(src, null, m));
|
||||
imageOutputStream.close();
|
||||
System.out.println("Writing done.");
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException("Writing test failed.", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static ITXtTest readFrom(File f) {
|
||||
try {
|
||||
ImageInputStream iis = ImageIO.createImageInputStream(f);
|
||||
ImageReader r = ImageIO.getImageReaders(iis).next();
|
||||
r.setInput(iis);
|
||||
|
||||
IIOImage dst = r.readAll(0, null);
|
||||
|
||||
// look for iTXt node
|
||||
IIOMetadata m = dst.getMetadata();
|
||||
Node root = m.getAsTree(m.getNativeMetadataFormatName());
|
||||
Node n = root.getFirstChild();
|
||||
while (n != null && !"iTXt".equals(n.getNodeName())) {
|
||||
n = n.getNextSibling();
|
||||
}
|
||||
if (n == null) {
|
||||
throw new RuntimeException("No iTXt node!");
|
||||
}
|
||||
ITXtTest t = ITXtTest.getFromNode((IIOMetadataNode)n);
|
||||
return t;
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException("Reading test failed.", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static BufferedImage createBufferedImage() {
|
||||
BufferedImage image = new BufferedImage(128, 128,
|
||||
BufferedImage.TYPE_4BYTE_ABGR_PRE);
|
||||
Graphics2D graph = image.createGraphics();
|
||||
graph.setPaintMode();
|
||||
graph.setColor(Color.orange);
|
||||
graph.fillRect(32, 32, 64, 64);
|
||||
graph.dispose();
|
||||
return image;
|
||||
}
|
||||
}
|
67
jdk/test/javax/print/CheckDupFlavor.java
Normal file
67
jdk/test/javax/print/CheckDupFlavor.java
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2004-2008 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4996318 6731937
|
||||
* @summary There should be no duplicates returned by getSupportedDocFlavors.
|
||||
* @run main CheckDupFlavor
|
||||
*/
|
||||
import javax.print.*;
|
||||
import javax.print.attribute.*;
|
||||
import javax.print.attribute.standard.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public class CheckDupFlavor {
|
||||
public static void main(String[] args){
|
||||
PrintService pservice =
|
||||
PrintServiceLookup.lookupDefaultPrintService();
|
||||
|
||||
if (pservice == null) {
|
||||
System.out.println("No default PrintService found. Test ABORTED.");
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println("Default service = "+pservice);
|
||||
|
||||
DocFlavor[] flavors = pservice.getSupportedDocFlavors();
|
||||
if (flavors==null) {
|
||||
System.out.println("No flavors supported. Test PASSED.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ArrayList flavorList = new ArrayList();
|
||||
for (int i=0; i<flavors.length; i++) {
|
||||
if (flavors[i] == null) {
|
||||
throw new RuntimeException("Null flavor. Test FAILED.");
|
||||
} else if (flavorList.contains(flavors[i])) {
|
||||
throw new RuntimeException("\n\tDuplicate flavor found : "+flavors[i]+" : Test FAILED.");
|
||||
} else {
|
||||
flavorList.add(flavors[i]);
|
||||
}
|
||||
}
|
||||
System.out.println("No duplicate found. Test PASSED.");
|
||||
}
|
||||
}
|
53
jdk/test/javax/print/TestRaceCond.java
Normal file
53
jdk/test/javax/print/TestRaceCond.java
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2008 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6731826
|
||||
* @summary There should be no RuntimeException.
|
||||
* @run main TestRaceCond
|
||||
*/
|
||||
|
||||
import javax.print.PrintService;
|
||||
import javax.print.PrintServiceLookup;
|
||||
|
||||
|
||||
public class TestRaceCond {
|
||||
|
||||
public static void main(String argv[]) {
|
||||
trial();
|
||||
}
|
||||
|
||||
static void trial() {
|
||||
PrintService pserv1 = PrintServiceLookup.lookupDefaultPrintService();
|
||||
PrintService[] pservs = PrintServiceLookup.lookupPrintServices(null, null);
|
||||
PrintService pserv2 = PrintServiceLookup.lookupDefaultPrintService();
|
||||
|
||||
if (pserv1.hashCode() != pserv2.hashCode()) {
|
||||
throw new RuntimeException("Different hashCodes for equal print "
|
||||
+ "services: " + pserv1.hashCode() + " "
|
||||
+ pserv2.hashCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 6527316
|
||||
* @bug 6527316 6732647
|
||||
* @summary Copies isn't supported for PS flavors.
|
||||
* @run main PSCopiesFlavorTest
|
||||
*/
|
||||
@ -50,5 +50,13 @@ public class PSCopiesFlavorTest {
|
||||
if (suppVal || us == null) {
|
||||
throw new RuntimeException("Copies should be unsupported value");
|
||||
}
|
||||
|
||||
Object value = ps.getSupportedAttributeValues(Copies.class, flavor, null);
|
||||
|
||||
//Copies Supported
|
||||
if(value instanceof CopiesSupported) {
|
||||
throw new RuntimeException("Copies should have no supported values.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,212 @@
|
||||
/*
|
||||
* Copyright 2008 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6728834 6749060
|
||||
* @summary Tests that LCD AA text rendering works properly with destinations
|
||||
* being VolatileImage of all transparency types
|
||||
* @author Dmitri.Trembovetski: area=Graphics
|
||||
* @run main/manual/othervm -Dsun.java2d.d3d=false NonOpaqueDestLCDAATest
|
||||
* @run main/manual/othervm NonOpaqueDestLCDAATest
|
||||
* @run main/manual/othervm -Dsun.java2d.opengl=True NonOpaqueDestLCDAATest
|
||||
*/
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.Image;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.VolatileImage;
|
||||
import java.io.File;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextArea;
|
||||
import static java.awt.Transparency.*;
|
||||
|
||||
public class NonOpaqueDestLCDAATest extends JFrame implements ActionListener {
|
||||
private static volatile boolean passed = true;
|
||||
private static CountDownLatch complete = new CountDownLatch(1);
|
||||
|
||||
public NonOpaqueDestLCDAATest() {
|
||||
JTextArea desc = new JTextArea();
|
||||
desc.setText(
|
||||
"\n Instructions: the three text strings below should appear" +
|
||||
" readable, without smudges or misshapen bold glyphs.\n" +
|
||||
" You may need a magnifier to notice some bad colorfringing in "+
|
||||
" in SW Translucent case, especially in vertical stems.\n\n"+
|
||||
" Basically text rendered to TRANSLUCENT destination should look"+
|
||||
" similar to one rendered to OPAQUE - it may differ in whether or" +
|
||||
" not it's LCD, but it should look 'correct'\n\n"+
|
||||
"If the text looks fine the test PASSED otherwise it FAILED.\n");
|
||||
desc.setEditable(false);
|
||||
desc.setBackground(Color.black);
|
||||
desc.setForeground(Color.green);
|
||||
add("North", desc);
|
||||
JPanel renderPanel = new JPanel() {
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
render(g, getWidth(), getHeight());
|
||||
}
|
||||
};
|
||||
renderPanel.setPreferredSize(new Dimension(1024, 650));
|
||||
renderPanel.addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
images = null;
|
||||
}
|
||||
});
|
||||
add("Center", renderPanel);
|
||||
|
||||
JButton passedBtn = new JButton("Passed");
|
||||
JButton failedBtn = new JButton("Failed");
|
||||
passedBtn.addActionListener(this);
|
||||
failedBtn.addActionListener(this);
|
||||
JPanel p = new JPanel();
|
||||
p.add(passedBtn);
|
||||
p.add(failedBtn);
|
||||
add("South", p);
|
||||
addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
complete.countDown();
|
||||
}
|
||||
});
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
}
|
||||
|
||||
public void render(Graphics g, int w, int h) {
|
||||
initImages(w, h);
|
||||
|
||||
g.setColor(new Color(0xAD, 0xD8, 0xE6));
|
||||
g.fillRect(0, 0, w, h);
|
||||
|
||||
Graphics2D g2d = (Graphics2D) g.create();
|
||||
for (Image im : images) {
|
||||
g2d.drawImage(im, 0, 0, null);
|
||||
g2d.translate(0, im.getHeight(null));
|
||||
}
|
||||
}
|
||||
|
||||
String tr[] = { "OPAQUE", "BITMASK", "TRANSLUCENT" };
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getActionCommand().equals("Passed")) {
|
||||
passed = true;
|
||||
System.out.println("Test Passed");
|
||||
} else if (e.getActionCommand().equals("Failed")) {
|
||||
System.out.println("Test Failed");
|
||||
for (int i = 0; i < images.length; i++) {
|
||||
String f = "NonOpaqueDestLCDAATest_"+tr[i];
|
||||
try {
|
||||
if (images[i] instanceof VolatileImage) {
|
||||
f += "_vi.png";
|
||||
ImageIO.write(((VolatileImage)images[i]).
|
||||
getSnapshot(), "png", new File(f));
|
||||
} else {
|
||||
f += "_bi.png";
|
||||
ImageIO.write((BufferedImage)images[i],
|
||||
"png", new File(f));
|
||||
}
|
||||
System.out.printf("Dumped %s image to %s\n", tr[i], f);
|
||||
} catch (Throwable t) {}
|
||||
}
|
||||
passed = false;
|
||||
}
|
||||
dispose();
|
||||
complete.countDown();
|
||||
}
|
||||
|
||||
static void clear(Graphics2D g, int type, int w, int h) {
|
||||
Graphics2D gg = (Graphics2D) g.create();
|
||||
if (type > OPAQUE) {
|
||||
gg.setColor(new Color(0, 0, 0, 0));
|
||||
gg.setComposite(AlphaComposite.Src);
|
||||
} else {
|
||||
gg.setColor(new Color(0xAD, 0xD8, 0xE6));
|
||||
}
|
||||
gg.fillRect(0, 0, w, h);
|
||||
}
|
||||
|
||||
private void render(Image im, int type, String s) {
|
||||
Graphics2D g2d = (Graphics2D) im.getGraphics();
|
||||
clear(g2d, type, im.getWidth(null), im.getHeight(null));
|
||||
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
|
||||
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
|
||||
Font f = new Font("Dialog", Font.BOLD, 40);// g2d.getFont().deriveFont(32.0f);
|
||||
g2d.setColor(Color.white);
|
||||
g2d.setFont(g2d.getFont().deriveFont(36.0f));
|
||||
g2d.drawString(s, 10, im.getHeight(null) / 2);
|
||||
}
|
||||
|
||||
Image images[];
|
||||
private void initImages(int w, int h) {
|
||||
if (images == null) {
|
||||
images = new Image[6];
|
||||
GraphicsConfiguration gc = getGraphicsConfiguration();
|
||||
for (int i = OPAQUE; i <= TRANSLUCENT; i++) {
|
||||
VolatileImage vi =
|
||||
gc.createCompatibleVolatileImage(w,h/images.length,i);
|
||||
images[i-1] = vi;
|
||||
vi.validate(gc);
|
||||
String s = "LCD AA Text rendered to " + tr[i - 1] + " HW destination";
|
||||
render(vi, i, s);
|
||||
|
||||
s = "LCD AA Text rendered to " + tr[i - 1] + " SW destination";
|
||||
images[i-1+3] = gc.createCompatibleImage(w, h/images.length, i);
|
||||
render(images[i-1+3], i, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NonOpaqueDestLCDAATest t = new NonOpaqueDestLCDAATest();
|
||||
t.pack();
|
||||
t.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
complete.await();
|
||||
if (!passed) {
|
||||
throw new RuntimeException("Test Failed!");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright 2007-2008 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6764257
|
||||
* @summary Tests that the alpha in opaque images doesn't affect result of alpha
|
||||
* compositing
|
||||
* @author Dmitri.Trembovetski@sun.com: area=Graphics
|
||||
* @run main/othervm OpaqueImageToSurfaceBlitTest
|
||||
* @run main/othervm -Dsun.java2d.noddraw=true OpaqueImageToSurfaceBlitTest
|
||||
* @run main/othervm -Dsun.java2d.opengl=True OpaqueImageToSurfaceBlitTest
|
||||
*/
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.awt.image.VolatileImage;
|
||||
|
||||
public class OpaqueImageToSurfaceBlitTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
GraphicsEnvironment ge =
|
||||
GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
GraphicsDevice gd = ge.getDefaultScreenDevice();
|
||||
GraphicsConfiguration gc = gd.getDefaultConfiguration();
|
||||
VolatileImage vi = gc.createCompatibleVolatileImage(16, 16);
|
||||
vi.validate(gc);
|
||||
|
||||
BufferedImage bi =
|
||||
new BufferedImage(2, 2, BufferedImage.TYPE_INT_RGB);
|
||||
int data[] = ((DataBufferInt)bi.getRaster().getDataBuffer()).getData();
|
||||
data[0] = 0x0000007f;
|
||||
data[1] = 0x0000007f;
|
||||
data[2] = 0xff00007f;
|
||||
data[3] = 0xff00007f;
|
||||
Graphics2D g = vi.createGraphics();
|
||||
g.setComposite(AlphaComposite.SrcOver.derive(0.999f));
|
||||
g.drawImage(bi, 0, 0, null);
|
||||
|
||||
bi = vi.getSnapshot();
|
||||
if (bi.getRGB(0, 0) != bi.getRGB(1, 1)) {
|
||||
throw new RuntimeException("Test FAILED: color at 0x0 ="+
|
||||
Integer.toHexString(bi.getRGB(0, 0))+" differs from 1x1 ="+
|
||||
Integer.toHexString(bi.getRGB(1,1)));
|
||||
}
|
||||
|
||||
System.out.println("Test PASSED.");
|
||||
}
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright 2007-2008 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6764257
|
||||
* @summary Tests that the color is reset properly after save/restore context
|
||||
* @author Dmitri.Trembovetski@sun.com: area=Graphics
|
||||
* @compile -XDignore.symbol.file=true RSLContextInvalidationTest.java
|
||||
* @run main/othervm RSLContextInvalidationTest
|
||||
* @run main/othervm -Dsun.java2d.noddraw=true RSLContextInvalidationTest
|
||||
* @run main/othervm -Dsun.java2d.opengl=True RSLContextInvalidationTest
|
||||
*/
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.VolatileImage;
|
||||
import sun.java2d.DestSurfaceProvider;
|
||||
import sun.java2d.Surface;
|
||||
import sun.java2d.pipe.RenderQueue;
|
||||
import sun.java2d.pipe.hw.*;
|
||||
|
||||
public class RSLContextInvalidationTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
GraphicsEnvironment ge =
|
||||
GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
GraphicsDevice gd = ge.getDefaultScreenDevice();
|
||||
GraphicsConfiguration gc = gd.getDefaultConfiguration();
|
||||
VolatileImage vi = gc.createCompatibleVolatileImage(100, 100);
|
||||
vi.validate(gc);
|
||||
VolatileImage vi1 = gc.createCompatibleVolatileImage(100, 100);
|
||||
vi1.validate(gc);
|
||||
|
||||
if (!(vi instanceof DestSurfaceProvider)) {
|
||||
System.out.println("Test considered PASSED: no HW acceleration");
|
||||
return;
|
||||
}
|
||||
|
||||
DestSurfaceProvider p = (DestSurfaceProvider)vi;
|
||||
Surface s = p.getDestSurface();
|
||||
if (!(s instanceof AccelSurface)) {
|
||||
System.out.println("Test considered PASSED: no HW acceleration");
|
||||
return;
|
||||
}
|
||||
AccelSurface dst = (AccelSurface)s;
|
||||
|
||||
Graphics g = vi.createGraphics();
|
||||
g.drawImage(vi1, 95, 95, null);
|
||||
g.setColor(Color.red);
|
||||
g.fillRect(0, 0, 100, 100);
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0, 0, 100, 100);
|
||||
// after this the validated context color is black
|
||||
|
||||
RenderQueue rq = dst.getContext().getRenderQueue();
|
||||
rq.lock();
|
||||
try {
|
||||
dst.getContext().saveState();
|
||||
dst.getContext().restoreState();
|
||||
} finally {
|
||||
rq.unlock();
|
||||
}
|
||||
|
||||
// this will cause ResetPaint (it will set color to extended EA=ff,
|
||||
// which is ffffffff==Color.white)
|
||||
g.drawImage(vi1, 95, 95, null);
|
||||
|
||||
// now try filling with black again, but it will come up as white
|
||||
// because this fill rect won't validate the color properly
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0, 0, 100, 100);
|
||||
|
||||
BufferedImage bi = vi.getSnapshot();
|
||||
if (bi.getRGB(50, 50) != Color.black.getRGB()) {
|
||||
throw new RuntimeException("Test FAILED: found color="+
|
||||
Integer.toHexString(bi.getRGB(50, 50))+" instead of "+
|
||||
Integer.toHexString(Color.black.getRGB()));
|
||||
}
|
||||
|
||||
System.out.println("Test PASSED.");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user