Java Code Examples for sun.awt.X11GraphicsConfig#getColorModel()

The following examples show how to use sun.awt.X11GraphicsConfig#getColorModel() . 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: X11VolatileSurfaceManager.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a pixmap-based SurfaceData object
 */
protected SurfaceData initAcceleratedSurface() {
    SurfaceData sData;

    try {
        X11GraphicsConfig gc = (X11GraphicsConfig)vImg.getGraphicsConfig();
        ColorModel cm = gc.getColorModel();
        long drawable = 0;
        if (context instanceof Long) {
            drawable = ((Long)context).longValue();
        }
        sData = X11SurfaceData.createData(gc,
                                          vImg.getWidth(),
                                          vImg.getHeight(),
                                          cm, vImg, drawable,
                                          Transparency.OPAQUE);
    } catch (NullPointerException ex) {
        sData = null;
    } catch (OutOfMemoryError er) {
        sData = null;
    }

    return sData;
}
 
Example 2
Source File: X11VolatileSurfaceManager.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a pixmap-based SurfaceData object
 */
protected SurfaceData initAcceleratedSurface() {
    SurfaceData sData;

    try {
        X11GraphicsConfig gc = (X11GraphicsConfig)vImg.getGraphicsConfig();
        ColorModel cm = gc.getColorModel();
        long drawable = 0;
        if (context instanceof Long) {
            drawable = ((Long)context).longValue();
        }
        sData = X11SurfaceData.createData(gc,
                                          vImg.getWidth(),
                                          vImg.getHeight(),
                                          cm, vImg, drawable,
                                          Transparency.OPAQUE);
    } catch (NullPointerException ex) {
        sData = null;
    } catch (OutOfMemoryError er) {
        sData = null;
    }

    return sData;
}
 
Example 3
Source File: X11VolatileSurfaceManager.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a pixmap-based SurfaceData object
 */
protected SurfaceData initAcceleratedSurface() {
    SurfaceData sData;

    try {
        X11GraphicsConfig gc = (X11GraphicsConfig)vImg.getGraphicsConfig();
        ColorModel cm = gc.getColorModel();
        long drawable = 0;
        if (context instanceof Long) {
            drawable = ((Long)context).longValue();
        }
        sData = X11SurfaceData.createData(gc,
                                          vImg.getWidth(),
                                          vImg.getHeight(),
                                          cm, vImg, drawable,
                                          Transparency.OPAQUE);
    } catch (NullPointerException ex) {
        sData = null;
    } catch (OutOfMemoryError er) {
        sData = null;
    }

    return sData;
}
 
Example 4
Source File: X11VolatileSurfaceManager.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a pixmap-based SurfaceData object
 */
protected SurfaceData initAcceleratedSurface() {
    SurfaceData sData;

    try {
        X11GraphicsConfig gc = (X11GraphicsConfig)vImg.getGraphicsConfig();
        ColorModel cm = gc.getColorModel();
        long drawable = 0;
        if (context instanceof Long) {
            drawable = ((Long)context).longValue();
        }
        sData = X11SurfaceData.createData(gc,
                                          vImg.getWidth(),
                                          vImg.getHeight(),
                                          cm, vImg, drawable,
                                          Transparency.OPAQUE);
    } catch (NullPointerException ex) {
        sData = null;
    } catch (OutOfMemoryError er) {
        sData = null;
    }

    return sData;
}
 
Example 5
Source File: X11VolatileSurfaceManager.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a pixmap-based SurfaceData object
 */
protected SurfaceData initAcceleratedSurface() {
    SurfaceData sData;

    try {
        X11GraphicsConfig gc = (X11GraphicsConfig)vImg.getGraphicsConfig();
        ColorModel cm = gc.getColorModel();
        long drawable = 0;
        if (context instanceof Long) {
            drawable = ((Long)context).longValue();
        }
        sData = X11SurfaceData.createData(gc,
                                          vImg.getWidth(),
                                          vImg.getHeight(),
                                          cm, vImg, drawable,
                                          Transparency.OPAQUE);
    } catch (NullPointerException ex) {
        sData = null;
    } catch (OutOfMemoryError er) {
        sData = null;
    }

    return sData;
}
 
Example 6
Source File: X11VolatileSurfaceManager.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a pixmap-based SurfaceData object
 */
protected SurfaceData initAcceleratedSurface() {
    SurfaceData sData;

    try {
        X11GraphicsConfig gc = (X11GraphicsConfig)vImg.getGraphicsConfig();
        ColorModel cm = gc.getColorModel();
        long drawable = 0;
        if (context instanceof Long) {
            drawable = ((Long)context).longValue();
        }
        sData = X11SurfaceData.createData(gc,
                                          vImg.getWidth(),
                                          vImg.getHeight(),
                                          cm, vImg, drawable,
                                          Transparency.OPAQUE);
    } catch (NullPointerException ex) {
        sData = null;
    } catch (OutOfMemoryError er) {
        sData = null;
    }

    return sData;
}
 
Example 7
Source File: X11VolatileSurfaceManager.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a pixmap-based SurfaceData object
 */
protected SurfaceData initAcceleratedSurface() {
    SurfaceData sData;

    try {
        X11GraphicsConfig gc = (X11GraphicsConfig)vImg.getGraphicsConfig();
        ColorModel cm = gc.getColorModel();
        long drawable = 0;
        if (context instanceof Long) {
            drawable = ((Long)context).longValue();
        }
        sData = X11SurfaceData.createData(gc,
                                          vImg.getWidth(),
                                          vImg.getHeight(),
                                          cm, vImg, drawable,
                                          Transparency.OPAQUE);
    } catch (NullPointerException ex) {
        sData = null;
    } catch (OutOfMemoryError er) {
        sData = null;
    }

    return sData;
}
 
Example 8
Source File: X11VolatileSurfaceManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a pixmap-based SurfaceData object
 */
protected SurfaceData initAcceleratedSurface() {
    SurfaceData sData;

    try {
        X11GraphicsConfig gc = (X11GraphicsConfig)vImg.getGraphicsConfig();
        ColorModel cm = gc.getColorModel();
        long drawable = 0;
        if (context instanceof Long) {
            drawable = ((Long)context).longValue();
        }
        sData = X11SurfaceData.createData(gc,
                                          vImg.getWidth(),
                                          vImg.getHeight(),
                                          cm, vImg, drawable,
                                          Transparency.OPAQUE);
    } catch (NullPointerException ex) {
        sData = null;
    } catch (OutOfMemoryError er) {
        sData = null;
    }

    return sData;
}
 
Example 9
Source File: X11VolatileSurfaceManager.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a pixmap-based SurfaceData object
 */
protected SurfaceData initAcceleratedSurface() {
    SurfaceData sData;

    try {
        X11GraphicsConfig gc = (X11GraphicsConfig)vImg.getGraphicsConfig();
        ColorModel cm = gc.getColorModel();
        long drawable = 0;
        if (context instanceof Long) {
            drawable = ((Long)context).longValue();
        }
        sData = X11SurfaceData.createData(gc,
                                          vImg.getWidth(),
                                          vImg.getHeight(),
                                          cm, vImg, drawable,
                                          Transparency.OPAQUE);
    } catch (NullPointerException ex) {
        sData = null;
    } catch (OutOfMemoryError er) {
        sData = null;
    }

    return sData;
}
 
Example 10
Source File: X11VolatileSurfaceManager.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a pixmap-based SurfaceData object
 */
protected SurfaceData initAcceleratedSurface() {
    SurfaceData sData;

    try {
        X11GraphicsConfig gc = (X11GraphicsConfig)vImg.getGraphicsConfig();
        ColorModel cm = gc.getColorModel();
        long drawable = 0;
        if (context instanceof Long) {
            drawable = ((Long)context).longValue();
        }
        sData = X11SurfaceData.createData(gc,
                                          vImg.getWidth(),
                                          vImg.getHeight(),
                                          cm, vImg, drawable,
                                          Transparency.OPAQUE);
    } catch (NullPointerException ex) {
        sData = null;
    } catch (OutOfMemoryError er) {
        sData = null;
    }

    return sData;
}
 
Example 11
Source File: X11VolatileSurfaceManager.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a pixmap-based SurfaceData object
 */
protected SurfaceData initAcceleratedSurface() {
    SurfaceData sData;

    try {
        X11GraphicsConfig gc = (X11GraphicsConfig)vImg.getGraphicsConfig();
        ColorModel cm = gc.getColorModel();
        long drawable = 0;
        if (context instanceof Long) {
            drawable = ((Long)context).longValue();
        }
        sData = X11SurfaceData.createData(gc,
                                          vImg.getWidth(),
                                          vImg.getHeight(),
                                          cm, vImg, drawable,
                                          Transparency.OPAQUE);
    } catch (NullPointerException ex) {
        sData = null;
    } catch (OutOfMemoryError er) {
        sData = null;
    }

    return sData;
}
 
Example 12
Source File: X11SurfaceData.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public static SurfaceType getSurfaceType(X11GraphicsConfig gc,
                                         int transparency,
                                         boolean pixmapSurface)
{
    boolean transparent = (transparency == Transparency.BITMASK);
    SurfaceType sType;
    ColorModel cm = gc.getColorModel();
    switch (cm.getPixelSize()) {
    case 24:
        if (gc.getBitsPerPixel() == 24) {
            if (cm instanceof DirectColorModel) {
                // 4517321: We will always use ThreeByteBgr for 24 bpp
                // surfaces, regardless of the pixel masks reported by
                // X11.  Despite ambiguity in the X11 spec in how 24 bpp
                // surfaces are treated, it appears that the best
                // SurfaceType for these configurations (including
                // some Matrox Millenium and ATI Radeon boards) is
                // ThreeByteBgr.
                sType = transparent ? X11SurfaceData.ThreeByteBgrX11_BM : X11SurfaceData.ThreeByteBgrX11;
            } else {
                throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                          "depth/cm combo: " +
                                                          cm.getPixelSize()  +
                                                          ", " + cm);
            }
            break;
        }
        // Fall through for 32 bit case
    case 32:
        if (cm instanceof DirectColorModel) {
            if (((SunToolkit)java.awt.Toolkit.getDefaultToolkit()
                 ).isTranslucencyCapable(gc) && !pixmapSurface)
            {
                sType = X11SurfaceData.IntArgbPreX11;
            } else {
                if (((DirectColorModel)cm).getRedMask() == 0xff0000) {
                    sType = transparent ? X11SurfaceData.IntRgbX11_BM :
                                          X11SurfaceData.IntRgbX11;
                } else {
                    sType = transparent ? X11SurfaceData.IntBgrX11_BM :
                                          X11SurfaceData.IntBgrX11;
                }
            }
        } else if (cm instanceof ComponentColorModel) {
               sType = X11SurfaceData.FourByteAbgrPreX11;
        } else {

            throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                      "depth/cm combo: " +
                                                      cm.getPixelSize()  +
                                                      ", " + cm);
        }
        break;
    case 15:
        sType = transparent ? X11SurfaceData.UShort555RgbX11_BM : X11SurfaceData.UShort555RgbX11;
        break;
    case 16:
        if ((cm instanceof DirectColorModel) &&
            (((DirectColorModel)cm).getGreenMask() == 0x3e0))
        {
            // fix for 4352984: Riva128 on Linux
            sType = transparent ? X11SurfaceData.UShort555RgbX11_BM : X11SurfaceData.UShort555RgbX11;
        } else {
            sType = transparent ? X11SurfaceData.UShort565RgbX11_BM : X11SurfaceData.UShort565RgbX11;
        }
        break;
    case  12:
        if (cm instanceof IndexColorModel) {
            sType = transparent ?
                X11SurfaceData.UShortIndexedX11_BM :
                X11SurfaceData.UShortIndexedX11;
        } else {
            throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                      "depth: " +
                                                      cm.getPixelSize() +
                                                      " cm="+cm);
        }
        break;
    case 8:
        if (cm.getColorSpace().getType() == ColorSpace.TYPE_GRAY &&
            cm instanceof ComponentColorModel) {
            sType = transparent ? X11SurfaceData.ByteGrayX11_BM : X11SurfaceData.ByteGrayX11;
        } else if (cm instanceof IndexColorModel &&
                   isOpaqueGray((IndexColorModel)cm)) {
            sType = transparent ? X11SurfaceData.Index8GrayX11_BM : X11SurfaceData.Index8GrayX11;
        } else {
            sType = transparent ? X11SurfaceData.ByteIndexedX11_BM : X11SurfaceData.ByteIndexedOpaqueX11;
        }
        break;
    default:
        throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                  "depth: " +
                                                  cm.getPixelSize());
    }
    return sType;
}
 
Example 13
Source File: X11SurfaceData.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static SurfaceType getSurfaceType(X11GraphicsConfig gc,
                                         int transparency,
                                         boolean pixmapSurface)
{
    boolean transparent = (transparency == Transparency.BITMASK);
    SurfaceType sType;
    ColorModel cm = gc.getColorModel();
    switch (cm.getPixelSize()) {
    case 24:
        if (gc.getBitsPerPixel() == 24) {
            if (cm instanceof DirectColorModel) {
                // 4517321: We will always use ThreeByteBgr for 24 bpp
                // surfaces, regardless of the pixel masks reported by
                // X11.  Despite ambiguity in the X11 spec in how 24 bpp
                // surfaces are treated, it appears that the best
                // SurfaceType for these configurations (including
                // some Matrox Millenium and ATI Radeon boards) is
                // ThreeByteBgr.
                sType = transparent ? X11SurfaceData.ThreeByteBgrX11_BM : X11SurfaceData.ThreeByteBgrX11;
            } else {
                throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                          "depth/cm combo: " +
                                                          cm.getPixelSize()  +
                                                          ", " + cm);
            }
            break;
        }
        // Fall through for 32 bit case
    case 32:
        if (cm instanceof DirectColorModel) {
            if (((SunToolkit)java.awt.Toolkit.getDefaultToolkit()
                 ).isTranslucencyCapable(gc) && !pixmapSurface)
            {
                sType = X11SurfaceData.IntArgbPreX11;
            } else {
                if (((DirectColorModel)cm).getRedMask() == 0xff0000) {
                    sType = transparent ? X11SurfaceData.IntRgbX11_BM :
                                          X11SurfaceData.IntRgbX11;
                } else {
                    sType = transparent ? X11SurfaceData.IntBgrX11_BM :
                                          X11SurfaceData.IntBgrX11;
                }
            }
        } else if (cm instanceof ComponentColorModel) {
               sType = X11SurfaceData.FourByteAbgrPreX11;
        } else {

            throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                      "depth/cm combo: " +
                                                      cm.getPixelSize()  +
                                                      ", " + cm);
        }
        break;
    case 15:
        sType = transparent ? X11SurfaceData.UShort555RgbX11_BM : X11SurfaceData.UShort555RgbX11;
        break;
    case 16:
        if ((cm instanceof DirectColorModel) &&
            (((DirectColorModel)cm).getGreenMask() == 0x3e0))
        {
            // fix for 4352984: Riva128 on Linux
            sType = transparent ? X11SurfaceData.UShort555RgbX11_BM : X11SurfaceData.UShort555RgbX11;
        } else {
            sType = transparent ? X11SurfaceData.UShort565RgbX11_BM : X11SurfaceData.UShort565RgbX11;
        }
        break;
    case  12:
        if (cm instanceof IndexColorModel) {
            sType = transparent ?
                X11SurfaceData.UShortIndexedX11_BM :
                X11SurfaceData.UShortIndexedX11;
        } else {
            throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                      "depth: " +
                                                      cm.getPixelSize() +
                                                      " cm="+cm);
        }
        break;
    case 8:
        if (cm.getColorSpace().getType() == ColorSpace.TYPE_GRAY &&
            cm instanceof ComponentColorModel) {
            sType = transparent ? X11SurfaceData.ByteGrayX11_BM : X11SurfaceData.ByteGrayX11;
        } else if (cm instanceof IndexColorModel &&
                   isOpaqueGray((IndexColorModel)cm)) {
            sType = transparent ? X11SurfaceData.Index8GrayX11_BM : X11SurfaceData.Index8GrayX11;
        } else {
            sType = transparent ? X11SurfaceData.ByteIndexedX11_BM : X11SurfaceData.ByteIndexedOpaqueX11;
        }
        break;
    default:
        throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                  "depth: " +
                                                  cm.getPixelSize());
    }
    return sType;
}
 
Example 14
Source File: X11SurfaceData.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("fallthrough")
public static SurfaceType getSurfaceType(X11GraphicsConfig gc,
                                         int transparency,
                                         boolean pixmapSurface)
{
    boolean transparent = (transparency == Transparency.BITMASK);
    SurfaceType sType;
    ColorModel cm = gc.getColorModel();
    switch (cm.getPixelSize()) {
    case 24:
        if (gc.getBitsPerPixel() == 24) {
            if (cm instanceof DirectColorModel) {
                // 4517321: We will always use ThreeByteBgr for 24 bpp
                // surfaces, regardless of the pixel masks reported by
                // X11.  Despite ambiguity in the X11 spec in how 24 bpp
                // surfaces are treated, it appears that the best
                // SurfaceType for these configurations (including
                // some Matrox Millenium and ATI Radeon boards) is
                // ThreeByteBgr.
                sType = transparent ? X11SurfaceData.ThreeByteBgrX11_BM : X11SurfaceData.ThreeByteBgrX11;
            } else {
                throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                          "depth/cm combo: " +
                                                          cm.getPixelSize()  +
                                                          ", " + cm);
            }
            break;
        }
        // Fall through for 32 bit case
    case 32:
        if (cm instanceof DirectColorModel) {
            if (((SunToolkit)java.awt.Toolkit.getDefaultToolkit()
                 ).isTranslucencyCapable(gc) && !pixmapSurface)
            {
                sType = X11SurfaceData.IntArgbPreX11;
            } else {
                if (((DirectColorModel)cm).getRedMask() == 0xff0000) {
                    sType = transparent ? X11SurfaceData.IntRgbX11_BM :
                                          X11SurfaceData.IntRgbX11;
                } else {
                    sType = transparent ? X11SurfaceData.IntBgrX11_BM :
                                          X11SurfaceData.IntBgrX11;
                }
            }
        } else if (cm instanceof ComponentColorModel) {
               sType = X11SurfaceData.FourByteAbgrPreX11;
        } else {

            throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                      "depth/cm combo: " +
                                                      cm.getPixelSize()  +
                                                      ", " + cm);
        }
        break;
    case 15:
        sType = transparent ? X11SurfaceData.UShort555RgbX11_BM : X11SurfaceData.UShort555RgbX11;
        break;
    case 16:
        if ((cm instanceof DirectColorModel) &&
            (((DirectColorModel)cm).getGreenMask() == 0x3e0))
        {
            // fix for 4352984: Riva128 on Linux
            sType = transparent ? X11SurfaceData.UShort555RgbX11_BM : X11SurfaceData.UShort555RgbX11;
        } else {
            sType = transparent ? X11SurfaceData.UShort565RgbX11_BM : X11SurfaceData.UShort565RgbX11;
        }
        break;
    case  12:
        if (cm instanceof IndexColorModel) {
            sType = transparent ?
                X11SurfaceData.UShortIndexedX11_BM :
                X11SurfaceData.UShortIndexedX11;
        } else {
            throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                      "depth: " +
                                                      cm.getPixelSize() +
                                                      " cm="+cm);
        }
        break;
    case 8:
        if (cm.getColorSpace().getType() == ColorSpace.TYPE_GRAY &&
            cm instanceof ComponentColorModel) {
            sType = transparent ? X11SurfaceData.ByteGrayX11_BM : X11SurfaceData.ByteGrayX11;
        } else if (cm instanceof IndexColorModel &&
                   isOpaqueGray((IndexColorModel)cm)) {
            sType = transparent ? X11SurfaceData.Index8GrayX11_BM : X11SurfaceData.Index8GrayX11;
        } else {
            sType = transparent ? X11SurfaceData.ByteIndexedX11_BM : X11SurfaceData.ByteIndexedOpaqueX11;
        }
        break;
    default:
        throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                  "depth: " +
                                                  cm.getPixelSize());
    }
    return sType;
}
 
Example 15
Source File: X11SurfaceData.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public static SurfaceType getSurfaceType(X11GraphicsConfig gc,
                                         int transparency,
                                         boolean pixmapSurface)
{
    boolean transparent = (transparency == Transparency.BITMASK);
    SurfaceType sType;
    ColorModel cm = gc.getColorModel();
    switch (cm.getPixelSize()) {
    case 24:
        if (gc.getBitsPerPixel() == 24) {
            if (cm instanceof DirectColorModel) {
                // 4517321: We will always use ThreeByteBgr for 24 bpp
                // surfaces, regardless of the pixel masks reported by
                // X11.  Despite ambiguity in the X11 spec in how 24 bpp
                // surfaces are treated, it appears that the best
                // SurfaceType for these configurations (including
                // some Matrox Millenium and ATI Radeon boards) is
                // ThreeByteBgr.
                sType = transparent ? X11SurfaceData.ThreeByteBgrX11_BM : X11SurfaceData.ThreeByteBgrX11;
            } else {
                throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                          "depth/cm combo: " +
                                                          cm.getPixelSize()  +
                                                          ", " + cm);
            }
            break;
        }
        // Fall through for 32 bit case
    case 32:
        if (cm instanceof DirectColorModel) {
            if (((SunToolkit)java.awt.Toolkit.getDefaultToolkit()
                 ).isTranslucencyCapable(gc) && !pixmapSurface)
            {
                sType = X11SurfaceData.IntArgbPreX11;
            } else {
                if (((DirectColorModel)cm).getRedMask() == 0xff0000) {
                    sType = transparent ? X11SurfaceData.IntRgbX11_BM :
                                          X11SurfaceData.IntRgbX11;
                } else {
                    sType = transparent ? X11SurfaceData.IntBgrX11_BM :
                                          X11SurfaceData.IntBgrX11;
                }
            }
        } else if (cm instanceof ComponentColorModel) {
               sType = X11SurfaceData.FourByteAbgrPreX11;
        } else {

            throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                      "depth/cm combo: " +
                                                      cm.getPixelSize()  +
                                                      ", " + cm);
        }
        break;
    case 15:
        sType = transparent ? X11SurfaceData.UShort555RgbX11_BM : X11SurfaceData.UShort555RgbX11;
        break;
    case 16:
        if ((cm instanceof DirectColorModel) &&
            (((DirectColorModel)cm).getGreenMask() == 0x3e0))
        {
            // fix for 4352984: Riva128 on Linux
            sType = transparent ? X11SurfaceData.UShort555RgbX11_BM : X11SurfaceData.UShort555RgbX11;
        } else {
            sType = transparent ? X11SurfaceData.UShort565RgbX11_BM : X11SurfaceData.UShort565RgbX11;
        }
        break;
    case  12:
        if (cm instanceof IndexColorModel) {
            sType = transparent ?
                X11SurfaceData.UShortIndexedX11_BM :
                X11SurfaceData.UShortIndexedX11;
        } else {
            throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                      "depth: " +
                                                      cm.getPixelSize() +
                                                      " cm="+cm);
        }
        break;
    case 8:
        if (cm.getColorSpace().getType() == ColorSpace.TYPE_GRAY &&
            cm instanceof ComponentColorModel) {
            sType = transparent ? X11SurfaceData.ByteGrayX11_BM : X11SurfaceData.ByteGrayX11;
        } else if (cm instanceof IndexColorModel &&
                   isOpaqueGray((IndexColorModel)cm)) {
            sType = transparent ? X11SurfaceData.Index8GrayX11_BM : X11SurfaceData.Index8GrayX11;
        } else {
            sType = transparent ? X11SurfaceData.ByteIndexedX11_BM : X11SurfaceData.ByteIndexedOpaqueX11;
        }
        break;
    default:
        throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                  "depth: " +
                                                  cm.getPixelSize());
    }
    return sType;
}
 
Example 16
Source File: X11SurfaceData.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static SurfaceType getSurfaceType(X11GraphicsConfig gc,
                                         int transparency,
                                         boolean pixmapSurface)
{
    boolean transparent = (transparency == Transparency.BITMASK);
    SurfaceType sType;
    ColorModel cm = gc.getColorModel();
    switch (cm.getPixelSize()) {
    case 24:
        if (gc.getBitsPerPixel() == 24) {
            if (cm instanceof DirectColorModel) {
                // 4517321: We will always use ThreeByteBgr for 24 bpp
                // surfaces, regardless of the pixel masks reported by
                // X11.  Despite ambiguity in the X11 spec in how 24 bpp
                // surfaces are treated, it appears that the best
                // SurfaceType for these configurations (including
                // some Matrox Millenium and ATI Radeon boards) is
                // ThreeByteBgr.
                sType = transparent ? X11SurfaceData.ThreeByteBgrX11_BM : X11SurfaceData.ThreeByteBgrX11;
            } else {
                throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                          "depth/cm combo: " +
                                                          cm.getPixelSize()  +
                                                          ", " + cm);
            }
            break;
        }
        // Fall through for 32 bit case
    case 32:
        if (cm instanceof DirectColorModel) {
            if (((SunToolkit)java.awt.Toolkit.getDefaultToolkit()
                 ).isTranslucencyCapable(gc) && !pixmapSurface)
            {
                sType = X11SurfaceData.IntArgbPreX11;
            } else {
                if (((DirectColorModel)cm).getRedMask() == 0xff0000) {
                    sType = transparent ? X11SurfaceData.IntRgbX11_BM :
                                          X11SurfaceData.IntRgbX11;
                } else {
                    sType = transparent ? X11SurfaceData.IntBgrX11_BM :
                                          X11SurfaceData.IntBgrX11;
                }
            }
        } else if (cm instanceof ComponentColorModel) {
               sType = X11SurfaceData.FourByteAbgrPreX11;
        } else {

            throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                      "depth/cm combo: " +
                                                      cm.getPixelSize()  +
                                                      ", " + cm);
        }
        break;
    case 15:
        sType = transparent ? X11SurfaceData.UShort555RgbX11_BM : X11SurfaceData.UShort555RgbX11;
        break;
    case 16:
        if ((cm instanceof DirectColorModel) &&
            (((DirectColorModel)cm).getGreenMask() == 0x3e0))
        {
            // fix for 4352984: Riva128 on Linux
            sType = transparent ? X11SurfaceData.UShort555RgbX11_BM : X11SurfaceData.UShort555RgbX11;
        } else {
            sType = transparent ? X11SurfaceData.UShort565RgbX11_BM : X11SurfaceData.UShort565RgbX11;
        }
        break;
    case  12:
        if (cm instanceof IndexColorModel) {
            sType = transparent ?
                X11SurfaceData.UShortIndexedX11_BM :
                X11SurfaceData.UShortIndexedX11;
        } else {
            throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                      "depth: " +
                                                      cm.getPixelSize() +
                                                      " cm="+cm);
        }
        break;
    case 8:
        if (cm.getColorSpace().getType() == ColorSpace.TYPE_GRAY &&
            cm instanceof ComponentColorModel) {
            sType = transparent ? X11SurfaceData.ByteGrayX11_BM : X11SurfaceData.ByteGrayX11;
        } else if (cm instanceof IndexColorModel &&
                   isOpaqueGray((IndexColorModel)cm)) {
            sType = transparent ? X11SurfaceData.Index8GrayX11_BM : X11SurfaceData.Index8GrayX11;
        } else {
            sType = transparent ? X11SurfaceData.ByteIndexedX11_BM : X11SurfaceData.ByteIndexedOpaqueX11;
        }
        break;
    default:
        throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                  "depth: " +
                                                  cm.getPixelSize());
    }
    return sType;
}
 
Example 17
Source File: X11SurfaceData.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public static SurfaceType getSurfaceType(X11GraphicsConfig gc,
                                         int transparency,
                                         boolean pixmapSurface)
{
    boolean transparent = (transparency == Transparency.BITMASK);
    SurfaceType sType;
    ColorModel cm = gc.getColorModel();
    switch (cm.getPixelSize()) {
    case 24:
        if (gc.getBitsPerPixel() == 24) {
            if (cm instanceof DirectColorModel) {
                // 4517321: We will always use ThreeByteBgr for 24 bpp
                // surfaces, regardless of the pixel masks reported by
                // X11.  Despite ambiguity in the X11 spec in how 24 bpp
                // surfaces are treated, it appears that the best
                // SurfaceType for these configurations (including
                // some Matrox Millenium and ATI Radeon boards) is
                // ThreeByteBgr.
                sType = transparent ? X11SurfaceData.ThreeByteBgrX11_BM : X11SurfaceData.ThreeByteBgrX11;
            } else {
                throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                          "depth/cm combo: " +
                                                          cm.getPixelSize()  +
                                                          ", " + cm);
            }
            break;
        }
        // Fall through for 32 bit case
    case 32:
        if (cm instanceof DirectColorModel) {
            if (((SunToolkit)java.awt.Toolkit.getDefaultToolkit()
                 ).isTranslucencyCapable(gc) && !pixmapSurface)
            {
                sType = X11SurfaceData.IntArgbPreX11;
            } else {
                if (((DirectColorModel)cm).getRedMask() == 0xff0000) {
                    sType = transparent ? X11SurfaceData.IntRgbX11_BM :
                                          X11SurfaceData.IntRgbX11;
                } else {
                    sType = transparent ? X11SurfaceData.IntBgrX11_BM :
                                          X11SurfaceData.IntBgrX11;
                }
            }
        } else if (cm instanceof ComponentColorModel) {
               sType = X11SurfaceData.FourByteAbgrPreX11;
        } else {

            throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                      "depth/cm combo: " +
                                                      cm.getPixelSize()  +
                                                      ", " + cm);
        }
        break;
    case 15:
        sType = transparent ? X11SurfaceData.UShort555RgbX11_BM : X11SurfaceData.UShort555RgbX11;
        break;
    case 16:
        if ((cm instanceof DirectColorModel) &&
            (((DirectColorModel)cm).getGreenMask() == 0x3e0))
        {
            // fix for 4352984: Riva128 on Linux
            sType = transparent ? X11SurfaceData.UShort555RgbX11_BM : X11SurfaceData.UShort555RgbX11;
        } else {
            sType = transparent ? X11SurfaceData.UShort565RgbX11_BM : X11SurfaceData.UShort565RgbX11;
        }
        break;
    case  12:
        if (cm instanceof IndexColorModel) {
            sType = transparent ?
                X11SurfaceData.UShortIndexedX11_BM :
                X11SurfaceData.UShortIndexedX11;
        } else {
            throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                      "depth: " +
                                                      cm.getPixelSize() +
                                                      " cm="+cm);
        }
        break;
    case 8:
        if (cm.getColorSpace().getType() == ColorSpace.TYPE_GRAY &&
            cm instanceof ComponentColorModel) {
            sType = transparent ? X11SurfaceData.ByteGrayX11_BM : X11SurfaceData.ByteGrayX11;
        } else if (cm instanceof IndexColorModel &&
                   isOpaqueGray((IndexColorModel)cm)) {
            sType = transparent ? X11SurfaceData.Index8GrayX11_BM : X11SurfaceData.Index8GrayX11;
        } else {
            sType = transparent ? X11SurfaceData.ByteIndexedX11_BM : X11SurfaceData.ByteIndexedOpaqueX11;
        }
        break;
    default:
        throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                  "depth: " +
                                                  cm.getPixelSize());
    }
    return sType;
}
 
Example 18
Source File: X11SurfaceData.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static SurfaceType getSurfaceType(X11GraphicsConfig gc,
                                         int transparency,
                                         boolean pixmapSurface)
{
    boolean transparent = (transparency == Transparency.BITMASK);
    SurfaceType sType;
    ColorModel cm = gc.getColorModel();
    switch (cm.getPixelSize()) {
    case 24:
        if (gc.getBitsPerPixel() == 24) {
            if (cm instanceof DirectColorModel) {
                // 4517321: We will always use ThreeByteBgr for 24 bpp
                // surfaces, regardless of the pixel masks reported by
                // X11.  Despite ambiguity in the X11 spec in how 24 bpp
                // surfaces are treated, it appears that the best
                // SurfaceType for these configurations (including
                // some Matrox Millenium and ATI Radeon boards) is
                // ThreeByteBgr.
                sType = transparent ? X11SurfaceData.ThreeByteBgrX11_BM : X11SurfaceData.ThreeByteBgrX11;
            } else {
                throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                          "depth/cm combo: " +
                                                          cm.getPixelSize()  +
                                                          ", " + cm);
            }
            break;
        }
        // Fall through for 32 bit case
    case 32:
        if (cm instanceof DirectColorModel) {
            if (((SunToolkit)java.awt.Toolkit.getDefaultToolkit()
                 ).isTranslucencyCapable(gc) && !pixmapSurface)
            {
                sType = X11SurfaceData.IntArgbPreX11;
            } else {
                if (((DirectColorModel)cm).getRedMask() == 0xff0000) {
                    sType = transparent ? X11SurfaceData.IntRgbX11_BM :
                                          X11SurfaceData.IntRgbX11;
                } else {
                    sType = transparent ? X11SurfaceData.IntBgrX11_BM :
                                          X11SurfaceData.IntBgrX11;
                }
            }
        } else if (cm instanceof ComponentColorModel) {
               sType = X11SurfaceData.FourByteAbgrPreX11;
        } else {

            throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                      "depth/cm combo: " +
                                                      cm.getPixelSize()  +
                                                      ", " + cm);
        }
        break;
    case 15:
        sType = transparent ? X11SurfaceData.UShort555RgbX11_BM : X11SurfaceData.UShort555RgbX11;
        break;
    case 16:
        if ((cm instanceof DirectColorModel) &&
            (((DirectColorModel)cm).getGreenMask() == 0x3e0))
        {
            // fix for 4352984: Riva128 on Linux
            sType = transparent ? X11SurfaceData.UShort555RgbX11_BM : X11SurfaceData.UShort555RgbX11;
        } else {
            sType = transparent ? X11SurfaceData.UShort565RgbX11_BM : X11SurfaceData.UShort565RgbX11;
        }
        break;
    case  12:
        if (cm instanceof IndexColorModel) {
            sType = transparent ?
                X11SurfaceData.UShortIndexedX11_BM :
                X11SurfaceData.UShortIndexedX11;
        } else {
            throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                      "depth: " +
                                                      cm.getPixelSize() +
                                                      " cm="+cm);
        }
        break;
    case 8:
        if (cm.getColorSpace().getType() == ColorSpace.TYPE_GRAY &&
            cm instanceof ComponentColorModel) {
            sType = transparent ? X11SurfaceData.ByteGrayX11_BM : X11SurfaceData.ByteGrayX11;
        } else if (cm instanceof IndexColorModel &&
                   isOpaqueGray((IndexColorModel)cm)) {
            sType = transparent ? X11SurfaceData.Index8GrayX11_BM : X11SurfaceData.Index8GrayX11;
        } else {
            sType = transparent ? X11SurfaceData.ByteIndexedX11_BM : X11SurfaceData.ByteIndexedOpaqueX11;
        }
        break;
    default:
        throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                  "depth: " +
                                                  cm.getPixelSize());
    }
    return sType;
}
 
Example 19
Source File: X11SurfaceData.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public static SurfaceType getSurfaceType(X11GraphicsConfig gc,
                                         int transparency,
                                         boolean pixmapSurface)
{
    boolean transparent = (transparency == Transparency.BITMASK);
    SurfaceType sType;
    ColorModel cm = gc.getColorModel();
    switch (cm.getPixelSize()) {
    case 24:
        if (gc.getBitsPerPixel() == 24) {
            if (cm instanceof DirectColorModel) {
                // 4517321: We will always use ThreeByteBgr for 24 bpp
                // surfaces, regardless of the pixel masks reported by
                // X11.  Despite ambiguity in the X11 spec in how 24 bpp
                // surfaces are treated, it appears that the best
                // SurfaceType for these configurations (including
                // some Matrox Millenium and ATI Radeon boards) is
                // ThreeByteBgr.
                sType = transparent ? X11SurfaceData.ThreeByteBgrX11_BM : X11SurfaceData.ThreeByteBgrX11;
            } else {
                throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                          "depth/cm combo: " +
                                                          cm.getPixelSize()  +
                                                          ", " + cm);
            }
            break;
        }
        // Fall through for 32 bit case
    case 32:
        if (cm instanceof DirectColorModel) {
            if (((SunToolkit)java.awt.Toolkit.getDefaultToolkit()
                 ).isTranslucencyCapable(gc) && !pixmapSurface)
            {
                sType = X11SurfaceData.IntArgbPreX11;
            } else {
                if (((DirectColorModel)cm).getRedMask() == 0xff0000) {
                    sType = transparent ? X11SurfaceData.IntRgbX11_BM :
                                          X11SurfaceData.IntRgbX11;
                } else {
                    sType = transparent ? X11SurfaceData.IntBgrX11_BM :
                                          X11SurfaceData.IntBgrX11;
                }
            }
        } else if (cm instanceof ComponentColorModel) {
               sType = X11SurfaceData.FourByteAbgrPreX11;
        } else {

            throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                      "depth/cm combo: " +
                                                      cm.getPixelSize()  +
                                                      ", " + cm);
        }
        break;
    case 15:
        sType = transparent ? X11SurfaceData.UShort555RgbX11_BM : X11SurfaceData.UShort555RgbX11;
        break;
    case 16:
        if ((cm instanceof DirectColorModel) &&
            (((DirectColorModel)cm).getGreenMask() == 0x3e0))
        {
            // fix for 4352984: Riva128 on Linux
            sType = transparent ? X11SurfaceData.UShort555RgbX11_BM : X11SurfaceData.UShort555RgbX11;
        } else {
            sType = transparent ? X11SurfaceData.UShort565RgbX11_BM : X11SurfaceData.UShort565RgbX11;
        }
        break;
    case  12:
        if (cm instanceof IndexColorModel) {
            sType = transparent ?
                X11SurfaceData.UShortIndexedX11_BM :
                X11SurfaceData.UShortIndexedX11;
        } else {
            throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                      "depth: " +
                                                      cm.getPixelSize() +
                                                      " cm="+cm);
        }
        break;
    case 8:
        if (cm.getColorSpace().getType() == ColorSpace.TYPE_GRAY &&
            cm instanceof ComponentColorModel) {
            sType = transparent ? X11SurfaceData.ByteGrayX11_BM : X11SurfaceData.ByteGrayX11;
        } else if (cm instanceof IndexColorModel &&
                   isOpaqueGray((IndexColorModel)cm)) {
            sType = transparent ? X11SurfaceData.Index8GrayX11_BM : X11SurfaceData.Index8GrayX11;
        } else {
            sType = transparent ? X11SurfaceData.ByteIndexedX11_BM : X11SurfaceData.ByteIndexedOpaqueX11;
        }
        break;
    default:
        throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                  "depth: " +
                                                  cm.getPixelSize());
    }
    return sType;
}
 
Example 20
Source File: X11SurfaceData.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static SurfaceType getSurfaceType(X11GraphicsConfig gc,
                                         int transparency,
                                         boolean pixmapSurface)
{
    boolean transparent = (transparency == Transparency.BITMASK);
    SurfaceType sType;
    ColorModel cm = gc.getColorModel();
    switch (cm.getPixelSize()) {
    case 24:
        if (gc.getBitsPerPixel() == 24) {
            if (cm instanceof DirectColorModel) {
                // 4517321: We will always use ThreeByteBgr for 24 bpp
                // surfaces, regardless of the pixel masks reported by
                // X11.  Despite ambiguity in the X11 spec in how 24 bpp
                // surfaces are treated, it appears that the best
                // SurfaceType for these configurations (including
                // some Matrox Millenium and ATI Radeon boards) is
                // ThreeByteBgr.
                sType = transparent ? X11SurfaceData.ThreeByteBgrX11_BM : X11SurfaceData.ThreeByteBgrX11;
            } else {
                throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                          "depth/cm combo: " +
                                                          cm.getPixelSize()  +
                                                          ", " + cm);
            }
            break;
        }
        // Fall through for 32 bit case
    case 32:
        if (cm instanceof DirectColorModel) {
            if (((SunToolkit)java.awt.Toolkit.getDefaultToolkit()
                 ).isTranslucencyCapable(gc) && !pixmapSurface)
            {
                sType = X11SurfaceData.IntArgbPreX11;
            } else {
                if (((DirectColorModel)cm).getRedMask() == 0xff0000) {
                    sType = transparent ? X11SurfaceData.IntRgbX11_BM :
                                          X11SurfaceData.IntRgbX11;
                } else {
                    sType = transparent ? X11SurfaceData.IntBgrX11_BM :
                                          X11SurfaceData.IntBgrX11;
                }
            }
        } else if (cm instanceof ComponentColorModel) {
               sType = X11SurfaceData.FourByteAbgrPreX11;
        } else {

            throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                      "depth/cm combo: " +
                                                      cm.getPixelSize()  +
                                                      ", " + cm);
        }
        break;
    case 15:
        sType = transparent ? X11SurfaceData.UShort555RgbX11_BM : X11SurfaceData.UShort555RgbX11;
        break;
    case 16:
        if ((cm instanceof DirectColorModel) &&
            (((DirectColorModel)cm).getGreenMask() == 0x3e0))
        {
            // fix for 4352984: Riva128 on Linux
            sType = transparent ? X11SurfaceData.UShort555RgbX11_BM : X11SurfaceData.UShort555RgbX11;
        } else {
            sType = transparent ? X11SurfaceData.UShort565RgbX11_BM : X11SurfaceData.UShort565RgbX11;
        }
        break;
    case  12:
        if (cm instanceof IndexColorModel) {
            sType = transparent ?
                X11SurfaceData.UShortIndexedX11_BM :
                X11SurfaceData.UShortIndexedX11;
        } else {
            throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                      "depth: " +
                                                      cm.getPixelSize() +
                                                      " cm="+cm);
        }
        break;
    case 8:
        if (cm.getColorSpace().getType() == ColorSpace.TYPE_GRAY &&
            cm instanceof ComponentColorModel) {
            sType = transparent ? X11SurfaceData.ByteGrayX11_BM : X11SurfaceData.ByteGrayX11;
        } else if (cm instanceof IndexColorModel &&
                   isOpaqueGray((IndexColorModel)cm)) {
            sType = transparent ? X11SurfaceData.Index8GrayX11_BM : X11SurfaceData.Index8GrayX11;
        } else {
            sType = transparent ? X11SurfaceData.ByteIndexedX11_BM : X11SurfaceData.ByteIndexedOpaqueX11;
        }
        break;
    default:
        throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                  "depth: " +
                                                  cm.getPixelSize());
    }
    return sType;
}