Search in sources :

Example 1 with SpanIterator

use of sun.java2d.pipe.SpanIterator in project jdk8u_jdk by JetBrains.

the class XorCopyArgbToAny method Blit.

public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int srcx, int srcy, int dstx, int dsty, int w, int h) {
    Raster srcRast = src.getRaster(srcx, srcy, w, h);
    ColorModel srcCM = src.getColorModel();
    Raster dstRast = dst.getRaster(dstx, dsty, w, h);
    IntegerComponentRaster icr = (IntegerComponentRaster) dstRast;
    int[] dstPix = icr.getDataStorage();
    Region roi = CustomComponent.getRegionOfInterest(src, dst, clip, srcx, srcy, dstx, dsty, w, h);
    SpanIterator si = roi.getSpanIterator();
    Object srcPix = null;
    int dstScan = icr.getScanlineStride();
    // assert(icr.getPixelStride() == 1);
    srcx -= dstx;
    srcy -= dsty;
    int[] span = new int[4];
    while (si.nextSpan(span)) {
        int rowoff = icr.getDataOffset(0) + span[1] * dstScan + span[0];
        for (int y = span[1]; y < span[3]; y++) {
            int off = rowoff;
            for (int x = span[0]; x < span[2]; x++) {
                srcPix = srcRast.getDataElements(x + srcx, y + srcy, srcPix);
                dstPix[off++] = srcCM.getRGB(srcPix);
            }
            rowoff += dstScan;
        }
    }
    // Pixels in the dest were modified directly, we must
    // manually notify the raster that it was modified
    icr.markDirty();
// REMIND: We need to do something to make sure that dstRast
// is put back to the destination (as in the native Release
// function)
// src.releaseRaster(srcRast);  // NOP?
// dst.releaseRaster(dstRast);
}
Also used : SpanIterator(sun.java2d.pipe.SpanIterator) ColorModel(java.awt.image.ColorModel) Raster(java.awt.image.Raster) IntegerComponentRaster(sun.awt.image.IntegerComponentRaster) WritableRaster(java.awt.image.WritableRaster) IntegerComponentRaster(sun.awt.image.IntegerComponentRaster) Region(sun.java2d.pipe.Region)

Aggregations

ColorModel (java.awt.image.ColorModel)1 Raster (java.awt.image.Raster)1 WritableRaster (java.awt.image.WritableRaster)1 IntegerComponentRaster (sun.awt.image.IntegerComponentRaster)1 Region (sun.java2d.pipe.Region)1 SpanIterator (sun.java2d.pipe.SpanIterator)1