6727719: Performance of TextLayout.getBounds()

Reviewed-by: jgodinez, dougfelt
This commit is contained in:
Phil Race 2009-03-12 12:01:49 -07:00
parent c9de141417
commit 5f9073cac0

View File

@ -842,8 +842,22 @@ public class FileFontStrike extends PhysicalStrike {
return fileFont.getGlyphOutlineBounds(pScalerContext, glyphCode);
}
private ConcurrentHashMap<Integer, GeneralPath> outlineMap;
GeneralPath getGlyphOutline(int glyphCode, float x, float y) {
return fileFont.getGlyphOutline(pScalerContext, glyphCode, x, y);
if (outlineMap == null) {
outlineMap = new ConcurrentHashMap<Integer, GeneralPath>();
}
GeneralPath gp = (GeneralPath)outlineMap.get(glyphCode);
if (gp == null) {
gp = fileFont.getGlyphOutline(pScalerContext, glyphCode, 0, 0);
outlineMap.put(glyphCode, gp);
}
gp = (GeneralPath)gp.clone(); // mutable!
if (x != 0f || y != 0f) {
gp.transform(AffineTransform.getTranslateInstance(x, y));
}
return gp;
}
GeneralPath getGlyphVectorOutline(int[] glyphs, float x, float y) {