Skip to content

Commit

Permalink
fixed dpqs javadoc + tests (setupOnce)
Browse files Browse the repository at this point in the history
  • Loading branch information
bourgesl committed Aug 13, 2022
1 parent 4839cea commit 32fedaf
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 59 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>marlinfx</artifactId>
<packaging>jar</packaging>
<version>0.9.4.5-Unsafe-OpenJFX11</version>
<version>0.9.4.6-Unsafe-OpenJFX11</version>
<name>Marlin software rasterizer</name>

<url>https://github.com/bourgesl/marlin-renderer</url>
Expand Down
39 changes: 27 additions & 12 deletions src/main/java/com/sun/marlin/DualPivotQuicksort20191112Ext.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
*/
public final class DualPivotQuicksort20191112Ext {

private static final boolean FAST_ISORT = false;
private static final boolean FAST_ISORT = true;

/*
From OpenJDK14 source code:
Expand Down Expand Up @@ -108,16 +108,19 @@ private DualPivotQuicksort20191112Ext() {
/**
* Sorts the specified range of the array.
*
* @param sorter sorter context
* @param a the array to be sorted
* @param b the permutation array to be handled
* @param auxA auxiliary storage for the array to be sorted
* @param b the secondary array to be ordered
* @param auxB auxiliary storage for the permutation array to be handled
* @param low the index of the first element, inclusive, to be sorted
* @param high the index of the last element, exclusive, to be sorted
*/
static void sort(DPQSSorterContext sorter, int[] a, int[] auxA, int[] b, int[] auxB, int low, int high) {
/*
* LBO Shortcut: Invoke insertion sort on the leftmost part.
*/
if (FAST_ISORT && ((high - low) <= 24)) {
if (FAST_ISORT && ((high - low) <= MAX_INSERTION_SORT_SIZE)) {
insertionSort(a, b, low, high);
return;
}
Expand All @@ -130,8 +133,9 @@ static void sort(DPQSSorterContext sorter, int[] a, int[] auxA, int[] b, int[] a
* Sorts the specified array using the Dual-Pivot Quicksort and/or
* other sorts in special-cases, possibly with parallel partitions.
*
* @param sorter parallel context
* @param sorter sorter context
* @param a the array to be sorted
* @param b the secondary array to be ordered
* @param bits the combination of recursion depth and bit flag, where
* the right bit "0" indicates that array is the leftmost part
* @param low the index of the first element, inclusive, to be sorted
Expand Down Expand Up @@ -425,6 +429,7 @@ && tryMergeRuns(sorter, a, b, low, size)) {
* iteration unless it is the leftmost call.
*
* @param a the array to be sorted
* @param b the secondary array to be ordered
* @param low the index of the first element, inclusive, to be sorted
* @param end the index of the last element for simple insertion sort
* @param high the index of the last element, exclusive, to be sorted
Expand Down Expand Up @@ -562,6 +567,7 @@ private static void mixedInsertionSort(int[] a, int[] b, int low, int end, int h
* Sorts the specified range of the array using insertion sort.
*
* @param a the array to be sorted
* @param b the secondary array to be ordered
* @param low the index of the first element, inclusive, to be sorted
* @param high the index of the last element, exclusive, to be sorted
*/
Expand All @@ -586,6 +592,7 @@ static void insertionSort(int[] a, int[] b, int low, int high) {
* Sorts the specified range of the array using heap sort.
*
* @param a the array to be sorted
* @param b the secondary array to be ordered
* @param low the index of the first element, inclusive, to be sorted
* @param high the index of the last element, exclusive, to be sorted
*/
Expand All @@ -605,9 +612,11 @@ private static void heapSort(int[] a, int[] b, int low, int high) {
/**
* Pushes specified element down during heap sort.
*
* @param a the given array
* @param a the array to be sorted
* @param b the secondary array to be ordered
* @param p the start index
* @param valueA the given element
* @param valueA the given element in a
* @param valueB the given element in b
* @param low the index of the first element, inclusive, to be sorted
* @param high the index of the last element, exclusive, to be sorted
*/
Expand All @@ -632,8 +641,9 @@ private static void pushDown(int[] a, int[] b, int p, int valueA, int valueB, in
/**
* Tries to sort the specified range of the array.
*
* @param sorter parallel context
* @param sorter sorter context
* @param a the array to be sorted
* @param b the secondary array to be ordered
* @param low the index of the first element to be sorted
* @param size the array size
* @return true if finally sorted, false otherwise
Expand Down Expand Up @@ -767,9 +777,11 @@ private static boolean tryMergeRuns(DPQSSorterContext sorter, int[] a, int[] b,
/**
* Merges the specified runs.
*
* @param srcA the source array
* @param dstA the temporary buffer used in merging
* @param srcA the source array for the array to be sorted (a)
* @param dstA the temporary buffer used in merging (a)
* @param srcB the source array for the secondary array to be ordered (b)
* @param offset the start index in the source, inclusive
* @param dstB the temporary buffer used in merging (b)
* @param aim specifies merging: to source ( > 0), buffer ( < 0) or any ( == 0)
* @param run the start indexes of the runs, inclusive
* @param lo the start index of the first run, inclusive
Expand Down Expand Up @@ -823,12 +835,15 @@ private static int[] mergeRuns(int[] srcA, int[] dstA, int[] srcB, int[] dstB, i
/**
* Merges the sorted parts.
*
* @param dstA the destination where parts are merged
* @param dstA the destination where parts are merged (a)
* @param dstB the destination where parts are merged (b)
* @param k the start index of the destination, inclusive
* @param a1 the first part
* @param a1 the first part (a)
* @param b1 the first part (b)
* @param lo1 the start index of the first part, inclusive
* @param hi1 the end index of the first part, exclusive
* @param a2 the second part
* @param a2 the second part (a)
* @param b2 the second part (b)
* @param lo2 the start index of the second part, inclusive
* @param hi2 the end index of the second part, exclusive
*/
Expand Down
12 changes: 3 additions & 9 deletions src/test/java/test/manual/marlin/ClipShapeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -974,18 +974,12 @@ static void subdivide(final Path2D p2d, final int type, final double[] in) {
}

@BeforeClass
public static void setupOnce() {
public static void setupOnce() throws Exception {
// Start the Application
new Thread(() -> Application.launch(MyApp.class, (String[]) null)).start();

try {
assertTrue("Timeout waiting for Application to launch",
launchLatch.await(TIMEOUT, TimeUnit.MILLISECONDS));
} catch (InterruptedException ex) {
AssertionFailedError err = new AssertionFailedError("Unexpected exception");
err.initCause(ex);
throw err;
}
assertTrue("Timeout waiting for Application to launch",
launchLatch.await(TIMEOUT, TimeUnit.MILLISECONDS));

assertEquals(0, launchLatch.getCount());
}
Expand Down
12 changes: 3 additions & 9 deletions src/test/java/test/manual/marlin/DashedRectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,12 @@ public void start(Stage primaryStage) throws Exception {
}

@BeforeClass
public static void setupOnce() {
public static void setupOnce() throws Exception {
// Start the Application
new Thread(() -> Application.launch(MyApp.class, (String[]) null)).start();

try {
assertTrue("Timeout waiting for Application to launch",
launchLatch.await(TIMEOUT, TimeUnit.MILLISECONDS));
} catch (InterruptedException ex) {
AssertionFailedError err = new AssertionFailedError("Unexpected exception");
err.initCause(ex);
throw err;
}
assertTrue("Timeout waiting for Application to launch",
launchLatch.await(TIMEOUT, TimeUnit.MILLISECONDS));

assertEquals(0, launchLatch.getCount());
}
Expand Down
13 changes: 3 additions & 10 deletions src/test/java/test/manual/marlin/HugePolygonClipTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,12 @@ public void start(Stage primaryStage) throws Exception {
}

@BeforeClass
public static void setupOnce() {

public static void setupOnce() throws Exception {
// Start the Application
new Thread(() -> Application.launch(MyApp.class, (String[]) null)).start();

try {
assertTrue("Timeout waiting for Application to launch",
launchLatch.await(TIMEOUT, TimeUnit.MILLISECONDS));
} catch (InterruptedException ex) {
AssertionFailedError err = new AssertionFailedError("Unexpected exception");
err.initCause(ex);
throw err;
}
assertTrue("Timeout waiting for Application to launch",
launchLatch.await(TIMEOUT, TimeUnit.MILLISECONDS));

assertEquals(0, launchLatch.getCount());
}
Expand Down
12 changes: 3 additions & 9 deletions src/test/java/test/manual/marlin/QPathTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,12 @@ public void start(Stage primaryStage) throws Exception {
}

@BeforeClass
public static void setupOnce() {
public static void setupOnce() throws Exception {
// Start the Application
new Thread(() -> Application.launch(MyApp.class, (String[]) null)).start();

try {
assertTrue("Timeout waiting for Application to launch",
launchLatch.await(TIMEOUT, TimeUnit.MILLISECONDS));
} catch (InterruptedException ex) {
AssertionFailedError err = new AssertionFailedError("Unexpected exception");
err.initCause(ex);
throw err;
}
assertTrue("Timeout waiting for Application to launch",
launchLatch.await(TIMEOUT, TimeUnit.MILLISECONDS));

assertEquals(0, launchLatch.getCount());
}
Expand Down
12 changes: 3 additions & 9 deletions src/test/java/test/manual/marlin/ScaleClipTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,12 @@ public void start(Stage primaryStage) throws Exception {
}

@BeforeClass
public static void setupOnce() {
public static void setupOnce() throws Exception {
// Start the Application
new Thread(() -> Application.launch(MyApp.class, (String[]) null)).start();

try {
assertTrue("Timeout waiting for Application to launch",
launchLatch.await(TIMEOUT, TimeUnit.MILLISECONDS));
} catch (InterruptedException ex) {
AssertionFailedError err = new AssertionFailedError("Unexpected exception");
err.initCause(ex);
throw err;
}
assertTrue("Timeout waiting for Application to launch",
launchLatch.await(TIMEOUT, TimeUnit.MILLISECONDS));

assertEquals(0, launchLatch.getCount());

Expand Down

0 comments on commit 32fedaf

Please sign in to comment.