/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* An object used to cache pre-rendered complex paths.
*
* @see PiscesRenderer#render
*/
final class PiscesCache {
// rowAARLE[i] holds the encoding of the pixel row with y = bboxY0+i.
// The format of each of the inner arrays is: rowAARLE[i][0,1] = (x0, n)
// where x0 is the first x in row i with nonzero alpha, and n is the
// number of RLE entries in this row. rowAARLE[i][j,j+1] for j>1 is
// (val,runlen)
final int[][] rowAARLE;
// RLE encodings are added in increasing y rows and then in increasing
// x inside those rows. Therefore, at any one time there is a well
// defined position (x,y) where a run length is about to be added (or
// the row terminated). x0,y0 is this (x,y)-(bboxX0,bboxY0). They
// are used to get indices into the current tile.
// touchedTile[i][j] is the sum of all the alphas in the tile with
// y=i*TILE_SIZE+bboxY0 and x=j*TILE_SIZE+bboxX0.
private final int[][] touchedTile;
// we could just leave the inner arrays as null and allocate them
// lazily (which would be beneficial for shapes with gaps), but we
// assume there won't be too many of those so we allocate everything
// up front (which is better for other cases)
x0 = 0;
// the ceiling of (maxy - miny + 1) / TILE_SIZE;
}
if (runLen > 0) {
if (val != 0) {
// the x and y of the current row, minus bboxX0, bboxY0
// while we forbid rows from starting before bboxx0, our users
// can still store rows that go beyond bboxx1 (although this
// shouldn't happen), so it's a good idea to check that i
// is not going out of bounds in touchedTile[ty]
}
} else {
}
tx++;
}
// don't go all the way to tx1 - we need to handle the last
// tile as a special case (just like we did with the first
// try {
// } catch (RuntimeException e) {
// System.out.println("x0, y0: " + x0 + ", " + y0);
// System.out.printf("tx, ty, tx1: %d, %d, %d %n", tx, ty, tx1);
// bboxX0, bboxY0, bboxX1, bboxY1);
// throw e;
// }
}
// they will be equal unless x0>>TILE_SIZE_LG == tx1
}
}
}
}
void startRow(int y, int x) {
// rows are supposed to be added by increasing y.
assert y <= bboxY1; // perhaps this should be < instead of <=
// this should be a new, uninitialized row.
// the way addTupleToRow is implemented it would work for this but it's
// not a good idea to use it because it is meant for adding
// RLE tuples, not the first tuple (which is special).
}
int alphaSumInTile(int x, int y) {
x -= bboxX0;
y -= bboxY0;
}
}
}
}
} else {
ret += "[]\n";
}
}
return ret;
}
}