changeset 1048:59696dfd5455

6727719: Performance of TextLayout.getBounds() Reviewed-by: jgodinez, dougfelt
author prr
date Thu, 12 Mar 2009 12:01:49 -0700
parents 8d5144dfc642
children 9318628e8eee
files src/share/classes/sun/font/FileFontStrike.java
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/font/FileFontStrike.java	Thu Mar 05 10:56:06 2009 -0800
+++ b/src/share/classes/sun/font/FileFontStrike.java	Thu Mar 12 12:01:49 2009 -0700
@@ -842,8 +842,22 @@
         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) {