Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/java2d/marlin/MarlinProperties.java
38918 views
/*1* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.java2d.marlin;2627import java.security.AccessController;28import static sun.java2d.marlin.MarlinUtils.logInfo;29import sun.security.action.GetPropertyAction;3031public final class MarlinProperties {3233private MarlinProperties() {34// no-op35}3637// marlin system properties3839public static boolean isUseThreadLocal() {40return getBoolean("sun.java2d.renderer.useThreadLocal", "true");41}4243/**44* Return the initial pixel size used to define initial arrays45* (tile AA chunk, alpha line, buckets)46*47* @return 64 < initial pixel size < 32768 (2048 by default)48*/49public static int getInitialImageSize() {50return getInteger("sun.java2d.renderer.pixelsize", 2048, 64, 32 * 1024);51}5253/**54* Return the log(2) corresponding to subpixel on x-axis (55*56* @return 1 (2 subpixels) < initial pixel size < 4 (256 subpixels)57* (3 by default ie 8 subpixels)58*/59public static int getSubPixel_Log2_X() {60return getInteger("sun.java2d.renderer.subPixel_log2_X", 3, 1, 8);61}6263/**64* Return the log(2) corresponding to subpixel on y-axis (65*66* @return 1 (2 subpixels) < initial pixel size < 8 (256 subpixels)67* (3 by default ie 8 subpixels)68*/69public static int getSubPixel_Log2_Y() {70return getInteger("sun.java2d.renderer.subPixel_log2_Y", 3, 1, 8);71}7273/**74* Return the log(2) corresponding to the square tile size in pixels75*76* @return 3 (8x8 pixels) < tile size < 8 (256x256 pixels)77* (5 by default ie 32x32 pixels)78*/79public static int getTileSize_Log2() {80return getInteger("sun.java2d.renderer.tileSize_log2", 5, 3, 8);81}8283/**84* Return the log(2) corresponding to the block size in pixels85*86* @return 3 (8 pixels) < block size < 8 (256 pixels)87* (5 by default ie 32 pixels)88*/89public static int getBlockSize_Log2() {90return getInteger("sun.java2d.renderer.blockSize_log2", 5, 3, 8);91}9293// RLE / blockFlags settings9495public static boolean isForceRLE() {96return getBoolean("sun.java2d.renderer.forceRLE", "false");97}9899public static boolean isForceNoRLE() {100return getBoolean("sun.java2d.renderer.forceNoRLE", "false");101}102103public static boolean isUseTileFlags() {104return getBoolean("sun.java2d.renderer.useTileFlags", "true");105}106107public static boolean isUseTileFlagsWithHeuristics() {108return isUseTileFlags()109&& getBoolean("sun.java2d.renderer.useTileFlags.useHeuristics", "true");110}111112public static int getRLEMinWidth() {113return getInteger("sun.java2d.renderer.rleMinWidth", 64, 0, Integer.MAX_VALUE);114}115116// optimisation parameters117118public static boolean isUseSimplifier() {119return getBoolean("sun.java2d.renderer.useSimplifier", "false");120}121122// debugging parameters123124public static boolean isDoStats() {125return getBoolean("sun.java2d.renderer.doStats", "false");126}127128public static boolean isDoMonitors() {129return getBoolean("sun.java2d.renderer.doMonitors", "false");130}131132public static boolean isDoChecks() {133return getBoolean("sun.java2d.renderer.doChecks", "false");134}135136// logging parameters137138public static boolean isLoggingEnabled() {139return getBoolean("sun.java2d.renderer.log", "false");140}141142public static boolean isUseLogger() {143return getBoolean("sun.java2d.renderer.useLogger", "false");144}145146public static boolean isLogCreateContext() {147return getBoolean("sun.java2d.renderer.logCreateContext", "false");148}149150public static boolean isLogUnsafeMalloc() {151return getBoolean("sun.java2d.renderer.logUnsafeMalloc", "false");152}153154// system property utilities155static boolean getBoolean(final String key, final String def) {156return Boolean.valueOf(AccessController.doPrivileged(157new GetPropertyAction(key, def)));158}159160static int getInteger(final String key, final int def,161final int min, final int max)162{163final String property = AccessController.doPrivileged(164new GetPropertyAction(key));165166int value = def;167if (property != null) {168try {169value = Integer.decode(property);170} catch (NumberFormatException e) {171logInfo("Invalid integer value for " + key + " = " + property);172}173}174175// check for invalid values176if ((value < min) || (value > max)) {177logInfo("Invalid value for " + key + " = " + value178+ "; expected value in range[" + min + ", " + max + "] !");179value = def;180}181return value;182}183184}185186187