Search in sources :

Example 1 with RenderQueue

use of sun.java2d.pipe.RenderQueue in project jdk8u_jdk by JetBrains.

the class RSLContextInvalidationTest method main.

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.");
}
Also used : Graphics(java.awt.Graphics) GraphicsDevice(java.awt.GraphicsDevice) VolatileImage(java.awt.image.VolatileImage) DestSurfaceProvider(sun.java2d.DestSurfaceProvider) RenderQueue(sun.java2d.pipe.RenderQueue) GraphicsEnvironment(java.awt.GraphicsEnvironment) BufferedImage(java.awt.image.BufferedImage) GraphicsConfiguration(java.awt.GraphicsConfiguration) Surface(sun.java2d.Surface)

Example 2 with RenderQueue

use of sun.java2d.pipe.RenderQueue in project jdk8u_jdk by JetBrains.

the class RSLAPITest method testContext.

private static void testContext(final AccelGraphicsConfig agc) {
    BufferedContext c = agc.getContext();
    final AccelDeviceEventListener l = new AccelDeviceEventListener() {

        public void onDeviceDispose() {
            System.out.println("onDeviceDispose invoked");
            agc.removeDeviceEventListener(this);
        }

        public void onDeviceReset() {
            System.out.println("onDeviceReset invoked");
        }
    };
    agc.addDeviceEventListener(l);
    RenderQueue rq = c.getRenderQueue();
    rq.lock();
    try {
        c.saveState();
        rq.flushNow();
        c.restoreState();
        rq.flushNow();
        System.out.println("Passed: Save/Restore");
    } finally {
        rq.unlock();
    }
}
Also used : RenderQueue(sun.java2d.pipe.RenderQueue) AccelDeviceEventListener(sun.java2d.pipe.hw.AccelDeviceEventListener) BufferedContext(sun.java2d.pipe.BufferedContext)

Example 3 with RenderQueue

use of sun.java2d.pipe.RenderQueue in project jdk8u_jdk by JetBrains.

the class StrikeCache method disposeStrike.

static void disposeStrike(final FontStrikeDisposer disposer) {
    if (Disposer.pollingQueue) {
        doDispose(disposer);
        return;
    }
    RenderQueue rq = null;
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    if (!ge.isHeadless()) {
        GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
        if (gc instanceof AccelGraphicsConfig) {
            AccelGraphicsConfig agc = (AccelGraphicsConfig) gc;
            BufferedContext bc = agc.getContext();
            if (bc != null) {
                rq = bc.getRenderQueue();
            }
        }
    }
    if (rq != null) {
        rq.lock();
        try {
            rq.flushAndInvokeNow(new Runnable() {

                public void run() {
                    doDispose(disposer);
                    Disposer.pollRemove();
                }
            });
        } finally {
            rq.unlock();
        }
    } else {
        doDispose(disposer);
    }
}
Also used : AccelGraphicsConfig(sun.java2d.pipe.hw.AccelGraphicsConfig) RenderQueue(sun.java2d.pipe.RenderQueue) GraphicsEnvironment(java.awt.GraphicsEnvironment) GraphicsConfiguration(java.awt.GraphicsConfiguration) BufferedContext(sun.java2d.pipe.BufferedContext)

Example 4 with RenderQueue

use of sun.java2d.pipe.RenderQueue in project jdk8u_jdk by JetBrains.

the class RSLAPITest method printSurface.

private static void printSurface(Surface s) {
    if (s instanceof AccelSurface) {
        final AccelSurface surface = (AccelSurface) s;
        System.out.println(" Accel Surface: ");
        System.out.println("  type=" + surface.getType());
        System.out.println("  bounds=" + surface.getBounds());
        System.out.println("  nativeBounds=" + surface.getNativeBounds());
        System.out.println("  isSurfaceLost=" + surface.isSurfaceLost());
        System.out.println("  isValid=" + surface.isValid());
        RenderQueue rq = surface.getContext().getRenderQueue();
        rq.lock();
        try {
            rq.flushAndInvokeNow(new Runnable() {

                public void run() {
                    System.out.printf("  getNativeResource(TEXTURE)=0x%x\n", surface.getNativeResource(TEXTURE));
                    System.out.printf("  getNativeResource(RT_TEXTURE)=0x%x\n", surface.getNativeResource(RT_TEXTURE));
                    System.out.printf("  getNativeResource(RT_PLAIN)=0x%x\n", surface.getNativeResource(RT_PLAIN));
                    System.out.printf("  getNativeResource(FLIP_BACKBUFFER)=0x%x\n", surface.getNativeResource(FLIP_BACKBUFFER));
                    testD3DDeviceResourceField(surface);
                    testInvalidType(surface, -1);
                    testInvalidType(surface, -150);
                    testInvalidType(surface, 300);
                    testInvalidType(surface, Integer.MAX_VALUE);
                    testInvalidType(surface, Integer.MIN_VALUE);
                }
            });
        } finally {
            rq.unlock();
        }
    } else {
        System.out.println("null accelerated surface");
    }
}
Also used : AccelSurface(sun.java2d.pipe.hw.AccelSurface) RenderQueue(sun.java2d.pipe.RenderQueue)

Aggregations

RenderQueue (sun.java2d.pipe.RenderQueue)4 GraphicsConfiguration (java.awt.GraphicsConfiguration)2 GraphicsEnvironment (java.awt.GraphicsEnvironment)2 BufferedContext (sun.java2d.pipe.BufferedContext)2 Graphics (java.awt.Graphics)1 GraphicsDevice (java.awt.GraphicsDevice)1 BufferedImage (java.awt.image.BufferedImage)1 VolatileImage (java.awt.image.VolatileImage)1 DestSurfaceProvider (sun.java2d.DestSurfaceProvider)1 Surface (sun.java2d.Surface)1 AccelDeviceEventListener (sun.java2d.pipe.hw.AccelDeviceEventListener)1 AccelGraphicsConfig (sun.java2d.pipe.hw.AccelGraphicsConfig)1 AccelSurface (sun.java2d.pipe.hw.AccelSurface)1