提交 edf68627 编写于 作者: P prr

8210384: SunLayoutEngine.isAAT() font is expensive on MacOS

Reviewed-by: dmarkov, kaddepalli
上级 25d5fc7a
......@@ -35,6 +35,7 @@ import java.awt.geom.Point2D;
import java.lang.ref.SoftReference;
import java.util.concurrent.ConcurrentHashMap;
import java.util.Locale;
import java.util.WeakHashMap;
/*
* different ways to do this
......@@ -149,17 +150,30 @@ public final class SunLayoutEngine implements LayoutEngine, LayoutEngineFactory
this.key = key;
}
static WeakHashMap<Font2D, Boolean> aatInfo = new WeakHashMap<>();
private boolean isAAT(Font2D font) {
Boolean aatObj;
synchronized (aatInfo) {
aatObj = aatInfo.get(font);
}
if (aatObj != null) {
return aatObj.booleanValue();
}
boolean aat = false;
if (font instanceof TrueTypeFont) {
TrueTypeFont ttf = (TrueTypeFont)font;
return ttf.getDirectoryEntry(TrueTypeFont.morxTag) != null ||
aat = ttf.getDirectoryEntry(TrueTypeFont.morxTag) != null ||
ttf.getDirectoryEntry(TrueTypeFont.mortTag) != null;
} else if (font instanceof PhysicalFont) {
PhysicalFont pf = (PhysicalFont)font;
return pf.getTableBytes(TrueTypeFont.morxTag) != null ||
aat = pf.getTableBytes(TrueTypeFont.morxTag) != null ||
pf.getTableBytes(TrueTypeFont.mortTag) != null;
}
return false;
synchronized (aatInfo) {
aatInfo.put(font, Boolean.valueOf(aat));
}
return aat;
}
public void layout(FontStrikeDesc desc, float[] mat, int gmask,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册