From 518bf8aba3e1d10a901461e917de0159fec9eab5 Mon Sep 17 00:00:00 2001 From: bourgesl Date: Fri, 4 May 2018 15:04:01 +0200 Subject: [PATCH] merge --- src/main/java/com/sun/marlin/DDasher.java | 17 +++++++++-------- src/main/java/com/sun/marlin/Dasher.java | 17 +++++++++-------- src/main/java/com/sun/marlin/Stroker.java | 2 +- .../sun/prism/impl/shape/DMarlinPrismUtils.java | 10 +++++----- .../sun/prism/impl/shape/MarlinPrismUtils.java | 12 ++++++------ 5 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/sun/marlin/DDasher.java b/src/main/java/com/sun/marlin/DDasher.java index fcce5de..36029c2 100644 --- a/src/main/java/com/sun/marlin/DDasher.java +++ b/src/main/java/com/sun/marlin/DDasher.java @@ -137,8 +137,8 @@ public final class DDasher implements DPathConsumer2D, MarlinConst { * @param recycleDashes true to indicate to recycle the given dash array * @return this instance */ - public DDasher init(final DPathConsumer2D out, double[] dash, int dashLen, - double phase, boolean recycleDashes) + public DDasher init(final DPathConsumer2D out, final double[] dash, final int dashLen, + double phase, final boolean recycleDashes) { this.out = out; @@ -146,9 +146,10 @@ public DDasher init(final DPathConsumer2D out, double[] dash, int dashLen, int sidx = 0; dashOn = true; + // note: BasicStroke constructor checks dash elements and sum > 0 double sum = 0.0d; - for (double d : dash) { - sum += d; + for (int i = 0; i < dashLen; i++) { + sum += dash[i]; } this.cycleLen = sum; @@ -158,13 +159,13 @@ public DDasher init(final DPathConsumer2D out, double[] dash, int dashLen, phase = 0.0d; } else { int fullcycles = FloatMath.floor_int(-cycles); - if ((fullcycles & dash.length & 1) != 0) { + if ((fullcycles & dashLen & 1) != 0) { dashOn = !dashOn; } phase += fullcycles * sum; while (phase < 0.0d) { if (--sidx < 0) { - sidx = dash.length - 1; + sidx = dashLen - 1; } phase += dash[sidx]; dashOn = !dashOn; @@ -175,14 +176,14 @@ public DDasher init(final DPathConsumer2D out, double[] dash, int dashLen, phase = 0.0d; } else { int fullcycles = FloatMath.floor_int(cycles); - if ((fullcycles & dash.length & 1) != 0) { + if ((fullcycles & dashLen & 1) != 0) { dashOn = !dashOn; } phase -= fullcycles * sum; double d; while (phase >= (d = dash[sidx])) { phase -= d; - sidx = (sidx + 1) % dash.length; + sidx = (sidx + 1) % dashLen; dashOn = !dashOn; } } diff --git a/src/main/java/com/sun/marlin/Dasher.java b/src/main/java/com/sun/marlin/Dasher.java index 8151918..5f7992f 100644 --- a/src/main/java/com/sun/marlin/Dasher.java +++ b/src/main/java/com/sun/marlin/Dasher.java @@ -138,8 +138,8 @@ public final class Dasher implements PathConsumer2D, MarlinConst { * @param recycleDashes true to indicate to recycle the given dash array * @return this instance */ - public Dasher init(final PathConsumer2D out, float[] dash, int dashLen, - float phase, boolean recycleDashes) + public Dasher init(final PathConsumer2D out, final float[] dash, final int dashLen, + float phase, final boolean recycleDashes) { this.out = out; @@ -147,9 +147,10 @@ public Dasher init(final PathConsumer2D out, float[] dash, int dashLen, int sidx = 0; dashOn = true; + // note: BasicStroke constructor checks dash elements and sum > 0 float sum = 0.0f; - for (float d : dash) { - sum += d; + for (int i = 0; i < dashLen; i++) { + sum += dash[i]; } this.cycleLen = sum; @@ -159,13 +160,13 @@ public Dasher init(final PathConsumer2D out, float[] dash, int dashLen, phase = 0.0f; } else { int fullcycles = FloatMath.floor_int(-cycles); - if ((fullcycles & dash.length & 1) != 0) { + if ((fullcycles & dashLen & 1) != 0) { dashOn = !dashOn; } phase += fullcycles * sum; while (phase < 0.0f) { if (--sidx < 0) { - sidx = dash.length - 1; + sidx = dashLen - 1; } phase += dash[sidx]; dashOn = !dashOn; @@ -176,14 +177,14 @@ public Dasher init(final PathConsumer2D out, float[] dash, int dashLen, phase = 0.0f; } else { int fullcycles = FloatMath.floor_int(cycles); - if ((fullcycles & dash.length & 1) != 0) { + if ((fullcycles & dashLen & 1) != 0) { dashOn = !dashOn; } phase -= fullcycles * sum; float d; while (phase >= (d = dash[sidx])) { phase -= d; - sidx = (sidx + 1) % dash.length; + sidx = (sidx + 1) % dashLen; dashOn = !dashOn; } } diff --git a/src/main/java/com/sun/marlin/Stroker.java b/src/main/java/com/sun/marlin/Stroker.java index e5bbac1..2a6136f 100644 --- a/src/main/java/com/sun/marlin/Stroker.java +++ b/src/main/java/com/sun/marlin/Stroker.java @@ -309,7 +309,7 @@ private void drawRoundJoin(float cx, float cy, // If it is >=0, we know that abs(ext) is <= 90 degrees, so we only // need 1 curve to approximate the circle section that joins omx,omy // and mx,my. - if (cosext >= 0.0d) { + if (cosext >= 0.0f) { drawBezApproxForArc(cx, cy, omx, omy, mx, my, rev); } else { // we need to split the arc into 2 arcs spanning the same angle. diff --git a/src/main/java/com/sun/prism/impl/shape/DMarlinPrismUtils.java b/src/main/java/com/sun/prism/impl/shape/DMarlinPrismUtils.java index cf2356f..38f3bd1 100644 --- a/src/main/java/com/sun/prism/impl/shape/DMarlinPrismUtils.java +++ b/src/main/java/com/sun/prism/impl/shape/DMarlinPrismUtils.java @@ -228,7 +228,7 @@ private static DPathConsumer2D initStroker( private static boolean nearZero(final double num) { return Math.abs(num) < 2.0d * Math.ulp(num); } - + private static DPathConsumer2D initRenderer( final DRendererContext rdrCtx, final BasicStroke stroke, @@ -334,8 +334,8 @@ private static void feedConsumer(final DRendererContext rdrCtx, final PathIterat // Use path simplifier at the first step // to remove useless points pc2d = rdrCtx.pathSimplifier.init(pc2d); - } - + } + // mark context as DIRTY: rdrCtx.dirty = true; @@ -461,8 +461,8 @@ private static void feedConsumer(final DRendererContext rdrCtx, // Use path simplifier at the first step // to remove useless points pc2d = rdrCtx.pathSimplifier.init(pc2d); - } - + } + // mark context as DIRTY: rdrCtx.dirty = true; diff --git a/src/main/java/com/sun/prism/impl/shape/MarlinPrismUtils.java b/src/main/java/com/sun/prism/impl/shape/MarlinPrismUtils.java index 69118a9..e7ee343 100644 --- a/src/main/java/com/sun/prism/impl/shape/MarlinPrismUtils.java +++ b/src/main/java/com/sun/prism/impl/shape/MarlinPrismUtils.java @@ -177,7 +177,7 @@ private static PathConsumer2D initStroker( // Curve Monotizer: rdrCtx.monotonizer.init(width); - + if (dashes != null) { if (!recycleDashes) { dashLen = dashes.length; @@ -226,7 +226,7 @@ private static PathConsumer2D initStroker( private static boolean nearZero(final double num) { return Math.abs(num) < 2.0d * Math.ulp(num); } - + private static PathConsumer2D initRenderer( final RendererContext rdrCtx, final BasicStroke stroke, @@ -332,8 +332,8 @@ private static void feedConsumer(final RendererContext rdrCtx, final PathIterato // Use path simplifier at the first step // to remove useless points pc2d = rdrCtx.pathSimplifier.init(pc2d); - } - + } + // mark context as DIRTY: rdrCtx.dirty = true; @@ -459,8 +459,8 @@ private static void feedConsumer(final RendererContext rdrCtx, // Use path simplifier at the first step // to remove useless points pc2d = rdrCtx.pathSimplifier.init(pc2d); - } - + } + // mark context as DIRTY: rdrCtx.dirty = true;