changeset 6129:f363150cc5f7

7191872: Xrender: No text displayed using 64 bit JDK on solaris11-sparc Reviewed-by: prr, ceisserer
author simonis
date Mon, 06 May 2013 12:57:42 -0700
parents d61d06e30d0b
children 060ab87975cb
files src/share/classes/sun/font/FileFontStrike.java src/share/classes/sun/font/GlyphList.java src/solaris/classes/sun/font/XRGlyphCacheEntry.java src/solaris/native/sun/java2d/x11/XRBackendNative.c
diffstat 4 files changed, 34 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/font/FileFontStrike.java	Wed May 29 20:10:59 2013 +0100
+++ b/src/share/classes/sun/font/FileFontStrike.java	Mon May 06 12:57:42 2013 -0700
@@ -747,14 +747,9 @@
             return origMinX;
         }
 
-        long pixelData;
-        if (StrikeCache.nativeAddressSize == 4) {
-            pixelData = 0xffffffff &
-                StrikeCache.unsafe.getInt(ptr + StrikeCache.pixelDataOffset);
-        } else {
-            pixelData =
-                StrikeCache.unsafe.getLong(ptr + StrikeCache.pixelDataOffset);
-        }
+        long pixelData =
+            StrikeCache.unsafe.getAddress(ptr + StrikeCache.pixelDataOffset);
+
         if (pixelData == 0L) {
             return origMinX;
         }
--- a/src/share/classes/sun/font/GlyphList.java	Wed May 29 20:10:59 2013 +0100
+++ b/src/share/classes/sun/font/GlyphList.java	Mon May 06 12:57:42 2013 -0700
@@ -361,16 +361,10 @@
                 graybits = new byte[len];
             }
         }
-        long pixelDataAddress;
-        if (StrikeCache.nativeAddressSize == 4) {
-            pixelDataAddress = 0xffffffff &
-                StrikeCache.unsafe.getInt(images[glyphindex] +
+        long pixelDataAddress =
+            StrikeCache.unsafe.getAddress(images[glyphindex] +
                                           StrikeCache.pixelDataOffset);
-        } else {
-            pixelDataAddress =
-            StrikeCache.unsafe.getLong(images[glyphindex] +
-                                       StrikeCache.pixelDataOffset);
-        }
+
         if (pixelDataAddress == 0L) {
             return graybits;
         }
--- a/src/solaris/classes/sun/font/XRGlyphCacheEntry.java	Wed May 29 20:10:59 2013 +0100
+++ b/src/solaris/classes/sun/font/XRGlyphCacheEntry.java	Mon May 06 12:57:42 2013 -0700
@@ -69,11 +69,28 @@
     }
 
     public static int getGlyphID(long glyphInfoPtr) {
-        return (int) StrikeCache.unsafe.getInt(glyphInfoPtr + StrikeCache.cacheCellOffset);
+        // We need to access the GlyphID with Unsafe.getAddress() because the
+        // corresponding field in the underlying C data-structure is of type
+        // 'void*' (see field 'cellInfo' of struct 'GlyphInfo'
+        // in src/share/native/sun/font/fontscalerdefs.h).
+        // On 64-bit Big-endian architectures it would be wrong to access this
+        // field with Unsafe.getInt().
+        return (int) StrikeCache.unsafe.getAddress(glyphInfoPtr +
+                                                   StrikeCache.cacheCellOffset);
     }
 
     public static void setGlyphID(long glyphInfoPtr, int id) {
-        StrikeCache.unsafe.putInt(glyphInfoPtr + StrikeCache.cacheCellOffset, id);
+        // We need to access the GlyphID with Unsafe.putAddress() because the
+        // corresponding field in the underlying C data-structure is of type
+        // 'void*' (see field 'cellInfo' of struct 'GlyphInfo' in
+        // src/share/native/sun/font/fontscalerdefs.h).
+        // On 64-bit Big-endian architectures it would be wrong to write this
+        // field with Unsafe.putInt() because it is also accessed from native
+        // code as a 'long'.
+        // See Java_sun_java2d_xr_XRBackendNative_XRAddGlyphsNative()
+        // in src/solaris/native/sun/java2d/x11/XRBackendNative.c
+        StrikeCache.unsafe.putAddress(glyphInfoPtr +
+                                      StrikeCache.cacheCellOffset, (long)id);
     }
 
     public int getGlyphID() {
@@ -105,12 +122,9 @@
     }
 
     public void writePixelData(ByteArrayOutputStream os, boolean uploadAsLCD) {
-        long pixelDataAddress;
-        if (StrikeCache.nativeAddressSize == 4) {
-            pixelDataAddress = 0xffffffff & StrikeCache.unsafe.getInt(glyphInfoPtr + StrikeCache.pixelDataOffset);
-        } else {
-            pixelDataAddress = StrikeCache.unsafe.getLong(glyphInfoPtr + StrikeCache.pixelDataOffset);
-        }
+        long pixelDataAddress =
+            StrikeCache.unsafe.getAddress(glyphInfoPtr +
+                                          StrikeCache.pixelDataOffset);
         if (pixelDataAddress == 0L) {
             return;
         }
--- a/src/solaris/native/sun/java2d/x11/XRBackendNative.c	Wed May 29 20:10:59 2013 +0100
+++ b/src/solaris/native/sun/java2d/x11/XRBackendNative.c	Mon May 06 12:57:42 2013 -0700
@@ -742,7 +742,12 @@
     for (i=0; i < glyphCnt; i++) {
       GlyphInfo *jginfo = (GlyphInfo *) jlong_to_ptr(glyphInfoPtrs[i]);
 
-      gid[i] = (Glyph) (0x0ffffffffL & ((unsigned long)(jginfo->cellInfo)));
+      // 'jginfo->cellInfo' is of type 'void*'
+      // (see definition of 'GlyphInfo' in fontscalerdefs.h)
+      // 'Glyph' is typedefed to 'unsigned long'
+      // (see http://www.x.org/releases/X11R7.7/doc/libXrender/libXrender.txt)
+      // Maybe we should assert that (sizeof(void*) == sizeof(Glyph)) ?
+      gid[i] = (Glyph) (jginfo->cellInfo);
       xginfo[i].x = (-jginfo->topLeftX);
       xginfo[i].y = (-jginfo->topLeftY);
       xginfo[i].width = jginfo->width;