51 // Smallest object used as Cleaner's parent reference 52 private final Object cleanerObj; 53 // dirty flag indicating an exception occured during pipeline in pathTo() 54 public boolean dirty = false; 55 // shared data 56 public final float[] float6 = new float[6]; 57 // shared curve (dirty) (Renderer / Stroker) 58 final DCurve curve = new DCurve(); 59 // MarlinRenderingEngine.TransformingPathConsumer2D 60 public final DTransformingPathConsumer2D transformerPC2D; 61 // shared memory between renderer instances: 62 final DRendererSharedMemory rdrMem; 63 public final DRenderer renderer; 64 private DRendererNoAA rendererNoAA = null; 65 public final DStroker stroker; 66 // Simplifies out collinear lines 67 public final DCollinearSimplifier simplifier = new DCollinearSimplifier(); 68 public final DDasher dasher; 69 // flag indicating the shape is stroked (1) or filled (0) 70 int stroking = 0; 71 72 // MarlinFX specific: 73 // dirty bbox rectangle 74 public final Rectangle clip = new Rectangle(); 75 // dirty MaskMarlinAlphaConsumer 76 public MaskMarlinAlphaConsumer consumer = null; 77 78 // Array caches: 79 /* clean int[] cache (zero-filled) = 4 refs */ 80 private final IntArrayCache cleanIntCache = new IntArrayCache(true, 4); 81 /* dirty int[] cache = 4 refs */ 82 private final IntArrayCache dirtyIntCache = new IntArrayCache(false, 4); 83 /* dirty double[] cache = 3 refs */ 84 private final DoubleArrayCache dirtyDoubleCache = new DoubleArrayCache(false, 3); 85 /* dirty byte[] cache = 1 ref */ 86 private final ByteArrayCache dirtyByteCache = new ByteArrayCache(false, 1); 87 88 // RendererContext statistics 89 final RendererStats stats; 90 94 * @param name context name (debugging) 95 */ 96 DRendererContext(final String name) { 97 if (LOG_CREATE_CONTEXT) { 98 MarlinUtils.logInfo("new RendererContext = " + name); 99 } 100 this.cleanerObj = new Object(); 101 102 // create first stats (needed by newOffHeapArray): 103 if (DO_STATS || DO_MONITORS) { 104 stats = RendererStats.createInstance(cleanerObj, name); 105 // push cache stats: 106 stats.cacheStats = new CacheStats[] { cleanIntCache.stats, 107 dirtyIntCache.stats, dirtyDoubleCache.stats, dirtyByteCache.stats 108 }; 109 } else { 110 stats = null; 111 } 112 113 // MarlinRenderingEngine.TransformingPathConsumer2D 114 transformerPC2D = new DTransformingPathConsumer2D(); 115 116 // Renderer shared memory: 117 rdrMem = new DRendererSharedMemory(this); 118 119 // Renderer: 120 renderer = new DRenderer(this); 121 122 stroker = new DStroker(this); 123 dasher = new DDasher(this); 124 } 125 126 /** 127 * Disposes this renderer context: 128 * clean up before reusing this context 129 */ 130 public void dispose() { 131 if (DO_STATS) { 132 if (stats.totalOffHeap > stats.totalOffHeapMax) { 133 stats.totalOffHeapMax = stats.totalOffHeap; 134 } 135 stats.totalOffHeap = 0L; 136 } 137 stroking = 0; 138 // if context is maked as DIRTY: 139 if (dirty) { 140 // may happen if an exception if thrown in the pipeline processing: 141 // force cleanup of all possible pipelined blocks (except Renderer): 142 143 // Dasher: 144 this.dasher.dispose(); 145 // Stroker: 146 this.stroker.dispose(); 147 148 // mark context as CLEAN: 149 dirty = false; 150 } 151 } 152 153 public DRendererNoAA getRendererNoAA() { 154 if (rendererNoAA == null) { 155 rendererNoAA = new DRendererNoAA(this); 156 } 157 return rendererNoAA; | 51 // Smallest object used as Cleaner's parent reference 52 private final Object cleanerObj; 53 // dirty flag indicating an exception occured during pipeline in pathTo() 54 public boolean dirty = false; 55 // shared data 56 public final float[] float6 = new float[6]; 57 // shared curve (dirty) (Renderer / Stroker) 58 final DCurve curve = new DCurve(); 59 // MarlinRenderingEngine.TransformingPathConsumer2D 60 public final DTransformingPathConsumer2D transformerPC2D; 61 // shared memory between renderer instances: 62 final DRendererSharedMemory rdrMem; 63 public final DRenderer renderer; 64 private DRendererNoAA rendererNoAA = null; 65 public final DStroker stroker; 66 // Simplifies out collinear lines 67 public final DCollinearSimplifier simplifier = new DCollinearSimplifier(); 68 public final DDasher dasher; 69 // flag indicating the shape is stroked (1) or filled (0) 70 int stroking = 0; 71 // flag indicating to clip the shape 72 public boolean doClip = false; 73 // flag indicating if the path is closed or not (in advance) to handle properly caps 74 boolean closedPath = false; 75 // clip rectangle (ymin, ymax, xmin, xmax): 76 public final double[] clipRect = new double[4]; 77 78 // MarlinFX specific: 79 // dirty bbox rectangle 80 public final Rectangle clip = new Rectangle(); 81 // dirty MaskMarlinAlphaConsumer 82 public MaskMarlinAlphaConsumer consumer = null; 83 84 // Array caches: 85 /* clean int[] cache (zero-filled) = 4 refs */ 86 private final IntArrayCache cleanIntCache = new IntArrayCache(true, 4); 87 /* dirty int[] cache = 4 refs */ 88 private final IntArrayCache dirtyIntCache = new IntArrayCache(false, 4); 89 /* dirty double[] cache = 3 refs */ 90 private final DoubleArrayCache dirtyDoubleCache = new DoubleArrayCache(false, 3); 91 /* dirty byte[] cache = 1 ref */ 92 private final ByteArrayCache dirtyByteCache = new ByteArrayCache(false, 1); 93 94 // RendererContext statistics 95 final RendererStats stats; 96 100 * @param name context name (debugging) 101 */ 102 DRendererContext(final String name) { 103 if (LOG_CREATE_CONTEXT) { 104 MarlinUtils.logInfo("new RendererContext = " + name); 105 } 106 this.cleanerObj = new Object(); 107 108 // create first stats (needed by newOffHeapArray): 109 if (DO_STATS || DO_MONITORS) { 110 stats = RendererStats.createInstance(cleanerObj, name); 111 // push cache stats: 112 stats.cacheStats = new CacheStats[] { cleanIntCache.stats, 113 dirtyIntCache.stats, dirtyDoubleCache.stats, dirtyByteCache.stats 114 }; 115 } else { 116 stats = null; 117 } 118 119 // MarlinRenderingEngine.TransformingPathConsumer2D 120 transformerPC2D = new DTransformingPathConsumer2D(this); 121 122 // Renderer shared memory: 123 rdrMem = new DRendererSharedMemory(this); 124 125 // Renderer: 126 renderer = new DRenderer(this); 127 128 stroker = new DStroker(this); 129 dasher = new DDasher(this); 130 } 131 132 /** 133 * Disposes this renderer context: 134 * clean up before reusing this context 135 */ 136 public void dispose() { 137 if (DO_STATS) { 138 if (stats.totalOffHeap > stats.totalOffHeapMax) { 139 stats.totalOffHeapMax = stats.totalOffHeap; 140 } 141 stats.totalOffHeap = 0L; 142 } 143 stroking = 0; 144 doClip = false; 145 closedPath = false; 146 147 // if context is maked as DIRTY: 148 if (dirty) { 149 // may happen if an exception if thrown in the pipeline processing: 150 // force cleanup of all possible pipelined blocks (except Renderer): 151 152 // Dasher: 153 this.dasher.dispose(); 154 // Stroker: 155 this.stroker.dispose(); 156 157 // mark context as CLEAN: 158 dirty = false; 159 } 160 } 161 162 public DRendererNoAA getRendererNoAA() { 163 if (rendererNoAA == null) { 164 rendererNoAA = new DRendererNoAA(this); 165 } 166 return rendererNoAA; |