提交 95b9d9bb 编写于 作者: L lana

Merge

...@@ -37,6 +37,7 @@ package java.awt.color; ...@@ -37,6 +37,7 @@ package java.awt.color;
import sun.java2d.cmm.PCMM; import sun.java2d.cmm.PCMM;
import sun.java2d.cmm.CMSManager; import sun.java2d.cmm.CMSManager;
import sun.java2d.cmm.ProfileDataVerifier;
import sun.java2d.cmm.ProfileDeferralMgr; import sun.java2d.cmm.ProfileDeferralMgr;
import sun.java2d.cmm.ProfileDeferralInfo; import sun.java2d.cmm.ProfileDeferralInfo;
import sun.java2d.cmm.ProfileActivator; import sun.java2d.cmm.ProfileActivator;
...@@ -775,6 +776,8 @@ public class ICC_Profile implements Serializable { ...@@ -775,6 +776,8 @@ public class ICC_Profile implements Serializable {
ProfileDeferralMgr.activateProfiles(); ProfileDeferralMgr.activateProfiles();
} }
ProfileDataVerifier.verify(data);
try { try {
theID = CMSManager.getModule().loadProfile(data); theID = CMSManager.getModule().loadProfile(data);
} catch (CMMException c) { } catch (CMMException c) {
......
/*
* Copyright (c) 2013, Oracle and/or its affiliates. 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.java2d.cmm;
public class ProfileDataVerifier {
/**
* Throws an IllegalArgumentException if the data does not correspond
* to a valid ICC Profile.
*
* @param data the specified profile data.
*/
public static void verify(byte[] data) {
if (data == null) {
throw new IllegalArgumentException("Invalid ICC Profile Data");
}
if (data.length < TOC_OFFSET) {
// not enough data for profile header
throw new IllegalArgumentException("Invalid ICC Profile Data");
}
// check profile size
final int size = readInt32(data, 0);
final int tagCount = readInt32(data, HEADER_SIZE);
if (tagCount < 0 || tagCount > MAX_TAG_COUNT) {
throw new IllegalArgumentException("Invalid ICC Profile Data");
}
if (size < (TOC_OFFSET + (tagCount * TOC_RECORD_SIZE)) ||
size > data.length)
{
throw new IllegalArgumentException("Invalid ICC Profile Data");
}
final int sig = readInt32(data, 36);
if (PROFILE_FILE_SIGNATURE != sig) {
throw new IllegalArgumentException("Invalid ICC Profile Data");
}
// verify table of content
for (int i = 0; i < tagCount; i++) {
final int tag_offset = getTagOffset(i, data);
final int tag_size = getTagSize(i, data);
if (tag_offset < TOC_OFFSET || tag_offset > size) {
throw new IllegalArgumentException("Invalid ICC Profile Data");
}
if (tag_size < 0 ||
tag_size > (Integer.MAX_VALUE - tag_offset) ||
tag_size + tag_offset > size)
{
throw new IllegalArgumentException("Invalid ICC Profile Data");
}
}
}
private static int getTagOffset(int idx, byte[] data) {
final int pos = TOC_OFFSET + idx * TOC_RECORD_SIZE + 4;
return readInt32(data, pos);
}
private static int getTagSize(int idx, byte[] data) {
final int pos = TOC_OFFSET + idx * TOC_RECORD_SIZE + 8;
return readInt32(data, pos);
}
private static int readInt32(byte[] data, int off) {
int res = 0;
for (int i = 0; i < 4; i++) {
res = res << 8;
res |= (0xff & data[off++]);
}
return res;
}
/**
* Lcms limit for the number of tags: 100
* Kcms limit for the number of tags: N/A
*/
private static final int MAX_TAG_COUNT = 100;
private static final int HEADER_SIZE = 128;
private static final int TOC_OFFSET = HEADER_SIZE + 4;
private static final int TOC_RECORD_SIZE = 12;
private static final int PROFILE_FILE_SIGNATURE = 0x61637370;
}
...@@ -96,7 +96,7 @@ LE_CORRECT_SIZE(KernTableHeader, KERN_TABLE_HEADER_SIZE) ...@@ -96,7 +96,7 @@ LE_CORRECT_SIZE(KernTableHeader, KERN_TABLE_HEADER_SIZE)
* TODO: respect header flags * TODO: respect header flags
*/ */
KernTable::KernTable(const LETableReference& base, LEErrorCode &success) KernTable::KernTable(const LETableReference& base, LEErrorCode &success)
: pairs(), pairsSwapped(NULL), fTable(base) : pairsSwapped(NULL), fTable(base)
{ {
if(LE_FAILURE(success) || (fTable.isEmpty())) { if(LE_FAILURE(success) || (fTable.isEmpty())) {
#if DEBUG #if DEBUG
...@@ -143,32 +143,36 @@ KernTable::KernTable(const LETableReference& base, LEErrorCode &success) ...@@ -143,32 +143,36 @@ KernTable::KernTable(const LETableReference& base, LEErrorCode &success)
#endif #endif
if(LE_SUCCESS(success) && nPairs>0) { if(LE_SUCCESS(success) && nPairs>0) {
// pairs is an instance member, and table is on the stack. // pairsSwapped is an instance member, and table is on the stack.
// set 'pairs' based on table.getAlias(). This will range check it. // set 'pairsSwapped' based on table.getAlias(). This will range check it.
pairs = LEReferenceToArrayOf<PairInfo>(fTable, // based on overall table pairsSwapped = (PairInfo*)(fTable.getFont()->getKernPairs());
success, if (pairsSwapped == NULL) {
(const PairInfo*)table.getAlias(), // subtable 0 + .. LEReferenceToArrayOf<PairInfo>pairs =
KERN_SUBTABLE_0_HEADER_SIZE, // .. offset of header size LEReferenceToArrayOf<PairInfo>(fTable, // based on overall table
nPairs); // count success,
} (const PairInfo*)table.getAlias(), // subtable 0 + ..
if (LE_SUCCESS(success) && pairs.isValid()) { KERN_SUBTABLE_0_HEADER_SIZE, // .. offset of header size
pairsSwapped = (PairInfo*)(malloc(nPairs*sizeof(PairInfo))); nPairs); // count
PairInfo *p = (PairInfo*)pairsSwapped; if (LE_SUCCESS(success) && pairs.isValid()) {
for (int i = 0; LE_SUCCESS(success) && i < nPairs; i++, p++) { pairsSwapped = (PairInfo*)(malloc(nPairs*sizeof(PairInfo)));
memcpy(p, pairs.getAlias(i,success), KERN_PAIRINFO_SIZE); PairInfo *p = (PairInfo*)pairsSwapped;
p->key = SWAPL(p->key); for (int i = 0; LE_SUCCESS(success) && i < nPairs; i++, p++) {
memcpy(p, pairs.getAlias(i,success), KERN_PAIRINFO_SIZE);
p->key = SWAPL(p->key);
}
fTable.getFont()->setKernPairs((void*)pairsSwapped); // store it
} }
fTable.getFont()->setKernPairs((void*)pairsSwapped); // store it }
} }
#if 0 #if 0
fprintf(stderr, "coverage: %0.4x nPairs: %d pairs %p\n", coverage, nPairs, pairs.getAlias()); fprintf(stderr, "coverage: %0.4x nPairs: %d pairs %p\n", coverage, nPairs, pairsSwapped);
fprintf(stderr, " searchRange: %d entrySelector: %d rangeShift: %d\n", searchRange, entrySelector, rangeShift); fprintf(stderr, " searchRange: %d entrySelector: %d rangeShift: %d\n", searchRange, entrySelector, rangeShift);
fprintf(stderr, "[[ ignored font table entries: range %d selector %d shift %d ]]\n", SWAPW(table->searchRange), SWAPW(table->entrySelector), SWAPW(table->rangeShift)); fprintf(stderr, "[[ ignored font table entries: range %d selector %d shift %d ]]\n", SWAPW(table->searchRange), SWAPW(table->entrySelector), SWAPW(table->rangeShift));
#endif #endif
#if DEBUG #if DEBUG
fprintf(stderr, "coverage: %0.4x nPairs: %d pairs 0x%x\n", coverage, nPairs, pairs); fprintf(stderr, "coverage: %0.4x nPairs: %d pairs 0x%x\n", coverage, nPairs, pairsSwapped);
fprintf(stderr, fprintf(stderr,
" searchRange(pairs): %d entrySelector: %d rangeShift(pairs): %d\n", " searchRange(pairs): %d entrySelector: %d rangeShift(pairs): %d\n",
searchRange, entrySelector, rangeShift); searchRange, entrySelector, rangeShift);
...@@ -182,7 +186,7 @@ KernTable::KernTable(const LETableReference& base, LEErrorCode &success) ...@@ -182,7 +186,7 @@ KernTable::KernTable(const LETableReference& base, LEErrorCode &success)
ids[id] = (char)i; ids[id] = (char)i;
} }
} }
PairInfo *p = pairs; PairInfo *p = pairsSwapped;
for (int i = 0; i < nPairs; ++i, p++) { for (int i = 0; i < nPairs; ++i, p++) {
le_uint32 k = p->key; le_uint32 k = p->key;
le_uint16 left = (k >> 16) & 0xffff; le_uint16 left = (k >> 16) & 0xffff;
......
...@@ -57,7 +57,6 @@ class U_LAYOUT_API KernTable ...@@ -57,7 +57,6 @@ class U_LAYOUT_API KernTable
private: private:
le_uint16 coverage; le_uint16 coverage;
le_uint16 nPairs; le_uint16 nPairs;
LEReferenceToArrayOf<PairInfo> pairs;
PairInfo *pairsSwapped; PairInfo *pairsSwapped;
const LETableReference &fTable; const LETableReference &fTable;
le_uint16 searchRange; le_uint16 searchRange;
......
...@@ -569,7 +569,6 @@ void LayoutEngine::reset() ...@@ -569,7 +569,6 @@ void LayoutEngine::reset()
{ {
if(fGlyphStorage!=NULL) { if(fGlyphStorage!=NULL) {
fGlyphStorage->reset(); fGlyphStorage->reset();
fGlyphStorage = NULL;
} }
} }
......
...@@ -362,10 +362,33 @@ public class UnixPrintServiceLookup extends PrintServiceLookup ...@@ -362,10 +362,33 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
*/ */
private PrintService getServiceByName(PrinterName nameAttr) { private PrintService getServiceByName(PrinterName nameAttr) {
String name = nameAttr.getValue(); String name = nameAttr.getValue();
PrintService printer = null;
if (name == null || name.equals("") || !checkPrinterName(name)) { if (name == null || name.equals("") || !checkPrinterName(name)) {
return null; return null;
} }
/* check is all printers are already available */
if (printServices != null) {
for (PrintService printService : printServices) {
if (printService.getName().equals(name)) {
return printService;
}
}
}
/* take CUPS into account first */
if (CUPSPrinter.isCupsRunning()) {
try {
return new IPPPrintService(name,
new URL("http://"+
CUPSPrinter.getServer()+":"+
CUPSPrinter.getPort()+"/"+
name));
} catch (Exception e) {
IPPPrintService.debug_println(debugPrefix+
" getServiceByName Exception "+
e);
}
}
/* fallback if nothing not having a printer at this point */
PrintService printer = null;
if (isMac() || isSysV()) { if (isMac() || isSysV()) {
printer = getNamedPrinterNameSysV(name); printer = getNamedPrinterNameSysV(name);
} else { } else {
......
...@@ -1269,11 +1269,13 @@ public class WPrinterJob extends RasterPrinterJob implements DisposerTarget { ...@@ -1269,11 +1269,13 @@ public class WPrinterJob extends RasterPrinterJob implements DisposerTarget {
mLastFontFamily = null; mLastFontFamily = null;
} }
private boolean defaultCopies = true;
/** /**
* Set the number of copies to be printed. * Set the number of copies to be printed.
*/ */
public void setCopies(int copies) { public void setCopies(int copies) {
super.setCopies(copies); super.setCopies(copies);
defaultCopies = false;
mAttCopies = copies; mAttCopies = copies;
setNativeCopies(copies); setNativeCopies(copies);
} }
...@@ -1529,8 +1531,9 @@ public class WPrinterJob extends RasterPrinterJob implements DisposerTarget { ...@@ -1529,8 +1531,9 @@ public class WPrinterJob extends RasterPrinterJob implements DisposerTarget {
} }
/* SheetCollate */ /* SheetCollate */
private final boolean getCollateAttrib() { private final int getCollateAttrib() {
return (mAttCollate == 1); // -1 means unset, 0 uncollated, 1 collated.
return mAttCollate;
} }
private void setCollateAttrib(Attribute attr) { private void setCollateAttrib(Attribute attr) {
...@@ -1553,6 +1556,10 @@ public class WPrinterJob extends RasterPrinterJob implements DisposerTarget { ...@@ -1553,6 +1556,10 @@ public class WPrinterJob extends RasterPrinterJob implements DisposerTarget {
int orient = PageFormat.PORTRAIT; int orient = PageFormat.PORTRAIT;
OrientationRequested orientReq = (attributes == null) ? null : OrientationRequested orientReq = (attributes == null) ? null :
(OrientationRequested)attributes.get(OrientationRequested.class); (OrientationRequested)attributes.get(OrientationRequested.class);
if (orientReq == null) {
orientReq = (OrientationRequested)
myService.getDefaultAttributeValue(OrientationRequested.class);
}
if (orientReq != null) { if (orientReq != null) {
if (orientReq == OrientationRequested.REVERSE_LANDSCAPE) { if (orientReq == OrientationRequested.REVERSE_LANDSCAPE) {
orient = PageFormat.REVERSE_LANDSCAPE; orient = PageFormat.REVERSE_LANDSCAPE;
...@@ -1573,7 +1580,11 @@ public class WPrinterJob extends RasterPrinterJob implements DisposerTarget { ...@@ -1573,7 +1580,11 @@ public class WPrinterJob extends RasterPrinterJob implements DisposerTarget {
/* Copies and Page Range. */ /* Copies and Page Range. */
private final int getCopiesAttrib() { private final int getCopiesAttrib() {
return getCopiesInt(); if (defaultCopies) {
return 0;
} else {
return getCopiesInt();
}
} }
private final void setRangeCopiesAttribute(int from, int to, private final void setRangeCopiesAttribute(int from, int to,
...@@ -1584,6 +1595,7 @@ public class WPrinterJob extends RasterPrinterJob implements DisposerTarget { ...@@ -1584,6 +1595,7 @@ public class WPrinterJob extends RasterPrinterJob implements DisposerTarget {
attributes.add(new PageRanges(from, to)); attributes.add(new PageRanges(from, to));
setPageRange(from, to); setPageRange(from, to);
} }
defaultCopies = false;
attributes.add(new Copies(copies)); attributes.add(new Copies(copies));
/* Since this is called from native to tell Java to sync /* Since this is called from native to tell Java to sync
* up with native, we don't call this class's own setCopies() * up with native, we don't call this class's own setCopies()
......
...@@ -180,6 +180,9 @@ public class Win32PrintService implements PrintService, AttributeUpdater, ...@@ -180,6 +180,9 @@ public class Win32PrintService implements PrintService, AttributeUpdater,
private static final int DMDUP_VERTICAL = 2; private static final int DMDUP_VERTICAL = 2;
private static final int DMDUP_HORIZONTAL = 3; private static final int DMDUP_HORIZONTAL = 3;
private static final int DMCOLLATE_TRUE = 1; private static final int DMCOLLATE_TRUE = 1;
private static final int DMCOLOR_MONOCHROME = 1;
private static final int DMCOLOR_COLOR = 2;
// media sizes with indices above dmPaperToPrintService' length // media sizes with indices above dmPaperToPrintService' length
private static final int DMPAPER_A2 = 66; private static final int DMPAPER_A2 = 66;
...@@ -1041,6 +1044,7 @@ public class Win32PrintService implements PrintService, AttributeUpdater, ...@@ -1041,6 +1044,7 @@ public class Win32PrintService implements PrintService, AttributeUpdater,
int defOrient = defaults[5]; int defOrient = defaults[5];
int defSides = defaults[6]; int defSides = defaults[6];
int defCollate = defaults[7]; int defCollate = defaults[7];
int defColor = defaults[8];
if (category == Copies.class) { if (category == Copies.class) {
if (defCopies > 0) { if (defCopies > 0) {
...@@ -1049,11 +1053,10 @@ public class Win32PrintService implements PrintService, AttributeUpdater, ...@@ -1049,11 +1053,10 @@ public class Win32PrintService implements PrintService, AttributeUpdater,
return new Copies(1); return new Copies(1);
} }
} else if (category == Chromaticity.class) { } else if (category == Chromaticity.class) {
int caps = getPrinterCapabilities(); if (defColor == DMCOLOR_COLOR) {
if ((caps & DEVCAP_COLOR) == 0) {
return Chromaticity.MONOCHROME;
} else {
return Chromaticity.COLOR; return Chromaticity.COLOR;
} else {
return Chromaticity.MONOCHROME;
} }
} else if (category == JobName.class) { } else if (category == JobName.class) {
return new JobName("Java Printing", null); return new JobName("Java Printing", null);
......
...@@ -750,7 +750,7 @@ Java_sun_print_Win32PrintService_getCapabilities(JNIEnv *env, ...@@ -750,7 +750,7 @@ Java_sun_print_Win32PrintService_getCapabilities(JNIEnv *env,
#define GETDEFAULT_ERROR -50 #define GETDEFAULT_ERROR -50
#define NDEFAULT 8 #define NDEFAULT 9
JNIEXPORT jintArray JNICALL JNIEXPORT jintArray JNICALL
Java_sun_print_Win32PrintService_getDefaultSettings(JNIEnv *env, Java_sun_print_Win32PrintService_getDefaultSettings(JNIEnv *env,
...@@ -859,6 +859,11 @@ Java_sun_print_Win32PrintService_getDefaultSettings(JNIEnv *env, ...@@ -859,6 +859,11 @@ Java_sun_print_Win32PrintService_getDefaultSettings(JNIEnv *env,
defIndices[7] = pDevMode->dmCollate; defIndices[7] = pDevMode->dmCollate;
} }
if (pDevMode->dmFields & DM_COLOR) {
defIndices[8] = pDevMode->dmColor;
}
GlobalFree(pDevMode); GlobalFree(pDevMode);
::ClosePrinter(hPrinter); ::ClosePrinter(hPrinter);
......
...@@ -252,7 +252,7 @@ void AwtPrintControl::initIDs(JNIEnv *env, jclass cls) ...@@ -252,7 +252,7 @@ void AwtPrintControl::initIDs(JNIEnv *env, jclass cls)
AwtPrintControl::getCopiesID = AwtPrintControl::getCopiesID =
env->GetMethodID(cls, "getCopiesAttrib", "()I"); env->GetMethodID(cls, "getCopiesAttrib", "()I");
AwtPrintControl::getCollateID = AwtPrintControl::getCollateID =
env->GetMethodID(cls, "getCollateAttrib","()Z"); env->GetMethodID(cls, "getCollateAttrib","()I");
AwtPrintControl::getOrientID = AwtPrintControl::getOrientID =
env->GetMethodID(cls, "getOrientAttrib", "()I"); env->GetMethodID(cls, "getOrientAttrib", "()I");
AwtPrintControl::getFromPageID = AwtPrintControl::getFromPageID =
...@@ -690,12 +690,6 @@ BOOL AwtPrintControl::InitPrintDialog(JNIEnv *env, ...@@ -690,12 +690,6 @@ BOOL AwtPrintControl::InitPrintDialog(JNIEnv *env,
pd.Flags = PD_ENABLEPRINTHOOK | PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE; pd.Flags = PD_ENABLEPRINTHOOK | PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE;
pd.lpfnPrintHook = (LPPRINTHOOKPROC)PrintDlgHook; pd.lpfnPrintHook = (LPPRINTHOOKPROC)PrintDlgHook;
if (env->CallBooleanMethod(printCtrl, AwtPrintControl::getCollateID)) {
pd.Flags |= PD_COLLATE;
}
pd.nCopies = (WORD)env->CallIntMethod(printCtrl,
AwtPrintControl::getCopiesID);
pd.nFromPage = (WORD)env->CallIntMethod(printCtrl, pd.nFromPage = (WORD)env->CallIntMethod(printCtrl,
AwtPrintControl::getFromPageID); AwtPrintControl::getFromPageID);
pd.nToPage = (WORD)env->CallIntMethod(printCtrl, pd.nToPage = (WORD)env->CallIntMethod(printCtrl,
...@@ -729,37 +723,52 @@ BOOL AwtPrintControl::InitPrintDialog(JNIEnv *env, ...@@ -729,37 +723,52 @@ BOOL AwtPrintControl::InitPrintDialog(JNIEnv *env,
DEVMODE *devmode = (DEVMODE *)::GlobalLock(pd.hDevMode); DEVMODE *devmode = (DEVMODE *)::GlobalLock(pd.hDevMode);
DASSERT(!IsBadWritePtr(devmode, sizeof(DEVMODE))); DASSERT(!IsBadWritePtr(devmode, sizeof(DEVMODE)));
devmode->dmFields |= DM_COPIES | DM_COLLATE | DM_ORIENTATION | WORD copies = (WORD)env->CallIntMethod(printCtrl,
DM_PAPERSIZE | DM_PRINTQUALITY | DM_COLOR | DM_DUPLEX; AwtPrintControl::getCopiesID);
if (copies > 0) {
devmode->dmCopies = pd.nCopies; devmode->dmFields |= DM_COPIES;
devmode->dmCopies = copies;
}
jint orient = env->CallIntMethod(printCtrl, jint orient = env->CallIntMethod(printCtrl,
AwtPrintControl::getOrientID); AwtPrintControl::getOrientID);
if (orient == 0) { if (orient == 0) { // PageFormat.LANDSCAPE == 0
devmode->dmFields |= DM_ORIENTATION;
devmode->dmOrientation = DMORIENT_LANDSCAPE; devmode->dmOrientation = DMORIENT_LANDSCAPE;
} else if (orient == 1) { } else if (orient == 1) { // PageFormat.PORTRAIT == 1
devmode->dmFields |= DM_ORIENTATION;
devmode->dmOrientation = DMORIENT_PORTRAIT; devmode->dmOrientation = DMORIENT_PORTRAIT;
} }
devmode->dmCollate = (pd.Flags & PD_COLLATE) ? DMCOLLATE_TRUE // -1 means unset, so we'll accept the printer default.
: DMCOLLATE_FALSE; int collate = env->CallIntMethod(printCtrl,
AwtPrintControl::getCollateID);
if (collate == 1) {
devmode->dmFields |= DM_COLLATE;
devmode->dmCollate = DMCOLLATE_TRUE;
} else if (collate == 0) {
devmode->dmFields |= DM_COLLATE;
devmode->dmCollate = DMCOLLATE_FALSE;
}
int quality = env->CallIntMethod(printCtrl, int quality = env->CallIntMethod(printCtrl,
AwtPrintControl::getQualityID); AwtPrintControl::getQualityID);
if (quality) { if (quality) {
devmode->dmFields |= DM_PRINTQUALITY;
devmode->dmPrintQuality = quality; devmode->dmPrintQuality = quality;
} }
int color = env->CallIntMethod(printCtrl, int color = env->CallIntMethod(printCtrl,
AwtPrintControl::getColorID); AwtPrintControl::getColorID);
if (color) { if (color) {
devmode->dmFields |= DM_COLOR;
devmode->dmColor = color; devmode->dmColor = color;
} }
int sides = env->CallIntMethod(printCtrl, int sides = env->CallIntMethod(printCtrl,
AwtPrintControl::getSidesID); AwtPrintControl::getSidesID);
if (sides) { if (sides) {
devmode->dmFields |= DM_DUPLEX;
devmode->dmDuplex = (int)sides; devmode->dmDuplex = (int)sides;
} }
...@@ -771,6 +780,7 @@ BOOL AwtPrintControl::InitPrintDialog(JNIEnv *env, ...@@ -771,6 +780,7 @@ BOOL AwtPrintControl::InitPrintDialog(JNIEnv *env,
double newWid = 0.0, newHt = 0.0; double newWid = 0.0, newHt = 0.0;
if (wid_ht != NULL && wid_ht[0] != 0 && wid_ht[1] != 0) { if (wid_ht != NULL && wid_ht[0] != 0 && wid_ht[1] != 0) {
devmode->dmFields |= DM_PAPERSIZE;
devmode->dmPaperSize = AwtPrintControl::getNearestMatchingPaper( devmode->dmPaperSize = AwtPrintControl::getNearestMatchingPaper(
printName, printName,
portName, portName,
......
/*
* Copyright (c) 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @bug 8015334
* @summary Memory leak with kerning.
*/
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.font.TextAttribute;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
public class KerningLeak {
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
leak();
}
});
}
private static void leak() {
Map<TextAttribute, Object> textAttributes = new HashMap<>();
textAttributes.put(TextAttribute.FAMILY, "Sans Serif");
textAttributes.put(TextAttribute.SIZE, 12);
textAttributes.put(TextAttribute.KERNING, TextAttribute.KERNING_ON);
Font font = Font.getFont(textAttributes);
JLabel label = new JLabel();
int dummy = 0;
for (int i = 0; i < 500; i++) {
if (i % 10 == 0) System.out.println("Starting iter " + (i+1));
for (int j = 0; j <1000; j++) {
FontMetrics fm = label.getFontMetrics(font);
dummy += SwingUtilities.computeStringWidth(fm, Integer.toString(j));
}
}
System.out.println("done " + dummy);
}
}
/*
* Copyright (c) 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.attribute.AttributeSet;
import javax.print.attribute.HashAttributeSet;
import javax.print.attribute.standard.PrinterName;
/*
* @test
* @bug 8013810
* @summary Test that print service returned without filter are of the same class as with name filter
*/
public class GetPrintServices {
public static void main(String[] args) throws Exception {
for (PrintService service : PrintServiceLookup.lookupPrintServices(null, null)) {
String serviceName = service.getName();
PrintService serviceByName = lookupByName(serviceName);
if (!service.equals(serviceByName)) {
throw new RuntimeException("NOK " + serviceName
+ " expected: " + service.getClass().getName()
+ " got: " + serviceByName.getClass().getName());
}
}
System.out.println("Test PASSED");
}
private static PrintService lookupByName(String name) {
AttributeSet attributes = new HashAttributeSet();
attributes.add(new PrinterName(name, null));
for (PrintService service : PrintServiceLookup.lookupPrintServices(null, attributes)) {
return service;
}
return null;
}
}
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/** /**
* @test * @test
* @bug 6476665 7033534 * @bug 6476665 7033534 6830714
* @summary Verifies color conversion of Component Color Model based images * @summary Verifies color conversion of Component Color Model based images
* @run main ColConvCCMTest * @run main ColConvCCMTest
*/ */
...@@ -57,9 +57,9 @@ public class ColConvCCMTest extends ColConvTest { ...@@ -57,9 +57,9 @@ public class ColConvCCMTest extends ColConvTest {
final static double [] ACCURACY = { final static double [] ACCURACY = {
// Accuracy for color conversions // Accuracy for color conversions
2.5, // sRGB 2.5, // sRGB
6.5, // LINEAR_RGB (isOpenProfile() ? 45.0 : 10.1), // LINEAR_RGB
10.5, // GRAY 10.5, // GRAY
45.5, // PYCC (isOpenProfile() ? 207 : 45.5), // PYCC
47.5 // CIEXYZ 47.5 // CIEXYZ
}; };
......
...@@ -62,7 +62,11 @@ public class ColConvDCMTest extends ColConvTest { ...@@ -62,7 +62,11 @@ public class ColConvDCMTest extends ColConvTest {
ColorSpace.CS_LINEAR_RGB, ColorSpace.CS_LINEAR_RGB,
}; };
final static double ACCURACY = 2.5; final static double [] ACCURACY = {
// Accuracy for color conversions
2.5, // sRGB
(isOpenProfile() ? 45.0 : 2.5), // LINEAR_RGB
};
final static String [] gldImgNames = { final static String [] gldImgNames = {
"SRGB.png", "SRGB555.png", "SRGB565.png", "LRGB.png", "LRGB555.png", "SRGB.png", "SRGB555.png", "SRGB565.png", "LRGB.png", "LRGB555.png",
...@@ -142,7 +146,7 @@ public class ColConvDCMTest extends ColConvTest { ...@@ -142,7 +146,7 @@ public class ColConvDCMTest extends ColConvTest {
if (!testImage(imgTypes[i][0], imgTypes[i][1], imgTypes[i][2], if (!testImage(imgTypes[i][0], imgTypes[i][1], imgTypes[i][2],
imgTypes[i][3], cSpaces[imgTypes[i][4]], gldImage, imgTypes[i][3], cSpaces[imgTypes[i][4]], gldImage,
ACCURACY)) ACCURACY[imgTypes[i][4]]))
{ {
throw new RuntimeException( throw new RuntimeException(
"Invalid result of the ColorConvertOp for " + "Invalid result of the ColorConvertOp for " +
...@@ -154,7 +158,8 @@ public class ColConvDCMTest extends ColConvTest { ...@@ -154,7 +158,8 @@ public class ColConvDCMTest extends ColConvTest {
if (!testSubImage(SI_X, SI_Y, SI_W, SI_H, imgTypes[i][0], if (!testSubImage(SI_X, SI_Y, SI_W, SI_H, imgTypes[i][0],
imgTypes[i][1], imgTypes[i][2], imgTypes[i][3], imgTypes[i][1], imgTypes[i][2], imgTypes[i][3],
cSpaces[imgTypes[i][4]], gldImage, ACCURACY)) cSpaces[imgTypes[i][4]], gldImage,
ACCURACY[imgTypes[i][4]]))
{ {
throw new RuntimeException( throw new RuntimeException(
"Invalid result of the ColorConvertOp for " + "Invalid result of the ColorConvertOp for " +
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
*/ */
import java.awt.color.ColorSpace; import java.awt.color.ColorSpace;
import java.awt.color.ICC_Profile;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer; import java.awt.image.DataBuffer;
...@@ -126,4 +127,33 @@ public abstract class ColConvTest implements Runnable { ...@@ -126,4 +127,33 @@ public abstract class ColConvTest implements Runnable {
public boolean isPassed() { public boolean isPassed() {
return passed; return passed;
} }
private static Boolean isOpenProfile = null;
public static boolean isOpenProfile() {
if (isOpenProfile == null) {
ICC_Profile p = ICC_Profile.getInstance(ColorSpace.CS_sRGB);
byte[] h = p.getData(ICC_Profile.icSigHead);
if (h == null || h.length < 128) {
throw new RuntimeException("Test failed: invalid sRGB header");
}
final byte[] lcmsID = new byte[] {
(byte)0x6c, // l
(byte)0x63, // c
(byte)0x6d, // m
(byte)0x73, // s
};
int off = ICC_Profile.icHdrCmmId;
isOpenProfile = ((h[off + 0] == lcmsID[0])
&& (h[off + 1] == lcmsID[1])
&& (h[off + 2] == lcmsID[2])
&& (h[off + 3] == lcmsID[3]));
}
return isOpenProfile;
}
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册