8191512: T2K font rasterizer code removal

Reviewed-by: serb, erikj
This commit is contained in:
Phil Race 2018-06-12 12:18:57 -07:00
parent 4800622742
commit fe746c5d2a
7 changed files with 17 additions and 109 deletions

View File

@ -179,7 +179,6 @@ if [ "$OPENJDK_TARGET_OS" = "solaris" ] && [ "$OPENJDK_TARGET_CPU" = "x86_64" ];
./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 @@ if [ "$OPENJDK_TARGET_OS" = "solaris" ] && [ "$OPENJDK_TARGET_CPU" = "sparcv9" ]
./lib/libsplashscreen.so
./lib/libsunec.so
./lib/libsunwjdga.so
./lib/libt2k.so
./lib/libunpack.so
./lib/libverify.so
./lib/libzip.so

View File

@ -28,7 +28,7 @@ package sun.font;
/* 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.
*

View File

@ -50,9 +50,6 @@ public class FontManagerNativeLibrary {
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");

View File

@ -29,7 +29,6 @@ import java.awt.geom.GeneralPath;
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 @@ import sun.java2d.DisposerRecord;
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 @@ public abstract class FontScaler implements DisposerRecord {
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();

View File

@ -52,10 +52,6 @@ public final class FontUtilities {
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 @@ public final class FontUtilities {
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");

View File

@ -132,10 +132,9 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
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 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
* 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 */

View File

@ -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 @@ typedef UInt32 Bool32;
#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.