changeset 51285:0c94d8cc5081

8191512: T2K font rasterizer code removal Reviewed-by: serb, erikj
author prr
date Tue, 12 Jun 2018 12:18:57 -0700
parents b57c4a6581fd
children 11f36b771afd
files make/scripts/compare_exceptions.sh.incl src/java.desktop/share/classes/sun/font/CompositeGlyphMapper.java src/java.desktop/share/classes/sun/font/FontManagerNativeLibrary.java src/java.desktop/share/classes/sun/font/FontScaler.java src/java.desktop/share/classes/sun/font/FontUtilities.java src/java.desktop/share/classes/sun/font/SunFontManager.java src/java.desktop/share/native/common/font/fontscalerdefs.h
diffstat 7 files changed, 17 insertions(+), 109 deletions(-) [+]
line wrap: on
line diff
--- a/make/scripts/compare_exceptions.sh.incl	Tue Jun 12 09:26:49 2018 -0700
+++ b/make/scripts/compare_exceptions.sh.incl	Tue Jun 12 12:18:57 2018 -0700
@@ -179,7 +179,6 @@
       ./lib/libsplashscreen.so
       ./lib/libsunec.so
       ./lib/libsunwjdga.so
-      ./lib/libt2k.so
       ./lib/libunpack.so
       ./lib/libverify.so
       ./lib/libzip.so
@@ -290,7 +289,6 @@
       ./lib/libsplashscreen.so
       ./lib/libsunec.so
       ./lib/libsunwjdga.so
-      ./lib/libt2k.so
       ./lib/libunpack.so
       ./lib/libverify.so
       ./lib/libzip.so
--- a/src/java.desktop/share/classes/sun/font/CompositeGlyphMapper.java	Tue Jun 12 09:26:49 2018 -0700
+++ b/src/java.desktop/share/classes/sun/font/CompositeGlyphMapper.java	Tue Jun 12 12:18:57 2018 -0700
@@ -28,7 +28,7 @@
 /* remember that the API requires a Font use a
  * consistent glyph id. for a code point, and this is a
  * problem if a particular strike uses native scaler sometimes
- * and T2K others. That needs to be dealt with somewhere, but
+ * and the JDK scaler others. That needs to be dealt with somewhere, but
  * here we can just always get the same glyph code without
  * needing a strike.
  *
--- a/src/java.desktop/share/classes/sun/font/FontManagerNativeLibrary.java	Tue Jun 12 09:26:49 2018 -0700
+++ b/src/java.desktop/share/classes/sun/font/FontManagerNativeLibrary.java	Tue Jun 12 12:18:57 2018 -0700
@@ -50,9 +50,6 @@
                       To avoid link error we have to load freetype explicitly
                       before we load fontmanager.
 
-                      Note that we do not need to do this for T2K because
-                      fontmanager.dll does not depend on t2k.dll.
-
                       NB: consider moving freetype wrapper part to separate
                           shared library in order to avoid dependency. */
                    System.loadLibrary("freetype");
--- a/src/java.desktop/share/classes/sun/font/FontScaler.java	Tue Jun 12 09:26:49 2018 -0700
+++ b/src/java.desktop/share/classes/sun/font/FontScaler.java	Tue Jun 12 12:18:57 2018 -0700
@@ -29,7 +29,6 @@
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
 import java.lang.ref.WeakReference;
-import java.lang.reflect.Constructor;
 
 import sun.java2d.Disposer;
 import sun.java2d.DisposerRecord;
@@ -82,51 +81,16 @@
 public abstract class FontScaler implements DisposerRecord {
 
     private static FontScaler nullScaler = null;
-    private static Constructor<? extends FontScaler> scalerConstructor = null;
 
     //Find preferred font scaler
     //
     //NB: we can allow property based preferences
     //   (theoretically logic can be font type specific)
-    static {
-        Class<? extends FontScaler> scalerClass = null;
-        Class<?>[] arglst = new Class<?>[] {Font2D.class, int.class,
-        boolean.class, int.class};
-
-        try {
-            @SuppressWarnings("unchecked")
-            Class<? extends FontScaler> tmp = (Class<? extends FontScaler>)
-                ((!FontUtilities.useT2K && !FontUtilities.useLegacy) ?
-                 Class.forName("sun.font.FreetypeFontScaler") :
-                 Class.forName("sun.font.T2KFontScaler"));
-            scalerClass = tmp;
-        } catch (ClassNotFoundException e) {
-            try {
-                @SuppressWarnings("unchecked")
-                Class<? extends FontScaler> tmp = (Class<? extends FontScaler>)
-                    Class.forName("sun.font.FreetypeFontScaler");
-                scalerClass = tmp;
-            } catch (ClassNotFoundException e1) {
-                scalerClass = NullFontScaler.class;
-            }
-        } finally {
-            if (FontUtilities.debugFonts()) {
-                System.out.println("Scaler class="+scalerClass);
-            }
-        }
-
-        //NB: rewrite using factory? constructor is ugly way
-        try {
-            scalerConstructor = scalerClass.getConstructor(arglst);
-        } catch (NoSuchMethodException e) {
-            //should not happen
-        }
-    }
 
     /* This is the only place to instantiate new FontScaler.
      * Therefore this is very convinient place to register
-     * scaler with Disposer as well as trigger deregistring bad font
-     * in case when scaler reports this.
+     * scaler with Disposer as well as trigger deregistering a bad font
+     * when the scaler reports this.
      */
     public static FontScaler getScaler(Font2D font,
                                 int indexInCollection,
@@ -135,14 +99,13 @@
         FontScaler scaler = null;
 
         try {
-            Object args[] = new Object[] {font, indexInCollection,
-                                          supportsCJK, filesize};
-            scaler = scalerConstructor.newInstance(args);
+            scaler = new FreetypeFontScaler(font, indexInCollection,
+                                            supportsCJK, filesize);
             Disposer.addObjectRecord(font, scaler);
         } catch (Throwable e) {
-            scaler = nullScaler;
+            scaler = getNullScaler();
 
-            //if we can not instantiate scaler assume bad font
+            //if we can not instantiate scaler assume a bad font
             //NB: technically it could be also because of internal scaler
             //    error but here we are assuming scaler is ok.
             FontManager fm = FontManagerFactory.getInstance();
--- a/src/java.desktop/share/classes/sun/font/FontUtilities.java	Tue Jun 12 09:26:49 2018 -0700
+++ b/src/java.desktop/share/classes/sun/font/FontUtilities.java	Tue Jun 12 12:18:57 2018 -0700
@@ -52,10 +52,6 @@
 
     public static boolean useJDKScaler;
 
-    public static boolean useT2K;
-    // useLegacy is a short-term debugging transition aid.
-    public static boolean useLegacy;
-
     public static boolean isWindows;
 
     private static boolean debugFonts = false;
@@ -76,33 +72,16 @@
 
                 isMacOSX = osName.contains("OS X"); // TODO: MacOSX
 
-                /* Support a value of "t2k" as meaning use the JDK internal
-                 * scaler over the platform scaler whether or not t2k is
-                 * actually available.
-                 * This can be considered transitional support for some
-                 * level of compatibility, as in it avoids the native scaler
-                 * as before but cannot guarantee rendering equivalence
-                 * with T2K.
-                 * It will also use t2k instead of freetype if t2k is
-                 * available - this is the same as before.
-                 * The new value of "jdk" means even if t2k is available,
-                 * the decision as to whether to use that or freetype is
-                 * not affected by this setting.
+                /* If set to "jdk", use the JDK's scaler rather than
+                 * the platform one. This may be a no-op on platforms where
+                 * JDK has been configured so that it always relies on the
+                 * platform scaler. The principal case where it has an
+                 * effect is that on Windows, 2D will never use GDI.
                  */
                 String scalerStr = System.getProperty("sun.java2d.font.scaler");
                 if (scalerStr != null) {
-                    useT2K = "t2k".equals(scalerStr);
-                    if (useT2K) {
-                        System.out.println("WARNING: t2k will be removed in JDK 11.");
-                    }
-                    useLegacy = "legacy".equals(scalerStr);
-                    if (useLegacy) {
-                        System.out.println("WARNING: legacy behavior will be removed in JDK 11.");
-                    }
-                    useJDKScaler = useT2K || "jdk".equals(scalerStr);
+                    useJDKScaler = "jdk".equals(scalerStr);
                 } else {
-                    useT2K = false;
-                    useLegacy = false;
                     useJDKScaler = false;
                 }
                 isWindows = osName.startsWith("Windows");
--- a/src/java.desktop/share/classes/sun/font/SunFontManager.java	Tue Jun 12 09:26:49 2018 -0700
+++ b/src/java.desktop/share/classes/sun/font/SunFontManager.java	Tue Jun 12 12:18:57 2018 -0700
@@ -132,10 +132,9 @@
      public static final int FONTFORMAT_NONE = -1;
      public static final int FONTFORMAT_TRUETYPE = 0;
      public static final int FONTFORMAT_TYPE1 = 1;
-     public static final int FONTFORMAT_T2K = 2;
-     public static final int FONTFORMAT_TTC = 3;
-     public static final int FONTFORMAT_COMPOSITE = 4;
-     public static final int FONTFORMAT_NATIVE = 5;
+     public static final int FONTFORMAT_TTC = 2;
+     public static final int FONTFORMAT_COMPOSITE = 3;
+     public static final int FONTFORMAT_NATIVE = 4;
 
      /* Pool of 20 font file channels chosen because some UTF-8 locale
       * composite fonts can use up to 16 platform fonts (including the
@@ -353,7 +352,7 @@
                          * handle two fonts of the same name, so the JRE one
                          * must be the first one registered. Pass "true" to
                          * registerFonts method as on-screen these JRE fonts
-                         * always go through the T2K rasteriser.
+                         * always go through the JDK rasteriser.
                          */
                         if (FontUtilities.isLinux) {
                             /* Linux font configuration uses these fonts */
--- a/src/java.desktop/share/native/common/font/fontscalerdefs.h	Tue Jun 12 09:26:49 2018 -0700
+++ b/src/java.desktop/share/native/common/font/fontscalerdefs.h	Tue Jun 12 12:18:57 2018 -0700
@@ -32,13 +32,6 @@
 extern "C" {
 #endif
 
-#define kPosInfinity16          (32767)
-#define kNegInfinity16          (-32768)
-
-#define kPosInfinity32          (0x7fffffff)
-#define kNegInfinity32          (0x80000000)
-
-
 #ifdef _LP64
 typedef unsigned int            UInt32;
 typedef int                     Int32;
@@ -65,27 +58,6 @@
 #endif
 #endif
 
-#define kPosInfinity32          (0x7fffffff)
-#define kNegInfinity32          (0x80000000)
-
-#define F26Dot6ToFixed(n)  ((n) << 10)
-#define F26Dot6ToScalar(n) (((t2kScalar)(n)) / (t2kScalar)64)
-
-  /* t2kFixed is the same as F16Dot16 format although T2K also uses 26.6 */
-typedef Int32 t2kFixed;
-typedef float t2kScalar;
-
-#define t2kIntToFixed(x) ((t2kFixed)(x) << 16)
-#define t2kFixedToInt(x) ((x) >> 16)
-
-#define t2kFixedRound(x) (((x) + 0x8000) >> 16)
-#define t2kFixed1 t2kIntToFixed(1)
-
-#define t2kFloatToFixed(f) (t2kFixed)((f) * (float)(t2kFixed1))
-#define t2kFixedToFloat(x) ((x) / (float)(65536))
-
-#define t2kScalarAverage(a, b) (((a) + (b)) / (t2kScalar)(2))
-
   /* managed: 1 means the glyph has a hardware cached
    * copy, and its freeing is managed by the usual
    * 2D disposer code.