< prev index next >

modules/javafx.graphics/src/main/java/com/sun/marlin/DRendererContext.java

Print this page

        

*** 23,75 **** * questions. */ package com.sun.marlin; - import java.awt.geom.Path2D; - import java.lang.ref.WeakReference; import java.util.concurrent.atomic.AtomicInteger; import com.sun.util.reentrant.ReentrantContext; import com.sun.javafx.geom.Rectangle; import com.sun.marlin.ArrayCacheConst.CacheStats; /** * This class is a renderer context dedicated to a single thread */ ! public final class RendererContext extends ReentrantContext implements MarlinConst { // RendererContext creation counter private static final AtomicInteger CTX_COUNT = new AtomicInteger(1); /** * Create a new renderer context * * @return new RendererContext instance */ ! public static RendererContext createContext() { ! return new RendererContext("ctx" + Integer.toString(CTX_COUNT.getAndIncrement())); } // Smallest object used as Cleaner's parent reference private final Object cleanerObj; // dirty flag indicating an exception occured during pipeline in pathTo() public boolean dirty = false; // shared data public final float[] float6 = new float[6]; // shared curve (dirty) (Renderer / Stroker) ! final Curve curve = new Curve(); // MarlinRenderingEngine.TransformingPathConsumer2D ! public final TransformingPathConsumer2D transformerPC2D; ! // recycled Path2D instance (weak) ! private WeakReference<Path2D.Float> refPath2D = null; ! public final Renderer renderer; ! private RendererNoAA rendererNoAA = null; ! public final Stroker stroker; // Simplifies out collinear lines ! public final CollinearSimplifier simplifier = new CollinearSimplifier(); ! public final Dasher dasher; // flag indicating the shape is stroked (1) or filled (0) int stroking = 0; // MarlinFX specific: // dirty bbox rectangle --- 23,71 ---- * questions. */ package com.sun.marlin; import java.util.concurrent.atomic.AtomicInteger; import com.sun.util.reentrant.ReentrantContext; import com.sun.javafx.geom.Rectangle; import com.sun.marlin.ArrayCacheConst.CacheStats; /** * This class is a renderer context dedicated to a single thread */ ! public final class DRendererContext extends ReentrantContext implements MarlinConst { // RendererContext creation counter private static final AtomicInteger CTX_COUNT = new AtomicInteger(1); /** * Create a new renderer context * * @return new RendererContext instance */ ! public static DRendererContext createContext() { ! return new DRendererContext("ctx" + Integer.toString(CTX_COUNT.getAndIncrement())); } // Smallest object used as Cleaner's parent reference private final Object cleanerObj; // dirty flag indicating an exception occured during pipeline in pathTo() public boolean dirty = false; // shared data public final float[] float6 = new float[6]; // shared curve (dirty) (Renderer / Stroker) ! final DCurve curve = new DCurve(); // MarlinRenderingEngine.TransformingPathConsumer2D ! public final DTransformingPathConsumer2D transformerPC2D; ! public final DRenderer renderer; ! private DRendererNoAA rendererNoAA = null; ! public final DStroker stroker; // Simplifies out collinear lines ! public final DCollinearSimplifier simplifier = new DCollinearSimplifier(); ! public final DDasher dasher; // flag indicating the shape is stroked (1) or filled (0) int stroking = 0; // MarlinFX specific: // dirty bbox rectangle
*** 80,91 **** // Array caches: /* clean int[] cache (zero-filled) = 5 refs */ private final IntArrayCache cleanIntCache = new IntArrayCache(true, 5); /* dirty int[] cache = 4 refs */ private final IntArrayCache dirtyIntCache = new IntArrayCache(false, 4); ! /* dirty float[] cache = 3 refs */ ! private final FloatArrayCache dirtyFloatCache = new FloatArrayCache(false, 3); /* dirty byte[] cache = 1 ref */ private final ByteArrayCache dirtyByteCache = new ByteArrayCache(false, 1); // RendererContext statistics final RendererStats stats; --- 76,87 ---- // Array caches: /* clean int[] cache (zero-filled) = 5 refs */ private final IntArrayCache cleanIntCache = new IntArrayCache(true, 5); /* dirty int[] cache = 4 refs */ private final IntArrayCache dirtyIntCache = new IntArrayCache(false, 4); ! /* dirty double[] cache = 3 refs */ ! private final DoubleArrayCache dirtyDoubleCache = new DoubleArrayCache(false, 3); /* dirty byte[] cache = 1 ref */ private final ByteArrayCache dirtyByteCache = new ByteArrayCache(false, 1); // RendererContext statistics final RendererStats stats;
*** 93,127 **** /** * Constructor * * @param name context name (debugging) */ ! RendererContext(final String name) { if (LOG_CREATE_CONTEXT) { MarlinUtils.logInfo("new RendererContext = " + name); } this.cleanerObj = new Object(); // create first stats (needed by newOffHeapArray): if (DO_STATS || DO_MONITORS) { stats = RendererStats.createInstance(cleanerObj, name); // push cache stats: stats.cacheStats = new CacheStats[] { cleanIntCache.stats, ! dirtyIntCache.stats, dirtyFloatCache.stats, dirtyByteCache.stats }; } else { stats = null; } // MarlinRenderingEngine.TransformingPathConsumer2D ! transformerPC2D = new TransformingPathConsumer2D(); // Renderer: ! renderer = new Renderer(this); ! stroker = new Stroker(this); ! dasher = new Dasher(this); } /** * Disposes this renderer context: * clean up before reusing this context --- 89,123 ---- /** * Constructor * * @param name context name (debugging) */ ! DRendererContext(final String name) { if (LOG_CREATE_CONTEXT) { MarlinUtils.logInfo("new RendererContext = " + name); } this.cleanerObj = new Object(); // create first stats (needed by newOffHeapArray): if (DO_STATS || DO_MONITORS) { stats = RendererStats.createInstance(cleanerObj, name); // push cache stats: stats.cacheStats = new CacheStats[] { cleanIntCache.stats, ! dirtyIntCache.stats, dirtyDoubleCache.stats, dirtyByteCache.stats }; } else { stats = null; } // MarlinRenderingEngine.TransformingPathConsumer2D ! transformerPC2D = new DTransformingPathConsumer2D(); // Renderer: ! renderer = new DRenderer(this); ! stroker = new DStroker(this); ! dasher = new DDasher(this); } /** * Disposes this renderer context: * clean up before reusing this context
*** 147,176 **** // mark context as CLEAN: dirty = false; } } ! Path2D.Float getPath2D() { ! // resolve reference: ! Path2D.Float p2d ! = (refPath2D != null) ? refPath2D.get() : null; ! ! // create a new Path2D ? ! if (p2d == null) { ! p2d = new Path2D.Float(Path2D.WIND_NON_ZERO, INITIAL_EDGES_COUNT); // 32K ! ! // update weak reference: ! refPath2D = new WeakReference<Path2D.Float>(p2d); ! } ! // reset the path anyway: ! p2d.reset(); ! return p2d; ! } ! ! public RendererNoAA getRendererNoAA() { if (rendererNoAA == null) { ! rendererNoAA = new RendererNoAA(this); } return rendererNoAA; } OffHeapArray newOffHeapArray(final long initialSize) { --- 143,155 ---- // mark context as CLEAN: dirty = false; } } ! public DRendererNoAA getRendererNoAA() { if (rendererNoAA == null) { ! rendererNoAA = new DRendererNoAA(this); } return rendererNoAA; } OffHeapArray newOffHeapArray(final long initialSize) {
*** 186,197 **** IntArrayCache.Reference newDirtyIntArrayRef(final int initialSize) { return dirtyIntCache.createRef(initialSize); } ! FloatArrayCache.Reference newDirtyFloatArrayRef(final int initialSize) { ! return dirtyFloatCache.createRef(initialSize); } ByteArrayCache.Reference newDirtyByteArrayRef(final int initialSize) { return dirtyByteCache.createRef(initialSize); } --- 165,176 ---- IntArrayCache.Reference newDirtyIntArrayRef(final int initialSize) { return dirtyIntCache.createRef(initialSize); } ! DoubleArrayCache.Reference newDirtyDoubleArrayRef(final int initialSize) { ! return dirtyDoubleCache.createRef(initialSize); } ByteArrayCache.Reference newDirtyByteArrayRef(final int initialSize) { return dirtyByteCache.createRef(initialSize); }
< prev index next >