< prev index next >

modules/javafx.graphics/src/main/java/com/sun/prism/impl/shape/MarlinPrismUtils.java

Print this page

        

*** 31,52 **** --- 31,57 ---- import com.sun.javafx.geom.Path2D; import com.sun.javafx.geom.Rectangle; import com.sun.javafx.geom.Shape; import com.sun.javafx.geom.transform.BaseTransform; import com.sun.marlin.MarlinConst; + import com.sun.marlin.MarlinProperties; import com.sun.marlin.MarlinRenderer; import com.sun.marlin.RendererContext; + import com.sun.marlin.Stroker; import com.sun.marlin.TransformingPathConsumer2D; import com.sun.prism.BasicStroke; public final class MarlinPrismUtils { private static final boolean FORCE_NO_AA = false; static final float UPPER_BND = Float.MAX_VALUE / 2.0f; static final float LOWER_BND = -UPPER_BND; + static final boolean DO_CLIP = MarlinProperties.isDoClip(); + static final boolean DO_TRACE = false; + /** * Private constructor to prevent instantiation. */ private MarlinPrismUtils() { }
*** 77,87 **** // transformation before the path processing. BaseTransform strokerTx = null; int dashLen = -1; boolean recycleDashes = false; ! float width = 0.0f, dashphase = 0.0f; float[] dashes = null; if (stroke != null) { width = stroke.getLineWidth(); --- 82,92 ---- // transformation before the path processing. BaseTransform strokerTx = null; int dashLen = -1; boolean recycleDashes = false; ! float scale = 1.0f; float width = 0.0f, dashphase = 0.0f; float[] dashes = null; if (stroke != null) { width = stroke.getLineWidth();
*** 99,109 **** // need to transform input paths to stroker and tell stroker // the scaled width. This condition is satisfied if // a*b == -c*d && a*a+c*c == b*b+d*d. In the actual check below, we // leave a bit of room for error. if (nearZero(a*b + c*d) && nearZero(a*a + c*c - (b*b + d*d))) { ! final float scale = (float) Math.sqrt(a*a + c*c); if (dashes != null) { recycleDashes = true; dashLen = dashes.length; dashes = rdrCtx.dasher.copyDashArray(dashes); --- 104,114 ---- // need to transform input paths to stroker and tell stroker // the scaled width. This condition is satisfied if // a*b == -c*d && a*a+c*c == b*b+d*d. In the actual check below, we // leave a bit of room for error. if (nearZero(a*b + c*d) && nearZero(a*a + c*c - (b*b + d*d))) { ! scale = (float) Math.sqrt(a*a + c*c); if (dashes != null) { recycleDashes = true; dashLen = dashes.length; dashes = rdrCtx.dasher.copyDashArray(dashes);
*** 134,168 **** // to stroker's output. } } } ! PathConsumer2D pc = renderer.init(clip.x, clip.y, clip.width, clip.height, oprule); if (MarlinConst.USE_SIMPLIFIER) { // Use simplifier after stroker before Renderer // to remove collinear segments (notably due to cap square) pc = rdrCtx.simplifier.init(pc); } ! final TransformingPathConsumer2D transformerPC2D = rdrCtx.transformerPC2D; ! pc = transformerPC2D.deltaTransformConsumer(pc, strokerTx); if (stroke != null) { pc = rdrCtx.stroker.init(pc, width, stroke.getEndCap(), ! stroke.getLineJoin(), stroke.getMiterLimit()); if (dashes != null) { if (!recycleDashes) { dashLen = dashes.length; } pc = rdrCtx.dasher.init(pc, dashes, dashLen, dashphase, recycleDashes); } } - pc = transformerPC2D.inverseDeltaTransformConsumer(pc, strokerTx); /* * Pipeline seems to be: * shape.getPathIterator(tx) * -> (inverseDeltaTransformConsumer) * -> (Dasher) --- 139,212 ---- // to stroker's output. } } } ! final MarlinRenderer rdr = renderer.init(clip.x, clip.y, clip.width, clip.height, oprule); ! PathConsumer2D pc = rdr; ! ! float rdrOffX = 0.0f, rdrOffY = 0.0f; ! ! if (DO_CLIP && stroke != null) { ! // Define the initial clip bounds: ! final float[] clipRect = rdrCtx.clipRect; ! clipRect[0] = clip.y; ! clipRect[1] = clip.y + clip.height; ! clipRect[2] = clip.x; ! clipRect[3] = clip.x + clip.width; ! ! // Get offsets: ! rdrOffX = rdr.getOffsetX(); ! rdrOffY = rdr.getOffsetY(); ! ! // Enable clipping: ! rdrCtx.doClip = true; ! } ! ! final TransformingPathConsumer2D transformerPC2D = rdrCtx.transformerPC2D; ! ! if (DO_TRACE) { ! // trace Stroker: ! pc = transformerPC2D.traceStroker(pc); ! } if (MarlinConst.USE_SIMPLIFIER) { // Use simplifier after stroker before Renderer // to remove collinear segments (notably due to cap square) pc = rdrCtx.simplifier.init(pc); } ! // deltaTransformConsumer may adjust the clip rectangle: ! pc = transformerPC2D.deltaTransformConsumer(pc, strokerTx, rdrOffX, rdrOffY); if (stroke != null) { + // stroker will adjust the clip rectangle (width / miter limit): pc = rdrCtx.stroker.init(pc, width, stroke.getEndCap(), ! stroke.getLineJoin(), stroke.getMiterLimit(), ! scale, rdrOffX, rdrOffY); if (dashes != null) { if (!recycleDashes) { dashLen = dashes.length; } pc = rdrCtx.dasher.init(pc, dashes, dashLen, dashphase, recycleDashes); + } else if (rdrCtx.doClip && (stroke.getEndCap() != Stroker.CAP_BUTT)) { + if (DO_TRACE) { + pc = transformerPC2D.traceClosedPathDetector(pc); + } + + // If no dash and clip is enabled: + // detect closedPaths (polygons) for caps + pc = transformerPC2D.detectClosedPath(pc); } } pc = transformerPC2D.inverseDeltaTransformConsumer(pc, strokerTx); + if (DO_TRACE) { + // trace Input: + pc = transformerPC2D.traceInput(pc); + } /* * Pipeline seems to be: * shape.getPathIterator(tx) * -> (inverseDeltaTransformConsumer) * -> (Dasher)
*** 356,367 **** // ported from DuctusRenderingEngine.feedConsumer() but simplified: // - removed skip flag = !subpathStarted // - removed pathClosed (ie subpathStarted not set to false) boolean subpathStarted = false; ! final float pCoords[] = p2d.getFloatCoordsNoClone(); ! final byte pTypes[] = p2d.getCommandsNoClone(); final int nsegs = p2d.getNumCommands(); for (int i = 0, coff = 0; i < nsegs; i++) { switch (pTypes[i]) { case PathIterator.SEG_MOVETO: --- 400,411 ---- // ported from DuctusRenderingEngine.feedConsumer() but simplified: // - removed skip flag = !subpathStarted // - removed pathClosed (ie subpathStarted not set to false) boolean subpathStarted = false; ! final float[] pCoords = p2d.getFloatCoordsNoClone(); ! final byte[] pTypes = p2d.getCommandsNoClone(); final int nsegs = p2d.getNumCommands(); for (int i = 0, coff = 0; i < nsegs; i++) { switch (pTypes[i]) { case PathIterator.SEG_MOVETO:
< prev index next >