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