提交 3516fb44 编写于 作者: J jgodinez

Merge

......@@ -125,7 +125,6 @@ FILES_2D_c = \
FourByteAbgrPre.c \
BufferedMaskBlit.c \
BufferedRenderPipe.c \
RenderBuffer.c \
ShapeSpanIterator.c \
SpanClipRenderer.c \
awt_ImageRep.c \
......
......@@ -70,7 +70,6 @@ FILES_c = \
FourByteAbgrPre.c \
BufferedMaskBlit.c \
BufferedRenderPipe.c \
RenderBuffer.c \
ShapeSpanIterator.c \
SpanClipRenderer.c \
SurfaceData.c \
......
......@@ -65,7 +65,6 @@ SUNWprivate_1.1 {
Java_sun_awt_image_ShortComponentRaster_initIDs;
Java_sun_java2d_pipe_BufferedMaskBlit_enqueueTile;
Java_sun_java2d_pipe_BufferedRenderPipe_fillSpans;
Java_sun_java2d_pipe_RenderBuffer_copyFromArray;
Java_sun_java2d_pipe_SpanClipRenderer_eraseTile;
Java_sun_java2d_pipe_SpanClipRenderer_fillTile;
Java_sun_java2d_pipe_ShapeSpanIterator_addSegment;
......
......@@ -117,7 +117,6 @@ SUNWprivate_1.1 {
Java_sun_java2d_loops_MaskBlit_MaskBlit;
Java_sun_java2d_loops_MaskFill_MaskFill;
Java_sun_java2d_pipe_BufferedRenderPipe_fillSpans;
Java_sun_java2d_pipe_RenderBuffer_copyFromArray;
Java_sun_java2d_pipe_SpanClipRenderer_initIDs;
sun_awt_image_GifImageDecoder_initIDs;
......
......@@ -552,17 +552,6 @@ public class TrueTypeFont extends FileFont {
ByteBuffer os2_Table = getTableBuffer(os_2Tag);
setStyle(os2_Table);
setCJKSupport(os2_Table);
ByteBuffer head_Table = getTableBuffer(headTag);
int upem = -1;
if (head_Table != null && head_Table.capacity() >= 18) {
ShortBuffer sb = head_Table.asShortBuffer();
upem = sb.get(9) & 0xffff;
}
setStrikethroughMetrics(os2_Table, upem);
ByteBuffer post_Table = getTableBuffer(postTag);
setUnderlineMetrics(post_Table, upem);
}
/* The array index corresponds to a bit offset in the TrueType
......@@ -1020,8 +1009,26 @@ public class TrueTypeFont extends FileFont {
}
public void getStyleMetrics(float pointSize, float[] metrics, int offset) {
if (ulSize == 0f && ulPos == 0f) {
ByteBuffer head_Table = getTableBuffer(headTag);
int upem = -1;
if (head_Table != null && head_Table.capacity() >= 18) {
ShortBuffer sb = head_Table.asShortBuffer();
upem = sb.get(9) & 0xffff;
}
ByteBuffer os2_Table = getTableBuffer(os_2Tag);
setStrikethroughMetrics(os2_Table, upem);
ByteBuffer post_Table = getTableBuffer(postTag);
setUnderlineMetrics(post_Table, upem);
}
metrics[offset] = stPos * pointSize;
metrics[offset+1] = stSize * pointSize;
metrics[offset+2] = ulPos * pointSize;
metrics[offset+3] = ulSize * pointSize;
}
......
......@@ -63,7 +63,7 @@ public class RenderBuffer {
* (This value can be adjusted if the cost of JNI downcalls is reduced
* in a future release.)
*/
private static final int COPY_FROM_ARRAY_THRESHOLD = 28;
private static final int COPY_FROM_ARRAY_THRESHOLD = 6;
protected final Unsafe unsafe;
protected final long baseAddress;
......@@ -92,20 +92,6 @@ public class RenderBuffer {
return baseAddress;
}
/**
* Copies length bytes from the Java-level srcArray to the native
* memory located at dstAddr. Note that this method performs no bounds
* checking. Verification that the copy will not result in memory
* corruption should be done by the caller prior to invocation.
*
* @param srcArray the source array
* @param srcPos the starting position of the source array (in bytes)
* @param dstAddr pointer to the destination block of native memory
* @param length the number of bytes to copy from source to destination
*/
private static native void copyFromArray(Object srcArray, long srcPos,
long dstAddr, long length);
/**
* The behavior (and names) of the following methods are nearly
* identical to their counterparts in the various NIO Buffer classes.
......@@ -147,9 +133,9 @@ public class RenderBuffer {
public RenderBuffer put(byte[] x, int offset, int length) {
if (length > COPY_FROM_ARRAY_THRESHOLD) {
long offsetInBytes = offset * SIZEOF_BYTE;
long offsetInBytes = offset * SIZEOF_BYTE + Unsafe.ARRAY_BYTE_BASE_OFFSET;
long lengthInBytes = length * SIZEOF_BYTE;
copyFromArray(x, offsetInBytes, curAddress, lengthInBytes);
unsafe.copyMemory(x, offsetInBytes, null, curAddress, lengthInBytes);
position(position() + lengthInBytes);
} else {
int end = offset + length;
......@@ -178,9 +164,9 @@ public class RenderBuffer {
public RenderBuffer put(short[] x, int offset, int length) {
// assert (position() % SIZEOF_SHORT == 0);
if (length > COPY_FROM_ARRAY_THRESHOLD) {
long offsetInBytes = offset * SIZEOF_SHORT;
long offsetInBytes = offset * SIZEOF_SHORT + Unsafe.ARRAY_SHORT_BASE_OFFSET;
long lengthInBytes = length * SIZEOF_SHORT;
copyFromArray(x, offsetInBytes, curAddress, lengthInBytes);
unsafe.copyMemory(x, offsetInBytes, null, curAddress, lengthInBytes);
position(position() + lengthInBytes);
} else {
int end = offset + length;
......@@ -215,9 +201,9 @@ public class RenderBuffer {
public RenderBuffer put(int[] x, int offset, int length) {
// assert (position() % SIZEOF_INT == 0);
if (length > COPY_FROM_ARRAY_THRESHOLD) {
long offsetInBytes = offset * SIZEOF_INT;
long offsetInBytes = offset * SIZEOF_INT + Unsafe.ARRAY_INT_BASE_OFFSET;
long lengthInBytes = length * SIZEOF_INT;
copyFromArray(x, offsetInBytes, curAddress, lengthInBytes);
unsafe.copyMemory(x, offsetInBytes, null, curAddress, lengthInBytes);
position(position() + lengthInBytes);
} else {
int end = offset + length;
......@@ -246,9 +232,9 @@ public class RenderBuffer {
public RenderBuffer put(float[] x, int offset, int length) {
// assert (position() % SIZEOF_FLOAT == 0);
if (length > COPY_FROM_ARRAY_THRESHOLD) {
long offsetInBytes = offset * SIZEOF_FLOAT;
long offsetInBytes = offset * SIZEOF_FLOAT + Unsafe.ARRAY_FLOAT_BASE_OFFSET;
long lengthInBytes = length * SIZEOF_FLOAT;
copyFromArray(x, offsetInBytes, curAddress, lengthInBytes);
unsafe.copyMemory(x, offsetInBytes, null, curAddress, lengthInBytes);
position(position() + lengthInBytes);
} else {
int end = offset + length;
......@@ -277,9 +263,9 @@ public class RenderBuffer {
public RenderBuffer put(long[] x, int offset, int length) {
// assert (position() % SIZEOF_LONG == 0);
if (length > COPY_FROM_ARRAY_THRESHOLD) {
long offsetInBytes = offset * SIZEOF_LONG;
long offsetInBytes = offset * SIZEOF_LONG + Unsafe.ARRAY_LONG_BASE_OFFSET;
long lengthInBytes = length * SIZEOF_LONG;
copyFromArray(x, offsetInBytes, curAddress, lengthInBytes);
unsafe.copyMemory(x, offsetInBytes, null, curAddress, lengthInBytes);
position(position() + lengthInBytes);
} else {
int end = offset + length;
......
......@@ -95,6 +95,11 @@ public abstract class RenderingEngine {
* <pre>
* java -Dsun.java2d.renderer=&lt;classname&gt;
* </pre>
*
* If no specific {@code RenderingEngine} is specified on the command
* or Ductus renderer is specified, it will attempt loading the
* sun.dc.DuctusRenderingEngine class using Class.forName as a fastpath;
* if not found, use the ServiceLoader.
* If no specific {@code RenderingEngine} is specified on the command
* line then the last one returned by enumerating all subclasses of
* {@code RenderingEngine} known to the ServiceLoader is used.
......@@ -115,9 +120,21 @@ public abstract class RenderingEngine {
reImpl = (RenderingEngine)
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
final String ductusREClass = "sun.dc.DuctusRenderingEngine";
String reClass =
System.getProperty("sun.java2d.renderer",
"sun.dc.DuctusRenderingEngine");
System.getProperty("sun.java2d.renderer", ductusREClass);
if (reClass.equals(ductusREClass)) {
try {
Class cls = Class.forName(ductusREClass);
return cls.newInstance();
} catch (ClassNotFoundException x) {
// not found
} catch (IllegalAccessException x) {
// should not reach here
} catch (InstantiationException x) {
// should not reach here
}
}
ServiceLoader<RenderingEngine> reLoader =
ServiceLoader.loadInstalled(RenderingEngine.class);
......
......@@ -181,7 +181,7 @@ public class Stroker extends LineSink {
Transform4 transform) {
this.lineWidth = lineWidth;
this.lineWidth2 = lineWidth >> 1;
this.scaledLineWidth2 = (long)transform.m00*lineWidth2;
this.scaledLineWidth2 = ((long)transform.m00*lineWidth2) >> 16;
this.capStyle = capStyle;
this.joinStyle = joinStyle;
this.miterLimit = miterLimit;
......@@ -243,8 +243,8 @@ public class Stroker extends LineSink {
if (ilen == 0) {
dx = dy = 0;
} else {
dx = (int)( (ly*scaledLineWidth2)/ilen >> 16);
dy = (int)(-(lx*scaledLineWidth2)/ilen >> 16);
dx = (int)( (ly*scaledLineWidth2)/ilen);
dy = (int)(-(lx*scaledLineWidth2)/ilen);
}
} else {
double dlx = x1 - x0;
......
......@@ -27,6 +27,7 @@
* @summary Verifies that (0, 0) is the upper-left corner of the page, not
* the upper-left corner adjusted for the margins.
* @author dpm
* @run main/manual EdgeTest
*/
import java.awt.*;
......@@ -43,7 +44,9 @@ public class EdgeTest extends Panel {
}
);
f.setVisible(true);
PrintJob pj = getToolkit().getPrintJob(f, "EdgeTest", null);
JobAttributes job = new JobAttributes();
job.setDialog(JobAttributes.DialogType.NONE);
PrintJob pj = getToolkit().getPrintJob(f, "EdgeTest", job, null);
if (pj != null) {
Graphics g = pj.getGraphics();
Dimension d = pj.getPageDimension();
......
......@@ -44,7 +44,10 @@ class MultipleEndFrame extends Frame {
public MultipleEndFrame() {
super("MultipleEnd");
setVisible(true);
PrintJob pj = getToolkit().getPrintJob(this, "MuiltipleEnd", null);
JobAttributes job = new JobAttributes();
job.setDialog(JobAttributes.DialogType.NONE);
PrintJob pj = getToolkit().getPrintJob(this, "MultipleEnd", job, null);
if (pj != null) {
pj.end();
pj.end();
......
/*
* Copyright 2009 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 6362683
* @summary Collation should work.
* @run main/manual Collate2DPrintingTest
*/
import java.awt.*;
import java.awt.event.*;
import java.awt.print.*;
import javax.print.attribute.standard.*;
import javax.print.attribute.*;
import javax.print.*;
import java.io.*;
public class Collate2DPrintingTest
extends Frame implements Doc, Printable, ActionListener {
Button print2D = new Button("2D Print");
Button printMerlin = new Button("PrintService");
PrinterJob pj = PrinterJob.getPrinterJob();
PrintService defService = null;
HashPrintRequestAttributeSet prSet = new HashPrintRequestAttributeSet();
public Collate2DPrintingTest() {
Panel butPanel = new Panel();
butPanel.add(print2D);
butPanel.add(printMerlin);
print2D.addActionListener(this);
printMerlin.addActionListener(this);
addWindowListener (new WindowAdapter() {
public void windowClosing (WindowEvent e) {
dispose();
}
});
add("South", butPanel);
defService = PrintServiceLookup.lookupDefaultPrintService();
PrintService[] pservice;
if (defService == null) {
pservice = PrintServiceLookup.lookupPrintServices(null, null);
if (pservice.length == 0) {
throw new RuntimeException("No printer found. TEST ABORTED");
}
defService = pservice[0];
}
prSet.add(SheetCollate.COLLATED);
prSet.add(new Copies(2));
pj.setPrintable(Collate2DPrintingTest.this);
setSize(300, 200);
setVisible(true);
}
public int print(Graphics g, PageFormat pf, int pageIndex)
throws PrinterException {
g.drawString("Page: " + pageIndex, 100, 100);
if (pageIndex == 2) {
return Printable.NO_SUCH_PAGE;
} else {
return Printable.PAGE_EXISTS;
}
}
public void actionPerformed (ActionEvent ae) {
try {
if (ae.getSource() == print2D) {
if (pj.printDialog(prSet)) {
pj.print(prSet);
}
} else {
DocPrintJob pj = defService.createPrintJob();
pj.print(this, prSet);
}
System.out.println ("DONE");
} catch (Exception e) {
e.printStackTrace();
}
}
public DocAttributeSet getAttributes() {
return null;
}
public DocFlavor getDocFlavor() {
DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
return flavor;
}
public Object getPrintData() {
return this;
}
public Reader getReaderForText() {
return null;
}
public InputStream getStreamForBytes() {
return null;
}
public static void main( String[] args) {
String[] instructions =
{
"You must have a printer available to perform this test",
"The print result should be collated."
};
Sysout.createDialog( );
Sysout.printInstructions( instructions );
new Collate2DPrintingTest();
}
}
class Sysout {
private static TestDialog dialog;
public static void createDialogWithInstructions( String[] instructions )
{
dialog = new TestDialog( new Frame(), "Instructions" );
dialog.printInstructions( instructions );
dialog.setVisible(true);
println( "Any messages for the tester will display here." );
}
public static void createDialog( )
{
dialog = new TestDialog( new Frame(), "Instructions" );
String[] defInstr = { "Instructions will appear here. ", "" } ;
dialog.printInstructions( defInstr );
dialog.setVisible(true);
println( "Any messages for the tester will display here." );
}
public static void printInstructions( String[] instructions )
{
dialog.printInstructions( instructions );
}
public static void println( String messageIn )
{
dialog.displayMessage( messageIn );
}
}// Sysout class
/**
This is part of the standard test machinery. It provides a place for the
test instructions to be displayed, and a place for interactive messages
to the user to be displayed.
To have the test instructions displayed, see Sysout.
To have a message to the user be displayed, see Sysout.
Do not call anything in this dialog directly.
*/
class TestDialog extends Dialog {
TextArea instructionsText;
TextArea messageText;
int maxStringLength = 80;
//DO NOT call this directly, go through Sysout
public TestDialog( Frame frame, String name )
{
super( frame, name );
int scrollBoth = TextArea.SCROLLBARS_BOTH;
instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
add( "North", instructionsText );
messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
add("Center", messageText);
pack();
setVisible(true);
}// TestDialog()
//DO NOT call this directly, go through Sysout
public void printInstructions( String[] instructions )
{
//Clear out any current instructions
instructionsText.setText( "" );
//Go down array of instruction strings
String printStr, remainingStr;
for( int i=0; i < instructions.length; i++ )
{
//chop up each into pieces maxSringLength long
remainingStr = instructions[ i ];
while( remainingStr.length() > 0 )
{
//if longer than max then chop off first max chars to print
if( remainingStr.length() >= maxStringLength )
{
//Try to chop on a word boundary
int posOfSpace = remainingStr.
lastIndexOf( ' ', maxStringLength - 1 );
if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
printStr = remainingStr.substring( 0, posOfSpace + 1 );
remainingStr = remainingStr.substring( posOfSpace + 1 );
}
//else just print
else
{
printStr = remainingStr;
remainingStr = "";
}
instructionsText.append( printStr + "\n" );
}// while
}// for
}//printInstructions()
//DO NOT call this directly, go through Sysout
public void displayMessage( String messageIn )
{
messageText.append( messageIn + "\n" );
}
}// TestDialog class
/*
* Copyright 2001-2009 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 4429544
@summary This test should not throw a printer exception. Test has been modified to correspond with the behavior of 1.5 and above.
@run main PrtException
*/
import java.awt.*;
import java.awt.print.*;
import javax.print.*;
public class PrtException implements Printable {
PrinterJob pj;
public PrtException() {
try{
PrintService[] svc;
PrintService defService = PrintServiceLookup.lookupDefaultPrintService();
if (defService == null) {
svc = PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
if (svc.length == 0) {
throw new RuntimeException("Printer is required for this test. TEST ABORTED");
}
defService = svc[0];
}
System.out.println("PrintService found : "+defService);
pj = PrinterJob.getPrinterJob();;
pj.setPrintService(defService);
//pj.setPrintable(this); // commenting this line should not result in PrinterException
pj.print();
} catch(PrinterException e ) {
e.printStackTrace();
throw new RuntimeException(" PrinterException should not be thrown. TEST FAILED");
}
System.out.println("TEST PASSED");
}
public int print(Graphics g,PageFormat pf,int pageIndex) {
Graphics2D g2= (Graphics2D)g;
if(pageIndex>=1){
return Printable.NO_SUCH_PAGE;
}
g2.translate(pf.getImageableX(), pf.getImageableY());
g2.setColor(Color.black);
g2.drawString("Hello world.", 10, 10);
return Printable.PAGE_EXISTS;
}
public static void main(String arg[]) {
PrtException sp = new PrtException();
}
}
/*
* Copyright 2004-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2004-2009 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
......@@ -35,17 +35,19 @@ import java.util.ArrayList;
public class CheckDupFlavor {
public static void main(String[] args){
PrintService pservice =
PrintServiceLookup.lookupDefaultPrintService();
if (pservice == null) {
System.out.println("No default PrintService found. Test ABORTED.");
return;
PrintService defService = PrintServiceLookup.lookupDefaultPrintService();
PrintService[] pservice;
if (defService == null) {
pservice = PrintServiceLookup.lookupPrintServices(null, null);
if (pservice.length == 0) {
throw new RuntimeException("No printer found. TEST ABORTED");
}
defService = pservice[0];
}
System.out.println("Default service = "+pservice);
System.out.println("PrintService = "+defService);
DocFlavor[] flavors = pservice.getSupportedDocFlavors();
DocFlavor[] flavors = defService.getSupportedDocFlavors();
if (flavors==null) {
System.out.println("No flavors supported. Test PASSED.");
return;
......@@ -54,13 +56,13 @@ public class CheckDupFlavor {
ArrayList flavorList = new ArrayList();
for (int i=0; i<flavors.length; i++) {
if (flavors[i] == null) {
throw new RuntimeException("Null flavor. Test FAILED.");
} else if (flavorList.contains(flavors[i])) {
throw new RuntimeException("\n\tDuplicate flavor found : "+flavors[i]+" : Test FAILED.");
} else {
flavorList.add(flavors[i]);
}
if (flavors[i] == null) {
throw new RuntimeException("Null flavor. Test FAILED.");
} else if (flavorList.contains(flavors[i])) {
throw new RuntimeException("\n\tDuplicate flavor found : "+flavors[i]+" : Test FAILED.");
} else {
flavorList.add(flavors[i]);
}
}
System.out.println("No duplicate found. Test PASSED.");
}
......
/*
* Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
* 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
......@@ -23,49 +21,30 @@
* have any questions.
*/
#include "jni.h"
#include "jni_util.h"
#include "jlong.h"
#include <string.h>
#include "sun_java2d_pipe_RenderBuffer.h"
/**
* Note: The code in this file is nearly identical to that in
* java/nio/Bits.c...
*/
/*
* @test
* @bug 4510477 6520186
* @summary No crash with HP OfficeJet 600 installed.
* @run main LookupServices
*/
#define MBYTE 1048576
import javax.print.attribute.*;
import javax.print.*;
JNIEXPORT void JNICALL
Java_sun_java2d_pipe_RenderBuffer_copyFromArray
(JNIEnv *env, jclass rb,
jobject srcArray, jlong srcPos, jlong dstAddr, jlong length)
{
jbyte *bytes;
size_t size;
public class LookupServices {
public static void main (String [] args) {
while (length > 0) {
/*
* Copy no more than one megabyte at a time, to allow for GC.
* (Probably not an issue for STR, since our buffer size is likely
* much smaller than a megabyte, but just in case...)
*/
size = (size_t)(length > MBYTE ? MBYTE : length);
DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF;
HashPrintRequestAttributeSet prSet = null;
bytes = (*env)->GetPrimitiveArrayCritical(env, srcArray, NULL);
if (bytes == NULL) {
JNU_ThrowInternalError(env, "Unable to get array");
PrintService[] serv = PrintServiceLookup.lookupPrintServices(flavor, null);
System.out.println("default "+PrintServiceLookup.lookupDefaultPrintService());
if (serv.length==0) {
System.out.println("no PrintService supports GIF");
return;
}
memcpy(jlong_to_ptr(dstAddr), bytes + srcPos, size);
(*env)->ReleasePrimitiveArrayCritical(env, srcArray,
bytes, JNI_ABORT);
length -= size;
dstAddr += size;
srcPos += size;
System.out.println("Selected print service: "+ serv[0]);
}
}
......@@ -43,6 +43,10 @@ public class TestRaceCond {
PrintService[] pservs = PrintServiceLookup.lookupPrintServices(null, null);
PrintService pserv2 = PrintServiceLookup.lookupDefaultPrintService();
if ((pserv1 == null) || (pserv2==null)) {
return;
}
if (pserv1.hashCode() != pserv2.hashCode()) {
throw new RuntimeException("Different hashCodes for equal print "
+ "services: " + pserv1.hashCode() + " "
......
/*
* Copyright 2001-2009 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 1.3 01/05/11
* @bug 4456750
* @summary Test for supported chromaticity values with null DocFlavor.
* No exception should be thrown.
* @run main Chroma
*/
// Chroma.java
import java.io.*;
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
public class Chroma {
public static void main(String args[]) {
StreamPrintServiceFactory []fact =
StreamPrintServiceFactory.lookupStreamPrintServiceFactories(
DocFlavor.SERVICE_FORMATTED.PRINTABLE,
DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType());
if (fact.length != 0) {
OutputStream out = new ByteArrayOutputStream();
StreamPrintService sps = fact[0].getPrintService(out);
checkChroma(sps);
}
PrintService defSvc = PrintServiceLookup.lookupDefaultPrintService();
if (defSvc != null) {
checkChroma(defSvc);
}
}
static void checkChroma(PrintService svc) {
if (svc.isAttributeCategorySupported(Chromaticity.class)) {
svc.getSupportedAttributeValues(Chromaticity.class,null,null);
}
}
}
/*
* Copyright 2001-2009 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 4446106
* @summary Test for chromaticity values.
* @run main ChromaticityValues
*/
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
import java.util.ArrayList;
public class ChromaticityValues {
public static void main(String args[]) {
System.out.println("=======================================================================");
System.out.println("INSTRUCTIONS: This test is only for WINDOWS platform. ");
System.out.println("You should have a printer configured as your default printer in your system.");
System.out.println("=======================================================================");
String os=System.getProperty("os.name").toLowerCase();
if (!(os.indexOf("win")>=0)) {
System.out.println("Not a Windows System. TEST ABORTED");
return;
}
PrintService pservice = PrintServiceLookup.lookupDefaultPrintService();
if (pservice == null) {
throw new RuntimeException("A printer is required for this test.");
}
System.out.println("Default Service is "+pservice);
ColorSupported psa = (ColorSupported)pservice.getAttribute(ColorSupported.class);
ArrayList cValues = new ArrayList();
if (pservice.isAttributeCategorySupported(Chromaticity.class)) {
Chromaticity[] values =(Chromaticity[])
(pservice.getSupportedAttributeValues(Chromaticity.class, DocFlavor.SERVICE_FORMATTED.PAGEABLE, null));
if ((values != null) && (values.length > 0)) {
for (int i=0; i<values.length; i++) {
cValues.add(values[i]);
}
} else {
System.out.println("Chromaticity value is unknown. TEST ABORTED");
return;
}
} else {
System.out.println("Chromaticity is not supported. TEST ABORTED");
return;
}
if (psa != null) {
if (psa.equals(ColorSupported.SUPPORTED)) {
if (cValues.size() < 2) {
throw new RuntimeException("ColorSupported is supported, values for Chromaticity should be monochrome and color.");
}
} else {
if ((cValues.size() != 1) ||
(!cValues.contains(Chromaticity.MONOCHROME))) {
throw new RuntimeException("ColorSupported is not supported, values for Chromaticity should only be monochrome.");
}
}
} else { // ColorSupported unknown
if (!cValues.contains(Chromaticity.COLOR)) {
throw new RuntimeException("ColorSupported is unknown, values for Chromaticity should at least include color.");
}
}
}
}
/*
* Copyright 2001-2009 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 4463280
@summary No ClassCastException should occur.
@run main GetCopiesSupported
*/
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
public class GetCopiesSupported {
public static void main(String args[]) {
PrintService service = PrintServiceLookup.lookupDefaultPrintService();
PrintService[] pservice;
if (service == null) {
pservice = PrintServiceLookup.lookupPrintServices(null, null);
if (pservice.length == 0) {
throw new RuntimeException("No printer found. TEST ABORTED");
}
service = pservice[0];
}
if (service != null) {
CopiesSupported c = (CopiesSupported)
service.getSupportedAttributeValues(Copies.class,
null, null);
System.out.println("CopiesSupported : "+c);
}
}
}
/*
* Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2007-2009 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
......@@ -37,26 +37,26 @@ public class PSCopiesFlavorTest {
public static void main(String args[]) {
DocFlavor flavor = DocFlavor.INPUT_STREAM.POSTSCRIPT;
PrintService ps = PrintServiceLookup.lookupDefaultPrintService();
if (!(ps.isDocFlavorSupported(flavor))) {
System.out.println("unsupported flavor :" + flavor);
return;
PrintService[] ps = PrintServiceLookup.lookupPrintServices(flavor, null);
if (ps.length > 0) {
System.out.println("found PrintService: "+ps[0]);
Copies c = new Copies(1);
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(c);
boolean suppVal = ps[0].isAttributeValueSupported(c, flavor, null);
AttributeSet us = ps[0].getUnsupportedAttributes(flavor, aset);
if (suppVal || us == null) {
throw new RuntimeException("Copies should be unsupported value");
}
Object value = ps[0].getSupportedAttributeValues(Copies.class,
flavor, null);
//Copies Supported
if(value instanceof CopiesSupported) {
throw new RuntimeException("Copies should have no supported values.");
}
}
Copies c = new Copies(1);
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(c);
boolean suppVal = ps.isAttributeValueSupported(c, flavor, null);
AttributeSet us = ps.getUnsupportedAttributes(flavor, aset);
if (suppVal || us == null) {
throw new RuntimeException("Copies should be unsupported value");
}
Object value = ps.getSupportedAttributeValues(Copies.class, flavor, null);
//Copies Supported
if(value instanceof CopiesSupported) {
throw new RuntimeException("Copies should have no supported values.");
}
}
}
/*
* Copyright 2003-2009 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 4903366
* @summary No crash should occur.
* @run main SidesPageRangesTest
*/
import java.awt.*;
import javax.print.*;
import javax.print.attribute.standard.*;
import javax.print.attribute.*;
import java.io.*;
import java.util.Locale;
import java.net.URL;
public class SidesPageRangesTest {
/**
* Constructor
*/
public SidesPageRangesTest() {
super();
}
/**
* Starts the application.
*/
public static void main(java.lang.String[] args) {
SidesPageRangesTest pd = new SidesPageRangesTest();
PrintService defService = null;
DocFlavor flavors[] = null;
PrintService[] pservice;
defService = PrintServiceLookup.lookupDefaultPrintService();
if (defService == null) {
pservice = PrintServiceLookup.lookupPrintServices(null, null);
if (pservice.length == 0) {
throw new RuntimeException("Printer is required for this test. TEST ABORTED");
}
defService = pservice[0];
}
System.out.println("Default Print Service "+defService);
if (defService.isAttributeCategorySupported(PageRanges.class)) {
System.out.println("\nPageRanges Attribute category is supported");
} else {
System.out.println("\nPageRanges Attribute category is not supported. terminating...");
System.exit(1);
}
flavors = defService.getSupportedDocFlavors();
System.out.println("\nGetting Supported values for PageRanges for each supported DocFlavor");
System.out.println("===============================================================\n");
for (int y = 0; y < flavors.length; y ++) {
System.out.println("\n\n");
System.out.println("Doc Flavor: "+flavors[y]);
System.out.println("-----------------------------");
Object vals = defService.getSupportedAttributeValues(PageRanges.class, flavors[y], null);
if (vals == null) {
System.out.println("No supported values for PageRanges for this doc flavor. ");
}
PageRanges[] pr = null;
if (vals instanceof PageRanges[]) {
pr = (PageRanges[]) vals;
for (int x = 0; x < pr.length; x ++) {
System.out.println("\nSupported Value "+pr[x]);
System.out.println("is "+pr[x]+" value supported? "+defService.isAttributeValueSupported(pr[x], flavors[y], null));
if (!defService.isAttributeValueSupported(pr[x], flavors[y], null)) {
throw new RuntimeException("PageRanges contradicts getSupportedAttributeValues");
}
}
} else if (vals instanceof PageRanges) {
System.out.println(vals);
System.out.println("is "+vals+" value supported? "+defService.isAttributeValueSupported((javax.print.attribute.Attribute)vals, flavors[y], null));
if (!defService.isAttributeValueSupported((javax.print.attribute.Attribute)vals, flavors[y], null)) {
throw new RuntimeException("PageRanges contradicts getSupportedAttributeValues");
}
}
// SIDES test
vals = defService.getSupportedAttributeValues(Sides.class, flavors[y], null);
if (vals == null) {
System.out.println("No supported values for Sides for this doc flavor. ");
}
Sides[] s = null;
if (vals instanceof Sides[]) {
s = (Sides[]) vals;
for (int x = 0; x < s.length; x ++) {
System.out.println("\nSupported Value "+s[x]);
System.out.println("is "+s[x]+" value supported? "+defService.isAttributeValueSupported(s[x], flavors[y], null));
if (!defService.isAttributeValueSupported(s[x], flavors[y], null)) {
throw new RuntimeException("Sides contradicts getSupportedAttributeValues");
}
}
}
}
}
}
/*
* Copyright 2003-2009 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 4762773 6289206 6324049 6362765
* @summary Tests that get non-null return list of printable areas.
* @run main SupportedPrintableAreas
*/
import javax.print.*;
import javax.print.event.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
public class SupportedPrintableAreas {
public static void main(String[] args) {
PrintService[] svc;
PrintService printer = PrintServiceLookup.lookupDefaultPrintService();
if (printer == null) {
svc = PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
if (svc.length == 0) {
throw new RuntimeException("Printer is required for this test. TEST ABORTED");
}
printer = svc[0];
}
System.out.println("PrintService found : "+printer);
if (!printer.isAttributeCategorySupported(MediaPrintableArea.class)) {
return;
}
Object value = printer.getSupportedAttributeValues(
MediaPrintableArea.class, null, null);
if (!value.getClass().isArray()) {
throw new RuntimeException("unexpected value");
}
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
value = printer.getSupportedAttributeValues(
MediaPrintableArea.class, null, aset);
if (!value.getClass().isArray()) {
throw new RuntimeException("unexpected value");
}
Media media = (Media)printer.getDefaultAttributeValue(Media.class);
aset.add(media);
value = printer.getSupportedAttributeValues(
MediaPrintableArea.class, null, aset);
if (!value.getClass().isArray()) {
throw new RuntimeException("unexpected value");
}
// test for 6289206
aset.add(MediaTray.MANUAL);
value = printer.getSupportedAttributeValues(
MediaPrintableArea.class, null, aset);
if ((value != null) && !value.getClass().isArray()) {
throw new RuntimeException("unexpected value");
}
}
}
/*
* Copyright 2001-2009 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 4468109
* @summary Test for printing AUTOSENSE DocFlavor. No exception should be thrown.
* @run main PrintAutoSenseData
*/
import java.io.*;
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
import java.net.URL;
public class PrintAutoSenseData
{
private DocFlavor flavor = DocFlavor.URL.AUTOSENSE; //represents the docflavor.
private PrintService[] service = PrintServiceLookup.lookupPrintServices(flavor, null);
public PrintAutoSenseData()
{
if (service.length == 0)
{
System.out.println("No print service available...");
return;
}
System.out.println("selected PrintService: " + this.service[0]);
if (service[0].isDocFlavorSupported(flavor)) {
System.out.println("DocFlavor.URL.AUTOSENSE supported");
} else {
System.out.println("DocFlavor.URL.AUTOSENSE not supported. Testing aborted !!");
return;
}
DocPrintJob job = service[0].createPrintJob();
this.print();
}
// The print method prints sample file with DocFlavor.URL.AUTOSENSE.
void print()
{
String fileName = "./sample.txt";
DocPrintJob job = service[0].createPrintJob();
// The representation class is a URL.
System.out.println("printing " + fileName + " using doc flavor: " + this.flavor);
System.out.println("Rep. class name: " + this.flavor.getRepresentationClassName() + " MimeType: " + this.flavor.getMimeType());
Doc doc = new URLDoc(fileName, this.flavor);
HashPrintRequestAttributeSet prSet =
new HashPrintRequestAttributeSet();
prSet.add(new Destination(new File("./dest.prn").toURI()));
//print the document.
try {
job.print(doc, prSet);
} catch ( Exception e ) {
e.printStackTrace();
}
}
public static void main(String[] args) {
new PrintAutoSenseData();
}
}
/* This class is for reading autosense data with URL representation class */
class URLDoc implements Doc
{
protected String fileName = null;
protected DocFlavor flavor = null;
protected Object printData = null;
protected InputStream instream = null;
public URLDoc(String filename, DocFlavor docFlavor)
{
this.fileName = filename;
this.flavor = docFlavor;
}
public DocFlavor getDocFlavor() {
return DocFlavor.URL.AUTOSENSE;
}
public DocAttributeSet getAttributes()
{
HashDocAttributeSet hset = new HashDocAttributeSet();
return hset;
}
public Object getPrintData()
{
if ( this.printData == null )
{
this.printData = URLDoc.class.getResource(this.fileName);
System.out.println("getPrintData(): " + this.printData);
}
return this.printData;
}
public Reader getReaderForText()
{
return null;
}
public InputStream getStreamForBytes()
{
System.out.println("getStreamForBytes(): " + this.printData);
try
{
if ( (this.printData != null) && (this.printData instanceof URL) )
{
this.instream = ((URL)this.printData).openStream();
}
if (this.instream == null)
{
URL url = URLDoc.class.getResource(this.fileName);
this.instream = url.openStream();
}
}
catch ( IOException ie )
{
System.out.println("URLDoc: exception: " + ie.toString());
}
return this.instream;
}
}
/*
* Copyright 2009 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.*;
import java.awt.geom.Ellipse2D;
import java.awt.geom.GeneralPath;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
/**
* @author chrisn@google.com (Chris Nokleberg)
* @author yamauchi@google.com (Hiroshi Yamauchi)
*/
public class StrokeShapeTest {
public static void main(String[] args) throws Exception {
BufferedImage image = new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB);
Graphics2D g = image.createGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setPaint(Color.WHITE);
g.fill(new Rectangle(image.getWidth(), image.getHeight()));
g.translate(25, 100);
Stroke stroke = new BasicStroke(200, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
Shape shape = new Polygon(new int[] {0, 1500, 0}, new int[] {750, 0, -750}, 3);
g.scale(.1, .1);
g.setPaint(Color.BLACK);
g.setStroke(stroke);
g.draw(shape);
g.setPaint(Color.RED);
g.fill(stroke.createStrokedShape(shape));
// To visually check it
//ImageIO.write(image, "PNG", new File(args[0]));
boolean blackPixelFound = false;
outer:
for (int x = 0; x < 200; ++x) {
for (int y = 0; y < 200; ++y) {
if (image.getRGB(x, y) == Color.BLACK.getRGB()) {
blackPixelFound = true;
break outer;
}
}
}
if (blackPixelFound) {
throw new RuntimeException("The shape hasn't been filled in red.");
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册