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