Java Code Examples for sun.java2d.DestSurfaceProvider#getDestSurface()
The following examples show how to use
sun.java2d.DestSurfaceProvider#getDestSurface() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RSLContextInvalidationTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); VolatileImage vi = gc.createCompatibleVolatileImage(100, 100); vi.validate(gc); VolatileImage vi1 = gc.createCompatibleVolatileImage(100, 100); vi1.validate(gc); if (!(vi instanceof DestSurfaceProvider)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } DestSurfaceProvider p = (DestSurfaceProvider)vi; Surface s = p.getDestSurface(); if (!(s instanceof AccelSurface)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } AccelSurface dst = (AccelSurface)s; Graphics g = vi.createGraphics(); g.drawImage(vi1, 95, 95, null); g.setColor(Color.red); g.fillRect(0, 0, 100, 100); g.setColor(Color.black); g.fillRect(0, 0, 100, 100); // after this the validated context color is black RenderQueue rq = dst.getContext().getRenderQueue(); rq.lock(); try { dst.getContext().saveState(); dst.getContext().restoreState(); } finally { rq.unlock(); } // this will cause ResetPaint (it will set color to extended EA=ff, // which is ffffffff==Color.white) g.drawImage(vi1, 95, 95, null); // now try filling with black again, but it will come up as white // because this fill rect won't validate the color properly g.setColor(Color.black); g.fillRect(0, 0, 100, 100); BufferedImage bi = vi.getSnapshot(); if (bi.getRGB(50, 50) != Color.black.getRGB()) { throw new RuntimeException("Test FAILED: found color="+ Integer.toHexString(bi.getRGB(50, 50))+" instead of "+ Integer.toHexString(Color.black.getRGB())); } System.out.println("Test PASSED."); }
Example 2
Source File: RSLContextInvalidationTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); VolatileImage vi = gc.createCompatibleVolatileImage(100, 100); vi.validate(gc); VolatileImage vi1 = gc.createCompatibleVolatileImage(100, 100); vi1.validate(gc); if (!(vi instanceof DestSurfaceProvider)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } DestSurfaceProvider p = (DestSurfaceProvider)vi; Surface s = p.getDestSurface(); if (!(s instanceof AccelSurface)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } AccelSurface dst = (AccelSurface)s; Graphics g = vi.createGraphics(); g.drawImage(vi1, 95, 95, null); g.setColor(Color.red); g.fillRect(0, 0, 100, 100); g.setColor(Color.black); g.fillRect(0, 0, 100, 100); // after this the validated context color is black RenderQueue rq = dst.getContext().getRenderQueue(); rq.lock(); try { dst.getContext().saveState(); dst.getContext().restoreState(); } finally { rq.unlock(); } // this will cause ResetPaint (it will set color to extended EA=ff, // which is ffffffff==Color.white) g.drawImage(vi1, 95, 95, null); // now try filling with black again, but it will come up as white // because this fill rect won't validate the color properly g.setColor(Color.black); g.fillRect(0, 0, 100, 100); BufferedImage bi = vi.getSnapshot(); if (bi.getRGB(50, 50) != Color.black.getRGB()) { throw new RuntimeException("Test FAILED: found color="+ Integer.toHexString(bi.getRGB(50, 50))+" instead of "+ Integer.toHexString(Color.black.getRGB())); } System.out.println("Test PASSED."); }
Example 3
Source File: RSLContextInvalidationTest.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); VolatileImage vi = gc.createCompatibleVolatileImage(100, 100); vi.validate(gc); VolatileImage vi1 = gc.createCompatibleVolatileImage(100, 100); vi1.validate(gc); if (!(vi instanceof DestSurfaceProvider)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } DestSurfaceProvider p = (DestSurfaceProvider)vi; Surface s = p.getDestSurface(); if (!(s instanceof AccelSurface)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } AccelSurface dst = (AccelSurface)s; Graphics g = vi.createGraphics(); g.drawImage(vi1, 95, 95, null); g.setColor(Color.red); g.fillRect(0, 0, 100, 100); g.setColor(Color.black); g.fillRect(0, 0, 100, 100); // after this the validated context color is black RenderQueue rq = dst.getContext().getRenderQueue(); rq.lock(); try { dst.getContext().saveState(); dst.getContext().restoreState(); } finally { rq.unlock(); } // this will cause ResetPaint (it will set color to extended EA=ff, // which is ffffffff==Color.white) g.drawImage(vi1, 95, 95, null); // now try filling with black again, but it will come up as white // because this fill rect won't validate the color properly g.setColor(Color.black); g.fillRect(0, 0, 100, 100); BufferedImage bi = vi.getSnapshot(); if (bi.getRGB(50, 50) != Color.black.getRGB()) { throw new RuntimeException("Test FAILED: found color="+ Integer.toHexString(bi.getRGB(50, 50))+" instead of "+ Integer.toHexString(Color.black.getRGB())); } System.out.println("Test PASSED."); }
Example 4
Source File: RSLContextInvalidationTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); VolatileImage vi = gc.createCompatibleVolatileImage(100, 100); vi.validate(gc); VolatileImage vi1 = gc.createCompatibleVolatileImage(100, 100); vi1.validate(gc); if (!(vi instanceof DestSurfaceProvider)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } DestSurfaceProvider p = (DestSurfaceProvider)vi; Surface s = p.getDestSurface(); if (!(s instanceof AccelSurface)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } AccelSurface dst = (AccelSurface)s; Graphics g = vi.createGraphics(); g.drawImage(vi1, 95, 95, null); g.setColor(Color.red); g.fillRect(0, 0, 100, 100); g.setColor(Color.black); g.fillRect(0, 0, 100, 100); // after this the validated context color is black RenderQueue rq = dst.getContext().getRenderQueue(); rq.lock(); try { dst.getContext().saveState(); dst.getContext().restoreState(); } finally { rq.unlock(); } // this will cause ResetPaint (it will set color to extended EA=ff, // which is ffffffff==Color.white) g.drawImage(vi1, 95, 95, null); // now try filling with black again, but it will come up as white // because this fill rect won't validate the color properly g.setColor(Color.black); g.fillRect(0, 0, 100, 100); BufferedImage bi = vi.getSnapshot(); if (bi.getRGB(50, 50) != Color.black.getRGB()) { throw new RuntimeException("Test FAILED: found color="+ Integer.toHexString(bi.getRGB(50, 50))+" instead of "+ Integer.toHexString(Color.black.getRGB())); } System.out.println("Test PASSED."); }
Example 5
Source File: RSLContextInvalidationTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); VolatileImage vi = gc.createCompatibleVolatileImage(100, 100); vi.validate(gc); VolatileImage vi1 = gc.createCompatibleVolatileImage(100, 100); vi1.validate(gc); if (!(vi instanceof DestSurfaceProvider)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } DestSurfaceProvider p = (DestSurfaceProvider)vi; Surface s = p.getDestSurface(); if (!(s instanceof AccelSurface)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } AccelSurface dst = (AccelSurface)s; Graphics g = vi.createGraphics(); g.drawImage(vi1, 95, 95, null); g.setColor(Color.red); g.fillRect(0, 0, 100, 100); g.setColor(Color.black); g.fillRect(0, 0, 100, 100); // after this the validated context color is black RenderQueue rq = dst.getContext().getRenderQueue(); rq.lock(); try { dst.getContext().saveState(); dst.getContext().restoreState(); } finally { rq.unlock(); } // this will cause ResetPaint (it will set color to extended EA=ff, // which is ffffffff==Color.white) g.drawImage(vi1, 95, 95, null); // now try filling with black again, but it will come up as white // because this fill rect won't validate the color properly g.setColor(Color.black); g.fillRect(0, 0, 100, 100); BufferedImage bi = vi.getSnapshot(); if (bi.getRGB(50, 50) != Color.black.getRGB()) { throw new RuntimeException("Test FAILED: found color="+ Integer.toHexString(bi.getRGB(50, 50))+" instead of "+ Integer.toHexString(Color.black.getRGB())); } System.out.println("Test PASSED."); }
Example 6
Source File: RSLContextInvalidationTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); VolatileImage vi = gc.createCompatibleVolatileImage(100, 100); vi.validate(gc); VolatileImage vi1 = gc.createCompatibleVolatileImage(100, 100); vi1.validate(gc); if (!(vi instanceof DestSurfaceProvider)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } DestSurfaceProvider p = (DestSurfaceProvider)vi; Surface s = p.getDestSurface(); if (!(s instanceof AccelSurface)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } AccelSurface dst = (AccelSurface)s; Graphics g = vi.createGraphics(); g.drawImage(vi1, 95, 95, null); g.setColor(Color.red); g.fillRect(0, 0, 100, 100); g.setColor(Color.black); g.fillRect(0, 0, 100, 100); // after this the validated context color is black RenderQueue rq = dst.getContext().getRenderQueue(); rq.lock(); try { dst.getContext().saveState(); dst.getContext().restoreState(); } finally { rq.unlock(); } // this will cause ResetPaint (it will set color to extended EA=ff, // which is ffffffff==Color.white) g.drawImage(vi1, 95, 95, null); // now try filling with black again, but it will come up as white // because this fill rect won't validate the color properly g.setColor(Color.black); g.fillRect(0, 0, 100, 100); BufferedImage bi = vi.getSnapshot(); if (bi.getRGB(50, 50) != Color.black.getRGB()) { throw new RuntimeException("Test FAILED: found color="+ Integer.toHexString(bi.getRGB(50, 50))+" instead of "+ Integer.toHexString(Color.black.getRGB())); } System.out.println("Test PASSED."); }
Example 7
Source File: RSLContextInvalidationTest.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); VolatileImage vi = gc.createCompatibleVolatileImage(100, 100); vi.validate(gc); VolatileImage vi1 = gc.createCompatibleVolatileImage(100, 100); vi1.validate(gc); if (!(vi instanceof DestSurfaceProvider)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } DestSurfaceProvider p = (DestSurfaceProvider)vi; Surface s = p.getDestSurface(); if (!(s instanceof AccelSurface)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } AccelSurface dst = (AccelSurface)s; Graphics g = vi.createGraphics(); g.drawImage(vi1, 95, 95, null); g.setColor(Color.red); g.fillRect(0, 0, 100, 100); g.setColor(Color.black); g.fillRect(0, 0, 100, 100); // after this the validated context color is black RenderQueue rq = dst.getContext().getRenderQueue(); rq.lock(); try { dst.getContext().saveState(); dst.getContext().restoreState(); } finally { rq.unlock(); } // this will cause ResetPaint (it will set color to extended EA=ff, // which is ffffffff==Color.white) g.drawImage(vi1, 95, 95, null); // now try filling with black again, but it will come up as white // because this fill rect won't validate the color properly g.setColor(Color.black); g.fillRect(0, 0, 100, 100); BufferedImage bi = vi.getSnapshot(); if (bi.getRGB(50, 50) != Color.black.getRGB()) { throw new RuntimeException("Test FAILED: found color="+ Integer.toHexString(bi.getRGB(50, 50))+" instead of "+ Integer.toHexString(Color.black.getRGB())); } System.out.println("Test PASSED."); }
Example 8
Source File: RSLContextInvalidationTest.java From hottub with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); VolatileImage vi = gc.createCompatibleVolatileImage(100, 100); vi.validate(gc); VolatileImage vi1 = gc.createCompatibleVolatileImage(100, 100); vi1.validate(gc); if (!(vi instanceof DestSurfaceProvider)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } DestSurfaceProvider p = (DestSurfaceProvider)vi; Surface s = p.getDestSurface(); if (!(s instanceof AccelSurface)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } AccelSurface dst = (AccelSurface)s; Graphics g = vi.createGraphics(); g.drawImage(vi1, 95, 95, null); g.setColor(Color.red); g.fillRect(0, 0, 100, 100); g.setColor(Color.black); g.fillRect(0, 0, 100, 100); // after this the validated context color is black RenderQueue rq = dst.getContext().getRenderQueue(); rq.lock(); try { dst.getContext().saveState(); dst.getContext().restoreState(); } finally { rq.unlock(); } // this will cause ResetPaint (it will set color to extended EA=ff, // which is ffffffff==Color.white) g.drawImage(vi1, 95, 95, null); // now try filling with black again, but it will come up as white // because this fill rect won't validate the color properly g.setColor(Color.black); g.fillRect(0, 0, 100, 100); BufferedImage bi = vi.getSnapshot(); if (bi.getRGB(50, 50) != Color.black.getRGB()) { throw new RuntimeException("Test FAILED: found color="+ Integer.toHexString(bi.getRGB(50, 50))+" instead of "+ Integer.toHexString(Color.black.getRGB())); } System.out.println("Test PASSED."); }
Example 9
Source File: RSLContextInvalidationTest.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); VolatileImage vi = gc.createCompatibleVolatileImage(100, 100); vi.validate(gc); VolatileImage vi1 = gc.createCompatibleVolatileImage(100, 100); vi1.validate(gc); if (!(vi instanceof DestSurfaceProvider)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } DestSurfaceProvider p = (DestSurfaceProvider)vi; Surface s = p.getDestSurface(); if (!(s instanceof AccelSurface)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } AccelSurface dst = (AccelSurface)s; Graphics g = vi.createGraphics(); g.drawImage(vi1, 95, 95, null); g.setColor(Color.red); g.fillRect(0, 0, 100, 100); g.setColor(Color.black); g.fillRect(0, 0, 100, 100); // after this the validated context color is black RenderQueue rq = dst.getContext().getRenderQueue(); rq.lock(); try { dst.getContext().saveState(); dst.getContext().restoreState(); } finally { rq.unlock(); } // this will cause ResetPaint (it will set color to extended EA=ff, // which is ffffffff==Color.white) g.drawImage(vi1, 95, 95, null); // now try filling with black again, but it will come up as white // because this fill rect won't validate the color properly g.setColor(Color.black); g.fillRect(0, 0, 100, 100); BufferedImage bi = vi.getSnapshot(); if (bi.getRGB(50, 50) != Color.black.getRGB()) { throw new RuntimeException("Test FAILED: found color="+ Integer.toHexString(bi.getRGB(50, 50))+" instead of "+ Integer.toHexString(Color.black.getRGB())); } System.out.println("Test PASSED."); }
Example 10
Source File: RSLContextInvalidationTest.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); VolatileImage vi = gc.createCompatibleVolatileImage(100, 100); vi.validate(gc); VolatileImage vi1 = gc.createCompatibleVolatileImage(100, 100); vi1.validate(gc); if (!(vi instanceof DestSurfaceProvider)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } DestSurfaceProvider p = (DestSurfaceProvider)vi; Surface s = p.getDestSurface(); if (!(s instanceof AccelSurface)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } AccelSurface dst = (AccelSurface)s; Graphics g = vi.createGraphics(); g.drawImage(vi1, 95, 95, null); g.setColor(Color.red); g.fillRect(0, 0, 100, 100); g.setColor(Color.black); g.fillRect(0, 0, 100, 100); // after this the validated context color is black RenderQueue rq = dst.getContext().getRenderQueue(); rq.lock(); try { dst.getContext().saveState(); dst.getContext().restoreState(); } finally { rq.unlock(); } // this will cause ResetPaint (it will set color to extended EA=ff, // which is ffffffff==Color.white) g.drawImage(vi1, 95, 95, null); // now try filling with black again, but it will come up as white // because this fill rect won't validate the color properly g.setColor(Color.black); g.fillRect(0, 0, 100, 100); BufferedImage bi = vi.getSnapshot(); if (bi.getRGB(50, 50) != Color.black.getRGB()) { throw new RuntimeException("Test FAILED: found color="+ Integer.toHexString(bi.getRGB(50, 50))+" instead of "+ Integer.toHexString(Color.black.getRGB())); } System.out.println("Test PASSED."); }
Example 11
Source File: RSLContextInvalidationTest.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); VolatileImage vi = gc.createCompatibleVolatileImage(100, 100); vi.validate(gc); VolatileImage vi1 = gc.createCompatibleVolatileImage(100, 100); vi1.validate(gc); if (!(vi instanceof DestSurfaceProvider)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } DestSurfaceProvider p = (DestSurfaceProvider)vi; Surface s = p.getDestSurface(); if (!(s instanceof AccelSurface)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } AccelSurface dst = (AccelSurface)s; Graphics g = vi.createGraphics(); g.drawImage(vi1, 95, 95, null); g.setColor(Color.red); g.fillRect(0, 0, 100, 100); g.setColor(Color.black); g.fillRect(0, 0, 100, 100); // after this the validated context color is black RenderQueue rq = dst.getContext().getRenderQueue(); rq.lock(); try { dst.getContext().saveState(); dst.getContext().restoreState(); } finally { rq.unlock(); } // this will cause ResetPaint (it will set color to extended EA=ff, // which is ffffffff==Color.white) g.drawImage(vi1, 95, 95, null); // now try filling with black again, but it will come up as white // because this fill rect won't validate the color properly g.setColor(Color.black); g.fillRect(0, 0, 100, 100); BufferedImage bi = vi.getSnapshot(); if (bi.getRGB(50, 50) != Color.black.getRGB()) { throw new RuntimeException("Test FAILED: found color="+ Integer.toHexString(bi.getRGB(50, 50))+" instead of "+ Integer.toHexString(Color.black.getRGB())); } System.out.println("Test PASSED."); }
Example 12
Source File: RSLContextInvalidationTest.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); VolatileImage vi = gc.createCompatibleVolatileImage(100, 100); vi.validate(gc); VolatileImage vi1 = gc.createCompatibleVolatileImage(100, 100); vi1.validate(gc); if (!(vi instanceof DestSurfaceProvider)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } DestSurfaceProvider p = (DestSurfaceProvider)vi; Surface s = p.getDestSurface(); if (!(s instanceof AccelSurface)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } AccelSurface dst = (AccelSurface)s; Graphics g = vi.createGraphics(); g.drawImage(vi1, 95, 95, null); g.setColor(Color.red); g.fillRect(0, 0, 100, 100); g.setColor(Color.black); g.fillRect(0, 0, 100, 100); // after this the validated context color is black RenderQueue rq = dst.getContext().getRenderQueue(); rq.lock(); try { dst.getContext().saveState(); dst.getContext().restoreState(); } finally { rq.unlock(); } // this will cause ResetPaint (it will set color to extended EA=ff, // which is ffffffff==Color.white) g.drawImage(vi1, 95, 95, null); // now try filling with black again, but it will come up as white // because this fill rect won't validate the color properly g.setColor(Color.black); g.fillRect(0, 0, 100, 100); BufferedImage bi = vi.getSnapshot(); if (bi.getRGB(50, 50) != Color.black.getRGB()) { throw new RuntimeException("Test FAILED: found color="+ Integer.toHexString(bi.getRGB(50, 50))+" instead of "+ Integer.toHexString(Color.black.getRGB())); } System.out.println("Test PASSED."); }
Example 13
Source File: RSLContextInvalidationTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); VolatileImage vi = gc.createCompatibleVolatileImage(100, 100); vi.validate(gc); VolatileImage vi1 = gc.createCompatibleVolatileImage(100, 100); vi1.validate(gc); if (!(vi instanceof DestSurfaceProvider)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } DestSurfaceProvider p = (DestSurfaceProvider)vi; Surface s = p.getDestSurface(); if (!(s instanceof AccelSurface)) { System.out.println("Test considered PASSED: no HW acceleration"); return; } AccelSurface dst = (AccelSurface)s; Graphics g = vi.createGraphics(); g.drawImage(vi1, 95, 95, null); g.setColor(Color.red); g.fillRect(0, 0, 100, 100); g.setColor(Color.black); g.fillRect(0, 0, 100, 100); // after this the validated context color is black RenderQueue rq = dst.getContext().getRenderQueue(); rq.lock(); try { dst.getContext().saveState(); dst.getContext().restoreState(); } finally { rq.unlock(); } // this will cause ResetPaint (it will set color to extended EA=ff, // which is ffffffff==Color.white) g.drawImage(vi1, 95, 95, null); // now try filling with black again, but it will come up as white // because this fill rect won't validate the color properly g.setColor(Color.black); g.fillRect(0, 0, 100, 100); BufferedImage bi = vi.getSnapshot(); if (bi.getRGB(50, 50) != Color.black.getRGB()) { throw new RuntimeException("Test FAILED: found color="+ Integer.toHexString(bi.getRGB(50, 50))+" instead of "+ Integer.toHexString(Color.black.getRGB())); } System.out.println("Test PASSED."); }