src/java.desktop/share/classes/sun/font/StrikeCache.java

Print this page
rev 12972 : 8140606: Update library code to use internal Unsafe
Reviewed-by: duke


  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.font;
  27 
  28 import java.awt.GraphicsConfiguration;
  29 import java.awt.GraphicsEnvironment;
  30 import java.lang.ref.Reference;
  31 import java.lang.ref.ReferenceQueue;
  32 import java.lang.ref.SoftReference;
  33 import java.lang.ref.WeakReference;
  34 import java.util.*;
  35 
  36 import sun.java2d.Disposer;
  37 import sun.java2d.pipe.BufferedContext;
  38 import sun.java2d.pipe.RenderQueue;
  39 import sun.java2d.pipe.hw.AccelGraphicsConfig;
  40 import sun.misc.Unsafe;
  41 
  42 /**
  43 
  44 A FontStrike is the keeper of scaled glyph image data which is expensive
  45 to compute so needs to be cached.
  46 So long as that data may be being used it cannot be invalidated.
  47 Yet we also need to limit the amount of native memory and number of
  48 strike objects in use.
  49 For scaleability and ease of use, a key goal is multi-threaded read
  50 access to a strike, so that it may be shared by multiple client objects,
  51 potentially executing on different threads, with no special reference
  52 counting or "check-out/check-in" requirements which would pass on the
  53 burden of keeping track of strike references to the SG2D and other clients.
  54 
  55 A cache of strikes is maintained via Reference objects.
  56 This helps in two ways :
  57 1. The VM will free references when memory is low or they have not been
  58 used in a long time.
  59 2. Reference queues provide a way to get notification of this so we can
  60 free native memory resources.




  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.font;
  27 
  28 import java.awt.GraphicsConfiguration;
  29 import java.awt.GraphicsEnvironment;
  30 import java.lang.ref.Reference;
  31 import java.lang.ref.ReferenceQueue;
  32 import java.lang.ref.SoftReference;
  33 import java.lang.ref.WeakReference;
  34 import java.util.*;
  35 
  36 import sun.java2d.Disposer;
  37 import sun.java2d.pipe.BufferedContext;
  38 import sun.java2d.pipe.RenderQueue;
  39 import sun.java2d.pipe.hw.AccelGraphicsConfig;
  40 import jdk.internal.misc.Unsafe;
  41 
  42 /**
  43 
  44 A FontStrike is the keeper of scaled glyph image data which is expensive
  45 to compute so needs to be cached.
  46 So long as that data may be being used it cannot be invalidated.
  47 Yet we also need to limit the amount of native memory and number of
  48 strike objects in use.
  49 For scaleability and ease of use, a key goal is multi-threaded read
  50 access to a strike, so that it may be shared by multiple client objects,
  51 potentially executing on different threads, with no special reference
  52 counting or "check-out/check-in" requirements which would pass on the
  53 burden of keeping track of strike references to the SG2D and other clients.
  54 
  55 A cache of strikes is maintained via Reference objects.
  56 This helps in two ways :
  57 1. The VM will free references when memory is low or they have not been
  58 used in a long time.
  59 2. Reference queues provide a way to get notification of this so we can
  60 free native memory resources.