Java Code Examples for sun.java2d.pipe.hw.AccelGraphicsConfig#createCompatibleVolatileImage()

The following examples show how to use sun.java2d.pipe.hw.AccelGraphicsConfig#createCompatibleVolatileImage() . 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: TranslucentWindowPainter.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Image getBackBuffer(boolean clear) {
    int w = window.getWidth();
    int h = window.getHeight();
    GraphicsConfiguration gc = peer.getGraphicsConfiguration();

    if (viBB == null || viBB.getWidth() != w || viBB.getHeight() != h ||
        viBB.validate(gc) == IMAGE_INCOMPATIBLE)
    {
        flush();

        if (gc instanceof AccelGraphicsConfig) {
            AccelGraphicsConfig agc = ((AccelGraphicsConfig)gc);
            viBB = agc.createCompatibleVolatileImage(w, h,
                                                     TRANSLUCENT,
                                                     RT_PLAIN);
        }
        if (viBB == null) {
            viBB = gc.createCompatibleVolatileImage(w, h, TRANSLUCENT);
        }
        viBB.validate(gc);
    }

    return clear ? clearImage(viBB) : viBB;
}
 
Example 2
Source File: TranslucentWindowPainter.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Image getBackBuffer(boolean clear) {
    int w = window.getWidth();
    int h = window.getHeight();
    GraphicsConfiguration gc = peer.getGraphicsConfiguration();

    if (viBB == null || viBB.getWidth() != w || viBB.getHeight() != h ||
        viBB.validate(gc) == IMAGE_INCOMPATIBLE)
    {
        flush();

        if (gc instanceof AccelGraphicsConfig) {
            AccelGraphicsConfig agc = ((AccelGraphicsConfig)gc);
            viBB = agc.createCompatibleVolatileImage(w, h,
                                                     TRANSLUCENT,
                                                     RT_PLAIN);
        }
        if (viBB == null) {
            viBB = gc.createCompatibleVolatileImage(w, h, TRANSLUCENT);
        }
        viBB.validate(gc);
    }

    return clear ? clearImage(viBB) : viBB;
}
 
Example 3
Source File: TranslucentWindowPainter.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Image getBackBuffer(boolean clear) {
    int w = window.getWidth();
    int h = window.getHeight();
    GraphicsConfiguration gc = peer.getGraphicsConfiguration();

    if (viBB == null || viBB.getWidth() != w || viBB.getHeight() != h ||
        viBB.validate(gc) == IMAGE_INCOMPATIBLE)
    {
        flush();

        if (gc instanceof AccelGraphicsConfig) {
            AccelGraphicsConfig agc = ((AccelGraphicsConfig)gc);
            viBB = agc.createCompatibleVolatileImage(w, h,
                                                     TRANSLUCENT,
                                                     RT_PLAIN);
        }
        if (viBB == null) {
            viBB = gc.createCompatibleVolatileImage(w, h, TRANSLUCENT);
        }
        viBB.validate(gc);
    }

    return clear ? clearImage(viBB) : viBB;
}
 
Example 4
Source File: TranslucentWindowPainter.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Image getBackBuffer(boolean clear) {
    int w = window.getWidth();
    int h = window.getHeight();
    GraphicsConfiguration gc = peer.getGraphicsConfiguration();

    if (viBB == null || viBB.getWidth() != w || viBB.getHeight() != h ||
        viBB.validate(gc) == IMAGE_INCOMPATIBLE)
    {
        flush();

        if (gc instanceof AccelGraphicsConfig) {
            AccelGraphicsConfig agc = ((AccelGraphicsConfig)gc);
            viBB = agc.createCompatibleVolatileImage(w, h,
                                                     TRANSLUCENT,
                                                     RT_PLAIN);
        }
        if (viBB == null) {
            viBB = gc.createCompatibleVolatileImage(w, h, TRANSLUCENT);
        }
        viBB.validate(gc);
    }

    return clear ? clearImage(viBB) : viBB;
}
 
Example 5
Source File: TranslucentWindowPainter.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Image getBackBuffer(boolean clear) {
    int w = window.getWidth();
    int h = window.getHeight();
    GraphicsConfiguration gc = peer.getGraphicsConfiguration();

    if (viBB == null || viBB.getWidth() != w || viBB.getHeight() != h ||
        viBB.validate(gc) == IMAGE_INCOMPATIBLE)
    {
        flush();

        if (gc instanceof AccelGraphicsConfig) {
            AccelGraphicsConfig agc = ((AccelGraphicsConfig)gc);
            viBB = agc.createCompatibleVolatileImage(w, h,
                                                     TRANSLUCENT,
                                                     RT_PLAIN);
        }
        if (viBB == null) {
            viBB = gc.createCompatibleVolatileImage(w, h, TRANSLUCENT);
        }
        viBB.validate(gc);
    }

    return clear ? clearImage(viBB) : viBB;
}
 
Example 6
Source File: TranslucentWindowPainter.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Image getBackBuffer(boolean clear) {
    int w = window.getWidth();
    int h = window.getHeight();
    GraphicsConfiguration gc = peer.getGraphicsConfiguration();

    if (viBB == null || viBB.getWidth() != w || viBB.getHeight() != h ||
        viBB.validate(gc) == IMAGE_INCOMPATIBLE)
    {
        flush();

        if (gc instanceof AccelGraphicsConfig) {
            AccelGraphicsConfig agc = ((AccelGraphicsConfig)gc);
            viBB = agc.createCompatibleVolatileImage(w, h,
                                                     TRANSLUCENT,
                                                     RT_PLAIN);
        }
        if (viBB == null) {
            viBB = gc.createCompatibleVolatileImage(w, h, TRANSLUCENT);
        }
        viBB.validate(gc);
    }

    return clear ? clearImage(viBB) : viBB;
}
 
Example 7
Source File: TranslucentWindowPainter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Image getBackBuffer(boolean clear) {
    int w = window.getWidth();
    int h = window.getHeight();
    GraphicsConfiguration gc = peer.getGraphicsConfiguration();

    if (viBB == null || viBB.getWidth() != w || viBB.getHeight() != h ||
        viBB.validate(gc) == IMAGE_INCOMPATIBLE)
    {
        flush();

        if (gc instanceof AccelGraphicsConfig) {
            AccelGraphicsConfig agc = ((AccelGraphicsConfig)gc);
            viBB = agc.createCompatibleVolatileImage(w, h,
                                                     TRANSLUCENT,
                                                     RT_PLAIN);
        }
        if (viBB == null) {
            viBB = gc.createCompatibleVolatileImage(w, h, TRANSLUCENT);
        }
        viBB.validate(gc);
    }

    return clear ? clearImage(viBB) : viBB;
}
 
Example 8
Source File: TranslucentWindowPainter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Image getBackBuffer(boolean clear) {
    int w = window.getWidth();
    int h = window.getHeight();
    GraphicsConfiguration gc = peer.getGraphicsConfiguration();

    if (viBB == null || viBB.getWidth() != w || viBB.getHeight() != h ||
        viBB.validate(gc) == IMAGE_INCOMPATIBLE)
    {
        flush();

        if (gc instanceof AccelGraphicsConfig) {
            AccelGraphicsConfig agc = ((AccelGraphicsConfig)gc);
            viBB = agc.createCompatibleVolatileImage(w, h,
                                                     TRANSLUCENT,
                                                     RT_PLAIN);
        }
        if (viBB == null) {
            viBB = gc.createCompatibleVolatileImage(w, h, TRANSLUCENT);
        }
        viBB.validate(gc);
    }

    return clear ? clearImage(viBB) : viBB;
}
 
Example 9
Source File: TranslucentWindowPainter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Image getBackBuffer(boolean clear) {
    int w = window.getWidth();
    int h = window.getHeight();
    GraphicsConfiguration gc = peer.getGraphicsConfiguration();

    if (viBB == null || viBB.getWidth() != w || viBB.getHeight() != h ||
        viBB.validate(gc) == IMAGE_INCOMPATIBLE)
    {
        flush();

        if (gc instanceof AccelGraphicsConfig) {
            AccelGraphicsConfig agc = ((AccelGraphicsConfig)gc);
            viBB = agc.createCompatibleVolatileImage(w, h,
                                                     TRANSLUCENT,
                                                     RT_PLAIN);
        }
        if (viBB == null) {
            viBB = gc.createCompatibleVolatileImage(w, h, TRANSLUCENT);
        }
        viBB.validate(gc);
    }

    return clear ? clearImage(viBB) : viBB;
}
 
Example 10
Source File: TranslucentWindowPainter.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Image getBackBuffer(boolean clear) {
    int w = window.getWidth();
    int h = window.getHeight();
    GraphicsConfiguration gc = peer.getGraphicsConfiguration();

    if (viBB == null || viBB.getWidth() != w || viBB.getHeight() != h ||
        viBB.validate(gc) == IMAGE_INCOMPATIBLE)
    {
        flush();

        if (gc instanceof AccelGraphicsConfig) {
            AccelGraphicsConfig agc = ((AccelGraphicsConfig)gc);
            viBB = agc.createCompatibleVolatileImage(w, h,
                                                     TRANSLUCENT,
                                                     RT_PLAIN);
        }
        if (viBB == null) {
            viBB = gc.createCompatibleVolatileImage(w, h, TRANSLUCENT);
        }
        viBB.validate(gc);
    }

    return clear ? clearImage(viBB) : viBB;
}
 
Example 11
Source File: TranslucentWindowPainter.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected Image getBackBuffer(boolean clear) {
    int w = window.getWidth();
    int h = window.getHeight();
    GraphicsConfiguration gc = peer.getGraphicsConfiguration();

    if (viBB == null || viBB.getWidth() != w || viBB.getHeight() != h ||
        viBB.validate(gc) == IMAGE_INCOMPATIBLE ||
        !checkScaleValid(viBB))
    {
        Image oldViBB = viBB;
        flush();

        if (gc instanceof AccelGraphicsConfig) {
            AccelGraphicsConfig agc = ((AccelGraphicsConfig)gc);
            viBB = agc.createCompatibleVolatileImage(w, h,
                                                     TRANSLUCENT,
                                                     RT_PLAIN);
        }
        if (viBB == null) {
            viBB = gc.createCompatibleVolatileImage(w, h, TRANSLUCENT);
        }
        paintOld(oldViBB, viBB);
        viBB.validate(gc);
    }

    return clear ? clearImage(viBB) : viBB;
}
 
Example 12
Source File: RSLAPITest.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static void testVICreation(AccelGraphicsConfig agc, int cap,
                                   int transparency, int type)
{
    int caps = agc.getContextCapabilities().getCaps();
    int w = 11, h = 17;

    VolatileImage vi =
        agc.createCompatibleVolatileImage(w, h, transparency, type);
    if ((cap & caps) != 0) {
        if (vi == null) {
            System.out.printf("Failed: cap=%d is supported but " +
                              "image wasn't created\n", cap);
            throw new RuntimeException("Failed: image wasn't created " +
                                       "for supported cap");
        } else {
            if (!(vi instanceof DestSurfaceProvider)) {
                throw new RuntimeException("Failed: created VI is not " +
                                           "DestSurfaceProvider");
            }
            Surface s = ((DestSurfaceProvider) vi).getDestSurface();
            if (s instanceof AccelSurface) {
                AccelSurface as = (AccelSurface) s;
                printSurface(as);
                if (as.getType() != type) {
                    throw new RuntimeException("Failed: returned VI is" +
                            " of incorrect type: " + as.getType() +
                            " requested type=" + type);
                } else {
                    System.out.printf("Passed: VI of type %d was " +
                            "created for cap=%d\n", type, cap);
                }
                if (as.getType() == TEXTURE) {
                    boolean ex = false;
                    try {
                        Graphics g = vi.getGraphics();
                        g.dispose();
                    } catch (UnsupportedOperationException e) {
                        ex = true;
                    }
                    if (!ex) {
                        throw new RuntimeException("Failed: " +
                            "texture.getGraphics() didn't throw exception");
                    } else {
                        System.out.println("Passed: VI.getGraphics()" +
                                " threw exception for texture-based VI");
                    }
                }
            } else {
                System.out.printf("Passed: VI of type %d was " +
                        "created for cap=%d but accel surface is null\n",
                        type, cap);
            }
        }
    } else {
        if (vi != null) {
            throw new RuntimeException("Failed: created VI for " +
                                       "unsupported cap=" + cap);
        }
    }
}
 
Example 13
Source File: RSLAPITest.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void testVICreation(AccelGraphicsConfig agc, int cap,
                                   int transparency, int type)
{
    int caps = agc.getContextCapabilities().getCaps();
    int w = 11, h = 17;

    VolatileImage vi =
        agc.createCompatibleVolatileImage(w, h, transparency, type);
    if ((cap & caps) != 0) {
        if (vi == null) {
            System.out.printf("Failed: cap=%d is supported but " +
                              "image wasn't created\n", cap);
            throw new RuntimeException("Failed: image wasn't created " +
                                       "for supported cap");
        } else {
            if (!(vi instanceof DestSurfaceProvider)) {
                throw new RuntimeException("Failed: created VI is not " +
                                           "DestSurfaceProvider");
            }
            Surface s = ((DestSurfaceProvider) vi).getDestSurface();
            if (s instanceof AccelSurface) {
                AccelSurface as = (AccelSurface) s;
                printSurface(as);
                if (as.getType() != type) {
                    throw new RuntimeException("Failed: returned VI is" +
                            " of incorrect type: " + as.getType() +
                            " requested type=" + type);
                } else {
                    System.out.printf("Passed: VI of type %d was " +
                            "created for cap=%d\n", type, cap);
                }
                if (as.getType() == TEXTURE) {
                    boolean ex = false;
                    try {
                        Graphics g = vi.getGraphics();
                        g.dispose();
                    } catch (UnsupportedOperationException e) {
                        ex = true;
                    }
                    if (!ex) {
                        throw new RuntimeException("Failed: " +
                            "texture.getGraphics() didn't throw exception");
                    } else {
                        System.out.println("Passed: VI.getGraphics()" +
                                " threw exception for texture-based VI");
                    }
                }
            } else {
                System.out.printf("Passed: VI of type %d was " +
                        "created for cap=%d but accel surface is null\n",
                        type, cap);
            }
        }
    } else {
        if (vi != null) {
            throw new RuntimeException("Failed: created VI for " +
                                       "unsupported cap=" + cap);
        }
    }
}
 
Example 14
Source File: RSLAPITest.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private static void testVICreation(AccelGraphicsConfig agc, int cap,
                                   int transparency, int type)
{
    int caps = agc.getContextCapabilities().getCaps();
    int w = 11, h = 17;

    VolatileImage vi =
        agc.createCompatibleVolatileImage(w, h, transparency, type);
    if ((cap & caps) != 0) {
        if (vi == null) {
            System.out.printf("Failed: cap=%d is supported but " +
                              "image wasn't created\n", cap);
            throw new RuntimeException("Failed: image wasn't created " +
                                       "for supported cap");
        } else {
            if (!(vi instanceof DestSurfaceProvider)) {
                throw new RuntimeException("Failed: created VI is not " +
                                           "DestSurfaceProvider");
            }
            Surface s = ((DestSurfaceProvider) vi).getDestSurface();
            if (s instanceof AccelSurface) {
                AccelSurface as = (AccelSurface) s;
                printSurface(as);
                if (as.getType() != type) {
                    throw new RuntimeException("Failed: returned VI is" +
                            " of incorrect type: " + as.getType() +
                            " requested type=" + type);
                } else {
                    System.out.printf("Passed: VI of type %d was " +
                            "created for cap=%d\n", type, cap);
                }
                if (as.getType() == TEXTURE) {
                    boolean ex = false;
                    try {
                        Graphics g = vi.getGraphics();
                        g.dispose();
                    } catch (UnsupportedOperationException e) {
                        ex = true;
                    }
                    if (!ex) {
                        throw new RuntimeException("Failed: " +
                            "texture.getGraphics() didn't throw exception");
                    } else {
                        System.out.println("Passed: VI.getGraphics()" +
                                " threw exception for texture-based VI");
                    }
                }
            } else {
                System.out.printf("Passed: VI of type %d was " +
                        "created for cap=%d but accel surface is null\n",
                        type, cap);
            }
        }
    } else {
        if (vi != null) {
            throw new RuntimeException("Failed: created VI for " +
                                       "unsupported cap=" + cap);
        }
    }
}
 
Example 15
Source File: RSLAPITest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private static void testVICreation(AccelGraphicsConfig agc, int cap,
                                   int transparency, int type)
{
    int caps = agc.getContextCapabilities().getCaps();
    int w = 11, h = 17;

    VolatileImage vi =
        agc.createCompatibleVolatileImage(w, h, transparency, type);
    if ((cap & caps) != 0) {
        if (vi == null) {
            System.out.printf("Failed: cap=%d is supported but " +
                              "image wasn't created\n", cap);
            throw new RuntimeException("Failed: image wasn't created " +
                                       "for supported cap");
        } else {
            if (!(vi instanceof DestSurfaceProvider)) {
                throw new RuntimeException("Failed: created VI is not " +
                                           "DestSurfaceProvider");
            }
            Surface s = ((DestSurfaceProvider) vi).getDestSurface();
            if (s instanceof AccelSurface) {
                AccelSurface as = (AccelSurface) s;
                printSurface(as);
                if (as.getType() != type) {
                    throw new RuntimeException("Failed: returned VI is" +
                            " of incorrect type: " + as.getType() +
                            " requested type=" + type);
                } else {
                    System.out.printf("Passed: VI of type %d was " +
                            "created for cap=%d\n", type, cap);
                }
                if (as.getType() == TEXTURE) {
                    boolean ex = false;
                    try {
                        Graphics g = vi.getGraphics();
                        g.dispose();
                    } catch (UnsupportedOperationException e) {
                        ex = true;
                    }
                    if (!ex) {
                        throw new RuntimeException("Failed: " +
                            "texture.getGraphics() didn't throw exception");
                    } else {
                        System.out.println("Passed: VI.getGraphics()" +
                                " threw exception for texture-based VI");
                    }
                }
            } else {
                System.out.printf("Passed: VI of type %d was " +
                        "created for cap=%d but accel surface is null\n",
                        type, cap);
            }
        }
    } else {
        if (vi != null) {
            throw new RuntimeException("Failed: created VI for " +
                                       "unsupported cap=" + cap);
        }
    }
}
 
Example 16
Source File: RSLAPITest.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void testVICreation(AccelGraphicsConfig agc, int cap,
                                   int transparency, int type)
{
    int caps = agc.getContextCapabilities().getCaps();
    int w = 11, h = 17;

    VolatileImage vi =
        agc.createCompatibleVolatileImage(w, h, transparency, type);
    if ((cap & caps) != 0) {
        if (vi == null) {
            System.out.printf("Failed: cap=%d is supported but " +
                              "image wasn't created\n", cap);
            throw new RuntimeException("Failed: image wasn't created " +
                                       "for supported cap");
        } else {
            if (!(vi instanceof DestSurfaceProvider)) {
                throw new RuntimeException("Failed: created VI is not " +
                                           "DestSurfaceProvider");
            }
            Surface s = ((DestSurfaceProvider) vi).getDestSurface();
            if (s instanceof AccelSurface) {
                AccelSurface as = (AccelSurface) s;
                printSurface(as);
                if (as.getType() != type) {
                    throw new RuntimeException("Failed: returned VI is" +
                            " of incorrect type: " + as.getType() +
                            " requested type=" + type);
                } else {
                    System.out.printf("Passed: VI of type %d was " +
                            "created for cap=%d\n", type, cap);
                }
                if (as.getType() == TEXTURE) {
                    boolean ex = false;
                    try {
                        Graphics g = vi.getGraphics();
                        g.dispose();
                    } catch (UnsupportedOperationException e) {
                        ex = true;
                    }
                    if (!ex) {
                        throw new RuntimeException("Failed: " +
                            "texture.getGraphics() didn't throw exception");
                    } else {
                        System.out.println("Passed: VI.getGraphics()" +
                                " threw exception for texture-based VI");
                    }
                }
            } else {
                System.out.printf("Passed: VI of type %d was " +
                        "created for cap=%d but accel surface is null\n",
                        type, cap);
            }
        }
    } else {
        if (vi != null) {
            throw new RuntimeException("Failed: created VI for " +
                                       "unsupported cap=" + cap);
        }
    }
}
 
Example 17
Source File: RSLAPITest.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void testVICreation(AccelGraphicsConfig agc, int cap,
                                   int transparency, int type)
{
    int caps = agc.getContextCapabilities().getCaps();
    int w = 11, h = 17;

    VolatileImage vi =
        agc.createCompatibleVolatileImage(w, h, transparency, type);
    if ((cap & caps) != 0) {
        if (vi == null) {
            System.out.printf("Failed: cap=%d is supported but " +
                              "image wasn't created\n", cap);
            throw new RuntimeException("Failed: image wasn't created " +
                                       "for supported cap");
        } else {
            if (!(vi instanceof DestSurfaceProvider)) {
                throw new RuntimeException("Failed: created VI is not " +
                                           "DestSurfaceProvider");
            }
            Surface s = ((DestSurfaceProvider) vi).getDestSurface();
            if (s instanceof AccelSurface) {
                AccelSurface as = (AccelSurface) s;
                printSurface(as);
                if (as.getType() != type) {
                    throw new RuntimeException("Failed: returned VI is" +
                            " of incorrect type: " + as.getType() +
                            " requested type=" + type);
                } else {
                    System.out.printf("Passed: VI of type %d was " +
                            "created for cap=%d\n", type, cap);
                }
                if (as.getType() == TEXTURE) {
                    boolean ex = false;
                    try {
                        Graphics g = vi.getGraphics();
                        g.dispose();
                    } catch (UnsupportedOperationException e) {
                        ex = true;
                    }
                    if (!ex) {
                        throw new RuntimeException("Failed: " +
                            "texture.getGraphics() didn't throw exception");
                    } else {
                        System.out.println("Passed: VI.getGraphics()" +
                                " threw exception for texture-based VI");
                    }
                }
            } else {
                System.out.printf("Passed: VI of type %d was " +
                        "created for cap=%d but accel surface is null\n",
                        type, cap);
            }
        }
    } else {
        if (vi != null) {
            throw new RuntimeException("Failed: created VI for " +
                                       "unsupported cap=" + cap);
        }
    }
}
 
Example 18
Source File: RSLAPITest.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private static void testVICreation(AccelGraphicsConfig agc, int cap,
                                   int transparency, int type)
{
    int caps = agc.getContextCapabilities().getCaps();
    int w = 11, h = 17;

    VolatileImage vi =
        agc.createCompatibleVolatileImage(w, h, transparency, type);
    if ((cap & caps) != 0) {
        if (vi == null) {
            System.out.printf("Failed: cap=%d is supported but " +
                              "image wasn't created\n", cap);
            throw new RuntimeException("Failed: image wasn't created " +
                                       "for supported cap");
        } else {
            if (!(vi instanceof DestSurfaceProvider)) {
                throw new RuntimeException("Failed: created VI is not " +
                                           "DestSurfaceProvider");
            }
            Surface s = ((DestSurfaceProvider) vi).getDestSurface();
            if (s instanceof AccelSurface) {
                AccelSurface as = (AccelSurface) s;
                printSurface(as);
                if (as.getType() != type) {
                    throw new RuntimeException("Failed: returned VI is" +
                            " of incorrect type: " + as.getType() +
                            " requested type=" + type);
                } else {
                    System.out.printf("Passed: VI of type %d was " +
                            "created for cap=%d\n", type, cap);
                }
                if (as.getType() == TEXTURE) {
                    boolean ex = false;
                    try {
                        Graphics g = vi.getGraphics();
                        g.dispose();
                    } catch (UnsupportedOperationException e) {
                        ex = true;
                    }
                    if (!ex) {
                        throw new RuntimeException("Failed: " +
                            "texture.getGraphics() didn't throw exception");
                    } else {
                        System.out.println("Passed: VI.getGraphics()" +
                                " threw exception for texture-based VI");
                    }
                }
            } else {
                System.out.printf("Passed: VI of type %d was " +
                        "created for cap=%d but accel surface is null\n",
                        type, cap);
            }
        }
    } else {
        if (vi != null) {
            throw new RuntimeException("Failed: created VI for " +
                                       "unsupported cap=" + cap);
        }
    }
}
 
Example 19
Source File: RSLAPITest.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private static void testVICreation(AccelGraphicsConfig agc, int cap,
                                   int transparency, int type)
{
    int caps = agc.getContextCapabilities().getCaps();
    int w = 11, h = 17;

    VolatileImage vi =
        agc.createCompatibleVolatileImage(w, h, transparency, type);
    if ((cap & caps) != 0) {
        if (vi == null) {
            System.out.printf("Failed: cap=%d is supported but " +
                              "image wasn't created\n", cap);
            throw new RuntimeException("Failed: image wasn't created " +
                                       "for supported cap");
        } else {
            if (!(vi instanceof DestSurfaceProvider)) {
                throw new RuntimeException("Failed: created VI is not " +
                                           "DestSurfaceProvider");
            }
            Surface s = ((DestSurfaceProvider) vi).getDestSurface();
            if (s instanceof AccelSurface) {
                AccelSurface as = (AccelSurface) s;
                printSurface(as);
                if (as.getType() != type) {
                    throw new RuntimeException("Failed: returned VI is" +
                            " of incorrect type: " + as.getType() +
                            " requested type=" + type);
                } else {
                    System.out.printf("Passed: VI of type %d was " +
                            "created for cap=%d\n", type, cap);
                }
                if (as.getType() == TEXTURE) {
                    boolean ex = false;
                    try {
                        Graphics g = vi.getGraphics();
                        g.dispose();
                    } catch (UnsupportedOperationException e) {
                        ex = true;
                    }
                    if (!ex) {
                        throw new RuntimeException("Failed: " +
                            "texture.getGraphics() didn't throw exception");
                    } else {
                        System.out.println("Passed: VI.getGraphics()" +
                                " threw exception for texture-based VI");
                    }
                }
            } else {
                System.out.printf("Passed: VI of type %d was " +
                        "created for cap=%d but accel surface is null\n",
                        type, cap);
            }
        }
    } else {
        if (vi != null) {
            throw new RuntimeException("Failed: created VI for " +
                                       "unsupported cap=" + cap);
        }
    }
}
 
Example 20
Source File: RSLAPITest.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private static void testVICreation(AccelGraphicsConfig agc, int cap,
                                   int transparency, int type)
{
    int caps = agc.getContextCapabilities().getCaps();
    int w = 11, h = 17;

    VolatileImage vi =
        agc.createCompatibleVolatileImage(w, h, transparency, type);
    if ((cap & caps) != 0) {
        if (vi == null) {
            System.out.printf("Failed: cap=%d is supported but " +
                              "image wasn't created\n", cap);
            throw new RuntimeException("Failed: image wasn't created " +
                                       "for supported cap");
        } else {
            if (!(vi instanceof DestSurfaceProvider)) {
                throw new RuntimeException("Failed: created VI is not " +
                                           "DestSurfaceProvider");
            }
            Surface s = ((DestSurfaceProvider) vi).getDestSurface();
            if (s instanceof AccelSurface) {
                AccelSurface as = (AccelSurface) s;
                printSurface(as);
                if (as.getType() != type) {
                    throw new RuntimeException("Failed: returned VI is" +
                            " of incorrect type: " + as.getType() +
                            " requested type=" + type);
                } else {
                    System.out.printf("Passed: VI of type %d was " +
                            "created for cap=%d\n", type, cap);
                }
                if (as.getType() == TEXTURE) {
                    boolean ex = false;
                    try {
                        Graphics g = vi.getGraphics();
                        g.dispose();
                    } catch (UnsupportedOperationException e) {
                        ex = true;
                    }
                    if (!ex) {
                        throw new RuntimeException("Failed: " +
                            "texture.getGraphics() didn't throw exception");
                    } else {
                        System.out.println("Passed: VI.getGraphics()" +
                                " threw exception for texture-based VI");
                    }
                }
            } else {
                System.out.printf("Passed: VI of type %d was " +
                        "created for cap=%d but accel surface is null\n",
                        type, cap);
            }
        }
    } else {
        if (vi != null) {
            throw new RuntimeException("Failed: created VI for " +
                                       "unsupported cap=" + cap);
        }
    }
}