jdk/src/share/classes/sun/java2d/pipe/AATileGenerator.java
author flar
Wed, 11 May 2011 16:12:01 -0700
changeset 9653 6a1eff16874d
parent 5506 202f599c92aa
permissions -rw-r--r--
7043054: REGRESSION: JDK 7 b126 : Wrong userBounds in Paint.createContext() Reviewed-by: prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2007, 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.pipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * The API for an object that generates alpha coverage tiles for a given
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * path.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * The {@link RenderingEngine} will be consulted as a factory to return
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * one of these objects for a given Shape and a given set of rendering
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * attributes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * This object will iterate through the bounds of the rendering primitive
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * and return tiles of a constant size as specified by the getTileWidth()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * and getTileHeight() parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * The iteration order of the tiles will be as specified by the pseudo-code:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *     int bbox[] = {left, top, right, bottom};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *     AATileGenerator aatg = renderengine.getAATileGenerator(..., bbox);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *     int tw = aatg.getTileWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *     int th = aatg.getTileHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *     byte tile[] = new byte[tw * th];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *     for (y = top; y < bottom; y += th) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *         for (x = left; x < right; x += tw) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *             int a = aatg.getTypicalAlpha();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *             int w = Math.min(tw, right-x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *             int h = Math.min(th, bottom-y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *             if (a == 0x00) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *                 // can skip this tile...
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *                 aatg.nextTile();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *             } else if (a == 0xff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *                 // can treat this tile like a fillRect
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *                 aatg.nextTile();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *                 doFill(x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *             } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *                 aatg.getAlpha(tile, 0, tw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *                 handleAlpha(tile, x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *             }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 *         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *     aatg.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * The bounding box for the iteration will be returned by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * {@code RenderingEngine} via an argument to the getAATileGenerator() method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
public interface AATileGenerator {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * Gets the width of the tiles that the generator batches output into.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * @return the width of the standard alpha tile
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    public int getTileWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * Gets the height of the tiles that the generator batches output into.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * @return the height of the standard alpha tile
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    public int getTileHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * Gets the typical alpha value that will characterize the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * tile.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * The answer may be 0x00 to indicate that the current tile has
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * no coverage in any of its pixels, or it may be 0xff to indicate
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * that the current tile is completely covered by the path, or any
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * other value to indicate non-trivial coverage cases.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * @return 0x00 for no coverage, 0xff for total coverage, or any other
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     *         value for partial coverage of the tile
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    public int getTypicalAlpha();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * Skips the current tile and moves on to the next tile.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * Either this method, or the getAlpha() method should be called
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * once per tile, but not both.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    public void nextTile();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * Gets the alpha coverage values for the current tile.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * Either this method, or the nextTile() method should be called
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * once per tile, but not both.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    public void getAlpha(byte tile[], int offset, int rowstride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * Disposes this tile generator.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * No further calls will be made on this instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public void dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
}