jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinConst.java
author lbourges
Mon, 14 Dec 2015 14:08:37 -0800
changeset 34689 4b5bf9f960c8
parent 34417 57a3863abbb4
child 34816 5ff696b1bbac
permissions -rw-r--r--
8145055: Marlin renderer causes unaligned write accesses Reviewed-by: flar, prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34417
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
     1
/*
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
     4
 *
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    10
 *
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    15
 * accompanied this code).
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    16
 *
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    20
 *
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    23
 * questions.
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    24
 */
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    25
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    26
package sun.java2d.marlin;
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    27
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    28
/**
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    29
 * Marlin constant holder using System properties
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    30
 */
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    31
interface MarlinConst {
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    32
    // enable Logs (logger or stdout)
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    33
    static final boolean enableLogs = false;
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    34
    // enable Logger
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    35
    static final boolean useLogger = enableLogs && MarlinProperties.isUseLogger();
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    36
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    37
    // log new RendererContext
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    38
    static final boolean logCreateContext = enableLogs
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    39
        && MarlinProperties.isLogCreateContext();
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    40
    // log misc.Unsafe alloc/realloc/free
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    41
    static final boolean logUnsafeMalloc = enableLogs
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    42
        && MarlinProperties.isLogUnsafeMalloc();
34689
4b5bf9f960c8 8145055: Marlin renderer causes unaligned write accesses
lbourges
parents: 34417
diff changeset
    43
    // do check unsafe alignment:
4b5bf9f960c8 8145055: Marlin renderer causes unaligned write accesses
lbourges
parents: 34417
diff changeset
    44
    static final boolean doCheckUnsafe = false;
34417
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    45
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    46
    // do statistics
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    47
    static final boolean doStats = enableLogs && MarlinProperties.isDoStats();
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    48
    // do monitors
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    49
    // disabled to reduce byte-code size a bit...
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    50
    static final boolean doMonitors = enableLogs && false; // MarlinProperties.isDoMonitors();
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    51
    // do checks
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    52
    static final boolean doChecks = false; // MarlinProperties.isDoChecks();
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    53
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    54
    // do AA range checks: disable when algorithm / code is stable
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    55
    static final boolean DO_AA_RANGE_CHECK = false;
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    56
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    57
    // enable logs
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    58
    static final boolean doLogWidenArray = enableLogs && false;
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    59
    // enable oversize logs
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    60
    static final boolean doLogOverSize = enableLogs && false;
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    61
    // enable traces
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    62
    static final boolean doTrace = enableLogs && false;
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    63
    // do flush monitors
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    64
    static final boolean doFlushMonitors = true;
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    65
    // use one polling thread to dump statistics/monitors
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    66
    static final boolean useDumpThread = false;
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    67
    // thread dump interval (ms)
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    68
    static final long statDump = 5000L;
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    69
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    70
    // do clean dirty array
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    71
    static final boolean doCleanDirty = false;
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    72
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    73
    // flag to use line simplifier
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    74
    static final boolean useSimplifier = MarlinProperties.isUseSimplifier();
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    75
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    76
    // flag to enable logs related bounds checks
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    77
    static final boolean doLogBounds = enableLogs && false;
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    78
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    79
    // Initial Array sizing (initial context capacity) ~ 512K
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    80
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    81
    // 2048 pixel (width x height) for initial capacity
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    82
    static final int INITIAL_PIXEL_DIM
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    83
        = MarlinProperties.getInitialImageSize();
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    84
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    85
    // typical array sizes: only odd numbers allowed below
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    86
    static final int INITIAL_ARRAY        = 256;
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    87
    static final int INITIAL_SMALL_ARRAY  = 1024;
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    88
    static final int INITIAL_MEDIUM_ARRAY = 4096;
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    89
    static final int INITIAL_LARGE_ARRAY  = 8192;
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    90
    static final int INITIAL_ARRAY_16K    = 16384;
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    91
    static final int INITIAL_ARRAY_32K    = 32768;
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    92
    // alpha row dimension
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    93
    static final int INITIAL_AA_ARRAY     = INITIAL_PIXEL_DIM;
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    94
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    95
    // initial edges (24 bytes) = 24K [ints] = 96K
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    96
    static final int INITIAL_EDGES_CAPACITY = 4096 * 24; // 6 ints per edges
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    97
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    98
    // zero value as byte
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
    99
    static final byte BYTE_0 = (byte) 0;
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
   100
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
   101
    // subpixels expressed as log2
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
   102
    public static final int SUBPIXEL_LG_POSITIONS_X
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
   103
        = MarlinProperties.getSubPixel_Log2_X();
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
   104
    public static final int SUBPIXEL_LG_POSITIONS_Y
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
   105
        = MarlinProperties.getSubPixel_Log2_Y();
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
   106
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
   107
    // number of subpixels
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
   108
    public static final int SUBPIXEL_POSITIONS_X = 1 << (SUBPIXEL_LG_POSITIONS_X);
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
   109
    public static final int SUBPIXEL_POSITIONS_Y = 1 << (SUBPIXEL_LG_POSITIONS_Y);
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
   110
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
   111
    public static final float NORM_SUBPIXELS
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
   112
        = (float)Math.sqrt(( SUBPIXEL_POSITIONS_X * SUBPIXEL_POSITIONS_X
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
   113
                           + SUBPIXEL_POSITIONS_Y * SUBPIXEL_POSITIONS_Y)/2.0);
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
   114
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
   115
    public static final int MAX_AA_ALPHA
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
   116
        = SUBPIXEL_POSITIONS_X * SUBPIXEL_POSITIONS_Y;
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
   117
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
   118
    public static final int TILE_SIZE_LG = MarlinProperties.getTileSize_Log2();
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
   119
    public static final int TILE_SIZE = 1 << TILE_SIZE_LG; // 32 by default
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
   120
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
   121
    public static final int BLOCK_SIZE_LG = MarlinProperties.getBlockSize_Log2();
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
   122
    public static final int BLOCK_SIZE    = 1 << BLOCK_SIZE_LG;
57a3863abbb4 8076529: Marlin antialiasing renderer integration
flar
parents:
diff changeset
   123
}