From a34896e821787d09854dcf64dadfbf152a7d2669 Mon Sep 17 00:00:00 2001 From: prr Date: Thu, 12 Mar 2009 12:01:49 -0700 Subject: [PATCH] 6727719: Performance of TextLayout.getBounds() Reviewed-by: jgodinez, dougfelt --- src/share/classes/sun/font/FileFontStrike.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/share/classes/sun/font/FileFontStrike.java b/src/share/classes/sun/font/FileFontStrike.java index dab135e96..4628016a2 100644 --- a/src/share/classes/sun/font/FileFontStrike.java +++ b/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) { -- GitLab