0N/A/*
3261N/A * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.java2d.pipe;
0N/A
0N/A/**
0N/A * The API for an object that generates alpha coverage tiles for a given
0N/A * path.
0N/A * The {@link RenderingEngine} will be consulted as a factory to return
0N/A * one of these objects for a given Shape and a given set of rendering
0N/A * attributes.
0N/A * This object will iterate through the bounds of the rendering primitive
0N/A * and return tiles of a constant size as specified by the getTileWidth()
2507N/A * and getTileHeight() parameters.
0N/A * The iteration order of the tiles will be as specified by the pseudo-code:
0N/A * <pre>
0N/A * int bbox[] = {left, top, right, bottom};
0N/A * AATileGenerator aatg = renderengine.getAATileGenerator(..., bbox);
0N/A * int tw = aatg.getTileWidth();
0N/A * int th = aatg.getTileHeight();
0N/A * byte tile[] = new byte[tw * th];
0N/A * for (y = top; y < bottom; y += th) {
0N/A * for (x = left; x < right; x += tw) {
0N/A * int a = aatg.getTypicalAlpha();
0N/A * int w = Math.min(tw, right-x);
0N/A * int h = Math.min(th, bottom-y);
0N/A * if (a == 0x00) {
0N/A * // can skip this tile...
0N/A * aatg.nextTile();
0N/A * } else if (a == 0xff) {
0N/A * // can treat this tile like a fillRect
0N/A * aatg.nextTile();
0N/A * doFill(x, y, w, h);
0N/A * } else {
0N/A * aatg.getAlpha(tile, 0, tw);
0N/A * handleAlpha(tile, x, y, w, h);
0N/A * }
0N/A * }
0N/A * }
0N/A * aatg.dispose();
0N/A * </pre>
0N/A * The bounding box for the iteration will be returned by the
0N/A * {@code RenderingEngine} via an argument to the getAATileGenerator() method.
0N/A */
0N/Apublic interface AATileGenerator {
0N/A /**
0N/A * Gets the width of the tiles that the generator batches output into.
0N/A * @return the width of the standard alpha tile
0N/A */
0N/A public int getTileWidth();
0N/A
0N/A /**
0N/A * Gets the height of the tiles that the generator batches output into.
0N/A * @return the height of the standard alpha tile
0N/A */
0N/A public int getTileHeight();
0N/A
0N/A /**
0N/A * Gets the typical alpha value that will characterize the current
0N/A * tile.
0N/A * The answer may be 0x00 to indicate that the current tile has
0N/A * no coverage in any of its pixels, or it may be 0xff to indicate
0N/A * that the current tile is completely covered by the path, or any
0N/A * other value to indicate non-trivial coverage cases.
0N/A * @return 0x00 for no coverage, 0xff for total coverage, or any other
0N/A * value for partial coverage of the tile
0N/A */
0N/A public int getTypicalAlpha();
0N/A
0N/A /**
0N/A * Skips the current tile and moves on to the next tile.
0N/A * Either this method, or the getAlpha() method should be called
0N/A * once per tile, but not both.
0N/A */
0N/A public void nextTile();
0N/A
0N/A /**
0N/A * Gets the alpha coverage values for the current tile.
0N/A * Either this method, or the nextTile() method should be called
0N/A * once per tile, but not both.
0N/A */
0N/A public void getAlpha(byte tile[], int offset, int rowstride);
0N/A
0N/A /**
0N/A * Disposes this tile generator.
0N/A * No further calls will be made on this instance.
0N/A */
0N/A public void dispose();
0N/A}
0N/A