Skip to content

Commit

Permalink
merged with marlin-jdk 0.9.4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
bourgesl committed Nov 19, 2022
1 parent d603642 commit 4eb778d
Show file tree
Hide file tree
Showing 49 changed files with 1,943 additions and 457 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<groupId>org.marlin</groupId>
<artifactId>marlin</artifactId>
<packaging>jar</packaging>
<version>0.9.4.5-Unsafe</version>
<version>0.9.4.6-Unsafe</version>
<name>Marlin software rasterizer</name>

<url>https://github.com/bourgesl/marlin-renderer</url>
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/sun/java2d/ReentrantContextProvider.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -136,14 +136,14 @@ protected final Reference<K> getOrCreateReference(final K ctx) {
// Create the reference:
switch (refType) {
case REF_HARD:
ctx.reference = new HardReference<K>(ctx);
ctx.reference = new HardReference<>(ctx);
break;
case REF_SOFT:
ctx.reference = new SoftReference<K>(ctx);
ctx.reference = new SoftReference<>(ctx);
break;
default:
case REF_WEAK:
ctx.reference = new WeakReference<K>(ctx);
ctx.reference = new WeakReference<>(ctx);
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/sun/java2d/ReentrantContextProviderCLQ.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -42,7 +42,7 @@ public abstract class ReentrantContextProviderCLQ<K extends ReentrantContext>
{
// ReentrantContext queue to store all contexts
private final ConcurrentLinkedQueue<Reference<K>> ctxQueue
= new ConcurrentLinkedQueue<Reference<K>>();
= new ConcurrentLinkedQueue<>();

/**
* Create a new ReentrantContext provider using the given reference type
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/sun/java2d/ReentrantContextProviderTL.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -42,7 +42,7 @@ public abstract class ReentrantContextProviderTL<K extends ReentrantContext>
{
// Thread-local storage:
private final ThreadLocal<Reference<K>> ctxTL
= new ThreadLocal<Reference<K>>();
= new ThreadLocal<>();

// ReentrantContext CLQ provider for child contexts:
private final ReentrantContextProviderCLQ<K> ctxProviderCLQ;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/sun/java2d/marlin/ArrayCacheByte.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -83,7 +83,7 @@ private Bucket[] getBuckets() {
}

// update weak reference:
refBuckets = new WeakReference<Bucket[]>(buckets);
refBuckets = new WeakReference<>(buckets);
}
return buckets;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/sun/java2d/marlin/ArrayCacheDouble.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -83,7 +83,7 @@ private Bucket[] getBuckets() {
}

// update weak reference:
refBuckets = new WeakReference<Bucket[]>(buckets);
refBuckets = new WeakReference<>(buckets);
}
return buckets;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/sun/java2d/marlin/ArrayCacheInt.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -83,7 +83,7 @@ private Bucket[] getBuckets() {
}

// update weak reference:
refBuckets = new WeakReference<Bucket[]>(buckets);
refBuckets = new WeakReference<>(buckets);
}
return buckets;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/sun/java2d/marlin/ArrayCacheIntClean.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -82,7 +82,7 @@ private Bucket[] getBuckets() {
}

// update weak reference:
refBuckets = new WeakReference<Bucket[]>(buckets);
refBuckets = new WeakReference<>(buckets);
}
return buckets;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/sun/java2d/marlin/CollinearSimplifier.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/sun/java2d/marlin/Curve.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ int rootsOfROCMinusW(final double[] roots, final int off, final double w2, final

int ret = off;
final int end = off + perpendiculardfddf(roots, off);

Helpers.isort(roots, off, end);

roots[end] = 1.0d; // always check interval end points

double t0 = 0.0d, ft0 = ROCsq(t0) - w2;
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/sun/java2d/marlin/DMarlinRenderingEngine.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -1082,7 +1082,7 @@ public AATileGenerator getAATileGenerator(double x, double y,

/**
* Returns the minimum pen width that the antialiasing rasterizer
* can represent without dropouts occuring.
* can represent without dropouts occurring.
* @since 1.7
*/
@Override
Expand Down Expand Up @@ -1235,6 +1235,11 @@ private static void logSettings(final String reClass) {
logInfo("sun.java2d.renderer.pathSimplifier.pixTol = "
+ MarlinProperties.getPathSimplifierPixelTolerance());

logInfo("sun.java2d.renderer.stroker.joinError= "
+ MarlinProperties.getStrokerJoinError());
logInfo("sun.java2d.renderer.stroker.joinStyle= "
+ MarlinProperties.getStrokerJoinStyle());

logInfo("sun.java2d.renderer.clip = "
+ MarlinProperties.isDoClip());
logInfo("sun.java2d.renderer.clip.runtime.enable = "
Expand All @@ -1253,6 +1258,11 @@ private static void logSettings(final String reClass) {
logInfo("sun.java2d.renderer.doChecks = "
+ MarlinConst.DO_CHECKS);

logInfo("sun.java2d.renderer.skip_rdr = "
+ MarlinProperties.isSkipRenderer());
logInfo("sun.java2d.renderer.skip_pipe = "
+ MarlinProperties.isSkipRenderTiles());

// logging parameters
logInfo("sun.java2d.renderer.useLogger = "
+ MarlinConst.USE_LOGGER);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/sun/java2d/marlin/DPQSSorterContext.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -35,7 +35,7 @@ final class DPQSSorterContext {
/**
* Max capacity of the index array for tracking runs.
*/
static final int MAX_RUN_CAPACITY = DualPivotQuicksort20191112Ext.MAX_RUN_CAPACITY;
static final int MAX_RUN_CAPACITY = DualPivotQuicksort20220112Ext.MAX_RUN_CAPACITY;

/* members */
final int[] run;
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/sun/java2d/marlin/DPathConsumer2D.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -27,30 +27,30 @@

public interface DPathConsumer2D {
/**
* @see java.awt.geom.Path2D.Float#moveTo
* @see java.awt.geom.Path2D.Double#moveTo
*/
public void moveTo(double x, double y);

/**
* @see java.awt.geom.Path2D.Float#lineTo
* @see java.awt.geom.Path2D.Double#lineTo
*/
public void lineTo(double x, double y);

/**
* @see java.awt.geom.Path2D.Float#quadTo
* @see java.awt.geom.Path2D.Double#quadTo
*/
public void quadTo(double x1, double y1,
double x2, double y2);

/**
* @see java.awt.geom.Path2D.Float#curveTo
* @see java.awt.geom.Path2D.Double#curveTo
*/
public void curveTo(double x1, double y1,
double x2, double y2,
double x3, double y3);

/**
* @see java.awt.geom.Path2D.Float#closePath
* @see java.awt.geom.Path2D.Double#closePath
*/
public void closePath();

Expand Down
68 changes: 46 additions & 22 deletions src/main/java/sun/java2d/marlin/Dasher.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -28,6 +28,7 @@
import java.util.Arrays;
import sun.java2d.marlin.TransformingPathConsumer2D.CurveBasicMonotonizer;
import sun.java2d.marlin.TransformingPathConsumer2D.CurveClipSplitter;
import sun.java2d.marlin.TransformingPathConsumer2D.StartFlagPathConsumer2D;

/**
* The <code>Dasher</code> class takes a series of linear commands
Expand All @@ -40,7 +41,7 @@
* semantics are unclear.
*
*/
final class Dasher implements DPathConsumer2D, MarlinConst {
final class Dasher implements StartFlagPathConsumer2D, MarlinConst {

/* huge circle with radius ~ 2E9 only needs 12 subdivision levels */
static final int REC_LIMIT = 16;
Expand Down Expand Up @@ -142,9 +143,7 @@ final class Dasher implements DPathConsumer2D, MarlinConst {
Dasher init(final DPathConsumer2D out, final double[] dash, final int dashLen,
double phase, final boolean recycleDashes)
{
if (this.out != out) {
this.out = out;
}
this.out = out;

// Normalize so 0 <= phase < dash[0]
int sidx = 0;
Expand Down Expand Up @@ -349,11 +348,38 @@ private void goTo_starting(final double[] pts, final int off, final int type) {
}
buf[segIdx++] = type;
len--;
// small arraycopy (2, 4 or 6) but with offset:
System.arraycopy(pts, off, buf, segIdx, len);

if (true && (len == 2)) {
// most probable case:
buf[segIdx ] = pts[off ];
buf[segIdx + 1] = pts[off + 1];
} else {
// small arraycopy (4 or 6) but with offset:
System.arraycopy(pts, off, buf, segIdx, len);
}
firstSegidx = segIdx + len;
}

/* Callback from CurveClipSplitter */
@Override
public void setStartFlag(boolean first) {
if (first) {
// reset flag:
rdrCtx.firstFlags &= 0b011;
} else {
rdrCtx.firstFlags |= 0b100;
}
}

public void setMonotonizerStartFlag(boolean first) {
if (first) {
// reset flag:
rdrCtx.firstFlags &= 0b101;
} else {
rdrCtx.firstFlags |= 0b010;
}
}

@Override
public void lineTo(final double x1, final double y1) {
final int outcode0 = this.cOutCode;
Expand Down Expand Up @@ -809,7 +835,7 @@ private boolean haveLowAcceleration(final double err) {
// and our quadratic root finder doesn't filter, so it's just a
// matter of convenience.
final int n = Helpers.cubicRootsInAB(a, b, c, d, nextRoots, 0, 0.0d, 1.0d);
if (n == 1 && !Double.isNaN(nextRoots[0])) {
if (n == 1) {
t = nextRoots[0];
}
}
Expand Down Expand Up @@ -956,7 +982,6 @@ public void curveTo(final double x1, final double y1,
return;
}
}

this.cOutCode = outcode3;

if (this.outside) {
Expand All @@ -981,19 +1006,19 @@ private void _curveTo(final double x1, final double y1,
final int nSplits = monotonizer.nbSplits;
final double[] mid = monotonizer.middle;

// Implicitely rdrCtx.isFirstSegment = true

for (int i = 0, off = 0; i <= nSplits; i++, off += 6) {
// optimize arraycopy (8 values faster than 6 = type):
System.arraycopy(mid, off, _curCurvepts, 0, 8);

somethingTo(8);

// set flag rdrCtx.isFirstSegment = false for other parts:
rdrCtx.isFirstSegment = false; // TODO: handle conflict with clipper
if (i == 0) {
// disable start flag:
setMonotonizerStartFlag(false);
}
}
// reset trigger to process further joins (normal operations)
rdrCtx.isFirstSegment = true;
// reset start flag:
setMonotonizerStartFlag(true);
}

private void skipCurveTo(final double x1, final double y1,
Expand Down Expand Up @@ -1049,7 +1074,6 @@ public void quadTo(final double x1, final double y1,
return;
}
}

this.cOutCode = outcode2;

if (this.outside) {
Expand All @@ -1073,19 +1097,19 @@ private void _quadTo(final double x1, final double y1,
final int nSplits = monotonizer.nbSplits;
final double[] mid = monotonizer.middle;

// Implicitely rdrCtx.isFirstSegment = true

for (int i = 0, off = 0; i <= nSplits; i++, off += 4) {
// optimize arraycopy (8 values faster than 6 = type):
System.arraycopy(mid, off, _curCurvepts, 0, 8);

somethingTo(6);

// set flag rdrCtx.isFirstSegment = false for other parts:
rdrCtx.isFirstSegment = false; // TODO: handle conflict with clipper
if (i == 0) {
// disable start flag:
setMonotonizerStartFlag(false);
}
}
// reset trigger to process further joins (normal operations)
rdrCtx.isFirstSegment = true;
// reset start flag:
setMonotonizerStartFlag(true);
}

private void skipQuadTo(final double x1, final double y1,
Expand Down
Loading

0 comments on commit 4eb778d

Please sign in to comment.