src/share/classes/sun/font/StandardGlyphVector.java

Print this page

        

*** 151,161 **** private AffineTransform ftx; // font transform without translation private AffineTransform dtx; // device transform used for strike calculations, no translation private AffineTransform invdtx; // inverse of dtx or null if dtx is identity private AffineTransform frctx; // font render context transform, wish we could just share it private Font2D font2D; // basic strike-independent stuff ! private SoftReference fsref; // font strike reference for glyphs with no per-glyph transform ///////////////////////////// // Constructors and Factory methods ///////////////////////////// --- 151,161 ---- private AffineTransform ftx; // font transform without translation private AffineTransform dtx; // device transform used for strike calculations, no translation private AffineTransform invdtx; // inverse of dtx or null if dtx is identity private AffineTransform frctx; // font render context transform, wish we could just share it private Font2D font2D; // basic strike-independent stuff ! private SoftReference<GlyphStrike> fsref; // font strike reference for glyphs with no per-glyph transform ///////////////////////////// // Constructors and Factory methods /////////////////////////////
*** 524,536 **** if (ix < 0 || ix >= glyphs.length) { throw new IndexOutOfBoundsException("ix = " + ix); } Shape[] lbcache; ! if (lbcacheRef == null || (lbcache = (Shape[])lbcacheRef.get()) == null) { lbcache = new Shape[glyphs.length]; ! lbcacheRef = new SoftReference(lbcache); } Shape result = lbcache[ix]; if (result == null) { setFRCTX(); --- 524,536 ---- if (ix < 0 || ix >= glyphs.length) { throw new IndexOutOfBoundsException("ix = " + ix); } Shape[] lbcache; ! if (lbcacheRef == null || (lbcache = lbcacheRef.get()) == null) { lbcache = new Shape[glyphs.length]; ! lbcacheRef = new SoftReference<>(lbcache); } Shape result = lbcache[ix]; if (result == null) { setFRCTX();
*** 566,597 **** lbcache[ix] = result; } return result; } ! private SoftReference lbcacheRef; public Shape getGlyphVisualBounds(int ix) { if (ix < 0 || ix >= glyphs.length) { throw new IndexOutOfBoundsException("ix = " + ix); } Shape[] vbcache; ! if (vbcacheRef == null || (vbcache = (Shape[])vbcacheRef.get()) == null) { vbcache = new Shape[glyphs.length]; ! vbcacheRef = new SoftReference(vbcache); } Shape result = vbcache[ix]; if (result == null) { result = new DelegatingShape(getGlyphOutlineBounds(ix)); vbcache[ix] = result; } return result; } ! private SoftReference vbcacheRef; public Rectangle getGlyphPixelBounds(int index, FontRenderContext renderFRC, float x, float y) { return getGlyphsPixelBounds(renderFRC, x, y, index, 1); } --- 566,597 ---- lbcache[ix] = result; } return result; } ! private SoftReference<Shape[]> lbcacheRef; public Shape getGlyphVisualBounds(int ix) { if (ix < 0 || ix >= glyphs.length) { throw new IndexOutOfBoundsException("ix = " + ix); } Shape[] vbcache; ! if (vbcacheRef == null || (vbcache = vbcacheRef.get()) == null) { vbcache = new Shape[glyphs.length]; ! vbcacheRef = new SoftReference<>(vbcache); } Shape result = vbcache[ix]; if (result == null) { result = new DelegatingShape(getGlyphOutlineBounds(ix)); vbcache[ix] = result; } return result; } ! private SoftReference<Shape[]> vbcacheRef; public Rectangle getGlyphPixelBounds(int index, FontRenderContext renderFRC, float x, float y) { return getGlyphsPixelBounds(renderFRC, x, y, index, 1); }
*** 1228,1245 **** return result != null ? result : r; } private void clearCaches(int ix) { if (lbcacheRef != null) { ! Shape[] lbcache = (Shape[])lbcacheRef.get(); if (lbcache != null) { lbcache[ix] = null; } } if (vbcacheRef != null) { ! Shape[] vbcache = (Shape[])vbcacheRef.get(); if (vbcache != null) { vbcache[ix] = null; } } } --- 1228,1245 ---- return result != null ? result : r; } private void clearCaches(int ix) { if (lbcacheRef != null) { ! Shape[] lbcache = lbcacheRef.get(); if (lbcache != null) { lbcache[ix] = null; } } if (vbcacheRef != null) { ! Shape[] vbcache = vbcacheRef.get(); if (vbcache != null) { vbcache[ix] = null; } } }
*** 1355,1369 **** // encapsulate access to cached default glyph strike private GlyphStrike getDefaultStrike() { GlyphStrike gs = null; if (fsref != null) { ! gs = (GlyphStrike)fsref.get(); } if (gs == null) { gs = GlyphStrike.create(this, dtx, null); ! fsref = new SoftReference(gs); } return gs; } --- 1355,1369 ---- // encapsulate access to cached default glyph strike private GlyphStrike getDefaultStrike() { GlyphStrike gs = null; if (fsref != null) { ! gs = fsref.get(); } if (gs == null) { gs = GlyphStrike.create(this, dtx, null); ! fsref = new SoftReference<>(gs); } return gs; }
*** 1377,1387 **** static final class GlyphTransformInfo { StandardGlyphVector sgv; // reference back to glyph vector - yuck int[] indices; // index into unique strikes double[] transforms; // six doubles per unique transform, because AT is a pain to manipulate ! SoftReference strikesRef; // ref to unique strikes, one per transform boolean haveAllStrikes; // true if the strike array has been filled by getStrikes(). // used when first setting a transform GlyphTransformInfo(StandardGlyphVector sgv) { this.sgv = sgv; --- 1377,1387 ---- static final class GlyphTransformInfo { StandardGlyphVector sgv; // reference back to glyph vector - yuck int[] indices; // index into unique strikes double[] transforms; // six doubles per unique transform, because AT is a pain to manipulate ! SoftReference<GlyphStrike[]> strikesRef; // ref to unique strikes, one per transform boolean haveAllStrikes; // true if the strike array has been filled by getStrikes(). // used when first setting a transform GlyphTransformInfo(StandardGlyphVector sgv) { this.sgv = sgv;
*** 1651,1666 **** } private GlyphStrike[] getStrikeArray() { GlyphStrike[] strikes = null; if (strikesRef != null) { ! strikes = (GlyphStrike[])strikesRef.get(); } if (strikes == null) { haveAllStrikes = false; strikes = new GlyphStrike[transformCount() + 1]; ! strikesRef = new SoftReference(strikes); } return strikes; } --- 1651,1666 ---- } private GlyphStrike[] getStrikeArray() { GlyphStrike[] strikes = null; if (strikesRef != null) { ! strikes = strikesRef.get(); } if (strikes == null) { haveAllStrikes = false; strikes = new GlyphStrike[transformCount() + 1]; ! strikesRef = new SoftReference<>(strikes); } return strikes; }