changeset 7834:64be71ae6185

Merge
author lana
date Tue, 20 Aug 2013 17:35:15 -0700
parents f1d8d15bfcb5 0c950b2be7ab
children fefa29e15a14
files
diffstat 5 files changed, 65 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/print/PSPrinterJob.java	Thu Aug 15 09:25:49 2013 -0700
+++ b/src/share/classes/sun/print/PSPrinterJob.java	Tue Aug 20 17:35:15 2013 -0700
@@ -339,6 +339,8 @@
     */
    private static Properties mFontProps = null;
 
+   private static boolean isMac;
+
     /* Class static initialiser block */
     static {
        //enable priviledges so initProps can access system properties,
@@ -347,6 +349,8 @@
                             new java.security.PrivilegedAction() {
             public Object run() {
                 mFontProps = initProps();
+                String osName = System.getProperty("os.name");
+                isMac = osName.startsWith("Mac");
                 return null;
             }
         });
@@ -473,6 +477,12 @@
                 PrintService pServ = getPrintService();
                 if (pServ != null) {
                     mDestination = pServ.getName();
+                   if (isMac) {
+                        PrintServiceAttributeSet psaSet = pServ.getAttributes() ;
+                        if (psaSet != null) {
+                            mDestination = psaSet.get(PrinterName.class).toString();
+                        }
+                    }
                 }
             }
         }
@@ -771,6 +781,12 @@
             PrintService pServ = getPrintService();
             if (pServ != null) {
                 mDestination = pServ.getName();
+               if (isMac) {
+                    PrintServiceAttributeSet psaSet = pServ.getAttributes();
+                    if (psaSet != null) {
+                        mDestination = psaSet.get(PrinterName.class).toString() ;
+                    }
+                }
             }
             PrinterSpooler spooler = new PrinterSpooler();
             java.security.AccessController.doPrivileged(spooler);
--- a/src/share/native/sun/font/sunFont.c	Thu Aug 15 09:25:49 2013 -0700
+++ b/src/share/native/sun/font/sunFont.c	Tue Aug 20 17:35:15 2013 -0700
@@ -71,13 +71,17 @@
 void initLCDGammaTables();
 
 /* placeholder for extern variable */
+static int initialisedFontIDs = 0;
 FontManagerNativeIDs sunFontIDs;
 
-JNIEXPORT void JNICALL
-Java_sun_font_SunFontManager_initIDs
-    (JNIEnv *env, jclass cls) {
+static void initFontIDs(JNIEnv *env) {
 
-     jclass tmpClass = (*env)->FindClass(env, "sun/font/TrueTypeFont");
+     jclass tmpClass;
+
+     if (initialisedFontIDs) {
+        return;
+     }
+     tmpClass = (*env)->FindClass(env, "sun/font/TrueTypeFont");
      sunFontIDs.ttReadBlockMID =
          (*env)->GetMethodID(env, tmpClass, "readBlock",
                              "(Ljava/nio/ByteBuffer;II)I");
@@ -173,9 +177,20 @@
          (*env)->GetFieldID(env, tmpClass, "lcdSubPixPos", "Z");
 
      initLCDGammaTables();
+
+     initialisedFontIDs = 1;
 }
 
-JNIEXPORT FontManagerNativeIDs getSunFontIDs() {
+JNIEXPORT void JNICALL
+Java_sun_font_SunFontManager_initIDs
+    (JNIEnv *env, jclass cls) {
+
+    initFontIDs(env);
+}
+
+JNIEXPORT FontManagerNativeIDs getSunFontIDs(JNIEnv *env) {
+
+    initFontIDs(env);
     return sunFontIDs;
 }
 
--- a/src/share/native/sun/font/sunfontids.h	Thu Aug 15 09:25:49 2013 -0700
+++ b/src/share/native/sun/font/sunfontids.h	Tue Aug 20 17:35:15 2013 -0700
@@ -84,7 +84,7 @@
 /* Note: we share variable in the context of fontmanager lib
    but we need access method to use it from separate rasterizer lib */
 extern FontManagerNativeIDs sunFontIDs;
-JNIEXPORT FontManagerNativeIDs getSunFontIDs();
+JNIEXPORT FontManagerNativeIDs getSunFontIDs(JNIEnv* env);
 
 #ifdef  __cplusplus
 }
--- a/src/solaris/classes/sun/print/UnixPrintServiceLookup.java	Thu Aug 15 09:25:49 2013 -0700
+++ b/src/solaris/classes/sun/print/UnixPrintServiceLookup.java	Tue Aug 20 17:35:15 2013 -0700
@@ -245,7 +245,7 @@
                 continue;
             }
             if ((defaultPrintService != null)
-                && printers[p].equals(defaultPrintService.getName())) {
+                && printers[p].equals(getPrinterDestName(defaultPrintService))) {
                 printerList.add(defaultPrintService);
                 defaultIndex = printerList.size() - 1;
             } else {
@@ -270,11 +270,12 @@
                 } else {
                     int j;
                     for (j=0; j<printServices.length; j++) {
-                        if ((printServices[j] != null) &&
-                            (printers[p].equals(printServices[j].getName()))) {
-                            printerList.add(printServices[j]);
-                            printServices[j] = null;
-                            break;
+                        if (printServices[j] != null) {
+                            if (printers[p].equals(getPrinterDestName(printServices[j]))) {
+                                printerList.add(printServices[j]);
+                                printServices[j] = null;
+                                break;
+                            }
                         }
                     }
 
@@ -360,6 +361,17 @@
         return true;
       }
 
+    /*
+     * Gets the printer name compatible with the list of printers returned by
+     * the system when we query default or all the available printers.
+     */
+    private String getPrinterDestName(PrintService ps) {
+        if (isMac()) {
+            return ((IPPPrintService)ps).getDest();
+        }
+        return ps.getName();
+    }
+
     /* On a network with many (hundreds) of network printers, it
      * can save several seconds if you know all you want is a particular
      * printer, to ask for that printer rather than retrieving all printers.
@@ -369,10 +381,12 @@
         if (name == null || name.equals("") || !checkPrinterName(name)) {
             return null;
         }
-        /* check is all printers are already available */
+        /* check if all printers are already available */
         if (printServices != null) {
             for (PrintService printService : printServices) {
-                if (printService.getName().equals(name)) {
+                PrinterName printerName =
+                    (PrinterName)printService.getAttribute(PrinterName.class);
+                if (printerName.getValue().equals(name)) {
                     return printService;
                 }
             }
@@ -567,7 +581,7 @@
         defaultPrintService = null;
         if (printServices != null) {
             for (int j=0; j<printServices.length; j++) {
-                if (defaultPrinter.equals(printServices[j].getName())) {
+                if (defaultPrinter.equals(getPrinterDestName(printServices[j]))) {
                     defaultPrintService = printServices[j];
                     break;
                 }
--- a/src/windows/native/sun/java2d/opengl/WGLSurfaceData.c	Thu Aug 15 09:25:49 2013 -0700
+++ b/src/windows/native/sun/java2d/opengl/WGLSurfaceData.c	Tue Aug 20 17:35:15 2013 -0700
@@ -67,12 +67,13 @@
 
     J2dTraceLn(J2D_TRACE_INFO, "WGLSurfaceData_initOps");
 
-    if (oglsdo == NULL) {
-        JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
+    if (wglsdo == NULL) {
+        JNU_ThrowOutOfMemoryError(env, "creating native wgl ops");
         return;
     }
-    if (wglsdo == NULL) {
-        JNU_ThrowOutOfMemoryError(env, "creating native wgl ops");
+    if (oglsdo == NULL) {
+        free(wglsdo);
+        JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
         return;
     }