From 791bcd74d1ee8ef932cc9cfa568d01cebd39a3c9 Mon Sep 17 00:00:00 2001 From: bourgesl Date: Wed, 9 May 2018 23:32:20 +0200 Subject: [PATCH] merge --- pom.xml | 2 +- src/main/java/com/sun/marlin/DDasher.java | 6 +-- src/main/java/com/sun/marlin/DHelpers.java | 20 ++++----- .../sun/marlin/DMarlinRenderingEngine.java | 6 ++- src/main/java/com/sun/marlin/Dasher.java | 6 +-- src/main/java/com/sun/marlin/Helpers.java | 20 ++++----- .../java/com/sun/marlin/MarlinProperties.java | 43 ++++++++++++++++--- .../com/sun/marlin/MarlinRenderingEngine.java | 6 ++- src/main/java/com/sun/marlin/Version.java | 2 +- 9 files changed, 75 insertions(+), 36 deletions(-) diff --git a/pom.xml b/pom.xml index da6742a..d5d0be5 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ org.marlin marlinfx jar - 0.9.1-Unsafe-OpenJDK9 + 0.9.2-Unsafe-OpenJDK9 Marlin software rasterizer https://github.com/bourgesl/marlin-renderer diff --git a/src/main/java/com/sun/marlin/DDasher.java b/src/main/java/com/sun/marlin/DDasher.java index 2a21ae0..6f04fa2 100644 --- a/src/main/java/com/sun/marlin/DDasher.java +++ b/src/main/java/com/sun/marlin/DDasher.java @@ -269,6 +269,9 @@ public void moveTo(final double x0, final double y0) { private void emitSeg(double[] buf, int off, int type) { switch (type) { + case 4: + out.lineTo(buf[off], buf[off + 1]); + return; case 8: out.curveTo(buf[off ], buf[off + 1], buf[off + 2], buf[off + 3], @@ -278,9 +281,6 @@ private void emitSeg(double[] buf, int off, int type) { out.quadTo(buf[off ], buf[off + 1], buf[off + 2], buf[off + 3]); return; - case 4: - out.lineTo(buf[off], buf[off + 1]); - return; default: } } diff --git a/src/main/java/com/sun/marlin/DHelpers.java b/src/main/java/com/sun/marlin/DHelpers.java index cdf58bb..03f1e20 100644 --- a/src/main/java/com/sun/marlin/DHelpers.java +++ b/src/main/java/com/sun/marlin/DHelpers.java @@ -764,17 +764,17 @@ void pullAll(final DPathConsumer2D io) { io.lineTo(_curves[e], _curves[e+1]); e += 2; continue; - case TYPE_QUADTO: - io.quadTo(_curves[e], _curves[e+1], - _curves[e+2], _curves[e+3]); - e += 4; - continue; case TYPE_CUBICTO: io.curveTo(_curves[e], _curves[e+1], _curves[e+2], _curves[e+3], _curves[e+4], _curves[e+5]); e += 6; continue; + case TYPE_QUADTO: + io.quadTo(_curves[e], _curves[e+1], + _curves[e+2], _curves[e+3]); + e += 4; + continue; default: } } @@ -806,17 +806,17 @@ void popAll(final DPathConsumer2D io) { e -= 2; io.lineTo(_curves[e], _curves[e+1]); continue; - case TYPE_QUADTO: - e -= 4; - io.quadTo(_curves[e], _curves[e+1], - _curves[e+2], _curves[e+3]); - continue; case TYPE_CUBICTO: e -= 6; io.curveTo(_curves[e], _curves[e+1], _curves[e+2], _curves[e+3], _curves[e+4], _curves[e+5]); continue; + case TYPE_QUADTO: + e -= 4; + io.quadTo(_curves[e], _curves[e+1], + _curves[e+2], _curves[e+3]); + continue; default: } } diff --git a/src/main/java/com/sun/marlin/DMarlinRenderingEngine.java b/src/main/java/com/sun/marlin/DMarlinRenderingEngine.java index 01c18bd..c8ef618 100644 --- a/src/main/java/com/sun/marlin/DMarlinRenderingEngine.java +++ b/src/main/java/com/sun/marlin/DMarlinRenderingEngine.java @@ -156,6 +156,10 @@ public static void logSettings(final String reClass) { logInfo("prism.marlin.pixelHeight = " + MarlinConst.INITIAL_PIXEL_HEIGHT); + logInfo("prism.marlin.profile = " + + (MarlinProperties.isProfileQuality() ? + "quality" : "speed")); + logInfo("prism.marlin.subPixel_log2_X = " + MarlinConst.SUBPIXEL_LG_POSITIONS_X); logInfo("prism.marlin.subPixel_log2_Y = " @@ -185,7 +189,7 @@ public static void logSettings(final String reClass) { logInfo("prism.marlin.pathSimplifier.pixTol = " + MarlinProperties.getPathSimplifierPixelTolerance()); - logInfo("sun.java2d.renderer.clip = " + logInfo("prism.marlin.clip = " + MarlinProperties.isDoClip()); logInfo("prism.marlin.clip.runtime.enable = " + MarlinProperties.isDoClipRuntimeFlag()); diff --git a/src/main/java/com/sun/marlin/Dasher.java b/src/main/java/com/sun/marlin/Dasher.java index ef4f1ed..31e0456 100644 --- a/src/main/java/com/sun/marlin/Dasher.java +++ b/src/main/java/com/sun/marlin/Dasher.java @@ -270,6 +270,9 @@ public void moveTo(final float x0, final float y0) { private void emitSeg(float[] buf, int off, int type) { switch (type) { + case 4: + out.lineTo(buf[off], buf[off + 1]); + return; case 8: out.curveTo(buf[off ], buf[off + 1], buf[off + 2], buf[off + 3], @@ -279,9 +282,6 @@ private void emitSeg(float[] buf, int off, int type) { out.quadTo(buf[off ], buf[off + 1], buf[off + 2], buf[off + 3]); return; - case 4: - out.lineTo(buf[off], buf[off + 1]); - return; default: } } diff --git a/src/main/java/com/sun/marlin/Helpers.java b/src/main/java/com/sun/marlin/Helpers.java index 7977b5d..a9e38c7 100644 --- a/src/main/java/com/sun/marlin/Helpers.java +++ b/src/main/java/com/sun/marlin/Helpers.java @@ -772,17 +772,17 @@ void pullAll(final PathConsumer2D io) { io.lineTo(_curves[e], _curves[e+1]); e += 2; continue; - case TYPE_QUADTO: - io.quadTo(_curves[e], _curves[e+1], - _curves[e+2], _curves[e+3]); - e += 4; - continue; case TYPE_CUBICTO: io.curveTo(_curves[e], _curves[e+1], _curves[e+2], _curves[e+3], _curves[e+4], _curves[e+5]); e += 6; continue; + case TYPE_QUADTO: + io.quadTo(_curves[e], _curves[e+1], + _curves[e+2], _curves[e+3]); + e += 4; + continue; default: } } @@ -814,17 +814,17 @@ void popAll(final PathConsumer2D io) { e -= 2; io.lineTo(_curves[e], _curves[e+1]); continue; - case TYPE_QUADTO: - e -= 4; - io.quadTo(_curves[e], _curves[e+1], - _curves[e+2], _curves[e+3]); - continue; case TYPE_CUBICTO: e -= 6; io.curveTo(_curves[e], _curves[e+1], _curves[e+2], _curves[e+3], _curves[e+4], _curves[e+5]); continue; + case TYPE_QUADTO: + e -= 4; + io.quadTo(_curves[e], _curves[e+1], + _curves[e+2], _curves[e+3]); + continue; default: } } diff --git a/src/main/java/com/sun/marlin/MarlinProperties.java b/src/main/java/com/sun/marlin/MarlinProperties.java index a3aa44b..62d9ddf 100644 --- a/src/main/java/com/sun/marlin/MarlinProperties.java +++ b/src/main/java/com/sun/marlin/MarlinProperties.java @@ -77,6 +77,25 @@ public static int getInitialPixelHeight() { 64); } + /** + * Return true if the profile is 'quality' (default) over 'speed' + * + * @return true if the profile is 'quality' (default), false otherwise + */ + public static boolean isProfileQuality() { + final String key = "prism.marlin.profile"; + final String profile = getString(key, "quality"); + if ("quality".equals(profile)) { + return true; + } + if ("speed".equals(profile)) { + return false; + } + logInfo("Invalid value for " + key + " = " + profile + + "; expect value in [quality, speed] !"); + return true; + } + /** * Return the log(2) corresponding to subpixel on x-axis * @@ -91,10 +110,12 @@ public static int getSubPixel_Log2_X() { * Return the log(2) corresponding to subpixel on y-axis * * @return 0 (1 subpixels) < initial pixel size < 8 (256 subpixels) - * (3 by default ie 8 subpixels) + * (3 by default ie 8 subpixels for the quality profile) + * (2 by default ie 4 subpixels for the speed profile) */ public static int getSubPixel_Log2_Y() { - return getInteger("prism.marlin.subPixel_log2_Y", 3, 0, 8); + final int def = isProfileQuality() ? 3 : 2; + return getInteger("prism.marlin.subPixel_log2_Y", def, 0, 8); } /** @@ -201,24 +222,34 @@ public static boolean isLogUnsafeMalloc() { } // quality settings - public static float getCurveLengthError() { return getFloat("prism.marlin.curve_len_err", 0.01f, 1e-6f, 1.0f); } public static float getCubicDecD2() { - return getFloat("prism.marlin.cubic_dec_d2", 1.0f, 1e-5f, 4.0f); + final float def = isProfileQuality() ? 1.0f : 2.5f; + return getFloat("prism.marlin.cubic_dec_d2", def, 1e-5f, 4.0f); } public static float getCubicIncD1() { - return getFloat("prism.marlin.cubic_inc_d1", 0.2f, 1e-6f, 1.0f); + final float def = isProfileQuality() ? 0.2f : 0.5f; + return getFloat("prism.marlin.cubic_inc_d1", def, 1e-6f, 1.0f); } public static float getQuadDecD2() { - return getFloat("prism.marlin.quad_dec_d2", 0.5f, 1e-5f, 4.0f); + final float def = isProfileQuality() ? 0.5f : 1.0f; + return getFloat("prism.marlin.quad_dec_d2", def, 1e-5f, 4.0f); } // system property utilities + static String getString(final String key, final String def) { + return AccessController.doPrivileged( + (PrivilegedAction) () -> { + String value = System.getProperty(key); + return (value == null) ? def : value; + }); + } + static boolean getBoolean(final String key, final String def) { return Boolean.valueOf(AccessController.doPrivileged( (PrivilegedAction) () -> { diff --git a/src/main/java/com/sun/marlin/MarlinRenderingEngine.java b/src/main/java/com/sun/marlin/MarlinRenderingEngine.java index 09087d3..80c35fd 100644 --- a/src/main/java/com/sun/marlin/MarlinRenderingEngine.java +++ b/src/main/java/com/sun/marlin/MarlinRenderingEngine.java @@ -156,6 +156,10 @@ public static void logSettings(final String reClass) { logInfo("prism.marlin.pixelHeight = " + MarlinConst.INITIAL_PIXEL_HEIGHT); + logInfo("prism.marlin.profile = " + + (MarlinProperties.isProfileQuality() ? + "quality" : "speed")); + logInfo("prism.marlin.subPixel_log2_X = " + MarlinConst.SUBPIXEL_LG_POSITIONS_X); logInfo("prism.marlin.subPixel_log2_Y = " @@ -185,7 +189,7 @@ public static void logSettings(final String reClass) { logInfo("prism.marlin.pathSimplifier.pixTol = " + MarlinProperties.getPathSimplifierPixelTolerance()); - logInfo("sun.java2d.renderer.clip = " + logInfo("prism.marlin.clip = " + MarlinProperties.isDoClip()); logInfo("prism.marlin.clip.runtime.enable = " + MarlinProperties.isDoClipRuntimeFlag()); diff --git a/src/main/java/com/sun/marlin/Version.java b/src/main/java/com/sun/marlin/Version.java index 49d8fc2..d739aae 100644 --- a/src/main/java/com/sun/marlin/Version.java +++ b/src/main/java/com/sun/marlin/Version.java @@ -27,7 +27,7 @@ public final class Version { - private static final String VERSION = "marlinFX-0.9.1-Unsafe-OpenJDK"; + private static final String VERSION = "marlinFX-0.9.2-Unsafe-OpenJDK"; public static String getVersion() { return VERSION;