Path: blob/master/src/java.desktop/share/classes/sun/java2d/pipe/AATileGenerator.java
41159 views
/*1* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.java2d.pipe;2627/**28* The API for an object that generates alpha coverage tiles for a given29* path.30* The {@link RenderingEngine} will be consulted as a factory to return31* one of these objects for a given Shape and a given set of rendering32* attributes.33* This object will iterate through the bounds of the rendering primitive34* and return tiles of a constant size as specified by the getTileWidth()35* and getTileHeight() parameters.36* The iteration order of the tiles will be as specified by the pseudo-code:37* <pre>38* int bbox[] = {left, top, right, bottom};39* AATileGenerator aatg = renderengine.getAATileGenerator(..., bbox);40* int tw = aatg.getTileWidth();41* int th = aatg.getTileHeight();42* byte tile[] = new byte[tw * th];43* for (y = top; y < bottom; y += th) {44* for (x = left; x < right; x += tw) {45* int a = aatg.getTypicalAlpha();46* int w = Math.min(tw, right-x);47* int h = Math.min(th, bottom-y);48* if (a == 0x00) {49* // can skip this tile...50* aatg.nextTile();51* } else if (a == 0xff) {52* // can treat this tile like a fillRect53* aatg.nextTile();54* doFill(x, y, w, h);55* } else {56* aatg.getAlpha(tile, 0, tw);57* handleAlpha(tile, x, y, w, h);58* }59* }60* }61* aatg.dispose();62* </pre>63* The bounding box for the iteration will be returned by the64* {@code RenderingEngine} via an argument to the getAATileGenerator() method.65*/66public interface AATileGenerator {67/**68* Gets the width of the tiles that the generator batches output into.69* @return the width of the standard alpha tile70*/71public int getTileWidth();7273/**74* Gets the height of the tiles that the generator batches output into.75* @return the height of the standard alpha tile76*/77public int getTileHeight();7879/**80* Gets the typical alpha value that will characterize the current81* tile.82* The answer may be 0x00 to indicate that the current tile has83* no coverage in any of its pixels, or it may be 0xff to indicate84* that the current tile is completely covered by the path, or any85* other value to indicate non-trivial coverage cases.86* @return 0x00 for no coverage, 0xff for total coverage, or any other87* value for partial coverage of the tile88*/89public int getTypicalAlpha();9091/**92* Skips the current tile and moves on to the next tile.93* Either this method, or the getAlpha() method should be called94* once per tile, but not both.95*/96public void nextTile();9798/**99* Gets the alpha coverage values for the current tile.100* Either this method, or the nextTile() method should be called101* once per tile, but not both.102*/103public void getAlpha(byte[] tile, int offset, int rowstride);104105/**106* Disposes this tile generator.107* No further calls will be made on this instance.108*/109public void dispose();110}111112113