< prev index next >

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

Print this page

        

*** 49,69 **** * Private constructor to prevent instantiation. */ private DMarlinPrismUtils() { } ! private static DPathConsumer2D initRenderer( final DRendererContext rdrCtx, final BasicStroke stroke, final BaseTransform tx, ! final Rectangle clip, ! final int pirule, ! final DMarlinRenderer renderer) { - final int oprule = (stroke == null && pirule == PathIterator.WIND_EVEN_ODD) ? - DMarlinRenderer.WIND_EVEN_ODD : DMarlinRenderer.WIND_NON_ZERO; - // We use strokerat so that in Stroker and Dasher we can work only // with the pre-transformation coordinates. This will repeat a lot of // computations done in the path iterator, but the alternative is to // work with transformed paths and compute untransformed coordinates // as needed. This would be faster but I do not think the complexity --- 49,69 ---- * Private constructor to prevent instantiation. */ private DMarlinPrismUtils() { } ! private static boolean nearZero(final double num) { ! return Math.abs(num) < 2.0d * Math.ulp(num); ! } ! ! private static DPathConsumer2D initPipeline( final DRendererContext rdrCtx, final BasicStroke stroke, + final float lineWidth, final BaseTransform tx, ! final DPathConsumer2D out) { // We use strokerat so that in Stroker and Dasher we can work only // with the pre-transformation coordinates. This will repeat a lot of // computations done in the path iterator, but the alternative is to // work with transformed paths and compute untransformed coordinates // as needed. This would be faster but I do not think the complexity
*** 77,103 **** // transformation before the path processing. BaseTransform strokerTx = null; int dashLen = -1; boolean recycleDashes = false; ! double width = 0.0f, dashphase = 0.0f; double[] dashesD = null; if (stroke != null) { ! width = stroke.getLineWidth(); final float[] dashes = stroke.getDashArray(); dashphase = stroke.getDashPhase(); // Ensure converting dashes to double precision: if (dashes != null) { recycleDashes = true; dashLen = dashes.length; dashesD = rdrCtx.dasher.copyDashArray(dashes); } ! if (tx != null && !tx.isIdentity()) { final double a = tx.getMxx(); final double b = tx.getMxy(); final double c = tx.getMyx(); final double d = tx.getMyy(); --- 77,103 ---- // transformation before the path processing. BaseTransform strokerTx = null; int dashLen = -1; boolean recycleDashes = false; ! double scale = 1.0d; double width = 0.0f, dashphase = 0.0f; double[] dashesD = null; if (stroke != null) { ! width = lineWidth; final float[] dashes = stroke.getDashArray(); dashphase = stroke.getDashPhase(); // Ensure converting dashes to double precision: if (dashes != null) { recycleDashes = true; dashLen = dashes.length; dashesD = rdrCtx.dasher.copyDashArray(dashes); } ! if ((tx != null) && !tx.isIdentity()) { final double a = tx.getMxx(); final double b = tx.getMxy(); final double c = tx.getMyx(); final double d = tx.getMyy();
*** 106,116 **** // 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 double scale = Math.sqrt(a*a + c*c); if (dashesD != null) { for (int i = 0; i < dashLen; i++) { dashesD[i] *= scale; } --- 106,116 ---- // 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 = Math.sqrt(a*a + c*c); if (dashesD != null) { for (int i = 0; i < dashLen; i++) { dashesD[i] *= scale; }
*** 138,169 **** // to stroker's output. } } } ! DPathConsumer2D 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 DTransformingPathConsumer2D transformerPC2D = rdrCtx.transformerPC2D; - pc = transformerPC2D.deltaTransformConsumer(pc, strokerTx); if (stroke != null) { pc = rdrCtx.stroker.init(pc, width, stroke.getEndCap(), stroke.getLineJoin(), stroke.getMiterLimit()); if (dashesD != null) { pc = rdrCtx.dasher.init(pc, dashesD, dashLen, dashphase, recycleDashes); } } - pc = transformerPC2D.inverseDeltaTransformConsumer(pc, strokerTx); - /* * Pipeline seems to be: * shape.getPathIterator(tx) * -> (inverseDeltaTransformConsumer) * -> (Dasher) --- 138,170 ---- // to stroker's output. } } } ! // Prepare the pipeline: ! DPathConsumer2D pc = out; 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 DTransformingPathConsumer2D transformerPC2D = rdrCtx.transformerPC2D; if (stroke != null) { + pc = transformerPC2D.deltaTransformConsumer(pc, strokerTx); + pc = rdrCtx.stroker.init(pc, width, stroke.getEndCap(), stroke.getLineJoin(), stroke.getMiterLimit()); if (dashesD != null) { pc = rdrCtx.dasher.init(pc, dashesD, dashLen, dashphase, recycleDashes); } + pc = transformerPC2D.inverseDeltaTransformConsumer(pc, strokerTx); } /* * Pipeline seems to be: * shape.getPathIterator(tx) * -> (inverseDeltaTransformConsumer) * -> (Dasher)
*** 175,230 **** * -> pc2d = Renderer (bounding box) */ return pc; } ! private static boolean nearZero(final double num) { ! return Math.abs(num) < 2.0d * Math.ulp(num); ! } ! ! public static DMarlinRenderer setupRenderer( final DRendererContext rdrCtx, - final Shape shape, final BasicStroke stroke, ! final BaseTransform xform, ! final Rectangle rclip, ! final boolean antialiasedShape) { ! // Test if transform is identity: ! final BaseTransform tf = (xform != null && !xform.isIdentity()) ? xform : null; ! final PathIterator pi = shape.getPathIterator(tf); ! final DMarlinRenderer r = (!FORCE_NO_AA && antialiasedShape) ? ! rdrCtx.renderer : rdrCtx.getRendererNoAA(); ! ! final DPathConsumer2D pc2d = initRenderer(rdrCtx, stroke, tf, rclip, pi.getWindingRule(), r); ! feedConsumer(rdrCtx, pi, pc2d); ! return r; } public static DMarlinRenderer setupRenderer( final DRendererContext rdrCtx, ! final Path2D p2d, final BasicStroke stroke, final BaseTransform xform, final Rectangle rclip, final boolean antialiasedShape) { // Test if transform is identity: ! final BaseTransform tf = (xform != null && !xform.isIdentity()) ? xform : null; final DMarlinRenderer r = (!FORCE_NO_AA && antialiasedShape) ? rdrCtx.renderer : rdrCtx.getRendererNoAA(); ! final DPathConsumer2D pc2d = initRenderer(rdrCtx, stroke, tf, rclip, p2d.getWindingRule(), r); ! feedConsumer(rdrCtx, p2d, tf, pc2d); ! return r; } private static void feedConsumer(final DRendererContext rdrCtx, final PathIterator pi, final DPathConsumer2D pc2d) { --- 176,247 ---- * -> pc2d = Renderer (bounding box) */ return pc; } ! private static DPathConsumer2D initRenderer( final DRendererContext rdrCtx, final BasicStroke stroke, ! final BaseTransform tx, ! final Rectangle clip, ! final int piRule, ! final DMarlinRenderer renderer) { ! final int oprule = ((stroke == null) && (piRule == PathIterator.WIND_EVEN_ODD)) ? ! DMarlinRenderer.WIND_EVEN_ODD : DMarlinRenderer.WIND_NON_ZERO; ! renderer.init(clip.x, clip.y, clip.width, clip.height, oprule); ! float lw = 0.0f; ! if (stroke != null) { ! lw = stroke.getLineWidth(); ! } ! return initPipeline(rdrCtx, stroke, lw, tx, renderer); } public static DMarlinRenderer setupRenderer( final DRendererContext rdrCtx, ! final Shape shape, final BasicStroke stroke, final BaseTransform xform, final Rectangle rclip, final boolean antialiasedShape) { // Test if transform is identity: ! final BaseTransform tf = ((xform != null) && !xform.isIdentity()) ? xform : null; final DMarlinRenderer r = (!FORCE_NO_AA && antialiasedShape) ? rdrCtx.renderer : rdrCtx.getRendererNoAA(); ! if (shape instanceof Path2D) { ! final Path2D p2d = (Path2D)shape; ! final DPathConsumer2D pc2d = initRenderer(rdrCtx, stroke, tf, rclip, p2d.getWindingRule(), r); ! feedConsumer(rdrCtx, p2d, tf, pc2d); ! } else { ! final PathIterator pi = shape.getPathIterator(tf); ! final DPathConsumer2D pc2d = initRenderer(rdrCtx, stroke, tf, rclip, pi.getWindingRule(), r); ! feedConsumer(rdrCtx, pi, pc2d); ! } ! return r; ! } ! public static void strokeTo( ! final DRendererContext rdrCtx, ! final Shape shape, ! final BasicStroke stroke, ! final float lineWidth, ! final DPathConsumer2D out) ! { ! final DPathConsumer2D pc2d = initPipeline(rdrCtx, stroke, lineWidth, null, out); ! if (shape instanceof Path2D) { ! feedConsumer(rdrCtx, (Path2D)shape, null, pc2d); ! } else { ! feedConsumer(rdrCtx, shape.getPathIterator(null), pc2d); ! } } private static void feedConsumer(final DRendererContext rdrCtx, final PathIterator pi, final DPathConsumer2D pc2d) {
*** 357,368 **** // 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: --- 374,385 ---- // 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 >