src/java.desktop/share/classes/sun/java2d/marlin/RendererContext.java
changeset 48284 fd7fbc929001
parent 47216 71c04702a3d5
child 49496 1ea202af7a97
equal deleted inserted replaced
48283:da1b57b17101 48284:fd7fbc929001
    73     final Dasher dasher;
    73     final Dasher dasher;
    74     final MarlinTileGenerator ptg;
    74     final MarlinTileGenerator ptg;
    75     final MarlinCache cache;
    75     final MarlinCache cache;
    76     // flag indicating the shape is stroked (1) or filled (0)
    76     // flag indicating the shape is stroked (1) or filled (0)
    77     int stroking = 0;
    77     int stroking = 0;
       
    78     // flag indicating to clip the shape
       
    79     boolean doClip = false;
       
    80     // flag indicating if the path is closed or not (in advance) to handle properly caps
       
    81     boolean closedPath = false;
       
    82     // clip rectangle (ymin, ymax, xmin, xmax):
       
    83     final float[] clipRect = new float[4];
    78 
    84 
    79     // Array caches:
    85     // Array caches:
    80     /* clean int[] cache (zero-filled) = 5 refs */
    86     /* clean int[] cache (zero-filled) = 5 refs */
    81     private final IntArrayCache cleanIntCache = new IntArrayCache(true, 5);
    87     private final IntArrayCache cleanIntCache = new IntArrayCache(true, 5);
    82     /* dirty int[] cache = 4 refs */
    88     /* dirty int[] cache = 5 refs */
    83     private final IntArrayCache dirtyIntCache = new IntArrayCache(false, 4);
    89     private final IntArrayCache dirtyIntCache = new IntArrayCache(false, 5);
    84     /* dirty float[] cache = 3 refs */
    90     /* dirty float[] cache = 4 refs (2 polystack) */
    85     private final FloatArrayCache dirtyFloatCache = new FloatArrayCache(false, 3);
    91     private final FloatArrayCache dirtyFloatCache = new FloatArrayCache(false, 4);
    86     /* dirty byte[] cache = 1 ref */
    92     /* dirty byte[] cache = 2 ref (2 polystack) */
    87     private final ByteArrayCache dirtyByteCache = new ByteArrayCache(false, 1);
    93     private final ByteArrayCache dirtyByteCache = new ByteArrayCache(false, 2);
    88 
    94 
    89     // RendererContext statistics
    95     // RendererContext statistics
    90     final RendererStats stats;
    96     final RendererStats stats;
    91 
    97 
    92     /**
    98     /**
   114         // NormalizingPathIterator instances:
   120         // NormalizingPathIterator instances:
   115         nPCPathIterator = new NormalizingPathIterator.NearestPixelCenter(float6);
   121         nPCPathIterator = new NormalizingPathIterator.NearestPixelCenter(float6);
   116         nPQPathIterator  = new NormalizingPathIterator.NearestPixelQuarter(float6);
   122         nPQPathIterator  = new NormalizingPathIterator.NearestPixelQuarter(float6);
   117 
   123 
   118         // MarlinRenderingEngine.TransformingPathConsumer2D
   124         // MarlinRenderingEngine.TransformingPathConsumer2D
   119         transformerPC2D = new TransformingPathConsumer2D();
   125         transformerPC2D = new TransformingPathConsumer2D(this);
   120 
   126 
   121         // Renderer:
   127         // Renderer:
   122         cache = new MarlinCache(this);
   128         cache = new MarlinCache(this);
   123         renderer = new Renderer(this); // needs MarlinCache from rdrCtx.cache
   129         renderer = new Renderer(this); // needs MarlinCache from rdrCtx.cache
   124         ptg = new MarlinTileGenerator(stats, renderer, cache);
   130         ptg = new MarlinTileGenerator(stats, renderer, cache);
   136             if (stats.totalOffHeap > stats.totalOffHeapMax) {
   142             if (stats.totalOffHeap > stats.totalOffHeapMax) {
   137                 stats.totalOffHeapMax = stats.totalOffHeap;
   143                 stats.totalOffHeapMax = stats.totalOffHeap;
   138             }
   144             }
   139             stats.totalOffHeap = 0L;
   145             stats.totalOffHeap = 0L;
   140         }
   146         }
   141         stroking = 0;
   147         stroking   = 0;
       
   148         doClip     = false;
       
   149         closedPath = false;
       
   150 
   142         // if context is maked as DIRTY:
   151         // if context is maked as DIRTY:
   143         if (dirty) {
   152         if (dirty) {
   144             // may happen if an exception if thrown in the pipeline processing:
   153             // may happen if an exception if thrown in the pipeline processing:
   145             // force cleanup of all possible pipelined blocks (except Renderer):
   154             // force cleanup of all possible pipelined blocks (except Renderer):
   146 
   155 
   157         }
   166         }
   158     }
   167     }
   159 
   168 
   160     Path2D.Float getPath2D() {
   169     Path2D.Float getPath2D() {
   161         // resolve reference:
   170         // resolve reference:
   162         Path2D.Float p2d
   171         Path2D.Float p2d = (refPath2D != null) ? refPath2D.get() : null;
   163             = (refPath2D != null) ? refPath2D.get() : null;
       
   164 
   172 
   165         // create a new Path2D ?
   173         // create a new Path2D ?
   166         if (p2d == null) {
   174         if (p2d == null) {
   167             p2d = new Path2D.Float(Path2D.WIND_NON_ZERO, INITIAL_EDGES_COUNT); // 32K
   175             p2d = new Path2D.Float(WIND_NON_ZERO, INITIAL_EDGES_COUNT); // 32K
   168 
   176 
   169             // update weak reference:
   177             // update weak reference:
   170             refPath2D = new WeakReference<Path2D.Float>(p2d);
   178             refPath2D = new WeakReference<Path2D.Float>(p2d);
   171         }
   179         }
   172         // reset the path anyway:
   180         // reset the path anyway: