Java Code Examples for sun.java2d.loops.CompositeType#SrcOverNoEa

The following examples show how to use sun.java2d.loops.CompositeType#SrcOverNoEa . 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: SunGraphics2D.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
void validateColor() {
    int eargb;
    if (imageComp == CompositeType.Clear) {
        eargb = 0;
    } else {
        eargb = foregroundColor.getRGB();
        if (compositeState <= COMP_ALPHA &&
            imageComp != CompositeType.SrcNoEa &&
            imageComp != CompositeType.SrcOverNoEa)
        {
            AlphaComposite alphacomp = (AlphaComposite) composite;
            int a = Math.round(alphacomp.getAlpha() * (eargb >>> 24));
            eargb = (eargb & 0x00ffffff) | (a << 24);
        }
    }
    this.eargb = eargb;
    this.pixel = surfaceData.pixelFor(eargb);
}
 
Example 2
Source File: SunGraphics2D.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
final void validateColor() {
    int eargb;
    if (imageComp == CompositeType.Clear) {
        eargb = 0;
    } else {
        eargb = foregroundColor.getRGB();
        if (compositeState <= COMP_ALPHA &&
            imageComp != CompositeType.SrcNoEa &&
            imageComp != CompositeType.SrcOverNoEa)
        {
            AlphaComposite alphacomp = (AlphaComposite) composite;
            int a = Math.round(alphacomp.getAlpha() * (eargb >>> 24));
            eargb = (eargb & 0x00ffffff) | (a << 24);
        }
    }
    this.eargb = eargb;
    this.pixel = surfaceData.pixelFor(eargb);
}
 
Example 3
Source File: SunGraphics2D.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
final void validateColor() {
    int eargb;
    if (imageComp == CompositeType.Clear) {
        eargb = 0;
    } else {
        eargb = foregroundColor.getRGB();
        if (compositeState <= COMP_ALPHA &&
            imageComp != CompositeType.SrcNoEa &&
            imageComp != CompositeType.SrcOverNoEa)
        {
            AlphaComposite alphacomp = (AlphaComposite) composite;
            int a = Math.round(alphacomp.getAlpha() * (eargb >>> 24));
            eargb = (eargb & 0x00ffffff) | (a << 24);
        }
    }
    this.eargb = eargb;
    this.pixel = surfaceData.pixelFor(eargb);
}
 
Example 4
Source File: SunGraphics2D.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
final void validateColor() {
    int eargb;
    if (imageComp == CompositeType.Clear) {
        eargb = 0;
    } else {
        eargb = foregroundColor.getRGB();
        if (compositeState <= COMP_ALPHA &&
            imageComp != CompositeType.SrcNoEa &&
            imageComp != CompositeType.SrcOverNoEa)
        {
            AlphaComposite alphacomp = (AlphaComposite) composite;
            int a = Math.round(alphacomp.getAlpha() * (eargb >>> 24));
            eargb = (eargb & 0x00ffffff) | (a << 24);
        }
    }
    this.eargb = eargb;
    this.pixel = surfaceData.pixelFor(eargb);
}
 
Example 5
Source File: SunGraphics2D.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the Paint in the current graphics state.
 * @param paint The Paint object to be used to generate color in
 * the rendering process.
 * @see java.awt.Graphics#setColor
 * @see GradientPaint
 * @see TexturePaint
 */
public void setPaint(Paint paint) {
    if (paint instanceof Color) {
        setColor((Color) paint);
        return;
    }
    if (paint == null || this.paint == paint) {
        return;
    }
    this.paint = paint;
    if (imageComp == CompositeType.SrcOverNoEa) {
        // special case where compState depends on opacity of paint
        if (paint.getTransparency() == Transparency.OPAQUE) {
            if (compositeState != COMP_ISCOPY) {
                compositeState = COMP_ISCOPY;
            }
        } else {
            if (compositeState == COMP_ISCOPY) {
                compositeState = COMP_ALPHA;
            }
        }
    }
    Class<? extends Paint> paintClass = paint.getClass();
    if (paintClass == GradientPaint.class) {
        paintState = PAINT_GRADIENT;
    } else if (paintClass == LinearGradientPaint.class) {
        paintState = PAINT_LIN_GRADIENT;
    } else if (paintClass == RadialGradientPaint.class) {
        paintState = PAINT_RAD_GRADIENT;
    } else if (paintClass == TexturePaint.class) {
        paintState = PAINT_TEXTURE;
    } else {
        paintState = PAINT_CUSTOM;
    }
    validFontInfo = false;
    invalidatePipe();
}
 
Example 6
Source File: SunGraphics2D.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the Paint in the current graphics state.
 * @param paint The Paint object to be used to generate color in
 * the rendering process.
 * @see java.awt.Graphics#setColor
 * @see GradientPaint
 * @see TexturePaint
 */
public void setPaint(Paint paint) {
    if (paint instanceof Color) {
        setColor((Color) paint);
        return;
    }
    if (paint == null || this.paint == paint) {
        return;
    }
    this.paint = paint;
    if (imageComp == CompositeType.SrcOverNoEa) {
        // special case where compState depends on opacity of paint
        if (paint.getTransparency() == Transparency.OPAQUE) {
            if (compositeState != COMP_ISCOPY) {
                compositeState = COMP_ISCOPY;
            }
        } else {
            if (compositeState == COMP_ISCOPY) {
                compositeState = COMP_ALPHA;
            }
        }
    }
    Class<? extends Paint> paintClass = paint.getClass();
    if (paintClass == GradientPaint.class) {
        paintState = PAINT_GRADIENT;
    } else if (paintClass == LinearGradientPaint.class) {
        paintState = PAINT_LIN_GRADIENT;
    } else if (paintClass == RadialGradientPaint.class) {
        paintState = PAINT_RAD_GRADIENT;
    } else if (paintClass == TexturePaint.class) {
        paintState = PAINT_TEXTURE;
    } else {
        paintState = PAINT_CUSTOM;
    }
    validFontInfo = false;
    invalidatePipe();
}
 
Example 7
Source File: SunGraphics2D.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public SunGraphics2D(SurfaceData sd, Color fg, Color bg, Font f) {
    surfaceData = sd;
    foregroundColor = fg;
    backgroundColor = bg;
    stroke = defaultStroke;
    composite = defaultComposite;
    paint = foregroundColor;

    imageComp = CompositeType.SrcOverNoEa;

    renderHint = SunHints.INTVAL_RENDER_DEFAULT;
    antialiasHint = SunHints.INTVAL_ANTIALIAS_OFF;
    textAntialiasHint = SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT;
    fractionalMetricsHint = SunHints.INTVAL_FRACTIONALMETRICS_OFF;
    lcdTextContrast = lcdTextContrastDefaultValue;
    interpolationHint = -1;
    strokeHint = SunHints.INTVAL_STROKE_DEFAULT;
    resolutionVariantHint = SunHints.INTVAL_RESOLUTION_VARIANT_DEFAULT;

    interpolationType = AffineTransformOp.TYPE_NEAREST_NEIGHBOR;

    transform = getDefaultTransform();
    if (!transform.isIdentity()) {
        invalidateTransform();
    }

    validateColor();

    font = f;
    if (font == null) {
        font = defaultFont;
    }

    setDevClip(sd.getBounds());
    invalidatePipe();
}
 
Example 8
Source File: SunGraphics2D.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public SunGraphics2D(SurfaceData sd, Color fg, Color bg, Font f) {
    surfaceData = sd;
    foregroundColor = fg;
    backgroundColor = bg;

    transform = new AffineTransform();
    stroke = defaultStroke;
    composite = defaultComposite;
    paint = foregroundColor;

    imageComp = CompositeType.SrcOverNoEa;

    renderHint = SunHints.INTVAL_RENDER_DEFAULT;
    antialiasHint = SunHints.INTVAL_ANTIALIAS_OFF;
    textAntialiasHint = SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT;
    fractionalMetricsHint = SunHints.INTVAL_FRACTIONALMETRICS_OFF;
    lcdTextContrast = lcdTextContrastDefaultValue;
    interpolationHint = -1;
    strokeHint = SunHints.INTVAL_STROKE_DEFAULT;
    resolutionVariantHint = SunHints.INTVAL_RESOLUTION_VARIANT_DEFAULT;

    interpolationType = AffineTransformOp.TYPE_NEAREST_NEIGHBOR;

    validateColor();

    devScale = sd.getDefaultScale();
    if (devScale != 1) {
        transform.setToScale(devScale, devScale);
        invalidateTransform();
    }

    font = f;
    if (font == null) {
        font = defaultFont;
    }

    setDevClip(sd.getBounds());
    invalidatePipe();
}
 
Example 9
Source File: SunGraphics2D.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the Paint in the current graphics state.
 * @param paint The Paint object to be used to generate color in
 * the rendering process.
 * @see java.awt.Graphics#setColor
 * @see GradientPaint
 * @see TexturePaint
 */
public void setPaint(Paint paint) {
    if (paint instanceof Color) {
        setColor((Color) paint);
        return;
    }
    if (paint == null || this.paint == paint) {
        return;
    }
    this.paint = paint;
    if (imageComp == CompositeType.SrcOverNoEa) {
        // special case where compState depends on opacity of paint
        if (paint.getTransparency() == Transparency.OPAQUE) {
            if (compositeState != COMP_ISCOPY) {
                compositeState = COMP_ISCOPY;
            }
        } else {
            if (compositeState == COMP_ISCOPY) {
                compositeState = COMP_ALPHA;
            }
        }
    }
    Class<? extends Paint> paintClass = paint.getClass();
    if (paintClass == GradientPaint.class) {
        paintState = PAINT_GRADIENT;
    } else if (paintClass == LinearGradientPaint.class) {
        paintState = PAINT_LIN_GRADIENT;
    } else if (paintClass == RadialGradientPaint.class) {
        paintState = PAINT_RAD_GRADIENT;
    } else if (paintClass == TexturePaint.class) {
        paintState = PAINT_TEXTURE;
    } else {
        paintState = PAINT_CUSTOM;
    }
    validFontInfo = false;
    invalidatePipe();
}
 
Example 10
Source File: SunGraphics2D.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public SunGraphics2D(SurfaceData sd, Color fg, Color bg, Font f) {
    surfaceData = sd;
    foregroundColor = fg;
    backgroundColor = bg;
    stroke = defaultStroke;
    composite = defaultComposite;
    paint = foregroundColor;

    imageComp = CompositeType.SrcOverNoEa;

    renderHint = SunHints.INTVAL_RENDER_DEFAULT;
    antialiasHint = SunHints.INTVAL_ANTIALIAS_OFF;
    textAntialiasHint = SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT;
    fractionalMetricsHint = SunHints.INTVAL_FRACTIONALMETRICS_OFF;
    lcdTextContrast = lcdTextContrastDefaultValue;
    interpolationHint = -1;
    strokeHint = SunHints.INTVAL_STROKE_DEFAULT;
    resolutionVariantHint = SunHints.INTVAL_RESOLUTION_VARIANT_DEFAULT;

    interpolationType = AffineTransformOp.TYPE_NEAREST_NEIGHBOR;

    transform = getDefaultTransform();
    if (!transform.isIdentity()) {
        invalidateTransform();
    }

    validateColor();

    font = f;
    if (font == null) {
        font = defaultFont;
    }

    setDevClip(sd.getBounds());
    invalidatePipe();
}
 
Example 11
Source File: SurfaceData.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static CompositeType getFillCompositeType(SunGraphics2D sg2d) {
    CompositeType compType = sg2d.imageComp;
    if (sg2d.compositeState == SunGraphics2D.COMP_ISCOPY) {
        if (compType == CompositeType.SrcOverNoEa) {
            compType = CompositeType.OpaqueSrcOverNoEa;
        } else {
            compType = CompositeType.SrcNoEa;
        }
    }
    return compType;
}
 
Example 12
Source File: SunGraphics2D.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void setColor(Color color) {
    if (color == null || color == paint) {
        return;
    }
    this.paint = foregroundColor = color;
    validateColor();
    if ((eargb >> 24) == -1) {
        if (paintState == PAINT_OPAQUECOLOR) {
            return;
        }
        paintState = PAINT_OPAQUECOLOR;
        if (imageComp == CompositeType.SrcOverNoEa) {
            // special case where compState depends on opacity of paint
            compositeState = COMP_ISCOPY;
        }
    } else {
        if (paintState == PAINT_ALPHACOLOR) {
            return;
        }
        paintState = PAINT_ALPHACOLOR;
        if (imageComp == CompositeType.SrcOverNoEa) {
            // special case where compState depends on opacity of paint
            compositeState = COMP_ALPHA;
        }
    }
    validFontInfo = false;
    invalidatePipe();
}
 
Example 13
Source File: SunGraphics2D.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public SunGraphics2D(SurfaceData sd, Color fg, Color bg, Font f) {
    surfaceData = sd;
    foregroundColor = fg;
    backgroundColor = bg;

    transform = new AffineTransform();
    stroke = defaultStroke;
    composite = defaultComposite;
    paint = foregroundColor;

    imageComp = CompositeType.SrcOverNoEa;

    renderHint = SunHints.INTVAL_RENDER_DEFAULT;
    antialiasHint = SunHints.INTVAL_ANTIALIAS_OFF;
    textAntialiasHint = SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT;
    fractionalMetricsHint = SunHints.INTVAL_FRACTIONALMETRICS_OFF;
    lcdTextContrast = lcdTextContrastDefaultValue;
    interpolationHint = -1;
    strokeHint = SunHints.INTVAL_STROKE_DEFAULT;

    interpolationType = AffineTransformOp.TYPE_NEAREST_NEIGHBOR;

    validateColor();

    devScale = sd.getDefaultScale();
    if (devScale != 1) {
        transform.setToScale(devScale, devScale);
        invalidateTransform();
    }

    font = f;
    if (font == null) {
        font = defaultFont;
    }

    setDevClip(sd.getBounds());
    invalidatePipe();
}
 
Example 14
Source File: SunGraphics2D.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Sets the Composite in the current graphics state. Composite is used
 * in all drawing methods such as drawImage, drawString, drawPath,
 * and fillPath.  It specifies how new pixels are to be combined with
 * the existing pixels on the graphics device in the rendering process.
 * @param comp The Composite object to be used for drawing.
 * @see java.awt.Graphics#setXORMode
 * @see java.awt.Graphics#setPaintMode
 * @see AlphaComposite
 */
public void setComposite(Composite comp) {
    if (composite == comp) {
        return;
    }
    int newCompState;
    CompositeType newCompType;
    if (comp instanceof AlphaComposite) {
        AlphaComposite alphacomp = (AlphaComposite) comp;
        newCompType = CompositeType.forAlphaComposite(alphacomp);
        if (newCompType == CompositeType.SrcOverNoEa) {
            if (paintState == PAINT_OPAQUECOLOR ||
                (paintState > PAINT_ALPHACOLOR &&
                 paint.getTransparency() == Transparency.OPAQUE))
            {
                newCompState = COMP_ISCOPY;
            } else {
                newCompState = COMP_ALPHA;
            }
        } else if (newCompType == CompositeType.SrcNoEa ||
                   newCompType == CompositeType.Src ||
                   newCompType == CompositeType.Clear)
        {
            newCompState = COMP_ISCOPY;
        } else if (surfaceData.getTransparency() == Transparency.OPAQUE &&
                   newCompType == CompositeType.SrcIn)
        {
            newCompState = COMP_ISCOPY;
        } else {
            newCompState = COMP_ALPHA;
        }
    } else if (comp instanceof XORComposite) {
        newCompState = COMP_XOR;
        newCompType = CompositeType.Xor;
    } else if (comp == null) {
        throw new IllegalArgumentException("null Composite");
    } else {
        surfaceData.checkCustomComposite();
        newCompState = COMP_CUSTOM;
        newCompType = CompositeType.General;
    }
    if (compositeState != newCompState ||
        imageComp != newCompType)
    {
        compositeState = newCompState;
        imageComp = newCompType;
        invalidatePipe();
        validFontInfo = false;
    }
    composite = comp;
    if (paintState <= PAINT_ALPHACOLOR) {
        validateColor();
    }
}
 
Example 15
Source File: SunGraphics2D.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Sets the Composite in the current graphics state. Composite is used
 * in all drawing methods such as drawImage, drawString, drawPath,
 * and fillPath.  It specifies how new pixels are to be combined with
 * the existing pixels on the graphics device in the rendering process.
 * @param comp The Composite object to be used for drawing.
 * @see java.awt.Graphics#setXORMode
 * @see java.awt.Graphics#setPaintMode
 * @see AlphaComposite
 */
public void setComposite(Composite comp) {
    if (composite == comp) {
        return;
    }
    int newCompState;
    CompositeType newCompType;
    if (comp instanceof AlphaComposite) {
        AlphaComposite alphacomp = (AlphaComposite) comp;
        newCompType = CompositeType.forAlphaComposite(alphacomp);
        if (newCompType == CompositeType.SrcOverNoEa) {
            if (paintState == PAINT_OPAQUECOLOR ||
                (paintState > PAINT_ALPHACOLOR &&
                 paint.getTransparency() == Transparency.OPAQUE))
            {
                newCompState = COMP_ISCOPY;
            } else {
                newCompState = COMP_ALPHA;
            }
        } else if (newCompType == CompositeType.SrcNoEa ||
                   newCompType == CompositeType.Src ||
                   newCompType == CompositeType.Clear)
        {
            newCompState = COMP_ISCOPY;
        } else if (surfaceData.getTransparency() == Transparency.OPAQUE &&
                   newCompType == CompositeType.SrcIn)
        {
            newCompState = COMP_ISCOPY;
        } else {
            newCompState = COMP_ALPHA;
        }
    } else if (comp instanceof XORComposite) {
        newCompState = COMP_XOR;
        newCompType = CompositeType.Xor;
    } else if (comp == null) {
        throw new IllegalArgumentException("null Composite");
    } else {
        surfaceData.checkCustomComposite();
        newCompState = COMP_CUSTOM;
        newCompType = CompositeType.General;
    }
    if (compositeState != newCompState ||
        imageComp != newCompType)
    {
        compositeState = newCompState;
        imageComp = newCompType;
        invalidatePipe();
        validFontInfo = false;
    }
    composite = comp;
    if (paintState <= PAINT_ALPHACOLOR) {
        validateColor();
    }
}
 
Example 16
Source File: X11PMBlitLoops.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public X11PMBlitLoops(SurfaceType srcType, SurfaceType dstType,
                      boolean over) {
    super(srcType,
          over ? CompositeType.SrcOverNoEa : CompositeType.SrcNoEa,
          dstType);
}
 
Example 17
Source File: X11PMBlitLoops.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public X11PMBlitLoops(SurfaceType srcType, SurfaceType dstType,
                      boolean over) {
    super(srcType,
          over ? CompositeType.SrcOverNoEa : CompositeType.SrcNoEa,
          dstType);
}
 
Example 18
Source File: X11PMBlitLoops.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public X11PMBlitLoops(SurfaceType srcType, SurfaceType dstType,
                      boolean over) {
    super(srcType,
          over ? CompositeType.SrcOverNoEa : CompositeType.SrcNoEa,
          dstType);
}
 
Example 19
Source File: SunGraphics2D.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Sets the Composite in the current graphics state. Composite is used
 * in all drawing methods such as drawImage, drawString, drawPath,
 * and fillPath.  It specifies how new pixels are to be combined with
 * the existing pixels on the graphics device in the rendering process.
 * @param comp The Composite object to be used for drawing.
 * @see java.awt.Graphics#setXORMode
 * @see java.awt.Graphics#setPaintMode
 * @see AlphaComposite
 */
public void setComposite(Composite comp) {
    if (composite == comp) {
        return;
    }
    int newCompState;
    CompositeType newCompType;
    if (comp instanceof AlphaComposite) {
        AlphaComposite alphacomp = (AlphaComposite) comp;
        newCompType = CompositeType.forAlphaComposite(alphacomp);
        if (newCompType == CompositeType.SrcOverNoEa) {
            if (paintState == PAINT_OPAQUECOLOR ||
                (paintState > PAINT_ALPHACOLOR &&
                 paint.getTransparency() == Transparency.OPAQUE))
            {
                newCompState = COMP_ISCOPY;
            } else {
                newCompState = COMP_ALPHA;
            }
        } else if (newCompType == CompositeType.SrcNoEa ||
                   newCompType == CompositeType.Src ||
                   newCompType == CompositeType.Clear)
        {
            newCompState = COMP_ISCOPY;
        } else if (surfaceData.getTransparency() == Transparency.OPAQUE &&
                   newCompType == CompositeType.SrcIn)
        {
            newCompState = COMP_ISCOPY;
        } else {
            newCompState = COMP_ALPHA;
        }
    } else if (comp instanceof XORComposite) {
        newCompState = COMP_XOR;
        newCompType = CompositeType.Xor;
    } else if (comp == null) {
        throw new IllegalArgumentException("null Composite");
    } else {
        surfaceData.checkCustomComposite();
        newCompState = COMP_CUSTOM;
        newCompType = CompositeType.General;
    }
    if (compositeState != newCompState ||
        imageComp != newCompType)
    {
        compositeState = newCompState;
        imageComp = newCompType;
        invalidatePipe();
        validFontInfo = false;
    }
    composite = comp;
    if (paintState <= PAINT_ALPHACOLOR) {
        validateColor();
    }
}
 
Example 20
Source File: X11PMBlitLoops.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public X11PMBlitLoops(SurfaceType srcType, SurfaceType dstType,
                      boolean over) {
    super(srcType,
          over ? CompositeType.SrcOverNoEa : CompositeType.SrcNoEa,
          dstType);
}