jdk/src/share/classes/sun/java2d/pisces/PiscesTileGenerator.java
author ohair
Wed, 06 Apr 2011 22:06:11 -0700
changeset 9035 1255eb81cc2f
parent 8748 99ac71f8ef92
permissions -rw-r--r--
7033660: Update copyright year to 2011 on any files changed in 2011 Reviewed-by: dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
9035
1255eb81cc2f 7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents: 8748
diff changeset
     2
 * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.java2d.pisces;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    28
import java.util.Map;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    29
import java.util.concurrent.ConcurrentHashMap;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    30
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import sun.java2d.pipe.AATileGenerator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
8131
e2932d8114cb 7016856: dashing performance was reduced during latest changes to the OpenJDK rasterizer
dlila
parents: 6997
diff changeset
    33
final class PiscesTileGenerator implements AATileGenerator {
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    34
    public static final int TILE_SIZE = PiscesCache.TILE_SIZE;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    35
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    36
    // perhaps we should be using weak references here, but right now
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    37
    // that's not necessary. The way the renderer is, this map will
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    38
    // never contain more than one element - the one with key 64, since
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    39
    // we only do 8x8 supersampling.
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    40
    private static final Map<Integer, byte[]> alphaMapsCache = new
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    41
                   ConcurrentHashMap<Integer, byte[]>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    PiscesCache cache;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    int x, y;
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    45
    final int maxalpha;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    46
    private final int maxTileAlphaSum;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    47
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    48
    // The alpha map used by this object (taken out of our map cache) to convert
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    49
    // pixel coverage counts gotten from PiscesCache (which are in the range
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    50
    // [0, maxalpha]) into alpha values, which are in [0,256).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    byte alphaMap[];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    53
    public PiscesTileGenerator(Renderer r, int maxalpha) {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    54
        this.cache = r.getCache();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        this.x = cache.bboxX0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        this.y = cache.bboxY0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        this.alphaMap = getAlphaMap(maxalpha);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        this.maxalpha = maxalpha;
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    59
        this.maxTileAlphaSum = TILE_SIZE*TILE_SIZE*maxalpha;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    62
    private static byte[] buildAlphaMap(int maxalpha) {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    63
        byte[] alMap = new byte[maxalpha+1];
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    64
        int halfmaxalpha = maxalpha>>2;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    65
        for (int i = 0; i <= maxalpha; i++) {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    66
            alMap[i] = (byte) ((i * 255 + halfmaxalpha) / maxalpha);
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    67
        }
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    68
        return alMap;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    69
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    71
    public static byte[] getAlphaMap(int maxalpha) {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    72
        if (!alphaMapsCache.containsKey(maxalpha)) {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    73
            alphaMapsCache.put(maxalpha, buildAlphaMap(maxalpha));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        }
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    75
        return alphaMapsCache.get(maxalpha);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    public void getBbox(int bbox[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        bbox[0] = cache.bboxX0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        bbox[1] = cache.bboxY0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        bbox[2] = cache.bboxX1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        bbox[3] = cache.bboxY1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        //System.out.println("bbox["+bbox[0]+", "+bbox[1]+" => "+bbox[2]+", "+bbox[3]+"]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * Gets the width of the tiles that the generator batches output into.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * @return the width of the standard alpha tile
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    public int getTileWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        return TILE_SIZE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * Gets the height of the tiles that the generator batches output into.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @return the height of the standard alpha tile
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    public int getTileHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        return TILE_SIZE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * Gets the typical alpha value that will characterize the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * tile.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * The answer may be 0x00 to indicate that the current tile has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * no coverage in any of its pixels, or it may be 0xff to indicate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * that the current tile is completely covered by the path, or any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * other value to indicate non-trivial coverage cases.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * @return 0x00 for no coverage, 0xff for total coverage, or any other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     *         value for partial coverage of the tile
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    public int getTypicalAlpha() {
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   113
        int al = cache.alphaSumInTile(x, y);
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   114
        // Note: if we have a filled rectangle that doesn't end on a tile
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   115
        // border, we could still return 0xff, even though al!=maxTileAlphaSum
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   116
        // This is because if we return 0xff, our users will fill a rectangle
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   117
        // starting at x,y that has width = Math.min(TILE_SIZE, bboxX1-x),
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   118
        // and height min(TILE_SIZE,bboxY1-y), which is what should happen.
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   119
        // However, to support this, we would have to use 2 Math.min's
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   120
        // and 2 multiplications per tile, instead of just 2 multiplications
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   121
        // to compute maxTileAlphaSum. The savings offered would probably
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   122
        // not be worth it, considering how rare this case is.
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   123
        // Note: I have not tested this, so in the future if it is determined
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   124
        // that it is worth it, it should be implemented. Perhaps this method's
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   125
        // interface should be changed to take arguments the width and height
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   126
        // of the current tile. This would eliminate the 2 Math.min calls that
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   127
        // would be needed here, since our caller needs to compute these 2
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   128
        // values anyway.
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   129
        return (al == 0x00 ? 0x00 :
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   130
            (al == maxTileAlphaSum ? 0xff : 0x80));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * Skips the current tile and moves on to the next tile.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * Either this method, or the getAlpha() method should be called
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * once per tile, but not both.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    public void nextTile() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        if ((x += TILE_SIZE) >= cache.bboxX1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            x = cache.bboxX0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            y += TILE_SIZE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * Gets the alpha coverage values for the current tile.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * Either this method, or the nextTile() method should be called
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * once per tile, but not both.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    public void getAlpha(byte tile[], int offset, int rowstride) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        // Decode run-length encoded alpha mask data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        // The data for row j begins at cache.rowOffsetsRLE[j]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        // and is encoded as a set of 2-byte pairs (val, runLen)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        // terminated by a (0, 0) pair.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        int x0 = this.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        int x1 = x0 + TILE_SIZE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        int y0 = this.y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        int y1 = y0 + TILE_SIZE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        if (x1 > cache.bboxX1) x1 = cache.bboxX1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        if (y1 > cache.bboxY1) y1 = cache.bboxY1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        y0 -= cache.bboxY0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        y1 -= cache.bboxY0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        int idx = offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        for (int cy = y0; cy < y1; cy++) {
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   167
            int[] row = cache.rowAARLE[cy];
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   168
            assert row != null;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   169
            int cx = cache.minTouched(cy);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            if (cx > x1) cx = x1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   172
            for (int i = x0; i < cx; i++) {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   173
                tile[idx++] = 0x00;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            }
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   175
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   176
            int pos = 2;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   177
            while (cx < x1 && pos < row[1]) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                byte val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                int runLen = 0;
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   180
                assert row[1] > 2;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                try {
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   182
                    val = alphaMap[row[pos]];
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   183
                    runLen = row[pos + 1];
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   184
                    assert runLen > 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                } catch (RuntimeException e0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                    System.out.println("maxalpha = "+maxalpha);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                    System.out.println("tile["+x0+", "+y0+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                                       " => "+x1+", "+y1+"]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                    System.out.println("cx = "+cx+", cy = "+cy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                    System.out.println("idx = "+idx+", pos = "+pos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                    System.out.println("len = "+runLen);
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   192
                    System.out.print(cache.toString());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                    e0.printStackTrace();
8748
99ac71f8ef92 7019861: Last scanline is skipped in pisces.Renderer.
dlila
parents: 8131
diff changeset
   194
                    throw e0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                }
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   196
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                int rx0 = cx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                cx += runLen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                int rx1 = cx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                if (rx0 < x0) rx0 = x0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                if (rx1 > x1) rx1 = x1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                runLen = rx1 - rx0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                //System.out.println("M["+runLen+"]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                while (--runLen >= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                        tile[idx++] = val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                    } catch (RuntimeException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                        System.out.println("maxalpha = "+maxalpha);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                        System.out.println("tile["+x0+", "+y0+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                                           " => "+x1+", "+y1+"]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                        System.out.println("cx = "+cx+", cy = "+cy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                        System.out.println("idx = "+idx+", pos = "+pos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                        System.out.println("rx0 = "+rx0+", rx1 = "+rx1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                        System.out.println("len = "+runLen);
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   215
                        System.out.print(cache.toString());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                        e.printStackTrace();
8748
99ac71f8ef92 7019861: Last scanline is skipped in pisces.Renderer.
dlila
parents: 8131
diff changeset
   217
                        throw e;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                pos += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            if (cx < x0) { cx = x0; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            while (cx < x1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                tile[idx++] = 0x00;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                cx++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            for (int i = idx - (x1-x0); i < idx; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                System.out.print(hex(tile[i], 2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            System.out.println();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            idx += (rowstride - (x1-x0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        nextTile();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    static String hex(int v, int d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        String s = Integer.toHexString(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        while (s.length() < d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            s = "0"+s;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        return s.substring(0, d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * Disposes this tile generator.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * No further calls will be made on this instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    public void dispose() {}
8748
99ac71f8ef92 7019861: Last scanline is skipped in pisces.Renderer.
dlila
parents: 8131
diff changeset
   251
}
99ac71f8ef92 7019861: Last scanline is skipped in pisces.Renderer.
dlila
parents: 8131
diff changeset
   252