1 /* 2 * Copyright (c) 2012, 2013, 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 com.sun.javafx.sg.prism; 27 28 import java.nio.Buffer; 29 import com.sun.glass.ui.Screen; 30 import com.sun.javafx.font.FontStrike; 31 import com.sun.javafx.geom.RectBounds; 32 import com.sun.javafx.geom.Shape; 33 import com.sun.javafx.geom.transform.BaseTransform; 34 import com.sun.javafx.scene.text.GlyphList; 35 import com.sun.prism.BasicStroke; 36 import com.sun.prism.Graphics; 37 import com.sun.prism.Image; 38 import com.sun.prism.MediaFrame; 39 import com.sun.prism.Mesh; 40 import com.sun.prism.MeshView; 41 import com.sun.prism.PhongMaterial; 42 import com.sun.prism.PixelFormat; 43 import com.sun.prism.Presentable; 44 import com.sun.prism.PresentableState; 45 import com.sun.prism.RTTexture; 46 import com.sun.prism.RenderTarget; 47 import com.sun.prism.ResourceFactory; 48 import com.sun.prism.ResourceFactoryListener; 49 import com.sun.prism.Texture; 50 import com.sun.prism.Texture.WrapMode; 51 import com.sun.prism.impl.BaseContext; 52 import com.sun.prism.impl.BaseGraphics; 53 import com.sun.prism.impl.TextureResourcePool; 54 import com.sun.prism.impl.VertexBuffer; 55 import com.sun.prism.paint.Color; 56 import com.sun.prism.shape.ShapeRep; 57 58 59 /** 60 * 61 */ 62 public class TestGraphics extends BaseGraphics { 63 64 public static final Graphics TEST_GRAPHICS = new TestGraphics(); 65 66 public TestGraphics() { 67 super(new TestContext(), new TestRenderTarget()); 68 } 69 70 @Override 71 protected void renderShape(Shape shape, BasicStroke stroke, float bx, float by, float bw, float bh) { 72 } 73 74 public void clear(Color color) { 75 } 76 77 public void clearQuad(float x1, float y1, float x2, float y2) { 78 } 79 80 public void fillQuad(float x1, float y1, float x2, float y2) { 81 } 82 83 public void fillRect(float x, float y, float width, float height) { 84 } 85 86 public void fillRoundRect(float x, float y, float width, float height, float arcw, float arch) { 87 } 88 89 public void fillEllipse(float x, float y, float width, float height) { 90 } 91 92 public void drawLine(float x1, float y1, float x2, float y2) { 93 } 94 95 public void drawRect(float x, float y, float width, float height) { 96 } 97 98 public void drawRoundRect(float x, float y, float width, float height, float arcw, float arch) { 99 } 100 101 public void drawEllipse(float x, float y, float width, float height) { 102 } 103 104 public void setNodeBounds(RectBounds bounds) { 105 } 106 107 @Override public void drawString(GlyphList gl, FontStrike strike, float x, float y, Color selectColor, int selectStart, int selectEnd) { 108 } 109 110 @Override public void drawTexture(Texture tex, float x, float y, float w, float h) { 111 } 112 113 @Override 114 public void drawTexture(Texture tex, float dx1, float dy1, float dx2, float dy2, float sx1, float sy1, float sx2, float sy2) { 115 } 116 117 @Override 118 public void drawTexture3SliceH(Texture tex, float dx1, float dy1, float dx2, float dy2, float sx1, float sy1, float sx2, float sy2, float dh1, float dh2, float sh1, float sh2) { 119 } 120 121 @Override 122 public void drawTexture3SliceV(Texture tex, float dx1, float dy1, float dx2, float dy2, float sx1, float sy1, float sx2, float sy2, float dv1, float dv2, float sv1, float sv2) { 123 } 124 125 @Override 126 public void drawTexture9Slice(Texture tex, float dx1, float dy1, float dx2, float dy2, float sx1, float sy1, float sx2, float sy2, float dh1, float dv1, float dh2, float dv2, float sh1, float sv1, float sh2, float sv2) { 127 } 128 129 public void sync() { 130 } 131 132 @Override 133 public void setState3D(boolean flag) { 134 } 135 136 @Override 137 public boolean isState3D() { 138 return false; 139 } 140 141 public void setup3DRendering() { 142 } 143 144 public void blit(RTTexture srcTex, RTTexture dstTex, int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1) { 145 } 146 147 private static class TestContext extends BaseContext { 148 149 public TestContext() { 150 super(null, new TestResourceFactory(), null); 151 } 152 153 @Override 154 protected void setRenderTarget(RenderTarget target, NGCamera camera, boolean depthTest, boolean state3D) { 155 } 156 157 @Override 158 public void validateClearOp(BaseGraphics g) { 159 } 160 161 @Override 162 public void validatePaintOp(BaseGraphics g, BaseTransform xform, Texture maskTex, float bx, float by, float bw, float bh) { 163 } 164 165 @Override 166 public void validateTextureOp(BaseGraphics g, BaseTransform xform, Texture src, PixelFormat format) { 167 } 168 169 @Override 170 public RTTexture getLCDBuffer() { 171 return null; 172 } 173 } 174 175 private static class TestResourceFactory implements ResourceFactory { 176 @Override public boolean isDeviceReady() { return true; } 177 178 @Override public TextureResourcePool getTextureResourcePool() { return null; } 179 @Override public Texture createTexture(Image image, Texture.Usage usageHint, WrapMode wrapMode) { return null; } 180 @Override public Texture createTexture(Image image, Texture.Usage usageHint, Texture.WrapMode wrapMode, boolean useMipmap) { return null; } 181 @Override public Texture createTexture(PixelFormat formatHint, Texture.Usage usageHint, WrapMode wrapMode, int w, int h) { return null; } 182 @Override public Texture createTexture(PixelFormat formatHint, Texture.Usage usageHint, Texture.WrapMode wrapMode, int w, int h, boolean useMipmap) { return null; } 183 @Override public Texture createTexture(MediaFrame frame) { return null; } 184 @Override public boolean isCompatibleTexture(Texture tex) { return true; } 185 @Override public boolean isWrapModeSupported(Texture.WrapMode mode) { return true; } 186 @Override public Texture getCachedTexture(Image image, WrapMode wrapMode) { return null; } 187 @Override public Texture getCachedTexture(Image image, WrapMode wrapMode, boolean useMipmap) { return null; } 188 @Override public boolean isFormatSupported(PixelFormat format) { return false; } 189 @Override public int getMaximumTextureSize() { return 0; } 190 @Override public Texture createMaskTexture(int width, int height, Texture.WrapMode wrapMode) { return null; } 191 @Override public Texture createFloatTexture(int width, int height) { return null; } 192 @Override public int getRTTWidth(int w, WrapMode wrapMode) { return w; } 193 @Override public int getRTTHeight(int h, WrapMode wrapMode) { return h; } 194 @Override public RTTexture createRTTexture(final int width, final int height, Texture.WrapMode wrapMode) { 195 return createRTTexture(width, height, wrapMode, false); 196 } 197 @Override public RTTexture createRTTexture(final int width, final int height, Texture.WrapMode wrapMode, boolean antiAliasing) { 198 return new RTTexture() { 199 @Override public int[] getPixels() { return new int[0]; } 200 @Override public boolean readPixels(Buffer pixels, int x, int y, int width, int height) { return false; } 201 @Override public boolean readPixels(Buffer pixels) { return false; } 202 @Override public boolean isVolatile() { return false; } 203 @Override public boolean isSurfaceLost() { return false; } 204 @Override public Screen getAssociatedScreen() { return null; } 205 @Override public Graphics createGraphics() { 206 return new TestGraphics(); 207 } 208 209 @Override public Texture getSharedTexture(WrapMode altMode) { return null; } 210 @Override public boolean isOpaque() { return false; } 211 @Override public PixelFormat getPixelFormat() { return null; } 212 @Override public int getPhysicalWidth() { return width; } 213 @Override public int getPhysicalHeight() { return height; } 214 @Override public int getContentX() { return 0; } 215 @Override public int getContentY() { return 0; } 216 @Override public int getContentWidth() { return width; } 217 @Override public int getContentHeight() { return height; } 218 @Override public int getLastImageSerial() { return 0; } 219 @Override public void setLastImageSerial(int serial) { } 220 @Override public void update(Image img) { } 221 @Override public void update(Image img, int dstx, int dsty) { } 222 @Override public void update(Image img, int dstx, int dsty, int srcw, int srch) { } 223 @Override public void update(Image img, int dstx, int dsty, int srcw, int srch, boolean skipFlush) { } 224 @Override public void update(Buffer buffer, PixelFormat format, int dstx, int dsty, int srcx, int srcy, int srcw, int srch, int srcscan, boolean skipFlush) { } 225 @Override public void update(MediaFrame frame, boolean skipFlush) { } 226 @Override public WrapMode getWrapMode() { return null; } 227 @Override public boolean getLinearFiltering() { return false; } 228 @Override public void setLinearFiltering(boolean linear) { } 229 @Override public void dispose() { } 230 @Override public void lock() { } 231 @Override public void unlock() { } 232 @Override public boolean isLocked() { return true; } 233 @Override public int getLockCount() { return 1; } 234 @Override public void assertLocked() { } 235 @Override public void makePermanent() { } 236 @Override public void contentsUseful() { } 237 @Override public void contentsNotUseful() { } 238 @Override public void setOpaque(boolean opaque) { } 239 @Override public boolean isAntiAliasing() { return false; } 240 @Override public int getMaxContentWidth() { return getPhysicalWidth(); } 241 @Override public int getMaxContentHeight() { return getPhysicalHeight(); } 242 @Override public void setContentWidth(int contentWidth) { } 243 @Override public void setContentHeight(int contentHeight) { } 244 @Override public boolean getUseMipmap() { return false; } 245 }; 246 } 247 @Override public Presentable createPresentable(PresentableState pstate) { return null; } 248 @Override public VertexBuffer createVertexBuffer(int maxQuads) { return null; } 249 @Override public ShapeRep createPathRep() { return null; } 250 @Override public ShapeRep createRoundRectRep() { return null; } 251 @Override public ShapeRep createEllipseRep() { return null; } 252 @Override public ShapeRep createArcRep() { return null; } 253 @Override public void addFactoryListener(ResourceFactoryListener l) { } 254 @Override public void removeFactoryListener(ResourceFactoryListener l) { } 255 @Override public void dispose() { } 256 257 @Override public PhongMaterial createPhongMaterial() { return null; } 258 @Override public MeshView createMeshView(Mesh mesh) { return null; } 259 @Override public Mesh createMesh() { return null; } 260 @Override public void setRegionTexture(Texture texture) { } 261 @Override public Texture getRegionTexture() { return null; } 262 @Override public void setGlyphTexture(Texture texture) { } 263 @Override public Texture getGlyphTexture() { return null; } 264 @Override public boolean isSuperShaderAllowed() {return false; } 265 266 } 267 268 private static class TestRenderTarget implements RenderTarget { 269 270 public Screen getAssociatedScreen() { 271 return null; 272 } 273 274 public Graphics createGraphics() { 275 return null; 276 } 277 278 public boolean isOpaque() { 279 return true; 280 } 281 282 public void setOpaque(boolean opaque) { 283 } 284 285 public int getPhysicalWidth() { 286 return 0; 287 } 288 289 public int getPhysicalHeight() { 290 return 0; 291 } 292 293 public int getContentX() { 294 return 0; 295 } 296 297 public int getContentY() { 298 return 0; 299 } 300 301 public int getContentWidth() { 302 return 0; 303 } 304 305 public int getContentHeight() { 306 return 0; 307 } 308 309 public boolean isAntiAliasing() { 310 return false; 311 } 312 313 } 314 315 @Override 316 public void setLights(NGLightBase[] lights) { 317 } 318 319 @Override 320 public NGLightBase[] getLights() { 321 return null; 322 } 323 }