jdk/src/share/classes/sun/java2d/pisces/PiscesCache.java
author ohair
Wed, 06 Apr 2011 22:06:11 -0700
changeset 9035 1255eb81cc2f
parent 8131 e2932d8114cb
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: 8131
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: 3008
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: 3008
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: 3008
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3008
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3008
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.Arrays;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    29
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * An object used to cache pre-rendered complex paths.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * @see PiscesRenderer#render
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 */
8131
e2932d8114cb 7016856: dashing performance was reduced during latest changes to the OpenJDK rasterizer
dlila
parents: 7668
diff changeset
    35
final class PiscesCache {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    37
    final int bboxX0, bboxY0, bboxX1, bboxY1;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    38
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    39
    // rowAARLE[i] holds the encoding of the pixel row with y = bboxY0+i.
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    40
    // The format of each of the inner arrays is: rowAARLE[i][0,1] = (x0, n)
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    41
    // where x0 is the first x in row i with nonzero alpha, and n is the
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    42
    // number of RLE entries in this row. rowAARLE[i][j,j+1] for j>1 is
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    43
    // (val,runlen)
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    44
    final int[][] rowAARLE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    46
    // RLE encodings are added in increasing y rows and then in increasing
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    47
    // x inside those rows. Therefore, at any one time there is a well
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    48
    // defined position (x,y) where a run length is about to be added (or
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    49
    // the row terminated). x0,y0 is this (x,y)-(bboxX0,bboxY0). They
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    50
    // are used to get indices into the current tile.
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    51
    private int x0 = Integer.MIN_VALUE, y0 = Integer.MIN_VALUE;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    52
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    53
    // touchedTile[i][j] is the sum of all the alphas in the tile with
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    54
    // y=i*TILE_SIZE+bboxY0 and x=j*TILE_SIZE+bboxX0.
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    55
    private final int[][] touchedTile;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    57
    static final int TILE_SIZE_LG = 5;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    58
    static final int TILE_SIZE = 1 << TILE_SIZE_LG; // 32
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    59
    private static final int INIT_ROW_SIZE = 8; // enough for 3 run lengths
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    61
    PiscesCache(int minx, int miny, int maxx, int maxy) {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    62
        assert maxy >= miny && maxx >= minx;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    63
        bboxX0 = minx;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    64
        bboxY0 = miny;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    65
        bboxX1 = maxx + 1;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    66
        bboxY1 = maxy + 1;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    67
        // we could just leave the inner arrays as null and allocate them
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    68
        // lazily (which would be beneficial for shapes with gaps), but we
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    69
        // assume there won't be too many of those so we allocate everything
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    70
        // up front (which is better for other cases)
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    71
        rowAARLE = new int[bboxY1 - bboxY0 + 1][INIT_ROW_SIZE];
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    72
        x0 = 0;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    73
        y0 = -1; // -1 makes the first assert in startRow succeed
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    74
        // the ceiling of (maxy - miny + 1) / TILE_SIZE;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    75
        int nyTiles = (maxy - miny + TILE_SIZE) >> TILE_SIZE_LG;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    76
        int nxTiles = (maxx - minx + TILE_SIZE) >> TILE_SIZE_LG;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    78
        touchedTile = new int[nyTiles][nxTiles];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    81
    void addRLERun(int val, int runLen) {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    82
        if (runLen > 0) {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    83
            addTupleToRow(y0, val, runLen);
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    84
            if (val != 0) {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    85
                // the x and y of the current row, minus bboxX0, bboxY0
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    86
                int tx = x0 >> TILE_SIZE_LG;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    87
                int ty = y0 >> TILE_SIZE_LG;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    88
                int tx1 = (x0 + runLen - 1) >> TILE_SIZE_LG;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    89
                // while we forbid rows from starting before bboxx0, our users
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    90
                // can still store rows that go beyond bboxx1 (although this
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    91
                // shouldn't happen), so it's a good idea to check that i
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    92
                // is not going out of bounds in touchedTile[ty]
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    93
                if (tx1 >= touchedTile[ty].length) {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    94
                    tx1 = touchedTile[ty].length - 1;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    95
                }
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    96
                if (tx <= tx1) {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    97
                    int nextTileXCoord = (tx + 1) << TILE_SIZE_LG;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    98
                    if (nextTileXCoord > x0+runLen) {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
    99
                        touchedTile[ty][tx] += val * runLen;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   100
                    } else {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   101
                        touchedTile[ty][tx] += val * (nextTileXCoord - x0);
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   102
                    }
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   103
                    tx++;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   104
                }
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   105
                // don't go all the way to tx1 - we need to handle the last
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   106
                // tile as a special case (just like we did with the first
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   107
                for (; tx < tx1; tx++) {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   108
//                    try {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   109
                    touchedTile[ty][tx] += (val << TILE_SIZE_LG);
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   110
//                    } catch (RuntimeException e) {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   111
//                        System.out.println("x0, y0: " + x0 + ", " + y0);
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   112
//                        System.out.printf("tx, ty, tx1: %d, %d, %d %n", tx, ty, tx1);
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   113
//                        System.out.printf("bboxX/Y0/1: %d, %d, %d, %d %n",
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   114
//                                bboxX0, bboxY0, bboxX1, bboxY1);
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   115
//                        throw e;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   116
//                    }
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   117
                }
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   118
                // they will be equal unless x0>>TILE_SIZE_LG == tx1
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   119
                if (tx == tx1) {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   120
                    int lastXCoord = Math.min(x0 + runLen, (tx + 1) << TILE_SIZE_LG);
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   121
                    int txXCoord = tx << TILE_SIZE_LG;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   122
                    touchedTile[ty][tx] += val * (lastXCoord - txXCoord);
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   123
                }
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   124
            }
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   125
            x0 += runLen;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   129
    void startRow(int y, int x) {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   130
        // rows are supposed to be added by increasing y.
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   131
        assert y - bboxY0 > y0;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   132
        assert y <= bboxY1; // perhaps this should be < instead of <=
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   133
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   134
        y0 = y - bboxY0;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   135
        // this should be a new, uninitialized row.
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   136
        assert rowAARLE[y0][1] == 0;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   137
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   138
        x0 = x - bboxX0;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   139
        assert x0 >= 0 : "Input must not be to the left of bbox bounds";
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   140
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   141
        // the way addTupleToRow is implemented it would work for this but it's
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   142
        // not a good idea to use it because it is meant for adding
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   143
        // RLE tuples, not the first tuple (which is special).
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   144
        rowAARLE[y0][0] = x;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   145
        rowAARLE[y0][1] = 2;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   148
    int alphaSumInTile(int x, int y) {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   149
        x -= bboxX0;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   150
        y -= bboxY0;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   151
        return touchedTile[y>>TILE_SIZE_LG][x>>TILE_SIZE_LG];
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   152
    }
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   153
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   154
    int minTouched(int rowidx) {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   155
        return rowAARLE[rowidx][0];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   158
    int rowLength(int rowidx) {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   159
        return rowAARLE[rowidx][1];
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   160
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   162
    private void addTupleToRow(int row, int a, int b) {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   163
        int end = rowAARLE[row][1];
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   164
        rowAARLE[row] = Helpers.widenArray(rowAARLE[row], end, 2);
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   165
        rowAARLE[row][end++] = a;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   166
        rowAARLE[row][end++] = b;
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   167
        rowAARLE[row][1] = end;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   170
    @Override
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   171
    public String toString() {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   172
        String ret = "bbox = ["+
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   173
                      bboxX0+", "+bboxY0+" => "+
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   174
                      bboxX1+", "+bboxY1+"]\n";
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   175
        for (int[] row : rowAARLE) {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   176
            if (row != null) {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   177
                ret += ("minTouchedX=" + row[0] +
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   178
                        "\tRLE Entries: " + Arrays.toString(
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   179
                                Arrays.copyOfRange(row, 2, row[1])) + "\n");
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   180
            } else {
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   181
                ret += "[]\n";
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   182
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        }
6997
3642614e2282 6967434: Round joins/caps of scaled up lines have poor quality.
dlila
parents: 5506
diff changeset
   184
        return ret;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
}