jdk/src/java.desktop/share/classes/sun/java2d/NullSurfaceData.java
author prr
Sat, 19 Sep 2015 15:45:59 -0700
changeset 32865 f9cb6e427f9e
parent 30948 0a0972d3b58d
permissions -rw-r--r--
8136783: Run blessed-modifier-order script on java.desktop Reviewed-by: martin, serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.java2d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.Rectangle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.image.Raster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.image.ColorModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.GraphicsConfiguration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import sun.java2d.StateTrackable.State;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import sun.java2d.loops.SurfaceType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import sun.java2d.pipe.NullPipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * This class provides an empty implementation of the SurfaceData
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * abstract superclass.  All operations on it translate into NOP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * or harmless operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
public class NullSurfaceData extends SurfaceData {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    public static final SurfaceData theInstance = new NullSurfaceData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    private NullSurfaceData() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        super(State.IMMUTABLE, SurfaceType.Any, ColorModel.getRGBdefault());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     * Sets this SurfaceData object to the invalid state.  All Graphics
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * objects must get a new SurfaceData object via the refresh method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * and revalidate their pipelines before continuing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    public void invalidate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * Return a new SurfaceData object that represents the current state
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * of the destination that this SurfaceData object describes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * This method is typically called when the SurfaceData is invalidated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    public SurfaceData getReplacement() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 30948
diff changeset
    66
    private static final NullPipe nullpipe = new NullPipe();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    public void validatePipe(SunGraphics2D sg2d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        sg2d.drawpipe = nullpipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        sg2d.fillpipe = nullpipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        sg2d.shapepipe = nullpipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        sg2d.textpipe = nullpipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        sg2d.imagepipe = nullpipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    public GraphicsConfiguration getDeviceConfiguration() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * Return a readable Raster which contains the pixels for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * specified rectangular region of the destination surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * The coordinate origin of the returned Raster is the same as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * the device space origin of the destination surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * In some cases the returned Raster might also be writeable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * In most cases, the returned Raster might contain more pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * than requested.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     *
30948
0a0972d3b58d 6587235: Incorrect javadoc: "no parameter" in 2d source code
serb
parents: 25859
diff changeset
    89
     * @see #useTightBBoxes
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    public Raster getRaster(int x, int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        throw new InvalidPipeException("should be NOP");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * Does the pixel accessibility of the destination surface
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * suggest that rendering algorithms might want to take
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * extra time to calculate a more accurate bounding box for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * the operation being performed?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * The typical case when this will be true is when a copy of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * the pixels has to be made when doing a getRaster.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * fewer pixels copied, the faster the operation will go.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     *
30948
0a0972d3b58d 6587235: Incorrect javadoc: "no parameter" in 2d source code
serb
parents: 25859
diff changeset
   104
     * @see #getRaster
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    public boolean useTightBBoxes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * Returns the pixel data for the specified Argb value packed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * into an integer for easy storage and conveyance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    public int pixelFor(int rgb) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        return rgb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * Returns the Argb representation for the specified integer value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * which is packed in the format of the associated ColorModel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    public int rgbFor(int pixel) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        return pixel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * Returns the bounds of the destination surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    public Rectangle getBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        return new Rectangle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * Performs Security Permissions checks to see if a Custom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * Composite object should be allowed access to the pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * of this surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    protected void checkCustomComposite() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * Performs a copyarea within this surface.  Returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * false if there is no algorithm to perform the copyarea
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * given the current settings of the SunGraphics2D.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    public boolean copyArea(SunGraphics2D sg2d,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                            int x, int y, int w, int h, int dx, int dy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * Returns destination Image associated with this SurfaceData (null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    public Object getDestination() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
}