Java Code Examples for sun.java2d.SunGraphics2D#getComposite()

The following examples show how to use sun.java2d.SunGraphics2D#getComposite() . 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
/**
 * Validates the Surface when used as destination.
 */
public void validateAsDestination(SunGraphics2D sg2d, Region clip) {
    if (!isValid()) {
        throw new InvalidPipeException("bounds changed");
    }

    boolean updateGCClip = false;
    if (clip != validatedClip) {
        renderQueue.setClipRectangles(picture, clip);
        validatedClip = clip;
        updateGCClip = true;
    }

    if (sg2d != null && sg2d.compositeState == SunGraphics2D.COMP_XOR) {
        if (validatedXorComp != sg2d.getComposite()) {
            validatedXorComp = (XORComposite) sg2d.getComposite();
            renderQueue.setGCMode(xgc, false);
        }

        // validate pixel
        int pixel = sg2d.pixel;
        if (validatedGCForegroundPixel != pixel) {
            int xorpixelmod = validatedXorComp.getXorPixel();
            renderQueue.setGCForeground(xgc, pixel ^ xorpixelmod);
            validatedGCForegroundPixel = pixel;
        }

        if (updateGCClip) {
            renderQueue.setGCClipRectangles(xgc, clip);
        }
    }
}
 
Example 2
Source File: GeneralRenderer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
static PixelWriter createXorPixelWriter(SunGraphics2D sg2d,
                                        SurfaceData sData)
{
    ColorModel dstCM = sData.getColorModel();

    Object srcPixel = dstCM.getDataElements(sg2d.eargb, null);

    XORComposite comp = (XORComposite)sg2d.getComposite();
    int xorrgb = comp.getXorColor().getRGB();
    Object xorPixel = dstCM.getDataElements(xorrgb, null);

    switch (dstCM.getTransferType()) {
    case DataBuffer.TYPE_BYTE:
        return new XorPixelWriter.ByteData(srcPixel, xorPixel);
    case DataBuffer.TYPE_SHORT:
    case DataBuffer.TYPE_USHORT:
        return new XorPixelWriter.ShortData(srcPixel, xorPixel);
    case DataBuffer.TYPE_INT:
        return new XorPixelWriter.IntData(srcPixel, xorPixel);
    case DataBuffer.TYPE_FLOAT:
        return new XorPixelWriter.FloatData(srcPixel, xorPixel);
    case DataBuffer.TYPE_DOUBLE:
        return new XorPixelWriter.DoubleData(srcPixel, xorPixel);
    default:
        throw new InternalError("Unsupported XOR pixel type");
    }
}
 
Example 3
Source File: XRSurfaceData.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validates the Surface when used as destination.
 */
public void validateAsDestination(SunGraphics2D sg2d, Region clip) {
    if (!isValid()) {
        throw new InvalidPipeException("bounds changed");
    }

    boolean updateGCClip = false;
    if (clip != validatedClip) {
        renderQueue.setClipRectangles(picture, clip);
        validatedClip = clip;
        updateGCClip = true;
    }

    if (sg2d != null && sg2d.compositeState == SunGraphics2D.COMP_XOR) {
        if (validatedXorComp != sg2d.getComposite()) {
            validatedXorComp = (XORComposite) sg2d.getComposite();
            renderQueue.setGCMode(xgc, false);
        }

        // validate pixel
        int pixel = sg2d.pixel;
        if (validatedGCForegroundPixel != pixel) {
            int xorpixelmod = validatedXorComp.getXorPixel();
            renderQueue.setGCForeground(xgc, pixel ^ xorpixelmod);
            validatedGCForegroundPixel = pixel;
        }

        if (updateGCClip) {
            renderQueue.setGCClipRectangles(xgc, clip);
        }
    }
}
 
Example 4
Source File: GeneralRenderer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
static PixelWriter createXorPixelWriter(SunGraphics2D sg2d,
                                        SurfaceData sData)
{
    ColorModel dstCM = sData.getColorModel();

    Object srcPixel = dstCM.getDataElements(sg2d.eargb, null);

    XORComposite comp = (XORComposite)sg2d.getComposite();
    int xorrgb = comp.getXorColor().getRGB();
    Object xorPixel = dstCM.getDataElements(xorrgb, null);

    switch (dstCM.getTransferType()) {
    case DataBuffer.TYPE_BYTE:
        return new XorPixelWriter.ByteData(srcPixel, xorPixel);
    case DataBuffer.TYPE_SHORT:
    case DataBuffer.TYPE_USHORT:
        return new XorPixelWriter.ShortData(srcPixel, xorPixel);
    case DataBuffer.TYPE_INT:
        return new XorPixelWriter.IntData(srcPixel, xorPixel);
    case DataBuffer.TYPE_FLOAT:
        return new XorPixelWriter.FloatData(srcPixel, xorPixel);
    case DataBuffer.TYPE_DOUBLE:
        return new XorPixelWriter.DoubleData(srcPixel, xorPixel);
    default:
        throw new InternalError("Unsupported XOR pixel type");
    }
}
 
Example 5
Source File: XRSurfaceData.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validates the Surface when used as destination.
 */
public void validateAsDestination(SunGraphics2D sg2d, Region clip) {
    if (!isValid()) {
        throw new InvalidPipeException("bounds changed");
    }

    boolean updateGCClip = false;
    if (clip != validatedClip) {
        renderQueue.setClipRectangles(picture, clip);
        validatedClip = clip;
        updateGCClip = true;
    }

    if (sg2d != null && sg2d.compositeState == SunGraphics2D.COMP_XOR) {
        if (validatedXorComp != sg2d.getComposite()) {
            validatedXorComp = (XORComposite) sg2d.getComposite();
            renderQueue.setGCMode(xgc, false);
        }

        // validate pixel
        int pixel = sg2d.pixel;
        if (validatedGCForegroundPixel != pixel) {
            int xorpixelmod = validatedXorComp.getXorPixel();
            renderQueue.setGCForeground(xgc, pixel ^ xorpixelmod);
            validatedGCForegroundPixel = pixel;
        }

        if (updateGCClip) {
            renderQueue.setGCClipRectangles(xgc, clip);
        }
    }
}
 
Example 6
Source File: GeneralRenderer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
static PixelWriter createXorPixelWriter(SunGraphics2D sg2d,
                                        SurfaceData sData)
{
    ColorModel dstCM = sData.getColorModel();

    Object srcPixel = dstCM.getDataElements(sg2d.eargb, null);

    XORComposite comp = (XORComposite)sg2d.getComposite();
    int xorrgb = comp.getXorColor().getRGB();
    Object xorPixel = dstCM.getDataElements(xorrgb, null);

    switch (dstCM.getTransferType()) {
    case DataBuffer.TYPE_BYTE:
        return new XorPixelWriter.ByteData(srcPixel, xorPixel);
    case DataBuffer.TYPE_SHORT:
    case DataBuffer.TYPE_USHORT:
        return new XorPixelWriter.ShortData(srcPixel, xorPixel);
    case DataBuffer.TYPE_INT:
        return new XorPixelWriter.IntData(srcPixel, xorPixel);
    case DataBuffer.TYPE_FLOAT:
        return new XorPixelWriter.FloatData(srcPixel, xorPixel);
    case DataBuffer.TYPE_DOUBLE:
        return new XorPixelWriter.DoubleData(srcPixel, xorPixel);
    default:
        throw new InternalError("Unsupported XOR pixel type");
    }
}
 
Example 7
Source File: XRSurfaceData.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validates the Surface when used as destination.
 */
public void validateAsDestination(SunGraphics2D sg2d, Region clip) {
    if (!isValid()) {
        throw new InvalidPipeException("bounds changed");
    }

    boolean updateGCClip = false;
    if (clip != validatedClip) {
        renderQueue.setClipRectangles(picture, clip);
        validatedClip = clip;
        updateGCClip = true;
    }

    if (sg2d != null && sg2d.compositeState == SunGraphics2D.COMP_XOR) {
        if (validatedXorComp != sg2d.getComposite()) {
            validatedXorComp = (XORComposite) sg2d.getComposite();
            renderQueue.setGCMode(xgc, false);
        }

        // validate pixel
        int pixel = sg2d.pixel;
        if (validatedGCForegroundPixel != pixel) {
            int xorpixelmod = validatedXorComp.getXorPixel();
            renderQueue.setGCForeground(xgc, pixel ^ xorpixelmod);
            validatedGCForegroundPixel = pixel;
        }

        if (updateGCClip) {
            renderQueue.setGCClipRectangles(xgc, clip);
        }
    }
}
 
Example 8
Source File: XRSurfaceData.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validates the Surface when used as destination.
 */
public void validateAsDestination(SunGraphics2D sg2d, Region clip) {
    if (!isValid()) {
        throw new InvalidPipeException("bounds changed");
    }

    boolean updateGCClip = false;
    if (clip != validatedClip) {
        renderQueue.setClipRectangles(picture, clip);
        validatedClip = clip;
        updateGCClip = true;
    }

    if (sg2d != null && sg2d.compositeState == SunGraphics2D.COMP_XOR) {
        if (validatedXorComp != sg2d.getComposite()) {
            validatedXorComp = (XORComposite) sg2d.getComposite();
            renderQueue.setGCMode(xgc, false);
        }

        // validate pixel
        int pixel = sg2d.pixel;
        if (validatedGCForegroundPixel != pixel) {
            int xorpixelmod = validatedXorComp.getXorPixel();
            renderQueue.setGCForeground(xgc, pixel ^ xorpixelmod);
            validatedGCForegroundPixel = pixel;
        }

        if (updateGCClip) {
            renderQueue.setGCClipRectangles(xgc, clip);
        }
    }
}
 
Example 9
Source File: XRSurfaceData.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validates the Surface when used as destination.
 */
public void validateAsDestination(SunGraphics2D sg2d, Region clip) {
    if (!isValid()) {
        throw new InvalidPipeException("bounds changed");
    }

    boolean updateGCClip = false;
    if (clip != validatedClip) {
        renderQueue.setClipRectangles(picture, clip);
        validatedClip = clip;
        updateGCClip = true;
    }

    if (sg2d != null && sg2d.compositeState == SunGraphics2D.COMP_XOR) {
        if (validatedXorComp != sg2d.getComposite()) {
            validatedXorComp = (XORComposite) sg2d.getComposite();
            renderQueue.setGCMode(xgc, false);
        }

        // validate pixel
        int pixel = sg2d.pixel;
        if (validatedGCForegroundPixel != pixel) {
            int xorpixelmod = validatedXorComp.getXorPixel();
            renderQueue.setGCForeground(xgc, pixel ^ xorpixelmod);
            validatedGCForegroundPixel = pixel;
        }

        if (updateGCClip) {
            renderQueue.setGCClipRectangles(xgc, clip);
        }
    }
}
 
Example 10
Source File: XRSurfaceData.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validates the Surface when used as destination.
 */
public void validateAsDestination(SunGraphics2D sg2d, Region clip) {
    if (!isValid()) {
        throw new InvalidPipeException("bounds changed");
    }

    boolean updateGCClip = false;
    if (clip != validatedClip) {
        renderQueue.setClipRectangles(picture, clip);
        validatedClip = clip;
        updateGCClip = true;
    }

    if (sg2d != null && sg2d.compositeState == SunGraphics2D.COMP_XOR) {
        if (validatedXorComp != sg2d.getComposite()) {
            validatedXorComp = (XORComposite) sg2d.getComposite();
            renderQueue.setGCMode(xgc, false);
        }

        // validate pixel
        int pixel = sg2d.pixel;
        if (validatedGCForegroundPixel != pixel) {
            int xorpixelmod = validatedXorComp.getXorPixel();
            renderQueue.setGCForeground(xgc, pixel ^ xorpixelmod);
            validatedGCForegroundPixel = pixel;
        }

        if (updateGCClip) {
            renderQueue.setGCClipRectangles(xgc, clip);
        }
    }
}
 
Example 11
Source File: GeneralRenderer.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
static PixelWriter createXorPixelWriter(SunGraphics2D sg2d,
                                        SurfaceData sData)
{
    ColorModel dstCM = sData.getColorModel();

    Object srcPixel = dstCM.getDataElements(sg2d.eargb, null);

    XORComposite comp = (XORComposite)sg2d.getComposite();
    int xorrgb = comp.getXorColor().getRGB();
    Object xorPixel = dstCM.getDataElements(xorrgb, null);

    switch (dstCM.getTransferType()) {
    case DataBuffer.TYPE_BYTE:
        return new XorPixelWriter.ByteData(srcPixel, xorPixel);
    case DataBuffer.TYPE_SHORT:
    case DataBuffer.TYPE_USHORT:
        return new XorPixelWriter.ShortData(srcPixel, xorPixel);
    case DataBuffer.TYPE_INT:
        return new XorPixelWriter.IntData(srcPixel, xorPixel);
    case DataBuffer.TYPE_FLOAT:
        return new XorPixelWriter.FloatData(srcPixel, xorPixel);
    case DataBuffer.TYPE_DOUBLE:
        return new XorPixelWriter.DoubleData(srcPixel, xorPixel);
    default:
        throw new InternalError("Unsupported XOR pixel type");
    }
}
 
Example 12
Source File: XRSurfaceData.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validates the Surface when used as destination.
 */
public void validateAsDestination(SunGraphics2D sg2d, Region clip) {
    if (!isValid()) {
        throw new InvalidPipeException("bounds changed");
    }

    boolean updateGCClip = false;
    if (clip != validatedClip) {
        renderQueue.setClipRectangles(picture, clip);
        validatedClip = clip;
        updateGCClip = true;
    }

    if (sg2d != null && sg2d.compositeState == SunGraphics2D.COMP_XOR) {
        if (validatedXorComp != sg2d.getComposite()) {
            validatedXorComp = (XORComposite) sg2d.getComposite();
            renderQueue.setGCMode(xgc, false);
        }

        // validate pixel
        int pixel = sg2d.pixel;
        if (validatedGCForegroundPixel != pixel) {
            int xorpixelmod = validatedXorComp.getXorPixel();
            renderQueue.setGCForeground(xgc, pixel ^ xorpixelmod);
            validatedGCForegroundPixel = pixel;
        }

        if (updateGCClip) {
            renderQueue.setGCClipRectangles(xgc, clip);
        }
    }
}
 
Example 13
Source File: GeneralRenderer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static PixelWriter createXorPixelWriter(SunGraphics2D sg2d,
                                        SurfaceData sData)
{
    ColorModel dstCM = sData.getColorModel();

    Object srcPixel = dstCM.getDataElements(sg2d.eargb, null);

    XORComposite comp = (XORComposite)sg2d.getComposite();
    int xorrgb = comp.getXorColor().getRGB();
    Object xorPixel = dstCM.getDataElements(xorrgb, null);

    switch (dstCM.getTransferType()) {
    case DataBuffer.TYPE_BYTE:
        return new XorPixelWriter.ByteData(srcPixel, xorPixel);
    case DataBuffer.TYPE_SHORT:
    case DataBuffer.TYPE_USHORT:
        return new XorPixelWriter.ShortData(srcPixel, xorPixel);
    case DataBuffer.TYPE_INT:
        return new XorPixelWriter.IntData(srcPixel, xorPixel);
    case DataBuffer.TYPE_FLOAT:
        return new XorPixelWriter.FloatData(srcPixel, xorPixel);
    case DataBuffer.TYPE_DOUBLE:
        return new XorPixelWriter.DoubleData(srcPixel, xorPixel);
    default:
        throw new InternalError("Unsupported XOR pixel type");
    }
}
 
Example 14
Source File: GeneralRenderer.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static PixelWriter createXorPixelWriter(SunGraphics2D sg2d,
                                        SurfaceData sData)
{
    ColorModel dstCM = sData.getColorModel();

    Object srcPixel = dstCM.getDataElements(sg2d.eargb, null);

    XORComposite comp = (XORComposite)sg2d.getComposite();
    int xorrgb = comp.getXorColor().getRGB();
    Object xorPixel = dstCM.getDataElements(xorrgb, null);

    switch (dstCM.getTransferType()) {
    case DataBuffer.TYPE_BYTE:
        return new XorPixelWriter.ByteData(srcPixel, xorPixel);
    case DataBuffer.TYPE_SHORT:
    case DataBuffer.TYPE_USHORT:
        return new XorPixelWriter.ShortData(srcPixel, xorPixel);
    case DataBuffer.TYPE_INT:
        return new XorPixelWriter.IntData(srcPixel, xorPixel);
    case DataBuffer.TYPE_FLOAT:
        return new XorPixelWriter.FloatData(srcPixel, xorPixel);
    case DataBuffer.TYPE_DOUBLE:
        return new XorPixelWriter.DoubleData(srcPixel, xorPixel);
    default:
        throw new InternalError("Unsupported XOR pixel type");
    }
}
 
Example 15
Source File: GeneralRenderer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static PixelWriter createXorPixelWriter(SunGraphics2D sg2d,
                                        SurfaceData sData)
{
    ColorModel dstCM = sData.getColorModel();

    Object srcPixel = dstCM.getDataElements(sg2d.eargb, null);

    XORComposite comp = (XORComposite)sg2d.getComposite();
    int xorrgb = comp.getXorColor().getRGB();
    Object xorPixel = dstCM.getDataElements(xorrgb, null);

    switch (dstCM.getTransferType()) {
    case DataBuffer.TYPE_BYTE:
        return new XorPixelWriter.ByteData(srcPixel, xorPixel);
    case DataBuffer.TYPE_SHORT:
    case DataBuffer.TYPE_USHORT:
        return new XorPixelWriter.ShortData(srcPixel, xorPixel);
    case DataBuffer.TYPE_INT:
        return new XorPixelWriter.IntData(srcPixel, xorPixel);
    case DataBuffer.TYPE_FLOAT:
        return new XorPixelWriter.FloatData(srcPixel, xorPixel);
    case DataBuffer.TYPE_DOUBLE:
        return new XorPixelWriter.DoubleData(srcPixel, xorPixel);
    default:
        throw new InternalError("Unsupported XOR pixel type");
    }
}
 
Example 16
Source File: GeneralRenderer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
static PixelWriter createXorPixelWriter(SunGraphics2D sg2d,
                                        SurfaceData sData)
{
    ColorModel dstCM = sData.getColorModel();

    Object srcPixel = dstCM.getDataElements(sg2d.eargb, null);

    XORComposite comp = (XORComposite)sg2d.getComposite();
    int xorrgb = comp.getXorColor().getRGB();
    Object xorPixel = dstCM.getDataElements(xorrgb, null);

    switch (dstCM.getTransferType()) {
    case DataBuffer.TYPE_BYTE:
        return new XorPixelWriter.ByteData(srcPixel, xorPixel);
    case DataBuffer.TYPE_SHORT:
    case DataBuffer.TYPE_USHORT:
        return new XorPixelWriter.ShortData(srcPixel, xorPixel);
    case DataBuffer.TYPE_INT:
        return new XorPixelWriter.IntData(srcPixel, xorPixel);
    case DataBuffer.TYPE_FLOAT:
        return new XorPixelWriter.FloatData(srcPixel, xorPixel);
    case DataBuffer.TYPE_DOUBLE:
        return new XorPixelWriter.DoubleData(srcPixel, xorPixel);
    default:
        throw new InternalError("Unsupported XOR pixel type");
    }
}
 
Example 17
Source File: GeneralRenderer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static PixelWriter createXorPixelWriter(SunGraphics2D sg2d,
                                        SurfaceData sData)
{
    ColorModel dstCM = sData.getColorModel();

    Object srcPixel = dstCM.getDataElements(sg2d.eargb, null);

    XORComposite comp = (XORComposite)sg2d.getComposite();
    int xorrgb = comp.getXorColor().getRGB();
    Object xorPixel = dstCM.getDataElements(xorrgb, null);

    switch (dstCM.getTransferType()) {
    case DataBuffer.TYPE_BYTE:
        return new XorPixelWriter.ByteData(srcPixel, xorPixel);
    case DataBuffer.TYPE_SHORT:
    case DataBuffer.TYPE_USHORT:
        return new XorPixelWriter.ShortData(srcPixel, xorPixel);
    case DataBuffer.TYPE_INT:
        return new XorPixelWriter.IntData(srcPixel, xorPixel);
    case DataBuffer.TYPE_FLOAT:
        return new XorPixelWriter.FloatData(srcPixel, xorPixel);
    case DataBuffer.TYPE_DOUBLE:
        return new XorPixelWriter.DoubleData(srcPixel, xorPixel);
    default:
        throw new InternalError("Unsupported XOR pixel type");
    }
}
 
Example 18
Source File: XRSurfaceData.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validates the Surface when used as destination.
 */
public void validateAsDestination(SunGraphics2D sg2d, Region clip) {
    if (!isValid()) {
        throw new InvalidPipeException("bounds changed");
    }

    boolean updateGCClip = false;
    if (clip != validatedClip) {
        renderQueue.setClipRectangles(picture, clip);
        validatedClip = clip;
        updateGCClip = true;
    }

    if (sg2d != null && sg2d.compositeState == SunGraphics2D.COMP_XOR) {
        if (validatedXorComp != sg2d.getComposite()) {
            validatedXorComp = (XORComposite) sg2d.getComposite();
            renderQueue.setGCMode(xgc, false);
        }

        // validate pixel
        int pixel = sg2d.pixel;
        if (validatedGCForegroundPixel != pixel) {
            int xorpixelmod = validatedXorComp.getXorPixel();
            renderQueue.setGCForeground(xgc, pixel ^ xorpixelmod);
            validatedGCForegroundPixel = pixel;
        }

        if (updateGCClip) {
            renderQueue.setGCClipRectangles(xgc, clip);
        }
    }
}
 
Example 19
Source File: GeneralRenderer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static PixelWriter createXorPixelWriter(SunGraphics2D sg2d,
                                        SurfaceData sData)
{
    ColorModel dstCM = sData.getColorModel();

    Object srcPixel = dstCM.getDataElements(sg2d.eargb, null);

    XORComposite comp = (XORComposite)sg2d.getComposite();
    int xorrgb = comp.getXorColor().getRGB();
    Object xorPixel = dstCM.getDataElements(xorrgb, null);

    switch (dstCM.getTransferType()) {
    case DataBuffer.TYPE_BYTE:
        return new XorPixelWriter.ByteData(srcPixel, xorPixel);
    case DataBuffer.TYPE_SHORT:
    case DataBuffer.TYPE_USHORT:
        return new XorPixelWriter.ShortData(srcPixel, xorPixel);
    case DataBuffer.TYPE_INT:
        return new XorPixelWriter.IntData(srcPixel, xorPixel);
    case DataBuffer.TYPE_FLOAT:
        return new XorPixelWriter.FloatData(srcPixel, xorPixel);
    case DataBuffer.TYPE_DOUBLE:
        return new XorPixelWriter.DoubleData(srcPixel, xorPixel);
    default:
        throw new InternalError("Unsupported XOR pixel type");
    }
}
 
Example 20
Source File: XRSurfaceData.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validates the Surface when used as destination.
 */
public void validateAsDestination(SunGraphics2D sg2d, Region clip) {
    if (!isValid()) {
        throw new InvalidPipeException("bounds changed");
    }

    boolean updateGCClip = false;
    if (clip != validatedClip) {
        renderQueue.setClipRectangles(picture, clip);
        validatedClip = clip;
        updateGCClip = true;
    }

    if (sg2d != null && sg2d.compositeState == SunGraphics2D.COMP_XOR) {
        if (validatedXorComp != sg2d.getComposite()) {
            validatedXorComp = (XORComposite) sg2d.getComposite();
            renderQueue.setGCMode(xgc, false);
        }

        // validate pixel
        int pixel = sg2d.pixel;
        if (validatedGCForegroundPixel != pixel) {
            int xorpixelmod = validatedXorComp.getXorPixel();
            renderQueue.setGCForeground(xgc, pixel ^ xorpixelmod);
            validatedGCForegroundPixel = pixel;
        }

        if (updateGCClip) {
            renderQueue.setGCClipRectangles(xgc, clip);
        }
    }
}