diff --git a/jdk/make/sun/awt/mapfile-mawt-vers b/jdk/make/sun/awt/mapfile-mawt-vers index ca3b430c57b..7eeef21f278 100644 --- a/jdk/make/sun/awt/mapfile-mawt-vers +++ b/jdk/make/sun/awt/mapfile-mawt-vers @@ -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; diff --git a/jdk/make/sun/xawt/mapfile-vers b/jdk/make/sun/xawt/mapfile-vers index 9e0b434b557..d4b5b6e32ba 100644 --- a/jdk/make/sun/xawt/mapfile-vers +++ b/jdk/make/sun/xawt/mapfile-vers @@ -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; diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java index 0f5407075a7..84a593264be 100644 --- a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java +++ b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java @@ -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(); + } } } diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java index 60db32fa10e..ea4233a68ea 100644 --- a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java +++ b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java @@ -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 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 = metadata.iTXt_translatedKeyword.iterator(); - Iterator textIter = metadata.iTXt_text.iterator(); + Iterator 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 { diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java index 19f4f67013e..5475fc79651 100644 --- a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java +++ b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java @@ -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 iTXt_keyword = new ArrayList(); + public ArrayList iTXt_compressionFlag = new ArrayList(); + public ArrayList iTXt_compressionMethod = new ArrayList(); + public ArrayList iTXt_languageTag = new ArrayList(); + public ArrayList iTXt_translatedKeyword = new ArrayList(); + public ArrayList iTXt_text = new ArrayList(); // 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(); + iTXt_compressionFlag = new ArrayList(); + iTXt_compressionMethod = new ArrayList(); + iTXt_languageTag = new ArrayList(); + iTXt_translatedKeyword = new ArrayList(); + iTXt_text = new ArrayList(); pHYs_present = false; sBIT_present = false; sPLT_present = false; diff --git a/jdk/src/share/classes/java/awt/print/PrinterJob.java b/jdk/src/share/classes/java/awt/print/PrinterJob.java index 28e500db79d..f0ec3152bb3 100644 --- a/jdk/src/share/classes/java/awt/print/PrinterJob.java +++ b/jdk/src/share/classes/java/awt/print/PrinterJob.java @@ -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(); * } * } * diff --git a/jdk/src/share/classes/javax/print/Doc.java b/jdk/src/share/classes/javax/print/Doc.java index ef1bdb5550e..01fe4a064a2 100644 --- a/jdk/src/share/classes/javax/print/Doc.java +++ b/jdk/src/share/classes/javax/print/Doc.java @@ -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; diff --git a/jdk/src/share/classes/javax/print/DocFlavor.java b/jdk/src/share/classes/javax/print/DocFlavor.java index bda24a70d80..e72970c9f45 100644 --- a/jdk/src/share/classes/javax/print/DocFlavor.java +++ b/jdk/src/share/classes/javax/print/DocFlavor.java @@ -30,7 +30,6 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; -import java.util.Map; /** * Class DocFlavor encapsulates an object that specifies the diff --git a/jdk/src/share/classes/javax/print/DocPrintJob.java b/jdk/src/share/classes/javax/print/DocPrintJob.java index 57040658d61..671a51d6e19 100644 --- a/jdk/src/share/classes/javax/print/DocPrintJob.java +++ b/jdk/src/share/classes/javax/print/DocPrintJob.java @@ -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; diff --git a/jdk/src/share/classes/javax/print/MultiDocPrintService.java b/jdk/src/share/classes/javax/print/MultiDocPrintService.java index 4c6e31c0876..e8262086991 100644 --- a/jdk/src/share/classes/javax/print/MultiDocPrintService.java +++ b/jdk/src/share/classes/javax/print/MultiDocPrintService.java @@ -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 diff --git a/jdk/src/share/classes/javax/print/PrintServiceLookup.java b/jdk/src/share/classes/javax/print/PrintServiceLookup.java index 1a78eded166..33bc357beef 100644 --- a/jdk/src/share/classes/javax/print/PrintServiceLookup.java +++ b/jdk/src/share/classes/javax/print/PrintServiceLookup.java @@ -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; diff --git a/jdk/src/share/classes/javax/print/attribute/URISyntax.java b/jdk/src/share/classes/javax/print/attribute/URISyntax.java index e4bfa9de2f6..3ae7acc988e 100644 --- a/jdk/src/share/classes/javax/print/attribute/URISyntax.java +++ b/jdk/src/share/classes/javax/print/attribute/URISyntax.java @@ -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 diff --git a/jdk/src/share/classes/javax/print/event/PrintServiceAttributeEvent.java b/jdk/src/share/classes/javax/print/event/PrintServiceAttributeEvent.java index 3ab488ffebd..d65d1376e83 100644 --- a/jdk/src/share/classes/javax/print/event/PrintServiceAttributeEvent.java +++ b/jdk/src/share/classes/javax/print/event/PrintServiceAttributeEvent.java @@ -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; diff --git a/jdk/src/share/classes/sun/font/Decoration.java b/jdk/src/share/classes/sun/font/Decoration.java index ebdf7c49ac6..647baf45ea5 100644 --- a/jdk/src/share/classes/sun/font/Decoration.java +++ b/jdk/src/share/classes/sun/font/Decoration.java @@ -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; diff --git a/jdk/src/share/classes/sun/font/FontManager.java b/jdk/src/share/classes/sun/font/FontManager.java index d217be16d98..f709f381ada 100644 --- a/jdk/src/share/classes/sun/font/FontManager.java +++ b/jdk/src/share/classes/sun/font/FontManager.java @@ -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")) { diff --git a/jdk/src/share/classes/sun/font/TrueTypeFont.java b/jdk/src/share/classes/sun/font/TrueTypeFont.java index f77003dd624..5d9477b6e92 100644 --- a/jdk/src/share/classes/sun/font/TrueTypeFont.java +++ b/jdk/src/share/classes/sun/font/TrueTypeFont.java @@ -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: diff --git a/jdk/src/share/classes/sun/font/Underline.java b/jdk/src/share/classes/sun/font/Underline.java index efe78985da8..ad1910b8412 100644 --- a/jdk/src/share/classes/sun/font/Underline.java +++ b/jdk/src/share/classes/sun/font/Underline.java @@ -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, diff --git a/jdk/src/share/classes/sun/java2d/SunGraphicsEnvironment.java b/jdk/src/share/classes/sun/java2d/SunGraphicsEnvironment.java index e0e03d36a2a..14029a0f8bb 100644 --- a/jdk/src/share/classes/sun/java2d/SunGraphicsEnvironment.java +++ b/jdk/src/share/classes/sun/java2d/SunGraphicsEnvironment.java @@ -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---- */ diff --git a/jdk/src/share/classes/sun/java2d/SurfaceData.java b/jdk/src/share/classes/sun/java2d/SurfaceData.java index 84acfbd8f0f..65a04c23220 100644 --- a/jdk/src/share/classes/sun/java2d/SurfaceData.java +++ b/jdk/src/share/classes/sun/java2d/SurfaceData.java @@ -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 = diff --git a/jdk/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java b/jdk/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java index 5be4fec72dd..37dce4264b2 100644 --- a/jdk/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java +++ b/jdk/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java @@ -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, diff --git a/jdk/src/share/classes/sun/java2d/opengl/OGLSurfaceData.java b/jdk/src/share/classes/sun/java2d/opengl/OGLSurfaceData.java index 78f16f7dcca..dc509a71af4 100644 --- a/jdk/src/share/classes/sun/java2d/opengl/OGLSurfaceData.java +++ b/jdk/src/share/classes/sun/java2d/opengl/OGLSurfaceData.java @@ -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) { diff --git a/jdk/src/share/classes/sun/java2d/pipe/BufferedContext.java b/jdk/src/share/classes/sun/java2d/pipe/BufferedContext.java index 05989523083..886ba1e11d4 100644 --- a/jdk/src/share/classes/sun/java2d/pipe/BufferedContext.java +++ b/jdk/src/share/classes/sun/java2d/pipe/BufferedContext.java @@ -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; } diff --git a/jdk/src/share/classes/sun/print/PSPathGraphics.java b/jdk/src/share/classes/sun/print/PSPathGraphics.java index 15bea939df4..3e7b057b83e 100644 --- a/jdk/src/share/classes/sun/print/PSPathGraphics.java +++ b/jdk/src/share/classes/sun/print/PSPathGraphics.java @@ -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; diff --git a/jdk/src/share/classes/sun/print/PrintJobAttributeException.java b/jdk/src/share/classes/sun/print/PrintJobAttributeException.java index 7a29690c4e3..52a939f86b9 100644 --- a/jdk/src/share/classes/sun/print/PrintJobAttributeException.java +++ b/jdk/src/share/classes/sun/print/PrintJobAttributeException.java @@ -25,7 +25,6 @@ package sun.print; -import javax.print.DocFlavor; import javax.print.AttributeException; import javax.print.PrintException; import javax.print.attribute.Attribute; diff --git a/jdk/src/share/classes/sun/print/SunMinMaxPage.java b/jdk/src/share/classes/sun/print/SunMinMaxPage.java index 19962c56eeb..0bd9acb2a73 100644 --- a/jdk/src/share/classes/sun/print/SunMinMaxPage.java +++ b/jdk/src/share/classes/sun/print/SunMinMaxPage.java @@ -25,7 +25,6 @@ package sun.print; -import javax.print.attribute.EnumSyntax; import javax.print.attribute.PrintRequestAttribute; /* diff --git a/jdk/src/share/classes/sun/print/SunPageSelection.java b/jdk/src/share/classes/sun/print/SunPageSelection.java index 2c2d82b8da9..f51f26e9233 100644 --- a/jdk/src/share/classes/sun/print/SunPageSelection.java +++ b/jdk/src/share/classes/sun/print/SunPageSelection.java @@ -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. diff --git a/jdk/src/share/classes/sun/swing/SwingUtilities2.java b/jdk/src/share/classes/sun/swing/SwingUtilities2.java index 0603e55b5d3..b22060bb815 100644 --- a/jdk/src/share/classes/sun/swing/SwingUtilities2.java +++ b/jdk/src/share/classes/sun/swing/SwingUtilities2.java @@ -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; } /** diff --git a/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/tests/ImageTests.java b/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/tests/ImageTests.java index 51c4828e83c..ab06b9f4924 100644 --- a/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/tests/ImageTests.java +++ b/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/tests/ImageTests.java @@ -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); + } } } } diff --git a/jdk/src/share/native/sun/font/freetypeScaler.c b/jdk/src/share/native/sun/font/freetypeScaler.c index 5f6385b2868..59c1a180c29 100644 --- a/jdk/src/share/native/sun/font/freetypeScaler.c +++ b/jdk/src/share/native/sun/font/freetypeScaler.c @@ -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)); } diff --git a/jdk/src/share/native/sun/java2d/opengl/OGLBlitLoops.c b/jdk/src/share/native/sun/java2d/opengl/OGLBlitLoops.c index 0a16a2b737c..a9f98c80c5a 100644 --- a/jdk/src/share/native/sun/java2d/opengl/OGLBlitLoops.c +++ b/jdk/src/share/native/sun/java2d/opengl/OGLBlitLoops.c @@ -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); + } } /** diff --git a/jdk/src/share/native/sun/java2d/opengl/OGLSurfaceData.c b/jdk/src/share/native/sun/java2d/opengl/OGLSurfaceData.c index 2b45a610be3..0cb11d105af 100644 --- a/jdk/src/share/native/sun/java2d/opengl/OGLSurfaceData.c +++ b/jdk/src/share/native/sun/java2d/opengl/OGLSurfaceData.c @@ -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 diff --git a/jdk/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java b/jdk/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java index dadfe84d71f..47ca64f1daa 100644 --- a/jdk/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java +++ b/jdk/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java @@ -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 { diff --git a/jdk/src/solaris/classes/sun/java2d/opengl/GLXGraphicsConfig.java b/jdk/src/solaris/classes/sun/java2d/opengl/GLXGraphicsConfig.java index 8e8e18448b6..d21e177542d 100644 --- a/jdk/src/solaris/classes/sun/java2d/opengl/GLXGraphicsConfig.java +++ b/jdk/src/solaris/classes/sun/java2d/opengl/GLXGraphicsConfig.java @@ -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(); } diff --git a/jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java b/jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java index 986f1b51e20..54f79769343 100644 --- a/jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java +++ b/jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java @@ -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())); } } } diff --git a/jdk/src/solaris/classes/sun/print/CUPSPrinter.java b/jdk/src/solaris/classes/sun/print/CUPSPrinter.java index cd7de38b260..a8c0dd0d3ea 100644 --- a/jdk/src/solaris/classes/sun/print/CUPSPrinter.java +++ b/jdk/src/solaris/classes/sun/print/CUPSPrinter.java @@ -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 { diff --git a/jdk/src/solaris/classes/sun/print/IPPPrintService.java b/jdk/src/solaris/classes/sun/print/IPPPrintService.java index ba438a93031..07b68b18fa8 100644 --- a/jdk/src/solaris/classes/sun/print/IPPPrintService.java +++ b/jdk/src/solaris/classes/sun/print/IPPPrintService.java @@ -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= 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(); + } } diff --git a/jdk/src/solaris/classes/sun/print/UnixPrintService.java b/jdk/src/solaris/classes/sun/print/UnixPrintService.java index f451f804c7a..30d2dc82ca8 100644 --- a/jdk/src/solaris/classes/sun/print/UnixPrintService.java +++ b/jdk/src/solaris/classes/sun/print/UnixPrintService.java @@ -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(); diff --git a/jdk/src/solaris/native/sun/awt/fontpath.c b/jdk/src/solaris/native/sun/awt/fontpath.c index 8f9f3d9a894..b944ff93360 100644 --- a/jdk/src/solaris/native/sun/awt/fontpath.c +++ b/jdk/src/solaris/native/sun/awt/fontpath.c @@ -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; jfonts[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) diff --git a/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c b/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c index 8b275bc91a8..8423f1eee04 100644 --- a/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c +++ b/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c @@ -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 diff --git a/jdk/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java b/jdk/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java index 80ee7747004..73b73dbb033 100644 --- a/jdk/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java +++ b/jdk/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java @@ -393,4 +393,9 @@ public class Win32GraphicsEnvironment private static void dwmCompositionChanged(boolean enabled) { isDWMCompositionEnabled = enabled; } + + @Override + public boolean isDisplayLocal() { + return true; + } } diff --git a/jdk/src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java b/jdk/src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java index 459a197fab6..45d6cd8fdd0 100644 --- a/jdk/src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java +++ b/jdk/src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java @@ -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, diff --git a/jdk/src/windows/classes/sun/java2d/d3d/D3DSurfaceData.java b/jdk/src/windows/classes/sun/java2d/d3d/D3DSurfaceData.java index 3d1457c721f..722440a77bd 100644 --- a/jdk/src/windows/classes/sun/java2d/d3d/D3DSurfaceData.java +++ b/jdk/src/windows/classes/sun/java2d/d3d/D3DSurfaceData.java @@ -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) { diff --git a/jdk/src/windows/classes/sun/java2d/opengl/WGLGraphicsConfig.java b/jdk/src/windows/classes/sun/java2d/opengl/WGLGraphicsConfig.java index 7ff7e1e8d09..bdd0ade4638 100644 --- a/jdk/src/windows/classes/sun/java2d/opengl/WGLGraphicsConfig.java +++ b/jdk/src/windows/classes/sun/java2d/opengl/WGLGraphicsConfig.java @@ -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(); } diff --git a/jdk/src/windows/native/sun/font/fontpath.c b/jdk/src/windows/native/sun/font/fontpath.c index 71b1da85f17..2fd3c3af9be 100644 --- a/jdk/src/windows/native/sun/font/fontpath.c +++ b/jdk/src/windows/native/sun/font/fontpath.c @@ -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); diff --git a/jdk/src/windows/native/sun/java2d/d3d/D3DBadHardware.h b/jdk/src/windows/native/sun/java2d/d3d/D3DBadHardware.h index 52629d1a5d0..20c9ad1e378 100644 --- a/jdk/src/windows/native/sun/java2d/d3d/D3DBadHardware.h +++ b/jdk/src/windows/native/sun/java2d/d3d/D3DBadHardware.h @@ -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 }, diff --git a/jdk/src/windows/native/sun/java2d/d3d/D3DBlitLoops.cpp b/jdk/src/windows/native/sun/java2d/d3d/D3DBlitLoops.cpp index 6792a444a7d..c8a5d786144 100644 --- a/jdk/src/windows/native/sun/java2d/d3d/D3DBlitLoops.cpp +++ b/jdk/src/windows/native/sun/java2d/d3d/D3DBlitLoops.cpp @@ -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, diff --git a/jdk/src/windows/native/sun/java2d/d3d/D3DContext.cpp b/jdk/src/windows/native/sun/java2d/d3d/D3DContext.cpp index e3937b8d3e9..186f4d7557c 100644 --- a/jdk/src/windows/native/sun/java2d/d3d/D3DContext.cpp +++ b/jdk/src/windows/native/sun/java2d/d3d/D3DContext.cpp @@ -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; } diff --git a/jdk/src/windows/native/sun/java2d/d3d/D3DSurfaceData.h b/jdk/src/windows/native/sun/java2d/d3d/D3DSurfaceData.h index 22a89bc156d..b115ed837e9 100644 --- a/jdk/src/windows/native/sun/java2d/d3d/D3DSurfaceData.h +++ b/jdk/src/windows/native/sun/java2d/d3d/D3DSurfaceData.h @@ -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 diff --git a/jdk/test/java/awt/FullScreen/UninitializedDisplayModeChangeTest/DisplayModeChanger.java b/jdk/test/java/awt/FullScreen/UninitializedDisplayModeChangeTest/DisplayModeChanger.java new file mode 100644 index 00000000000..e73457f128d --- /dev/null +++ b/jdk/test/java/awt/FullScreen/UninitializedDisplayModeChangeTest/DisplayModeChanger.java @@ -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; + } + +} diff --git a/jdk/test/java/awt/font/TextLayout/DecorationBoundsTest.java b/jdk/test/java/awt/font/TextLayout/DecorationBoundsTest.java new file mode 100644 index 00000000000..286b75d8bfb --- /dev/null +++ b/jdk/test/java/awt/font/TextLayout/DecorationBoundsTest.java @@ -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 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!"); + } + } +} diff --git a/jdk/test/sun/java2d/DirectX/OpaqueImageToSurfaceBlitTest/OpaqueImageToSurfaceBlitTest.java b/jdk/test/sun/java2d/DirectX/OpaqueImageToSurfaceBlitTest/OpaqueImageToSurfaceBlitTest.java new file mode 100644 index 00000000000..2135fa75ec1 --- /dev/null +++ b/jdk/test/sun/java2d/DirectX/OpaqueImageToSurfaceBlitTest/OpaqueImageToSurfaceBlitTest.java @@ -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."); + } +} diff --git a/jdk/test/sun/java2d/pipe/hw/RSLContextInvalidationTest/RSLContextInvalidationTest.java b/jdk/test/sun/java2d/pipe/hw/RSLContextInvalidationTest/RSLContextInvalidationTest.java new file mode 100644 index 00000000000..1a895c3c550 --- /dev/null +++ b/jdk/test/sun/java2d/pipe/hw/RSLContextInvalidationTest/RSLContextInvalidationTest.java @@ -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."); + } +}