1 /* 2 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.marlin; 27 28 /** 29 * Marlin constant holder using System properties 30 */ 31 public interface MarlinConst { 32 // enable Logs (logger or stdout) 33 static final boolean ENABLE_LOGS = MarlinProperties.isLoggingEnabled(); 34 // use Logger instead of stdout 35 static final boolean USE_LOGGER = ENABLE_LOGS && MarlinProperties.isUseLogger(); 36 37 // log new RendererContext 38 static final boolean LOG_CREATE_CONTEXT = ENABLE_LOGS 39 && MarlinProperties.isLogCreateContext(); 40 // log misc.Unsafe alloc/realloc/free 41 static final boolean LOG_UNSAFE_MALLOC = ENABLE_LOGS 42 && MarlinProperties.isLogUnsafeMalloc(); 43 // do check unsafe alignment: 44 static final boolean DO_CHECK_UNSAFE = false; 45 46 // do statistics 47 static final boolean DO_STATS = ENABLE_LOGS && MarlinProperties.isDoStats(); 48 // do monitors 49 // disabled to reduce byte-code size a bit... 50 static final boolean DO_MONITORS = false; 51 // static final boolean DO_MONITORS = ENABLE_LOGS && MarlinProperties.isDoMonitors(); 52 // do checks 53 static final boolean DO_CHECKS = ENABLE_LOGS && MarlinProperties.isDoChecks(); 54 55 // do AA range checks: disable when algorithm / code is stable 56 static final boolean DO_AA_RANGE_CHECK = false; 57 58 // enable logs 59 static final boolean DO_LOG_WIDEN_ARRAY = ENABLE_LOGS && false; 60 // enable oversize logs 61 static final boolean DO_LOG_OVERSIZE = ENABLE_LOGS && false; 62 // enable traces 63 static final boolean DO_TRACE = ENABLE_LOGS && false; 64 65 // do flush stats 66 static final boolean DO_FLUSH_STATS = true; 67 // do flush monitors 68 static final boolean DO_FLUSH_MONITORS = true; 69 // use one polling thread to dump statistics/monitors 70 static final boolean USE_DUMP_THREAD = false; 71 // thread dump interval (ms) 72 static final long DUMP_INTERVAL = 5000L; 73 74 // do clean dirty array 75 static final boolean DO_CLEAN_DIRTY = false; 76 77 // flag to use collinear simplifier 78 static final boolean USE_SIMPLIFIER = MarlinProperties.isUseSimplifier(); 79 80 // flag to use path simplifier 81 static final boolean USE_PATH_SIMPLIFIER = MarlinProperties.isUsePathSimplifier(); 82 83 static final boolean DO_CLIP_SUBDIVIDER = MarlinProperties.isDoClipSubdivider(); 84 85 // flag to enable logs related to bounds checks 86 static final boolean DO_LOG_BOUNDS = ENABLE_LOGS && false; 87 88 // flag to enable logs related to clip rect 89 static final boolean DO_LOG_CLIP = ENABLE_LOGS && false; 90 91 // Initial Array sizing (initial context capacity) ~ 450K 92 93 // 4096 pixels (width) for initial capacity 94 static final int INITIAL_PIXEL_WIDTH 95 = MarlinProperties.getInitialPixelWidth(); 96 // 2176 pixels (height) for initial capacity 97 static final int INITIAL_PIXEL_HEIGHT 98 = MarlinProperties.getInitialPixelHeight(); 99 100 // typical array sizes: only odd numbers allowed below 101 static final int INITIAL_ARRAY = 256; 102 103 // alpha row dimension 104 static final int INITIAL_AA_ARRAY = INITIAL_PIXEL_WIDTH; 105 106 // 4096 edges for initial capacity 107 static final int INITIAL_EDGES_COUNT = MarlinProperties.getInitialEdges(); 108 109 // initial edges = edges count (4096) 110 // 6 ints per edges = 24 bytes 111 // edges capacity = 24 x initial edges = 24 * edges count (4096) = 96K 112 static final int INITIAL_EDGES_CAPACITY = INITIAL_EDGES_COUNT * 24; 113 114 // crossing capacity = edges count / 4 ~ 1024 115 static final int INITIAL_CROSSING_COUNT = INITIAL_EDGES_COUNT >> 2; 116 117 // zero value as byte 118 static final byte BYTE_0 = (byte) 0; 119 120 // subpixels expressed as log2 121 public static final int SUBPIXEL_LG_POSITIONS_X 122 = MarlinProperties.getSubPixel_Log2_X(); 123 public static final int SUBPIXEL_LG_POSITIONS_Y 124 = MarlinProperties.getSubPixel_Log2_Y(); 125 126 public static final int MIN_SUBPIXEL_LG_POSITIONS 127 = Math.min(SUBPIXEL_LG_POSITIONS_X, SUBPIXEL_LG_POSITIONS_Y); 128 129 // number of subpixels 130 public static final int SUBPIXEL_POSITIONS_X = 1 << (SUBPIXEL_LG_POSITIONS_X); 131 public static final int SUBPIXEL_POSITIONS_Y = 1 << (SUBPIXEL_LG_POSITIONS_Y); 132 133 public static final float MIN_SUBPIXELS = 1 << MIN_SUBPIXEL_LG_POSITIONS; 134 135 // 2176 pixels (height) x 8 subpixels = 68K 136 static final int INITIAL_BUCKET_ARRAY 137 = INITIAL_PIXEL_HEIGHT * SUBPIXEL_POSITIONS_Y; 138 139 public static final int MAX_AA_ALPHA 140 = (SUBPIXEL_POSITIONS_X * SUBPIXEL_POSITIONS_Y); 141 142 public static final int BLOCK_SIZE_LG = MarlinProperties.getBlockSize_Log2(); 143 public static final int BLOCK_SIZE = 1 << BLOCK_SIZE_LG; 144 145 static final boolean ENABLE_BLOCK_FLAGS = MarlinProperties.isUseTileFlags(); 146 static final boolean ENABLE_BLOCK_FLAGS_HEURISTICS = MarlinProperties.isUseTileFlagsWithHeuristics(); 147 148 static final boolean FORCE_RLE = MarlinProperties.isForceRLE(); 149 static final boolean FORCE_NO_RLE = MarlinProperties.isForceNoRLE(); 150 // minimum width to try using RLE encoding: 151 static final int RLE_MIN_WIDTH 152 = Math.max(BLOCK_SIZE, MarlinProperties.getRLEMinWidth()); 153 154 // Constants 155 public static final int WIND_EVEN_ODD = 0; 156 public static final int WIND_NON_ZERO = 1; 157 158 /** 159 * Constant value for join style. 160 */ 161 public static final int JOIN_MITER = 0; 162 163 /** 164 * Constant value for join style. 165 */ 166 public static final int JOIN_ROUND = 1; 167 168 /** 169 * Constant value for join style. 170 */ 171 public static final int JOIN_BEVEL = 2; 172 173 /** 174 * Constant value for end cap style. 175 */ 176 public static final int CAP_BUTT = 0; 177 178 /** 179 * Constant value for end cap style. 180 */ 181 public static final int CAP_ROUND = 1; 182 183 /** 184 * Constant value for end cap style. 185 */ 186 public static final int CAP_SQUARE = 2; 187 188 // Out codes 189 static final int OUTCODE_TOP = 1; 190 static final int OUTCODE_BOTTOM = 2; 191 static final int OUTCODE_LEFT = 4; 192 static final int OUTCODE_RIGHT = 8; 193 static final int OUTCODE_MASK_T_B = OUTCODE_TOP | OUTCODE_BOTTOM; 194 static final int OUTCODE_MASK_L_R = OUTCODE_LEFT | OUTCODE_RIGHT; 195 static final int OUTCODE_MASK_T_B_L_R = OUTCODE_MASK_T_B | OUTCODE_MASK_L_R; 196 }