From 5f9073cac047936d83062743a9c1789305b8f827 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Thu, 12 Mar 2009 12:01:49 -0700 Subject: [PATCH] 6727719: Performance of TextLayout.getBounds() Reviewed-by: jgodinez, dougfelt --- .../share/classes/sun/font/FileFontStrike.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/jdk/src/share/classes/sun/font/FileFontStrike.java b/jdk/src/share/classes/sun/font/FileFontStrike.java index dab135e96d2..4628016a216 100644 --- a/jdk/src/share/classes/sun/font/FileFontStrike.java +++ b/jdk/src/share/classes/sun/font/FileFontStrike.java @@ -842,8 +842,22 @@ public class FileFontStrike extends PhysicalStrike { return fileFont.getGlyphOutlineBounds(pScalerContext, glyphCode); } + private ConcurrentHashMap outlineMap; + GeneralPath getGlyphOutline(int glyphCode, float x, float y) { - return fileFont.getGlyphOutline(pScalerContext, glyphCode, x, y); + if (outlineMap == null) { + outlineMap = new ConcurrentHashMap(); + } + 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) {