Java Code Examples for sun.java2d.SunGraphics2D#PAINT_ALPHACOLOR

The following examples show how to use sun.java2d.SunGraphics2D#PAINT_ALPHACOLOR . 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: OGLSurfaceData.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected MaskFill getMaskFill(SunGraphics2D sg2d) {
    if (sg2d.paintState > SunGraphics2D.PAINT_ALPHACOLOR) {
        /*
         * We can only accelerate non-Color MaskFill operations if
         * all of the following conditions hold true:
         *   - there is an implementation for the given paintState
         *   - the current Paint can be accelerated for this destination
         *   - multitexturing is available (since we need to modulate
         *     the alpha mask texture with the paint texture)
         *
         * In all other cases, we return null, in which case the
         * validation code will choose a more general software-based loop.
         */
        if (!OGLPaints.isValid(sg2d) ||
            !graphicsConfig.isCapPresent(CAPS_MULTITEXTURE))
        {
            return null;
        }
    }
    return super.getMaskFill(sg2d);
}
 
Example 2
Source File: XRSurfaceData.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected MaskFill getMaskFill(SunGraphics2D sg2d) {
    AlphaComposite aComp = null;
    if(sg2d.composite != null
            && sg2d.composite instanceof AlphaComposite) {
        aComp = (AlphaComposite) sg2d.composite;
    }

    boolean supportedPaint = sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR
            || XRPaints.isValid(sg2d);

    boolean supportedCompOp = false;
    if(aComp != null) {
        int rule = aComp.getRule();
        supportedCompOp = XRUtils.isMaskEvaluated(XRUtils.j2dAlphaCompToXR(rule));
    }

    return (supportedPaint && supportedCompOp) ?  super.getMaskFill(sg2d) : null;
}
 
Example 3
Source File: OGLSurfaceData.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected MaskFill getMaskFill(SunGraphics2D sg2d) {
    if (sg2d.paintState > SunGraphics2D.PAINT_ALPHACOLOR) {
        /*
         * We can only accelerate non-Color MaskFill operations if
         * all of the following conditions hold true:
         *   - there is an implementation for the given paintState
         *   - the current Paint can be accelerated for this destination
         *   - multitexturing is available (since we need to modulate
         *     the alpha mask texture with the paint texture)
         *
         * In all other cases, we return null, in which case the
         * validation code will choose a more general software-based loop.
         */
        if (!OGLPaints.isValid(sg2d) ||
            !graphicsConfig.isCapPresent(CAPS_MULTITEXTURE))
        {
            return null;
        }
    }
    return super.getMaskFill(sg2d);
}
 
Example 4
Source File: OGLSurfaceData.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
@Override
protected MaskFill getMaskFill(SunGraphics2D sg2d) {
    if (sg2d.paintState > SunGraphics2D.PAINT_ALPHACOLOR) {
        /*
         * We can only accelerate non-Color MaskFill operations if
         * all of the following conditions hold true:
         *   - there is an implementation for the given paintState
         *   - the current Paint can be accelerated for this destination
         *   - multitexturing is available (since we need to modulate
         *     the alpha mask texture with the paint texture)
         *
         * In all other cases, we return null, in which case the
         * validation code will choose a more general software-based loop.
         */
        if (!OGLPaints.isValid(sg2d) ||
            !graphicsConfig.isCapPresent(CAPS_MULTITEXTURE))
        {
            return null;
        }
    }
    return super.getMaskFill(sg2d);
}
 
Example 5
Source File: XRSurfaceData.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
protected MaskFill getMaskFill(SunGraphics2D sg2d) {
    AlphaComposite aComp = null;
    if(sg2d.composite != null
            && sg2d.composite instanceof AlphaComposite) {
        aComp = (AlphaComposite) sg2d.composite;
    }

    boolean supportedPaint = sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR
            || XRPaints.isValid(sg2d);

    boolean supportedCompOp = false;
    if(aComp != null) {
        int rule = aComp.getRule();
        supportedCompOp = XRUtils.isMaskEvaluated(XRUtils.j2dAlphaCompToXR(rule));
    }

    return (supportedPaint && supportedCompOp) ?  super.getMaskFill(sg2d) : null;
}
 
Example 6
Source File: XRSurfaceData.java    From jdk8u_jdk 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 openjdk-jdk9 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: BufImgSurfaceData.java    From jdk8u60 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_ISCOPY)
    {
        return solidloops;
    }
    return super.getRenderLoops(sg2d);
}
 
Example 9
Source File: X11SurfaceData.java    From jdk8u60 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_ISCOPY)
    {
        return solidloops;
    }
    return super.getRenderLoops(sg2d);
}
 
Example 10
Source File: XRSurfaceData.java    From openjdk-8-source 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 11
Source File: X11SurfaceData.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_ISCOPY)
    {
        return solidloops;
    }
    return super.getRenderLoops(sg2d);
}
 
Example 12
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 13
Source File: XRSurfaceData.java    From jdk8u-jdk 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 14
Source File: BufImgSurfaceData.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public RenderLoops getRenderLoops(SunGraphics2D sg2d) {
    if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR &&
        sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY)
    {
        return solidloops;
    }
    return super.getRenderLoops(sg2d);
}
 
Example 15
Source File: X11SurfaceData.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_ISCOPY)
    {
        return solidloops;
    }
    return super.getRenderLoops(sg2d);
}
 
Example 16
Source File: XRSurfaceData.java    From dragonwell8_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 17
Source File: BufferedPaints.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static void setPaint(RenderQueue rq, SunGraphics2D sg2d,
                     Paint paint, int ctxflags)
{
    if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) {
        setColor(rq, sg2d.pixel);
    } else {
        boolean useMask = (ctxflags & BufferedContext.USE_MASK) != 0;
        switch (sg2d.paintState) {
        case SunGraphics2D.PAINT_GRADIENT:
            setGradientPaint(rq, sg2d,
                             (GradientPaint)paint, useMask);
            break;
        case SunGraphics2D.PAINT_LIN_GRADIENT:
            setLinearGradientPaint(rq, sg2d,
                                   (LinearGradientPaint)paint, useMask);
            break;
        case SunGraphics2D.PAINT_RAD_GRADIENT:
            setRadialGradientPaint(rq, sg2d,
                                   (RadialGradientPaint)paint, useMask);
            break;
        case SunGraphics2D.PAINT_TEXTURE:
            setTexturePaint(rq, sg2d,
                            (TexturePaint)paint, useMask);
            break;
        default:
            break;
        }
    }
}
 
Example 18
Source File: XRSurfaceData.java    From openjdk-jdk8u 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 19
Source File: GDIWindowSurfaceData.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void validatePipe(SunGraphics2D sg2d) {
    if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON &&
        sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR &&
        (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY ||
         sg2d.compositeState == SunGraphics2D.COMP_XOR))
    {
        if (sg2d.clipState == SunGraphics2D.CLIP_SHAPE) {
            // Do this to init textpipe correctly; we will override the
            // other non-text pipes below
            // REMIND: we should clean this up eventually instead of
            // having this work duplicated.
            super.validatePipe(sg2d);
        } else {
            switch (sg2d.textAntialiasHint) {

            case SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT:
                /* equate DEFAULT to OFF which it is for us */
            case SunHints.INTVAL_TEXT_ANTIALIAS_OFF:
                sg2d.textpipe = solidTextRenderer;
                break;

            case SunHints.INTVAL_TEXT_ANTIALIAS_ON:
                sg2d.textpipe = aaTextRenderer;
                break;

            default:
                switch (sg2d.getFontInfo().aaHint) {

                case SunHints.INTVAL_TEXT_ANTIALIAS_LCD_HRGB:
                case SunHints.INTVAL_TEXT_ANTIALIAS_LCD_VRGB:
                    sg2d.textpipe = lcdTextRenderer;
                    break;

                case SunHints.INTVAL_TEXT_ANTIALIAS_ON:
                    sg2d.textpipe = aaTextRenderer;
                    break;

                default:
                    sg2d.textpipe = solidTextRenderer;
                }
            }
        }
        sg2d.imagepipe = imagepipe;
        if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
            sg2d.drawpipe = gdiTxPipe;
            sg2d.fillpipe = gdiTxPipe;
        } else if (sg2d.strokeState != SunGraphics2D.STROKE_THIN){
            sg2d.drawpipe = gdiTxPipe;
            sg2d.fillpipe = gdiPipe;
        } else {
            sg2d.drawpipe = gdiPipe;
            sg2d.fillpipe = gdiPipe;
        }
        sg2d.shapepipe = gdiPipe;
        // This is needed for AA text.
        // Note that even a SolidTextRenderer can dispatch AA text
        // if a GlyphVector overrides the AA setting.
        // We use getRenderLoops() rather than setting solidloops
        // directly so that we get the appropriate loops in XOR mode.
        if (sg2d.loops == null) {
            // assert(some pipe will always be a LoopBasedPipe)
            sg2d.loops = getRenderLoops(sg2d);
        }
    } else {
        super.validatePipe(sg2d);
    }
}
 
Example 20
Source File: XRSurfaceData.java    From dragonwell8_jdk 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;
}