Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
bourgesl committed May 4, 2018
1 parent 0f2f2e8 commit 518bf8a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 28 deletions.
17 changes: 9 additions & 8 deletions src/main/java/com/sun/marlin/DDasher.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,19 @@ 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;

// Normalize so 0 <= phase < dash[0]
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;

Expand All @@ -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;
Expand All @@ -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;
}
}
Expand Down
17 changes: 9 additions & 8 deletions src/main/java/com/sun/marlin/Dasher.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,19 @@ 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;

// Normalize so 0 <= phase < dash[0]
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;

Expand All @@ -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;
Expand All @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/sun/marlin/Stroker.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/sun/prism/impl/shape/DMarlinPrismUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/sun/prism/impl/shape/MarlinPrismUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private static PathConsumer2D initStroker(

// Curve Monotizer:
rdrCtx.monotonizer.init(width);

if (dashes != null) {
if (!recycleDashes) {
dashLen = dashes.length;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 518bf8a

Please sign in to comment.