Java Code Examples for sun.java2d.SunGraphics2D#COMP_ALPHA

The following examples show how to use sun.java2d.SunGraphics2D#COMP_ALPHA . 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: XRSurfaceData.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected TextPipe getTextPipe(SunGraphics2D sg2d) {
    boolean supportedPaint = sg2d.compositeState <= SunGraphics2D.COMP_ALPHA
            && (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR || sg2d.composite == null);

    boolean supportedCompOp = false;
    if (sg2d.composite instanceof AlphaComposite) {
        int compRule = ((AlphaComposite) sg2d.composite).getRule();
        supportedCompOp = XRUtils.isMaskEvaluated(XRUtils.j2dAlphaCompToXR(compRule))
                || (compRule == AlphaComposite.SRC
                            && sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR);
    }

    return (supportedPaint && supportedCompOp) ? xrtextpipe : null;
}
 
Example 2
Source File: XRSurfaceData.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
protected TextPipe getTextPipe(SunGraphics2D sg2d) {
    boolean supportedPaint = sg2d.compositeState <= SunGraphics2D.COMP_ALPHA
            && (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR || sg2d.composite == null);

    boolean supportedCompOp = false;
    if (sg2d.composite instanceof AlphaComposite) {
        int compRule = ((AlphaComposite) sg2d.composite).getRule();
        supportedCompOp = XRUtils.isMaskEvaluated(XRUtils.j2dAlphaCompToXR(compRule))
                || (compRule == AlphaComposite.SRC
                            && sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR);
    }

    return (supportedPaint && supportedCompOp) ? xrtextpipe : null;
}
 
Example 3
Source File: XRSurfaceData.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public RenderLoops getRenderLoops(SunGraphics2D sg2d) {
    if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR &&
        sg2d.compositeState <= SunGraphics2D.COMP_ALPHA)
    {
        return solidloops;
    }

    return super.getRenderLoops(sg2d);
}
 
Example 4
Source File: XRSurfaceData.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
protected TextPipe getTextPipe(SunGraphics2D sg2d) {
    boolean supportedPaint = sg2d.compositeState <= SunGraphics2D.COMP_ALPHA
            && (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR || sg2d.composite == null);

    boolean supportedCompOp = false;
    if (sg2d.composite instanceof AlphaComposite) {
        int compRule = ((AlphaComposite) sg2d.composite).getRule();
        supportedCompOp = XRUtils.isMaskEvaluated(XRUtils.j2dAlphaCompToXR(compRule))
                || (compRule == AlphaComposite.SRC
                            && sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR);
    }

    return (supportedPaint && supportedCompOp) ? xrtextpipe : null;
}
 
Example 5
Source File: XRSurfaceData.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
protected TextPipe getTextPipe(SunGraphics2D sg2d) {
    boolean supportedPaint = sg2d.compositeState <= SunGraphics2D.COMP_ALPHA
            && (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR || sg2d.composite == null);

    boolean supportedCompOp = false;
    if (sg2d.composite instanceof AlphaComposite) {
        int compRule = ((AlphaComposite) sg2d.composite).getRule();
        supportedCompOp = XRUtils.isMaskEvaluated(XRUtils.j2dAlphaCompToXR(compRule))
                || (compRule == AlphaComposite.SRC
                            && sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR);
    }

    return (supportedPaint && supportedCompOp) ? xrtextpipe : null;
}
 
Example 6
Source File: XRSurfaceData.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public RenderLoops getRenderLoops(SunGraphics2D sg2d) {
    if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR &&
        sg2d.compositeState <= SunGraphics2D.COMP_ALPHA)
    {
        return solidloops;
    }

    return super.getRenderLoops(sg2d);
}
 
Example 7
Source File: XRSurfaceData.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
protected TextPipe getTextPipe(SunGraphics2D sg2d) {
    boolean supportedPaint = sg2d.compositeState <= SunGraphics2D.COMP_ALPHA
            && (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR || sg2d.composite == null);

    boolean supportedCompOp = false;
    if (sg2d.composite instanceof AlphaComposite) {
        int compRule = ((AlphaComposite) sg2d.composite).getRule();
        supportedCompOp = XRUtils.isMaskEvaluated(XRUtils.j2dAlphaCompToXR(compRule))
                || (compRule == AlphaComposite.SRC
                            && sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR);
    }

    return (supportedPaint && supportedCompOp) ? xrtextpipe : null;
}
 
Example 8
Source File: OGLBufImgOps.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * This method is called from OGLDrawImage.transformImage() only.  It
 * validates the provided BufferedImageOp to determine whether the op
 * is one that can be accelerated by the OGL pipeline.  If the operation
 * cannot be completed for any reason, this method returns false;
 * otherwise, the given BufferedImage is rendered to the destination
 * using the provided BufferedImageOp and this method returns true.
 */
static boolean renderImageWithOp(SunGraphics2D sg, BufferedImage img,
                                 BufferedImageOp biop, int x, int y)
{
    // Validate the provided BufferedImage (make sure it is one that
    // is supported, and that its properties are acceleratable)
    if (biop instanceof ConvolveOp) {
        if (!isConvolveOpValid((ConvolveOp)biop)) {
            return false;
        }
    } else if (biop instanceof RescaleOp) {
        if (!isRescaleOpValid((RescaleOp)biop, img)) {
            return false;
        }
    } else if (biop instanceof LookupOp) {
        if (!isLookupOpValid((LookupOp)biop, img)) {
            return false;
        }
    } else {
        // No acceleration for other BufferedImageOps (yet)
        return false;
    }

    SurfaceData dstData = sg.surfaceData;
    if (!(dstData instanceof OGLSurfaceData) ||
        (sg.interpolationType == AffineTransformOp.TYPE_BICUBIC) ||
        (sg.compositeState > SunGraphics2D.COMP_ALPHA))
    {
        return false;
    }

    SurfaceData srcData =
        dstData.getSourceSurfaceData(img, SunGraphics2D.TRANSFORM_ISIDENT,
                                     CompositeType.SrcOver, null);
    if (!(srcData instanceof OGLSurfaceData)) {
        // REMIND: this hack tries to ensure that we have a cached texture
        srcData =
            dstData.getSourceSurfaceData(img, SunGraphics2D.TRANSFORM_ISIDENT,
                                         CompositeType.SrcOver, null);
        if (!(srcData instanceof OGLSurfaceData)) {
            return false;
        }
    }

    // Verify that the source surface is actually a texture and
    // that the operation is supported
    OGLSurfaceData oglSrc = (OGLSurfaceData)srcData;
    OGLGraphicsConfig gc = oglSrc.getOGLGraphicsConfig();
    if (oglSrc.getType() != OGLSurfaceData.TEXTURE ||
        !gc.isCapPresent(CAPS_EXT_BIOP_SHADER))
    {
        return false;
    }

    int sw = img.getWidth();
    int sh = img.getHeight();
    OGLBlitLoops.IsoBlit(srcData, dstData,
                         img, biop,
                         sg.composite, sg.getCompClip(),
                         sg.transform, sg.interpolationType,
                         0, 0, sw, sh,
                         x, y, x+sw, y+sh,
                         true);

    return true;
}
 
Example 9
Source File: OGLBufImgOps.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * This method is called from OGLDrawImage.transformImage() only.  It
 * validates the provided BufferedImageOp to determine whether the op
 * is one that can be accelerated by the OGL pipeline.  If the operation
 * cannot be completed for any reason, this method returns false;
 * otherwise, the given BufferedImage is rendered to the destination
 * using the provided BufferedImageOp and this method returns true.
 */
static boolean renderImageWithOp(SunGraphics2D sg, BufferedImage img,
                                 BufferedImageOp biop, int x, int y)
{
    // Validate the provided BufferedImage (make sure it is one that
    // is supported, and that its properties are acceleratable)
    if (biop instanceof ConvolveOp) {
        if (!isConvolveOpValid((ConvolveOp)biop)) {
            return false;
        }
    } else if (biop instanceof RescaleOp) {
        if (!isRescaleOpValid((RescaleOp)biop, img)) {
            return false;
        }
    } else if (biop instanceof LookupOp) {
        if (!isLookupOpValid((LookupOp)biop, img)) {
            return false;
        }
    } else {
        // No acceleration for other BufferedImageOps (yet)
        return false;
    }

    SurfaceData dstData = sg.surfaceData;
    if (!(dstData instanceof OGLSurfaceData) ||
        (sg.interpolationType == AffineTransformOp.TYPE_BICUBIC) ||
        (sg.compositeState > SunGraphics2D.COMP_ALPHA))
    {
        return false;
    }

    SurfaceData srcData =
        dstData.getSourceSurfaceData(img, SunGraphics2D.TRANSFORM_ISIDENT,
                                     CompositeType.SrcOver, null);
    if (!(srcData instanceof OGLSurfaceData)) {
        // REMIND: this hack tries to ensure that we have a cached texture
        srcData =
            dstData.getSourceSurfaceData(img, SunGraphics2D.TRANSFORM_ISIDENT,
                                         CompositeType.SrcOver, null);
        if (!(srcData instanceof OGLSurfaceData)) {
            return false;
        }
    }

    // Verify that the source surface is actually a texture and
    // that the operation is supported
    OGLSurfaceData oglSrc = (OGLSurfaceData)srcData;
    OGLGraphicsConfig gc = oglSrc.getOGLGraphicsConfig();
    if (oglSrc.getType() != OGLSurfaceData.TEXTURE ||
        !gc.isCapPresent(CAPS_EXT_BIOP_SHADER))
    {
        return false;
    }

    int sw = img.getWidth();
    int sh = img.getHeight();
    OGLBlitLoops.IsoBlit(srcData, dstData,
                         img, biop,
                         sg.composite, sg.getCompClip(),
                         sg.transform, sg.interpolationType,
                         0, 0, sw, sh,
                         x, y, x+sw, y+sh,
                         true);

    return true;
}
 
Example 10
Source File: OGLBufImgOps.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * This method is called from OGLDrawImage.transformImage() only.  It
 * validates the provided BufferedImageOp to determine whether the op
 * is one that can be accelerated by the OGL pipeline.  If the operation
 * cannot be completed for any reason, this method returns false;
 * otherwise, the given BufferedImage is rendered to the destination
 * using the provided BufferedImageOp and this method returns true.
 */
static boolean renderImageWithOp(SunGraphics2D sg, BufferedImage img,
                                 BufferedImageOp biop, int x, int y)
{
    // Validate the provided BufferedImage (make sure it is one that
    // is supported, and that its properties are acceleratable)
    if (biop instanceof ConvolveOp) {
        if (!isConvolveOpValid((ConvolveOp)biop)) {
            return false;
        }
    } else if (biop instanceof RescaleOp) {
        if (!isRescaleOpValid((RescaleOp)biop, img)) {
            return false;
        }
    } else if (biop instanceof LookupOp) {
        if (!isLookupOpValid((LookupOp)biop, img)) {
            return false;
        }
    } else {
        // No acceleration for other BufferedImageOps (yet)
        return false;
    }

    SurfaceData dstData = sg.surfaceData;
    if (!(dstData instanceof OGLSurfaceData) ||
        (sg.interpolationType == AffineTransformOp.TYPE_BICUBIC) ||
        (sg.compositeState > SunGraphics2D.COMP_ALPHA))
    {
        return false;
    }

    SurfaceData srcData =
        dstData.getSourceSurfaceData(img, SunGraphics2D.TRANSFORM_ISIDENT,
                                     CompositeType.SrcOver, null);
    if (!(srcData instanceof OGLSurfaceData)) {
        // REMIND: this hack tries to ensure that we have a cached texture
        srcData =
            dstData.getSourceSurfaceData(img, SunGraphics2D.TRANSFORM_ISIDENT,
                                         CompositeType.SrcOver, null);
        if (!(srcData instanceof OGLSurfaceData)) {
            return false;
        }
    }

    // Verify that the source surface is actually a texture and
    // that the operation is supported
    OGLSurfaceData oglSrc = (OGLSurfaceData)srcData;
    OGLGraphicsConfig gc = oglSrc.getOGLGraphicsConfig();
    if (oglSrc.getType() != OGLSurfaceData.TEXTURE ||
        !gc.isCapPresent(CAPS_EXT_BIOP_SHADER))
    {
        return false;
    }

    int sw = img.getWidth();
    int sh = img.getHeight();
    OGLBlitLoops.IsoBlit(srcData, dstData,
                         img, biop,
                         sg.composite, sg.getCompClip(),
                         sg.transform, sg.interpolationType,
                         0, 0, sw, sh,
                         x, y, x+sw, y+sh,
                         true);

    return true;
}
 
Example 11
Source File: D3DBufImgOps.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * This method is called from D3DDrawImage.transformImage() only.  It
 * validates the provided BufferedImageOp to determine whether the op
 * is one that can be accelerated by the D3D pipeline.  If the operation
 * cannot be completed for any reason, this method returns false;
 * otherwise, the given BufferedImage is rendered to the destination
 * using the provided BufferedImageOp and this method returns true.
 */
static boolean renderImageWithOp(SunGraphics2D sg, BufferedImage img,
                                 BufferedImageOp biop, int x, int y)
{
    // Validate the provided BufferedImage (make sure it is one that
    // is supported, and that its properties are acceleratable)
    if (biop instanceof ConvolveOp) {
        if (!isConvolveOpValid((ConvolveOp)biop)) {
            return false;
        }
    } else if (biop instanceof RescaleOp) {
        if (!isRescaleOpValid((RescaleOp)biop, img)) {
            return false;
        }
    } else if (biop instanceof LookupOp) {
        if (!isLookupOpValid((LookupOp)biop, img)) {
            return false;
        }
    } else {
        // No acceleration for other BufferedImageOps (yet)
        return false;
    }

    SurfaceData dstData = sg.surfaceData;
    if (!(dstData instanceof D3DSurfaceData) ||
        (sg.interpolationType == AffineTransformOp.TYPE_BICUBIC) ||
        (sg.compositeState > SunGraphics2D.COMP_ALPHA))
    {
        return false;
    }

    SurfaceData srcData =
        dstData.getSourceSurfaceData(img, sg.TRANSFORM_ISIDENT,
                                     CompositeType.SrcOver, null);
    if (!(srcData instanceof D3DSurfaceData)) {
        // REMIND: this hack tries to ensure that we have a cached texture
        srcData =
            dstData.getSourceSurfaceData(img, sg.TRANSFORM_ISIDENT,
                                         CompositeType.SrcOver, null);
        if (!(srcData instanceof D3DSurfaceData)) {
            return false;
        }
    }

    // Verify that the source surface is actually a texture and that
    // shaders are supported
    D3DSurfaceData d3dSrc = (D3DSurfaceData)srcData;
    D3DGraphicsDevice gd =
        (D3DGraphicsDevice)d3dSrc.getDeviceConfiguration().getDevice();
    if (d3dSrc.getType() != D3DSurfaceData.TEXTURE ||
        !gd.isCapPresent(CAPS_LCD_SHADER))
    {
        return false;
    }

    int sw = img.getWidth();
    int sh = img.getHeight();
    D3DBlitLoops.IsoBlit(srcData, dstData,
                         img, biop,
                         sg.composite, sg.getCompClip(),
                         sg.transform, sg.interpolationType,
                         0, 0, sw, sh,
                         x, y, x+sw, y+sh,
                         true);

    return true;
}
 
Example 12
Source File: D3DBufImgOps.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * This method is called from D3DDrawImage.transformImage() only.  It
 * validates the provided BufferedImageOp to determine whether the op
 * is one that can be accelerated by the D3D pipeline.  If the operation
 * cannot be completed for any reason, this method returns false;
 * otherwise, the given BufferedImage is rendered to the destination
 * using the provided BufferedImageOp and this method returns true.
 */
static boolean renderImageWithOp(SunGraphics2D sg, BufferedImage img,
                                 BufferedImageOp biop, int x, int y)
{
    // Validate the provided BufferedImage (make sure it is one that
    // is supported, and that its properties are acceleratable)
    if (biop instanceof ConvolveOp) {
        if (!isConvolveOpValid((ConvolveOp)biop)) {
            return false;
        }
    } else if (biop instanceof RescaleOp) {
        if (!isRescaleOpValid((RescaleOp)biop, img)) {
            return false;
        }
    } else if (biop instanceof LookupOp) {
        if (!isLookupOpValid((LookupOp)biop, img)) {
            return false;
        }
    } else {
        // No acceleration for other BufferedImageOps (yet)
        return false;
    }

    SurfaceData dstData = sg.surfaceData;
    if (!(dstData instanceof D3DSurfaceData) ||
        (sg.interpolationType == AffineTransformOp.TYPE_BICUBIC) ||
        (sg.compositeState > SunGraphics2D.COMP_ALPHA))
    {
        return false;
    }

    SurfaceData srcData =
        dstData.getSourceSurfaceData(img, sg.TRANSFORM_ISIDENT,
                                     CompositeType.SrcOver, null);
    if (!(srcData instanceof D3DSurfaceData)) {
        // REMIND: this hack tries to ensure that we have a cached texture
        srcData =
            dstData.getSourceSurfaceData(img, sg.TRANSFORM_ISIDENT,
                                         CompositeType.SrcOver, null);
        if (!(srcData instanceof D3DSurfaceData)) {
            return false;
        }
    }

    // Verify that the source surface is actually a texture and that
    // shaders are supported
    D3DSurfaceData d3dSrc = (D3DSurfaceData)srcData;
    D3DGraphicsDevice gd =
        (D3DGraphicsDevice)d3dSrc.getDeviceConfiguration().getDevice();
    if (d3dSrc.getType() != D3DSurfaceData.TEXTURE ||
        !gd.isCapPresent(CAPS_LCD_SHADER))
    {
        return false;
    }

    int sw = img.getWidth();
    int sh = img.getHeight();
    D3DBlitLoops.IsoBlit(srcData, dstData,
                         img, biop,
                         sg.composite, sg.getCompClip(),
                         sg.transform, sg.interpolationType,
                         0, 0, sw, sh,
                         x, y, x+sw, y+sh,
                         true);

    return true;
}
 
Example 13
Source File: D3DBufImgOps.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * This method is called from D3DDrawImage.transformImage() only.  It
 * validates the provided BufferedImageOp to determine whether the op
 * is one that can be accelerated by the D3D pipeline.  If the operation
 * cannot be completed for any reason, this method returns false;
 * otherwise, the given BufferedImage is rendered to the destination
 * using the provided BufferedImageOp and this method returns true.
 */
static boolean renderImageWithOp(SunGraphics2D sg, BufferedImage img,
                                 BufferedImageOp biop, int x, int y)
{
    // Validate the provided BufferedImage (make sure it is one that
    // is supported, and that its properties are acceleratable)
    if (biop instanceof ConvolveOp) {
        if (!isConvolveOpValid((ConvolveOp)biop)) {
            return false;
        }
    } else if (biop instanceof RescaleOp) {
        if (!isRescaleOpValid((RescaleOp)biop, img)) {
            return false;
        }
    } else if (biop instanceof LookupOp) {
        if (!isLookupOpValid((LookupOp)biop, img)) {
            return false;
        }
    } else {
        // No acceleration for other BufferedImageOps (yet)
        return false;
    }

    SurfaceData dstData = sg.surfaceData;
    if (!(dstData instanceof D3DSurfaceData) ||
        (sg.interpolationType == AffineTransformOp.TYPE_BICUBIC) ||
        (sg.compositeState > SunGraphics2D.COMP_ALPHA))
    {
        return false;
    }

    SurfaceData srcData =
        dstData.getSourceSurfaceData(img, sg.TRANSFORM_ISIDENT,
                                     CompositeType.SrcOver, null);
    if (!(srcData instanceof D3DSurfaceData)) {
        // REMIND: this hack tries to ensure that we have a cached texture
        srcData =
            dstData.getSourceSurfaceData(img, sg.TRANSFORM_ISIDENT,
                                         CompositeType.SrcOver, null);
        if (!(srcData instanceof D3DSurfaceData)) {
            return false;
        }
    }

    // Verify that the source surface is actually a texture and that
    // shaders are supported
    D3DSurfaceData d3dSrc = (D3DSurfaceData)srcData;
    D3DGraphicsDevice gd =
        (D3DGraphicsDevice)d3dSrc.getDeviceConfiguration().getDevice();
    if (d3dSrc.getType() != D3DSurfaceData.TEXTURE ||
        !gd.isCapPresent(CAPS_LCD_SHADER))
    {
        return false;
    }

    int sw = img.getWidth();
    int sh = img.getHeight();
    D3DBlitLoops.IsoBlit(srcData, dstData,
                         img, biop,
                         sg.composite, sg.getCompClip(),
                         sg.transform, sg.interpolationType,
                         0, 0, sw, sh,
                         x, y, x+sw, y+sh,
                         true);

    return true;
}
 
Example 14
Source File: D3DBufImgOps.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * This method is called from D3DDrawImage.transformImage() only.  It
 * validates the provided BufferedImageOp to determine whether the op
 * is one that can be accelerated by the D3D pipeline.  If the operation
 * cannot be completed for any reason, this method returns false;
 * otherwise, the given BufferedImage is rendered to the destination
 * using the provided BufferedImageOp and this method returns true.
 */
static boolean renderImageWithOp(SunGraphics2D sg, BufferedImage img,
                                 BufferedImageOp biop, int x, int y)
{
    // Validate the provided BufferedImage (make sure it is one that
    // is supported, and that its properties are acceleratable)
    if (biop instanceof ConvolveOp) {
        if (!isConvolveOpValid((ConvolveOp)biop)) {
            return false;
        }
    } else if (biop instanceof RescaleOp) {
        if (!isRescaleOpValid((RescaleOp)biop, img)) {
            return false;
        }
    } else if (biop instanceof LookupOp) {
        if (!isLookupOpValid((LookupOp)biop, img)) {
            return false;
        }
    } else {
        // No acceleration for other BufferedImageOps (yet)
        return false;
    }

    SurfaceData dstData = sg.surfaceData;
    if (!(dstData instanceof D3DSurfaceData) ||
        (sg.interpolationType == AffineTransformOp.TYPE_BICUBIC) ||
        (sg.compositeState > SunGraphics2D.COMP_ALPHA))
    {
        return false;
    }

    SurfaceData srcData =
        dstData.getSourceSurfaceData(img, sg.TRANSFORM_ISIDENT,
                                     CompositeType.SrcOver, null);
    if (!(srcData instanceof D3DSurfaceData)) {
        // REMIND: this hack tries to ensure that we have a cached texture
        srcData =
            dstData.getSourceSurfaceData(img, sg.TRANSFORM_ISIDENT,
                                         CompositeType.SrcOver, null);
        if (!(srcData instanceof D3DSurfaceData)) {
            return false;
        }
    }

    // Verify that the source surface is actually a texture and that
    // shaders are supported
    D3DSurfaceData d3dSrc = (D3DSurfaceData)srcData;
    D3DGraphicsDevice gd =
        (D3DGraphicsDevice)d3dSrc.getDeviceConfiguration().getDevice();
    if (d3dSrc.getType() != D3DSurfaceData.TEXTURE ||
        !gd.isCapPresent(CAPS_LCD_SHADER))
    {
        return false;
    }

    int sw = img.getWidth();
    int sh = img.getHeight();
    D3DBlitLoops.IsoBlit(srcData, dstData,
                         img, biop,
                         sg.composite, sg.getCompClip(),
                         sg.transform, sg.interpolationType,
                         0, 0, sw, sh,
                         x, y, x+sw, y+sh,
                         true);

    return true;
}
 
Example 15
Source File: OGLBufImgOps.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * This method is called from OGLDrawImage.transformImage() only.  It
 * validates the provided BufferedImageOp to determine whether the op
 * is one that can be accelerated by the OGL pipeline.  If the operation
 * cannot be completed for any reason, this method returns false;
 * otherwise, the given BufferedImage is rendered to the destination
 * using the provided BufferedImageOp and this method returns true.
 */
static boolean renderImageWithOp(SunGraphics2D sg, BufferedImage img,
                                 BufferedImageOp biop, int x, int y)
{
    // Validate the provided BufferedImage (make sure it is one that
    // is supported, and that its properties are acceleratable)
    if (biop instanceof ConvolveOp) {
        if (!isConvolveOpValid((ConvolveOp)biop)) {
            return false;
        }
    } else if (biop instanceof RescaleOp) {
        if (!isRescaleOpValid((RescaleOp)biop, img)) {
            return false;
        }
    } else if (biop instanceof LookupOp) {
        if (!isLookupOpValid((LookupOp)biop, img)) {
            return false;
        }
    } else {
        // No acceleration for other BufferedImageOps (yet)
        return false;
    }

    SurfaceData dstData = sg.surfaceData;
    if (!(dstData instanceof OGLSurfaceData) ||
        (sg.interpolationType == AffineTransformOp.TYPE_BICUBIC) ||
        (sg.compositeState > SunGraphics2D.COMP_ALPHA))
    {
        return false;
    }

    SurfaceData srcData =
        dstData.getSourceSurfaceData(img, SunGraphics2D.TRANSFORM_ISIDENT,
                                     CompositeType.SrcOver, null);
    if (!(srcData instanceof OGLSurfaceData)) {
        // REMIND: this hack tries to ensure that we have a cached texture
        srcData =
            dstData.getSourceSurfaceData(img, SunGraphics2D.TRANSFORM_ISIDENT,
                                         CompositeType.SrcOver, null);
        if (!(srcData instanceof OGLSurfaceData)) {
            return false;
        }
    }

    // Verify that the source surface is actually a texture and
    // that the operation is supported
    OGLSurfaceData oglSrc = (OGLSurfaceData)srcData;
    OGLGraphicsConfig gc = oglSrc.getOGLGraphicsConfig();
    if (oglSrc.getType() != OGLSurfaceData.TEXTURE ||
        !gc.isCapPresent(CAPS_EXT_BIOP_SHADER))
    {
        return false;
    }

    int sw = img.getWidth();
    int sh = img.getHeight();
    OGLBlitLoops.IsoBlit(srcData, dstData,
                         img, biop,
                         sg.composite, sg.getCompClip(),
                         sg.transform, sg.interpolationType,
                         0, 0, sw, sh,
                         x, y, x+sw, y+sh,
                         true);

    return true;
}
 
Example 16
Source File: XRSurfaceData.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void validatePipe(SunGraphics2D sg2d) {
    TextPipe textpipe;
    boolean validated = false;

    /*
     * The textpipe for now can't handle TexturePaint when extra-alpha is
     * specified nore XOR mode
     */
    if ((textpipe = getTextPipe(sg2d)) == null)
    {
        super.validatePipe(sg2d);
        textpipe = sg2d.textpipe;
        validated = true;
    }

    PixelToShapeConverter txPipe = null;
    XRRenderer nonTxPipe = null;

    /*
     * TODO: Can we rely on the GC for ARGB32 surfaces?
     */
    if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON) {
        if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) {
            if (sg2d.compositeState <= SunGraphics2D.COMP_XOR) {
                txPipe = xrtxpipe;
                nonTxPipe = xrpipe;
            }
        } else if (sg2d.compositeState <= SunGraphics2D.COMP_ALPHA) {
            if (XRPaints.isValid(sg2d)) {
                txPipe = xrtxpipe;
                nonTxPipe = xrpipe;
            }
            // custom paints handled by super.validatePipe() below
        }
    }

    if (sg2d.antialiasHint == SunHints.INTVAL_ANTIALIAS_ON &&
        JulesPathBuf.isCairoAvailable())
    {
        sg2d.shapepipe = aaShapePipe;
        sg2d.drawpipe = aaPixelToShapeConv;
        sg2d.fillpipe = aaPixelToShapeConv;
    } else {
        if (txPipe != null) {
            if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
                sg2d.drawpipe = txPipe;
                sg2d.fillpipe = txPipe;
            } else if (sg2d.strokeState != SunGraphics2D.STROKE_THIN) {
                sg2d.drawpipe = txPipe;
                sg2d.fillpipe = nonTxPipe;
            } else {
                sg2d.drawpipe = nonTxPipe;
                sg2d.fillpipe = nonTxPipe;
            }
            sg2d.shapepipe = nonTxPipe;
        } else {
            if (!validated) {
                super.validatePipe(sg2d);
            }
        }
    }

    // install the text pipe based on our earlier decision
    sg2d.textpipe = textpipe;

    // always override the image pipe with the specialized XRender pipe
    sg2d.imagepipe = xrDrawImage;
}
 
Example 17
Source File: OGLBufImgOps.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * This method is called from OGLDrawImage.transformImage() only.  It
 * validates the provided BufferedImageOp to determine whether the op
 * is one that can be accelerated by the OGL pipeline.  If the operation
 * cannot be completed for any reason, this method returns false;
 * otherwise, the given BufferedImage is rendered to the destination
 * using the provided BufferedImageOp and this method returns true.
 */
static boolean renderImageWithOp(SunGraphics2D sg, BufferedImage img,
                                 BufferedImageOp biop, int x, int y)
{
    // Validate the provided BufferedImage (make sure it is one that
    // is supported, and that its properties are acceleratable)
    if (biop instanceof ConvolveOp) {
        if (!isConvolveOpValid((ConvolveOp)biop)) {
            return false;
        }
    } else if (biop instanceof RescaleOp) {
        if (!isRescaleOpValid((RescaleOp)biop, img)) {
            return false;
        }
    } else if (biop instanceof LookupOp) {
        if (!isLookupOpValid((LookupOp)biop, img)) {
            return false;
        }
    } else {
        // No acceleration for other BufferedImageOps (yet)
        return false;
    }

    SurfaceData dstData = sg.surfaceData;
    if (!(dstData instanceof OGLSurfaceData) ||
        (sg.interpolationType == AffineTransformOp.TYPE_BICUBIC) ||
        (sg.compositeState > SunGraphics2D.COMP_ALPHA))
    {
        return false;
    }

    SurfaceData srcData =
        dstData.getSourceSurfaceData(img, SunGraphics2D.TRANSFORM_ISIDENT,
                                     CompositeType.SrcOver, null);
    if (!(srcData instanceof OGLSurfaceData)) {
        // REMIND: this hack tries to ensure that we have a cached texture
        srcData =
            dstData.getSourceSurfaceData(img, SunGraphics2D.TRANSFORM_ISIDENT,
                                         CompositeType.SrcOver, null);
        if (!(srcData instanceof OGLSurfaceData)) {
            return false;
        }
    }

    // Verify that the source surface is actually a texture and
    // that the operation is supported
    OGLSurfaceData oglSrc = (OGLSurfaceData)srcData;
    OGLGraphicsConfig gc = oglSrc.getOGLGraphicsConfig();
    if (oglSrc.getType() != OGLSurfaceData.TEXTURE ||
        !gc.isCapPresent(CAPS_EXT_BIOP_SHADER))
    {
        return false;
    }

    int sw = img.getWidth();
    int sh = img.getHeight();
    OGLBlitLoops.IsoBlit(srcData, dstData,
                         img, biop,
                         sg.composite, sg.getCompClip(),
                         sg.transform, sg.interpolationType,
                         0, 0, sw, sh,
                         x, y, x+sw, y+sh,
                         true);

    return true;
}
 
Example 18
Source File: D3DBufImgOps.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * This method is called from D3DDrawImage.transformImage() only.  It
 * validates the provided BufferedImageOp to determine whether the op
 * is one that can be accelerated by the D3D pipeline.  If the operation
 * cannot be completed for any reason, this method returns false;
 * otherwise, the given BufferedImage is rendered to the destination
 * using the provided BufferedImageOp and this method returns true.
 */
static boolean renderImageWithOp(SunGraphics2D sg, BufferedImage img,
                                 BufferedImageOp biop, int x, int y)
{
    // Validate the provided BufferedImage (make sure it is one that
    // is supported, and that its properties are acceleratable)
    if (biop instanceof ConvolveOp) {
        if (!isConvolveOpValid((ConvolveOp)biop)) {
            return false;
        }
    } else if (biop instanceof RescaleOp) {
        if (!isRescaleOpValid((RescaleOp)biop, img)) {
            return false;
        }
    } else if (biop instanceof LookupOp) {
        if (!isLookupOpValid((LookupOp)biop, img)) {
            return false;
        }
    } else {
        // No acceleration for other BufferedImageOps (yet)
        return false;
    }

    SurfaceData dstData = sg.surfaceData;
    if (!(dstData instanceof D3DSurfaceData) ||
        (sg.interpolationType == AffineTransformOp.TYPE_BICUBIC) ||
        (sg.compositeState > SunGraphics2D.COMP_ALPHA))
    {
        return false;
    }

    SurfaceData srcData =
        dstData.getSourceSurfaceData(img, sg.TRANSFORM_ISIDENT,
                                     CompositeType.SrcOver, null);
    if (!(srcData instanceof D3DSurfaceData)) {
        // REMIND: this hack tries to ensure that we have a cached texture
        srcData =
            dstData.getSourceSurfaceData(img, sg.TRANSFORM_ISIDENT,
                                         CompositeType.SrcOver, null);
        if (!(srcData instanceof D3DSurfaceData)) {
            return false;
        }
    }

    // Verify that the source surface is actually a texture and that
    // shaders are supported
    D3DSurfaceData d3dSrc = (D3DSurfaceData)srcData;
    D3DGraphicsDevice gd =
        (D3DGraphicsDevice)d3dSrc.getDeviceConfiguration().getDevice();
    if (d3dSrc.getType() != D3DSurfaceData.TEXTURE ||
        !gd.isCapPresent(CAPS_LCD_SHADER))
    {
        return false;
    }

    int sw = img.getWidth();
    int sh = img.getHeight();
    D3DBlitLoops.IsoBlit(srcData, dstData,
                         img, biop,
                         sg.composite, sg.getCompClip(),
                         sg.transform, sg.interpolationType,
                         0, 0, sw, sh,
                         x, y, x+sw, y+sh,
                         true);

    return true;
}
 
Example 19
Source File: D3DBufImgOps.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * This method is called from D3DDrawImage.transformImage() only.  It
 * validates the provided BufferedImageOp to determine whether the op
 * is one that can be accelerated by the D3D pipeline.  If the operation
 * cannot be completed for any reason, this method returns false;
 * otherwise, the given BufferedImage is rendered to the destination
 * using the provided BufferedImageOp and this method returns true.
 */
static boolean renderImageWithOp(SunGraphics2D sg, BufferedImage img,
                                 BufferedImageOp biop, int x, int y)
{
    // Validate the provided BufferedImage (make sure it is one that
    // is supported, and that its properties are acceleratable)
    if (biop instanceof ConvolveOp) {
        if (!isConvolveOpValid((ConvolveOp)biop)) {
            return false;
        }
    } else if (biop instanceof RescaleOp) {
        if (!isRescaleOpValid((RescaleOp)biop, img)) {
            return false;
        }
    } else if (biop instanceof LookupOp) {
        if (!isLookupOpValid((LookupOp)biop, img)) {
            return false;
        }
    } else {
        // No acceleration for other BufferedImageOps (yet)
        return false;
    }

    SurfaceData dstData = sg.surfaceData;
    if (!(dstData instanceof D3DSurfaceData) ||
        (sg.interpolationType == AffineTransformOp.TYPE_BICUBIC) ||
        (sg.compositeState > SunGraphics2D.COMP_ALPHA))
    {
        return false;
    }

    SurfaceData srcData =
        dstData.getSourceSurfaceData(img, sg.TRANSFORM_ISIDENT,
                                     CompositeType.SrcOver, null);
    if (!(srcData instanceof D3DSurfaceData)) {
        // REMIND: this hack tries to ensure that we have a cached texture
        srcData =
            dstData.getSourceSurfaceData(img, sg.TRANSFORM_ISIDENT,
                                         CompositeType.SrcOver, null);
        if (!(srcData instanceof D3DSurfaceData)) {
            return false;
        }
    }

    // Verify that the source surface is actually a texture and that
    // shaders are supported
    D3DSurfaceData d3dSrc = (D3DSurfaceData)srcData;
    D3DGraphicsDevice gd =
        (D3DGraphicsDevice)d3dSrc.getDeviceConfiguration().getDevice();
    if (d3dSrc.getType() != D3DSurfaceData.TEXTURE ||
        !gd.isCapPresent(CAPS_LCD_SHADER))
    {
        return false;
    }

    int sw = img.getWidth();
    int sh = img.getHeight();
    D3DBlitLoops.IsoBlit(srcData, dstData,
                         img, biop,
                         sg.composite, sg.getCompClip(),
                         sg.transform, sg.interpolationType,
                         0, 0, sw, sh,
                         x, y, x+sw, y+sh,
                         true);

    return true;
}
 
Example 20
Source File: XRSurfaceData.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void validatePipe(SunGraphics2D sg2d) {
    TextPipe textpipe;
    boolean validated = false;

    /*
     * The textpipe for now can't handle TexturePaint when extra-alpha is
     * specified nore XOR mode
     */
    if ((textpipe = getTextPipe(sg2d)) == null)
    {
        super.validatePipe(sg2d);
        textpipe = sg2d.textpipe;
        validated = true;
    }

    PixelToShapeConverter txPipe = null;
    XRRenderer nonTxPipe = null;

    /*
     * TODO: Can we rely on the GC for ARGB32 surfaces?
     */
    if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON) {
        if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) {
            if (sg2d.compositeState <= SunGraphics2D.COMP_XOR) {
                txPipe = xrtxpipe;
                nonTxPipe = xrpipe;
            }
        } else if (sg2d.compositeState <= SunGraphics2D.COMP_ALPHA) {
            if (XRPaints.isValid(sg2d)) {
                txPipe = xrtxpipe;
                nonTxPipe = xrpipe;
            }
            // custom paints handled by super.validatePipe() below
        }
    }

    if (sg2d.antialiasHint == SunHints.INTVAL_ANTIALIAS_ON &&
        JulesPathBuf.isCairoAvailable())
    {
        sg2d.shapepipe = aaShapePipe;
        sg2d.drawpipe = aaPixelToShapeConv;
        sg2d.fillpipe = aaPixelToShapeConv;
    } else {
        if (txPipe != null) {
            if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
                sg2d.drawpipe = txPipe;
                sg2d.fillpipe = txPipe;
            } else if (sg2d.strokeState != SunGraphics2D.STROKE_THIN) {
                sg2d.drawpipe = txPipe;
                sg2d.fillpipe = nonTxPipe;
            } else {
                sg2d.drawpipe = nonTxPipe;
                sg2d.fillpipe = nonTxPipe;
            }
            sg2d.shapepipe = nonTxPipe;
        } else {
            if (!validated) {
                super.validatePipe(sg2d);
            }
        }
    }

    // install the text pipe based on our earlier decision
    sg2d.textpipe = textpipe;

    // always override the image pipe with the specialized XRender pipe
    sg2d.imagepipe = xrDrawImage;
}