jdk/src/share/classes/sun/java2d/SurfaceData.java
author lana
Wed, 05 Jan 2011 11:21:00 -0800
changeset 7762 6e45e1e87347
parent 7751 3ffe25b53aad
parent 7668 d4a77089c587
child 11080 7e18e343964e
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
7668
d4a77089c587 6962318: Update copyright year
ohair
parents: 7487
diff changeset
     2
 * Copyright (c) 1999, 2010, 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: 4250
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: 4250
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: 4250
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4250
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4250
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;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.Color;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.Rectangle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.Transparency;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.GraphicsConfiguration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.Image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.image.ColorModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.image.IndexColorModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.image.Raster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import sun.java2d.loops.RenderCache;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import sun.java2d.loops.RenderLoops;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import sun.java2d.loops.CompositeType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import sun.java2d.loops.SurfaceType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import sun.java2d.loops.MaskFill;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import sun.java2d.loops.DrawLine;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import sun.java2d.loops.FillRect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import sun.java2d.loops.DrawRect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import sun.java2d.loops.DrawPolygons;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import sun.java2d.loops.DrawPath;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import sun.java2d.loops.FillPath;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import sun.java2d.loops.FillSpans;
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
    49
import sun.java2d.loops.FillParallelogram;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
    50
import sun.java2d.loops.DrawParallelogram;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import sun.java2d.loops.FontInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
import sun.java2d.loops.DrawGlyphList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
import sun.java2d.loops.DrawGlyphListAA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
import sun.java2d.loops.DrawGlyphListLCD;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
import sun.java2d.pipe.LoopPipe;
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
    56
import sun.java2d.pipe.ShapeDrawPipe;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
    57
import sun.java2d.pipe.ParallelogramPipe;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
import sun.java2d.pipe.CompositePipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
import sun.java2d.pipe.GeneralCompositePipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
import sun.java2d.pipe.SpanClipRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
import sun.java2d.pipe.SpanShapeRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
import sun.java2d.pipe.AAShapePipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
import sun.java2d.pipe.AlphaPaintPipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
import sun.java2d.pipe.AlphaColorPipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
import sun.java2d.pipe.PixelToShapeConverter;
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
    66
import sun.java2d.pipe.PixelToParallelogramConverter;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
import sun.java2d.pipe.TextPipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
import sun.java2d.pipe.TextRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
import sun.java2d.pipe.AATextRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
import sun.java2d.pipe.LCDTextRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
import sun.java2d.pipe.SolidTextRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
import sun.java2d.pipe.OutlineTextRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
import sun.java2d.pipe.DrawImagePipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
import sun.java2d.pipe.DrawImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
import sun.awt.SunHints;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
import sun.awt.image.SurfaceManager;
4250
e88776b21913 6896068: SunGraphics2D exposes a reference to itself while non fully initialised.
neugens
parents: 1726
diff changeset
    77
import sun.java2d.pipe.LoopBasedPipe;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * This class provides various pieces of information relevant to a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * particular drawing surface.  The information obtained from this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * object describes the pixels of a particular instance of a drawing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * surface and can only be shared among the various graphics objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * that target the same BufferedImage or the same screen Component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * Each SurfaceData object holds a StateTrackableDelegate object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * which tracks both changes to the content of the pixels of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * surface and changes to the overall state of the pixels - such
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * as becoming invalid or losing the surface.  The delegate is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * marked "dirty" whenever the setSurfaceLost() or invalidate()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * methods are called and should also be marked "dirty" by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * rendering pipelines whenever they modify the pixels of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * SurfaceData.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * If you get a StateTracker from a SurfaceData and it reports
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * that it is still "current", then you can trust that the pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * have not changed and that the SurfaceData is still valid and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * has not lost its underlying storage (surfaceLost) since you
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * retrieved the tracker.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
public abstract class SurfaceData
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   102
    implements Transparency, DisposerTarget, StateTrackable, Surface
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    private long pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    private boolean valid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    private boolean surfaceLost; // = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    private SurfaceType surfaceType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    private ColorModel colorModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    private Object disposerReferent = new Object();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    private static native void initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    private Object blitProxyKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    private StateTrackableDelegate stateDelegate;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    protected SurfaceData(SurfaceType surfaceType, ColorModel cm) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        this(State.STABLE, surfaceType, cm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    protected SurfaceData(State state, SurfaceType surfaceType, ColorModel cm) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        this(StateTrackableDelegate.createInstance(state), surfaceType, cm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    protected SurfaceData(StateTrackableDelegate trackable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                          SurfaceType surfaceType, ColorModel cm)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        this.stateDelegate = trackable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        this.colorModel = cm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        this.surfaceType = surfaceType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        valid = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    protected SurfaceData(State state) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        this.stateDelegate = StateTrackableDelegate.createInstance(state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        valid = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * Subclasses can set a "blit proxy key" which will be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * along with the SurfaceManager.getCacheData() mechanism to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * store acceleration-compatible cached copies of source images.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * This key is a "tag" used to identify which cached copies
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * are compatible with this destination SurfaceData.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * The getSourceSurfaceData() method uses this key to manage
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * cached copies of a source image as described below.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * The Object used as this key should be as unique as it needs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * to be to ensure that multiple acceleratible destinations can
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * each store their cached copies separately under different keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * without interfering with each other or getting back the wrong
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * cached copy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * Many acceleratable SurfaceData objects can use their own
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * GraphicsConfiguration as their proxy key as the GC object will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * typically be unique to a given screen and pixel format, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * other rendering destinations may have more or less stringent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * sharing requirements.  For instance, X11 pixmaps can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * shared on a given screen by any GraphicsConfiguration that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * has the same depth and SurfaceType.  Multiple such GCs with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * the same depth and SurfaceType can exist per screen so storing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * a different cached proxy for each would be a waste.  One can
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * imagine platforms where a single cached copy can be created
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * and shared across all screens and pixel formats - such
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * implementations could use a single heavily shared key Object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    protected void setBlitProxyKey(Object key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        // Caching is effectively disabled if we never have a proxy key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        // since the getSourceSurfaceData() method only does caching
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        // if the key is not null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        if (SurfaceDataProxy.isCachingAllowed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            this.blitProxyKey = key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * This method is called on a destination SurfaceData to choose
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * the best SurfaceData from a source Image for an imaging
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * operation, with help from its SurfaceManager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * The method may determine that the default SurfaceData was
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * really the best choice in the first place, or it may decide
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * to use a cached surface.  Some general decisions about whether
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * acceleration is enabled are made by this method, but any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * decision based on the type of the source image is made in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * the makeProxyFor method below when it comes up with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * appropriate SurfaceDataProxy instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * The parameters describe the type of imaging operation being performed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * If a blitProxyKey was supplied by the subclass then it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * used to potentially override the choice of source SurfaceData.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * The outline of this process is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * <ol>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * <li> Image pipeline asks destSD to find an appropriate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     *      srcSD for a given source Image object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * <li> destSD gets the SurfaceManager of the source Image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     *      and first retrieves the default SD from it using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     *      getPrimarySurfaceData()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * <li> destSD uses its "blit proxy key" (if set) to look for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     *      some cached data stored in the source SurfaceManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * <li> If the cached data is null then makeProxyFor() is used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     *      to create some cached data which is stored back in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     *      source SurfaceManager under the same key for future uses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * <li> The cached data will be a SurfaceDataProxy object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * <li> The SurfaceDataProxy object is then consulted to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     *      return a replacement SurfaceData object (typically
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     *      a cached copy if appropriate, or the original if not).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * </ol>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    public SurfaceData getSourceSurfaceData(Image img,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                                            int txtype,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                                            CompositeType comp,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                                            Color bgColor)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        SurfaceManager srcMgr = SurfaceManager.getManager(img);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        SurfaceData srcData = srcMgr.getPrimarySurfaceData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        if (img.getAccelerationPriority() > 0.0f &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            blitProxyKey != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            SurfaceDataProxy sdp =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                (SurfaceDataProxy) srcMgr.getCacheData(blitProxyKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            if (sdp == null || !sdp.isValid()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                if (srcData.getState() == State.UNTRACKABLE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                    sdp = SurfaceDataProxy.UNCACHED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                    sdp = makeProxyFor(srcData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                srcMgr.setCacheData(blitProxyKey, sdp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            srcData = sdp.replaceData(srcData, txtype, comp, bgColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        return srcData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * This method is called on a destination SurfaceData to choose
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * a proper SurfaceDataProxy subclass for a source SurfaceData
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * to use to control when and with what surface to override a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * given image operation.  The argument is the default SurfaceData
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * for the source Image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * The type of the return object is chosen based on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * acceleration capabilities of this SurfaceData and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * type of the given source SurfaceData object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * In some cases the original SurfaceData will always be the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * best choice to use to blit to this SurfaceData.  This can
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * happen if the source image is a hardware surface of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * same type as this one and so acceleration will happen without
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * any caching.  It may also be the case that the source image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * can never be accelerated on this SurfaceData - for example
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * because it is translucent and there are no accelerated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * translucent image ops for this surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * In those cases there is a special SurfaceDataProxy.UNCACHED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * instance that represents a NOP for caching purposes - it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * always returns the original sourceSD object as the replacement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * copy so no caching is ever performed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    public SurfaceDataProxy makeProxyFor(SurfaceData srcData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        return SurfaceDataProxy.UNCACHED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * Extracts the SurfaceManager from the given Image, and then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * returns the SurfaceData object that would best be suited as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * destination surface in some rendering operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    public static SurfaceData getPrimarySurfaceData(Image img) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        SurfaceManager sMgr = SurfaceManager.getManager(img);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        return sMgr.getPrimarySurfaceData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * Restores the contents of the given Image and then returns the new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * SurfaceData object in use by the Image's SurfaceManager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    public static SurfaceData restoreContents(Image img) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        SurfaceManager sMgr = SurfaceManager.getManager(img);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        return sMgr.restoreContents();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    public State getState() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        return stateDelegate.getState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    public StateTracker getStateTracker() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        return stateDelegate.getStateTracker();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * Marks this surface as dirty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    public final void markDirty() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        stateDelegate.markDirty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * Sets the value of the surfaceLost variable, which indicates whether
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * something has happened to the rendering surface such that it needs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * to be restored and re-rendered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    public void setSurfaceLost(boolean lost) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        surfaceLost = lost;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        stateDelegate.markDirty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    public boolean isSurfaceLost() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        return surfaceLost;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * Returns a boolean indicating whether or not this SurfaceData is valid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    public final boolean isValid() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        return valid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    public Object getDisposerReferent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        return disposerReferent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    public long getNativeOps() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        return pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * Sets this SurfaceData object to the invalid state.  All Graphics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * objects must get a new SurfaceData object via the refresh method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * and revalidate their pipelines before continuing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    public void invalidate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        valid = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        stateDelegate.markDirty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * Certain changes in the configuration of a surface require the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * invalidation of existing associated SurfaceData objects and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * the creation of brand new ones.  These changes include size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * ColorModel, or SurfaceType.  Existing Graphics objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * which are directed at such surfaces, however, must continue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * to render to them even after the change occurs underneath
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * the covers.  The getReplacement() method is called from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * SunGraphics2D.revalidateAll() when the associated SurfaceData
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * is found to be invalid so that a Graphics object can continue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * to render to the surface in its new configuration.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * Such changes only tend to happen to window based surfaces since
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * most image based surfaces never change size or pixel format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * Even VolatileImage objects never change size and they only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * change their pixel format when manually validated against a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * new GraphicsConfiguration, at which point old Graphics objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * are no longer expected to render to them after the validation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * step.  Thus, only window based surfaces really need to deal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * with this form of replacement.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    public abstract SurfaceData getReplacement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    protected static final LoopPipe colorPrimitives;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    public static final TextPipe outlineTextRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    public static final TextPipe solidTextRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    public static final TextPipe aaTextRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    public static final TextPipe lcdTextRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   370
    protected static final AlphaColorPipe colorPipe;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    protected static final PixelToShapeConverter colorViaShape;
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   372
    protected static final PixelToParallelogramConverter colorViaPgram;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    protected static final TextPipe colorText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    protected static final CompositePipe clipColorPipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    protected static final TextPipe clipColorText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    protected static final AAShapePipe AAColorShape;
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   377
    protected static final PixelToParallelogramConverter AAColorViaShape;
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   378
    protected static final PixelToParallelogramConverter AAColorViaPgram;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    protected static final AAShapePipe AAClipColorShape;
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   380
    protected static final PixelToParallelogramConverter AAClipColorViaShape;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    protected static final CompositePipe paintPipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    protected static final SpanShapeRenderer paintShape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    protected static final PixelToShapeConverter paintViaShape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    protected static final TextPipe paintText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    protected static final CompositePipe clipPaintPipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    protected static final TextPipe clipPaintText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    protected static final AAShapePipe AAPaintShape;
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   389
    protected static final PixelToParallelogramConverter AAPaintViaShape;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    protected static final AAShapePipe AAClipPaintShape;
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   391
    protected static final PixelToParallelogramConverter AAClipPaintViaShape;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    protected static final CompositePipe compPipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    protected static final SpanShapeRenderer compShape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    protected static final PixelToShapeConverter compViaShape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    protected static final TextPipe compText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    protected static final CompositePipe clipCompPipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    protected static final TextPipe clipCompText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    protected static final AAShapePipe AACompShape;
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   400
    protected static final PixelToParallelogramConverter AACompViaShape;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    protected static final AAShapePipe AAClipCompShape;
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   402
    protected static final PixelToParallelogramConverter AAClipCompViaShape;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    protected static final DrawImagePipe imagepipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   406
    // Utility subclass to add the LoopBasedPipe tagging interface
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   407
    static class PixelToShapeLoopConverter
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   408
        extends PixelToShapeConverter
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   409
        implements LoopBasedPipe
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   410
    {
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   411
        public PixelToShapeLoopConverter(ShapeDrawPipe pipe) {
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   412
            super(pipe);
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   413
        }
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   414
    }
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   415
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   416
    // Utility subclass to add the LoopBasedPipe tagging interface
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   417
    static class PixelToPgramLoopConverter
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   418
        extends PixelToParallelogramConverter
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   419
        implements LoopBasedPipe
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   420
    {
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   421
        public PixelToPgramLoopConverter(ShapeDrawPipe shapepipe,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   422
                                         ParallelogramPipe pgrampipe,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   423
                                         double minPenSize,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   424
                                         double normPosition,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   425
                                         boolean adjustfill)
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   426
        {
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   427
            super(shapepipe, pgrampipe, minPenSize, normPosition, adjustfill);
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   428
        }
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   429
    }
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   430
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   431
    private static PixelToParallelogramConverter
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   432
        makeConverter(AAShapePipe renderer,
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   433
                      ParallelogramPipe pgrampipe)
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   434
    {
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   435
        return new PixelToParallelogramConverter(renderer,
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   436
                                                 pgrampipe,
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   437
                                                 1.0/8.0, 0.499,
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   438
                                                 false);
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   439
    }
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   440
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   441
    private static PixelToParallelogramConverter
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   442
        makeConverter(AAShapePipe renderer)
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   443
    {
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   444
        return makeConverter(renderer, renderer);
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   445
    }
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   446
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        colorPrimitives = new LoopPipe();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        outlineTextRenderer = new OutlineTextRenderer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        solidTextRenderer = new SolidTextRenderer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        aaTextRenderer = new AATextRenderer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        lcdTextRenderer = new LCDTextRenderer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        colorPipe = new AlphaColorPipe();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        // colorShape = colorPrimitives;
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   457
        colorViaShape = new PixelToShapeLoopConverter(colorPrimitives);
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   458
        colorViaPgram = new PixelToPgramLoopConverter(colorPrimitives,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   459
                                                      colorPrimitives,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   460
                                                      1.0, 0.25, true);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        colorText = new TextRenderer(colorPipe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        clipColorPipe = new SpanClipRenderer(colorPipe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        clipColorText = new TextRenderer(clipColorPipe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        AAColorShape = new AAShapePipe(colorPipe);
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   465
        AAColorViaShape = makeConverter(AAColorShape);
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   466
        AAColorViaPgram = makeConverter(AAColorShape, colorPipe);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        AAClipColorShape = new AAShapePipe(clipColorPipe);
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   468
        AAClipColorViaShape = makeConverter(AAClipColorShape);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        paintPipe = new AlphaPaintPipe();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        paintShape = new SpanShapeRenderer.Composite(paintPipe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        paintViaShape = new PixelToShapeConverter(paintShape);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        paintText = new TextRenderer(paintPipe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        clipPaintPipe = new SpanClipRenderer(paintPipe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        clipPaintText = new TextRenderer(clipPaintPipe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        AAPaintShape = new AAShapePipe(paintPipe);
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   477
        AAPaintViaShape = makeConverter(AAPaintShape);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        AAClipPaintShape = new AAShapePipe(clipPaintPipe);
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   479
        AAClipPaintViaShape = makeConverter(AAClipPaintShape);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        compPipe = new GeneralCompositePipe();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        compShape = new SpanShapeRenderer.Composite(compPipe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        compViaShape = new PixelToShapeConverter(compShape);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        compText = new TextRenderer(compPipe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        clipCompPipe = new SpanClipRenderer(compPipe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        clipCompText = new TextRenderer(clipCompPipe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        AACompShape = new AAShapePipe(compPipe);
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   488
        AACompViaShape = makeConverter(AACompShape);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        AAClipCompShape = new AAShapePipe(clipCompPipe);
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   490
        AAClipCompViaShape = makeConverter(AAClipCompShape);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        imagepipe = new DrawImage();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    /* Not all surfaces and rendering mode combinations support LCD text. */
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   496
    static final int LOOP_UNKNOWN = 0;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   497
    static final int LOOP_FOUND = 1;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   498
    static final int LOOP_NOTFOUND = 2;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    int haveLCDLoop;
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   500
    int havePgramXORLoop;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   501
    int havePgramSolidLoop;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    public boolean canRenderLCDText(SunGraphics2D sg2d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        // For now the answer can only be true in the following cases:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        if (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
            sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR &&
1726
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 888
diff changeset
   507
            sg2d.clipState <= SunGraphics2D.CLIP_RECTANGULAR &&
6b8261d50f69 6749060: LCD AA text rendered incorrectly when destination is non opaque (sw pipeline only)
tdv
parents: 888
diff changeset
   508
            sg2d.surfaceData.getTransparency() == Transparency.OPAQUE)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        {
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   510
            if (haveLCDLoop == LOOP_UNKNOWN) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
                DrawGlyphListLCD loop =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
                    DrawGlyphListLCD.locate(SurfaceType.AnyColor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
                                            CompositeType.SrcNoEa,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                                            getSurfaceType());
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   515
                haveLCDLoop = (loop != null) ? LOOP_FOUND : LOOP_NOTFOUND;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
            }
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   517
            return haveLCDLoop == LOOP_FOUND;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        return false; /* for now - in the future we may want to search */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   522
    public boolean canRenderParallelograms(SunGraphics2D sg2d) {
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   523
        if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR) {
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   524
            if (sg2d.compositeState == sg2d.COMP_XOR) {
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   525
                if (havePgramXORLoop == LOOP_UNKNOWN) {
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   526
                    FillParallelogram loop =
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   527
                        FillParallelogram.locate(SurfaceType.AnyColor,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   528
                                                 CompositeType.Xor,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   529
                                                 getSurfaceType());
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   530
                    havePgramXORLoop =
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   531
                        (loop != null) ? LOOP_FOUND : LOOP_NOTFOUND;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   532
                }
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   533
                return havePgramXORLoop == LOOP_FOUND;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   534
            } else if (sg2d.compositeState <= sg2d.COMP_ISCOPY &&
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   535
                       sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON &&
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   536
                       sg2d.clipState != sg2d.CLIP_SHAPE)
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   537
            {
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   538
                if (havePgramSolidLoop == LOOP_UNKNOWN) {
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   539
                    FillParallelogram loop =
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   540
                        FillParallelogram.locate(SurfaceType.AnyColor,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   541
                                                 CompositeType.SrcNoEa,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   542
                                                 getSurfaceType());
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   543
                    havePgramSolidLoop =
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   544
                        (loop != null) ? LOOP_FOUND : LOOP_NOTFOUND;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   545
                }
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   546
                return havePgramSolidLoop == LOOP_FOUND;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   547
            }
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   548
        }
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   549
        return false;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   550
    }
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   551
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    public void validatePipe(SunGraphics2D sg2d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        sg2d.imagepipe = imagepipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        if (sg2d.compositeState == sg2d.COMP_XOR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
            if (sg2d.paintState > sg2d.PAINT_ALPHACOLOR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
                sg2d.drawpipe = paintViaShape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
                sg2d.fillpipe = paintViaShape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                sg2d.shapepipe = paintShape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
                // REMIND: Ideally custom paint mode would use glyph
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
                // rendering as opposed to outline rendering but the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
                // glyph paint rendering pipeline uses MaskBlit which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
                // is not defined for XOR.  This means that text drawn
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
                // in XOR mode with a Color object is different than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                // text drawn in XOR mode with a Paint object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                sg2d.textpipe = outlineTextRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
            } else {
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   567
                PixelToShapeConverter converter;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   568
                if (canRenderParallelograms(sg2d)) {
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   569
                    converter = colorViaPgram;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   570
                    // Note that we use the transforming pipe here because it
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   571
                    // will examine the shape and possibly perform an optimized
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   572
                    // operation if it can be simplified.  The simplifications
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   573
                    // will be valid for all STROKE and TRANSFORM types.
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   574
                    sg2d.shapepipe = colorViaPgram;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   575
                } else {
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   576
                    converter = colorViaShape;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   577
                    sg2d.shapepipe = colorPrimitives;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   578
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                if (sg2d.clipState == sg2d.CLIP_SHAPE) {
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   580
                    sg2d.drawpipe = converter;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   581
                    sg2d.fillpipe = converter;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
                    // REMIND: We should not be changing text strategies
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
                    // between outline and glyph rendering based upon the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
                    // presence of a complex clip as that could cause a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                    // mismatch when drawing the same text both clipped
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
                    // and unclipped on two separate rendering passes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
                    // Unfortunately, all of the clipped glyph rendering
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                    // pipelines rely on the use of the MaskBlit operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                    // which is not defined for XOR.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                    sg2d.textpipe = outlineTextRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                    if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) {
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   593
                        sg2d.drawpipe = converter;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   594
                        sg2d.fillpipe = converter;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                        if (sg2d.strokeState != sg2d.STROKE_THIN) {
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   597
                            sg2d.drawpipe = converter;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
                            sg2d.drawpipe = colorPrimitives;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
                        sg2d.fillpipe = colorPrimitives;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
                    sg2d.textpipe = solidTextRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
                // assert(sg2d.surfaceData == this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        } else if (sg2d.compositeState == sg2d.COMP_CUSTOM) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
            if (sg2d.antialiasHint == SunHints.INTVAL_ANTIALIAS_ON) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
                if (sg2d.clipState == sg2d.CLIP_SHAPE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                    sg2d.drawpipe = AAClipCompViaShape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                    sg2d.fillpipe = AAClipCompViaShape;
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   612
                    sg2d.shapepipe = AAClipCompViaShape;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
                    sg2d.textpipe = clipCompText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
                    sg2d.drawpipe = AACompViaShape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
                    sg2d.fillpipe = AACompViaShape;
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   617
                    sg2d.shapepipe = AACompViaShape;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
                    sg2d.textpipe = compText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
                sg2d.drawpipe = compViaShape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
                sg2d.fillpipe = compViaShape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
                sg2d.shapepipe = compShape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
                if (sg2d.clipState == sg2d.CLIP_SHAPE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
                    sg2d.textpipe = clipCompText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
                    sg2d.textpipe = compText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        } else if (sg2d.antialiasHint == SunHints.INTVAL_ANTIALIAS_ON) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
            sg2d.alphafill = getMaskFill(sg2d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
            // assert(sg2d.surfaceData == this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
            if (sg2d.alphafill != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
                if (sg2d.clipState == sg2d.CLIP_SHAPE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
                    sg2d.drawpipe = AAClipColorViaShape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                    sg2d.fillpipe = AAClipColorViaShape;
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   637
                    sg2d.shapepipe = AAClipColorViaShape;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
                    sg2d.textpipe = clipColorText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
                } else {
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   640
                    PixelToParallelogramConverter converter =
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   641
                        (sg2d.alphafill.canDoParallelograms()
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   642
                         ? AAColorViaPgram
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   643
                         : AAColorViaShape);
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   644
                    sg2d.drawpipe = converter;
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   645
                    sg2d.fillpipe = converter;
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   646
                    sg2d.shapepipe = converter;
7751
3ffe25b53aad 6996867: Garbage rendering of LCD text with SRC composite mode
prr
parents: 7745
diff changeset
   647
                    if (sg2d.paintState > sg2d.PAINT_ALPHACOLOR ||
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
                        sg2d.compositeState > sg2d.COMP_ISCOPY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
                    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
                        sg2d.textpipe = colorText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
                        sg2d.textpipe = getTextPipe(sg2d, true /* AA==ON */);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
                if (sg2d.clipState == sg2d.CLIP_SHAPE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
                    sg2d.drawpipe = AAClipPaintViaShape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
                    sg2d.fillpipe = AAClipPaintViaShape;
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   659
                    sg2d.shapepipe = AAClipPaintViaShape;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
                    sg2d.textpipe = clipPaintText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
                    sg2d.drawpipe = AAPaintViaShape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
                    sg2d.fillpipe = AAPaintViaShape;
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   664
                    sg2d.shapepipe = AAPaintViaShape;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
                    sg2d.textpipe = paintText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        } else if (sg2d.paintState > sg2d.PAINT_ALPHACOLOR ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
                   sg2d.compositeState > sg2d.COMP_ISCOPY ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
                   sg2d.clipState == sg2d.CLIP_SHAPE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
            sg2d.drawpipe = paintViaShape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
            sg2d.fillpipe = paintViaShape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
            sg2d.shapepipe = paintShape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
            sg2d.alphafill = getMaskFill(sg2d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
            // assert(sg2d.surfaceData == this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
            if (sg2d.alphafill != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
                if (sg2d.clipState == sg2d.CLIP_SHAPE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
                    sg2d.textpipe = clipColorText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
                    sg2d.textpipe = colorText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
                if (sg2d.clipState == sg2d.CLIP_SHAPE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
                    sg2d.textpipe = clipPaintText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
                    sg2d.textpipe = paintText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
        } else {
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   691
            PixelToShapeConverter converter;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   692
            if (canRenderParallelograms(sg2d)) {
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   693
                converter = colorViaPgram;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   694
                // Note that we use the transforming pipe here because it
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   695
                // will examine the shape and possibly perform an optimized
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   696
                // operation if it can be simplified.  The simplifications
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   697
                // will be valid for all STROKE and TRANSFORM types.
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   698
                sg2d.shapepipe = colorViaPgram;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   699
            } else {
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   700
                converter = colorViaShape;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   701
                sg2d.shapepipe = colorPrimitives;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   702
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
            if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) {
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   704
                sg2d.drawpipe = converter;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   705
                sg2d.fillpipe = converter;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
                if (sg2d.strokeState != sg2d.STROKE_THIN) {
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   708
                    sg2d.drawpipe = converter;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
                    sg2d.drawpipe = colorPrimitives;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
                sg2d.fillpipe = colorPrimitives;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
            sg2d.textpipe = getTextPipe(sg2d, false /* AA==OFF */);
4250
e88776b21913 6896068: SunGraphics2D exposes a reference to itself while non fully initialised.
neugens
parents: 1726
diff changeset
   716
            // assert(sg2d.surfaceData == this);
e88776b21913 6896068: SunGraphics2D exposes a reference to itself while non fully initialised.
neugens
parents: 1726
diff changeset
   717
        }
e88776b21913 6896068: SunGraphics2D exposes a reference to itself while non fully initialised.
neugens
parents: 1726
diff changeset
   718
e88776b21913 6896068: SunGraphics2D exposes a reference to itself while non fully initialised.
neugens
parents: 1726
diff changeset
   719
        // check for loops
e88776b21913 6896068: SunGraphics2D exposes a reference to itself while non fully initialised.
neugens
parents: 1726
diff changeset
   720
        if (sg2d.textpipe  instanceof LoopBasedPipe ||
e88776b21913 6896068: SunGraphics2D exposes a reference to itself while non fully initialised.
neugens
parents: 1726
diff changeset
   721
            sg2d.shapepipe instanceof LoopBasedPipe ||
e88776b21913 6896068: SunGraphics2D exposes a reference to itself while non fully initialised.
neugens
parents: 1726
diff changeset
   722
            sg2d.fillpipe  instanceof LoopBasedPipe ||
e88776b21913 6896068: SunGraphics2D exposes a reference to itself while non fully initialised.
neugens
parents: 1726
diff changeset
   723
            sg2d.drawpipe  instanceof LoopBasedPipe ||
e88776b21913 6896068: SunGraphics2D exposes a reference to itself while non fully initialised.
neugens
parents: 1726
diff changeset
   724
            sg2d.imagepipe instanceof LoopBasedPipe)
e88776b21913 6896068: SunGraphics2D exposes a reference to itself while non fully initialised.
neugens
parents: 1726
diff changeset
   725
        {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
            sg2d.loops = getRenderLoops(sg2d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
    /* Return the text pipe to be used based on the graphics AA hint setting,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
     * and the rest of the graphics state is compatible with these loops.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
     * If the text AA hint is "DEFAULT", then the AA graphics hint requests
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
     * the AA text renderer, else it requests the B&W text renderer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
    private TextPipe getTextPipe(SunGraphics2D sg2d, boolean aaHintIsOn) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
        /* Try to avoid calling getFontInfo() unless its needed to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
         * resolve one of the new AA types.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
        switch (sg2d.textAntialiasHint) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
        case SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
            if (aaHintIsOn) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
                return aaTextRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
                return solidTextRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
        case SunHints.INTVAL_TEXT_ANTIALIAS_OFF:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
            return solidTextRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        case SunHints.INTVAL_TEXT_ANTIALIAS_ON:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
            return aaTextRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
            switch (sg2d.getFontInfo().aaHint) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
            case SunHints.INTVAL_TEXT_ANTIALIAS_LCD_HRGB:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
            case SunHints.INTVAL_TEXT_ANTIALIAS_LCD_VRGB:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
                return lcdTextRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
            case SunHints.INTVAL_TEXT_ANTIALIAS_ON:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
                return aaTextRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
            case SunHints.INTVAL_TEXT_ANTIALIAS_OFF:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
                return solidTextRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
                 /* This should not be reached as the FontInfo will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
                 * always explicitly set its hint value. So whilst
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
                 * this could be collapsed to returning say just
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
                 * solidTextRenderer, or even removed, its left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
                 * here in case DEFAULT is ever passed in.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
                if (aaHintIsOn) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
                    return aaTextRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
                    return solidTextRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
    private static SurfaceType getPaintSurfaceType(SunGraphics2D sg2d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
        switch (sg2d.paintState) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
        case SunGraphics2D.PAINT_OPAQUECOLOR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
            return SurfaceType.OpaqueColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
        case SunGraphics2D.PAINT_ALPHACOLOR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
            return SurfaceType.AnyColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
        case SunGraphics2D.PAINT_GRADIENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
            if (sg2d.paint.getTransparency() == OPAQUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
                return SurfaceType.OpaqueGradientPaint;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
                return SurfaceType.GradientPaint;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
        case SunGraphics2D.PAINT_LIN_GRADIENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
            if (sg2d.paint.getTransparency() == OPAQUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
                return SurfaceType.OpaqueLinearGradientPaint;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
                return SurfaceType.LinearGradientPaint;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
        case SunGraphics2D.PAINT_RAD_GRADIENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
            if (sg2d.paint.getTransparency() == OPAQUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
                return SurfaceType.OpaqueRadialGradientPaint;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
                return SurfaceType.RadialGradientPaint;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
        case SunGraphics2D.PAINT_TEXTURE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
            if (sg2d.paint.getTransparency() == OPAQUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
                return SurfaceType.OpaqueTexturePaint;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
                return SurfaceType.TexturePaint;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
        case SunGraphics2D.PAINT_CUSTOM:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
            return SurfaceType.AnyPaint;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   818
    private static CompositeType getFillCompositeType(SunGraphics2D sg2d) {
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   819
        CompositeType compType = sg2d.imageComp;
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   820
        if (sg2d.compositeState == sg2d.COMP_ISCOPY) {
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   821
            if (compType == CompositeType.SrcOverNoEa) {
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   822
                compType = CompositeType.OpaqueSrcOverNoEa;
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   823
            } else {
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   824
                compType = CompositeType.SrcNoEa;
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   825
            }
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   826
        }
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   827
        return compType;
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   828
    }
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   829
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
     * Returns a MaskFill object that can be used on this destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
     * with the source (paint) and composite types determined by the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
     * SunGraphics2D, or null if no such MaskFill object can be located.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
     * Subclasses can override this method if they wish to filter other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
     * attributes (such as the hardware capabilities of the destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
     * surface) before returning a specific MaskFill object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
    protected MaskFill getMaskFill(SunGraphics2D sg2d) {
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   839
        SurfaceType src = getPaintSurfaceType(sg2d);
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   840
        CompositeType comp = getFillCompositeType(sg2d);
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   841
        SurfaceType dst = getSurfaceType();
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   842
        return MaskFill.getFromCache(src, comp, dst);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
    private static RenderCache loopcache = new RenderCache(30);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
     * Return a RenderLoops object containing all of the basic
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
     * GraphicsPrimitive objects for rendering to the destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
     * surface with the current attributes of the given SunGraphics2D.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
    public RenderLoops getRenderLoops(SunGraphics2D sg2d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
        SurfaceType src = getPaintSurfaceType(sg2d);
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 7487
diff changeset
   854
        CompositeType comp = getFillCompositeType(sg2d);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
        SurfaceType dst = sg2d.getSurfaceData().getSurfaceType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
        Object o = loopcache.get(src, comp, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
        if (o != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
            return (RenderLoops) o;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
        RenderLoops loops = makeRenderLoops(src, comp, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
        loopcache.put(src, comp, dst, loops);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
        return loops;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
     * Construct and return a RenderLoops object containing all of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
     * the basic GraphicsPrimitive objects for rendering to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
     * destination surface with the given source, destination, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
     * composite types.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
    public static RenderLoops makeRenderLoops(SurfaceType src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
                                              CompositeType comp,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
                                              SurfaceType dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
        RenderLoops loops = new RenderLoops();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
        loops.drawLineLoop = DrawLine.locate(src, comp, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
        loops.fillRectLoop = FillRect.locate(src, comp, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
        loops.drawRectLoop = DrawRect.locate(src, comp, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
        loops.drawPolygonsLoop = DrawPolygons.locate(src, comp, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
        loops.drawPathLoop = DrawPath.locate(src, comp, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
        loops.fillPathLoop = FillPath.locate(src, comp, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
        loops.fillSpansLoop = FillSpans.locate(src, comp, dst);
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   885
        loops.fillParallelogramLoop = FillParallelogram.locate(src, comp, dst);
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   886
        loops.drawParallelogramLoop = DrawParallelogram.locate(src, comp, dst);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
        loops.drawGlyphListLoop = DrawGlyphList.locate(src, comp, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
        loops.drawGlyphListAALoop = DrawGlyphListAA.locate(src, comp, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
        loops.drawGlyphListLCDLoop = DrawGlyphListLCD.locate(src, comp, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
        System.out.println("drawLine: "+loops.drawLineLoop);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
        System.out.println("fillRect: "+loops.fillRectLoop);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
        System.out.println("drawRect: "+loops.drawRectLoop);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
        System.out.println("drawPolygons: "+loops.drawPolygonsLoop);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
        System.out.println("fillSpans: "+loops.fillSpansLoop);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
        System.out.println("drawGlyphList: "+loops.drawGlyphListLoop);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
        System.out.println("drawGlyphListAA: "+loops.drawGlyphListAALoop);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
        System.out.println("drawGlyphListLCD: "+loops.drawGlyphListLCDLoop);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
        return loops;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
     * Return the GraphicsConfiguration object that describes this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
     * destination surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
    public abstract GraphicsConfiguration getDeviceConfiguration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
     * Return the SurfaceType object that describes the destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
     * surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
    public final SurfaceType getSurfaceType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
        return surfaceType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
     * Return the ColorModel for the destination surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
    public final ColorModel getColorModel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
        return colorModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
     * Returns the type of this <code>Transparency</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
     * @return the field type of this <code>Transparency</code>, which is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
     *          either OPAQUE, BITMASK or TRANSLUCENT.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
    public int getTransparency() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
        return getColorModel().getTransparency();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
     * Return a readable Raster which contains the pixels for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
     * specified rectangular region of the destination surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
     * The coordinate origin of the returned Raster is the same as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
     * the device space origin of the destination surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
     * In some cases the returned Raster might also be writeable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
     * In most cases, the returned Raster might contain more pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
     * than requested.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
     * @see useTightBBoxes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
    public abstract Raster getRaster(int x, int y, int w, int h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
     * Does the pixel accessibility of the destination surface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
     * suggest that rendering algorithms might want to take
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
     * extra time to calculate a more accurate bounding box for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
     * the operation being performed?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
     * The typical case when this will be true is when a copy of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
     * the pixels has to be made when doing a getRaster.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
     * fewer pixels copied, the faster the operation will go.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
     * @see getRaster
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
    public boolean useTightBBoxes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
        // Note: The native equivalent would trigger on VISIBLE_TO_NATIVE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
        // REMIND: This is not used - should be obsoleted maybe
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
     * Returns the pixel data for the specified Argb value packed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
     * into an integer for easy storage and conveyance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
    public int pixelFor(int rgb) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
        return surfaceType.pixelFor(rgb, colorModel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
     * Returns the pixel data for the specified color packed into an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
     * integer for easy storage and conveyance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
     * This method will use the getRGB() method of the Color object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
     * and defer to the pixelFor(int rgb) method if not overridden.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
     * For now this is a convenience function, but for cases where
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
     * the highest quality color conversion is requested, this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
     * should be overridden in those cases so that a more direct
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
     * conversion of the color to the destination color space
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
     * can be done using the additional information in the Color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
     * object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
    public int pixelFor(Color c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
        return pixelFor(c.getRGB());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
     * Returns the Argb representation for the specified integer value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
     * which is packed in the format of the associated ColorModel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
    public int rgbFor(int pixel) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
        return surfaceType.rgbFor(pixel, colorModel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
     * Returns the bounds of the destination surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
    public abstract Rectangle getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
    static java.security.Permission compPermission;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
     * Performs Security Permissions checks to see if a Custom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
     * Composite object should be allowed access to the pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
     * of this surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
    protected void checkCustomComposite() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
        SecurityManager sm = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
        if (sm != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
            if (compPermission == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
                compPermission =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
                    new java.awt.AWTPermission("readDisplayPixels");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
            sm.checkPermission(compPermission);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
     * Fetches private field IndexColorModel.allgrayopaque
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
     * which is true when all palette entries in the color
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
     * model are gray and opaque.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
    protected static native boolean isOpaqueGray(IndexColorModel icm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
     * For our purposes null and NullSurfaceData are the same as
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
     * they represent a disposed surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
    public static boolean isNull(SurfaceData sd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
        if (sd == null || sd == NullSurfaceData.theInstance) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
     * Performs a copyarea within this surface.  Returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
     * false if there is no algorithm to perform the copyarea
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
     * given the current settings of the SunGraphics2D.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
    public boolean copyArea(SunGraphics2D sg2d,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
                            int x, int y, int w, int h, int dx, int dy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
     * Synchronously releases resources associated with this surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
    public void flush() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
     * Returns destination associated with this SurfaceData.  This could be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
     * either an Image or a Component; subclasses of SurfaceData are
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
     * responsible for returning the appropriate object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
    public abstract Object getDestination();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
}