From 32fedaffb3532984c644717f72d2b7d236b43335 Mon Sep 17 00:00:00 2001 From: bourgesl Date: Sat, 13 Aug 2022 15:07:15 +0200 Subject: [PATCH] fixed dpqs javadoc + tests (setupOnce) --- pom.xml | 2 +- .../marlin/DualPivotQuicksort20191112Ext.java | 39 +++++++++++++------ .../test/manual/marlin/ClipShapeTest.java | 12 ++---- .../test/manual/marlin/DashedRectTest.java | 12 ++---- .../manual/marlin/HugePolygonClipTest.java | 13 ++----- .../java/test/manual/marlin/QPathTest.java | 12 ++---- .../test/manual/marlin/ScaleClipTest.java | 12 ++---- 7 files changed, 43 insertions(+), 59 deletions(-) diff --git a/pom.xml b/pom.xml index 0c60f85..30cd8ea 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ org.marlin marlinfx jar - 0.9.4.5-Unsafe-OpenJFX11 + 0.9.4.6-Unsafe-OpenJFX11 Marlin software rasterizer https://github.com/bourgesl/marlin-renderer diff --git a/src/main/java/com/sun/marlin/DualPivotQuicksort20191112Ext.java b/src/main/java/com/sun/marlin/DualPivotQuicksort20191112Ext.java index f060dfe..0360075 100644 --- a/src/main/java/com/sun/marlin/DualPivotQuicksort20191112Ext.java +++ b/src/main/java/com/sun/marlin/DualPivotQuicksort20191112Ext.java @@ -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: @@ -108,8 +108,11 @@ 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 */ @@ -117,7 +120,7 @@ static void sort(DPQSSorterContext sorter, int[] a, int[] auxA, int[] b, int[] a /* * 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; } @@ -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 @@ -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 @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 @@ -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 @@ -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 */ diff --git a/src/test/java/test/manual/marlin/ClipShapeTest.java b/src/test/java/test/manual/marlin/ClipShapeTest.java index be80854..f2b890d 100644 --- a/src/test/java/test/manual/marlin/ClipShapeTest.java +++ b/src/test/java/test/manual/marlin/ClipShapeTest.java @@ -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()); } diff --git a/src/test/java/test/manual/marlin/DashedRectTest.java b/src/test/java/test/manual/marlin/DashedRectTest.java index b976b09..9dd5310 100644 --- a/src/test/java/test/manual/marlin/DashedRectTest.java +++ b/src/test/java/test/manual/marlin/DashedRectTest.java @@ -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()); } diff --git a/src/test/java/test/manual/marlin/HugePolygonClipTest.java b/src/test/java/test/manual/marlin/HugePolygonClipTest.java index 97cea2b..df6ed38 100644 --- a/src/test/java/test/manual/marlin/HugePolygonClipTest.java +++ b/src/test/java/test/manual/marlin/HugePolygonClipTest.java @@ -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()); } diff --git a/src/test/java/test/manual/marlin/QPathTest.java b/src/test/java/test/manual/marlin/QPathTest.java index b5b5fd8..b758397 100644 --- a/src/test/java/test/manual/marlin/QPathTest.java +++ b/src/test/java/test/manual/marlin/QPathTest.java @@ -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()); } diff --git a/src/test/java/test/manual/marlin/ScaleClipTest.java b/src/test/java/test/manual/marlin/ScaleClipTest.java index a79c174..76a1087 100644 --- a/src/test/java/test/manual/marlin/ScaleClipTest.java +++ b/src/test/java/test/manual/marlin/ScaleClipTest.java @@ -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());