Java Code Examples for sun.java2d.SurfaceData#getRaster()

The following examples show how to use sun.java2d.SurfaceData#getRaster() . 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: GeneralRenderer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static void doSetRect(SurfaceData sData, PixelWriter pw,
                      int x1, int y1, int x2, int y2) {
    WritableRaster dstRast =
        (WritableRaster) sData.getRaster(x1, y1, x2-x1, y2-y1);
    pw.setRaster(dstRast);

    while (y1 < y2) {
        for (int x = x1; x < x2; x++) {
            pw.writePixel(x, y1);
        }
        y1++;
    }
}
 
Example 2
Source File: GeneralRenderer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void doSetRect(SurfaceData sData, PixelWriter pw,
                      int x1, int y1, int x2, int y2) {
    WritableRaster dstRast =
        (WritableRaster) sData.getRaster(x1, y1, x2-x1, y2-y1);
    pw.setRaster(dstRast);

    while (y1 < y2) {
        for (int x = x1; x < x2; x++) {
            pw.writePixel(x, y1);
        }
        y1++;
    }
}
 
Example 3
Source File: Blit.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void Blit(SurfaceData srcData,
                 SurfaceData dstData,
                 Composite comp,
                 Region clip,
                 int srcx, int srcy,
                 int dstx, int dsty,
                 int width, int height)
{
    ColorModel srcCM = srcData.getColorModel();
    ColorModel dstCM = dstData.getColorModel();
    // REMIND: Should get RenderingHints from sg2d
    CompositeContext ctx = comp.createContext(srcCM, dstCM,
                                              new RenderingHints(null));
    Raster srcRas = srcData.getRaster(srcx, srcy, width, height);
    WritableRaster dstRas =
        (WritableRaster) dstData.getRaster(dstx, dsty, width, height);

    if (clip == null) {
        clip = Region.getInstanceXYWH(dstx, dsty, width, height);
    }
    int span[] = {dstx, dsty, dstx+width, dsty+height};
    SpanIterator si = clip.getSpanIterator(span);
    srcx -= dstx;
    srcy -= dsty;
    while (si.nextSpan(span)) {
        int w = span[2] - span[0];
        int h = span[3] - span[1];
        Raster tmpSrcRas = srcRas.createChild(srcx + span[0], srcy + span[1],
                                              w, h, 0, 0, null);
        WritableRaster tmpDstRas = dstRas.createWritableChild(span[0], span[1],
                                                              w, h, 0, 0, null);
        ctx.compose(tmpSrcRas, tmpDstRas, tmpDstRas);
    }
    ctx.dispose();
}
 
Example 4
Source File: Blit.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void Blit(SurfaceData srcData,
                 SurfaceData dstData,
                 Composite comp,
                 Region clip,
                 int srcx, int srcy,
                 int dstx, int dsty,
                 int width, int height)
{
    ColorModel srcCM = srcData.getColorModel();
    ColorModel dstCM = dstData.getColorModel();
    // REMIND: Should get RenderingHints from sg2d
    CompositeContext ctx = comp.createContext(srcCM, dstCM,
                                              new RenderingHints(null));
    Raster srcRas = srcData.getRaster(srcx, srcy, width, height);
    WritableRaster dstRas =
        (WritableRaster) dstData.getRaster(dstx, dsty, width, height);

    if (clip == null) {
        clip = Region.getInstanceXYWH(dstx, dsty, width, height);
    }
    int span[] = {dstx, dsty, dstx+width, dsty+height};
    SpanIterator si = clip.getSpanIterator(span);
    srcx -= dstx;
    srcy -= dsty;
    while (si.nextSpan(span)) {
        int w = span[2] - span[0];
        int h = span[3] - span[1];
        Raster tmpSrcRas = srcRas.createChild(srcx + span[0], srcy + span[1],
                                              w, h, 0, 0, null);
        WritableRaster tmpDstRas = dstRas.createWritableChild(span[0], span[1],
                                                              w, h, 0, 0, null);
        ctx.compose(tmpSrcRas, tmpDstRas, tmpDstRas);
    }
    ctx.dispose();
}
 
Example 5
Source File: GeneralRenderer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static void doSetRect(SurfaceData sData, PixelWriter pw,
                      int x1, int y1, int x2, int y2) {
    WritableRaster dstRast =
        (WritableRaster) sData.getRaster(x1, y1, x2-x1, y2-y1);
    pw.setRaster(dstRast);

    while (y1 < y2) {
        for (int x = x1; x < x2; x++) {
            pw.writePixel(x, y1);
        }
        y1++;
    }
}
 
Example 6
Source File: GeneralRenderer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static void doSetRect(SurfaceData sData, PixelWriter pw,
                      int x1, int y1, int x2, int y2) {
    WritableRaster dstRast =
        (WritableRaster) sData.getRaster(x1, y1, x2-x1, y2-y1);
    pw.setRaster(dstRast);

    while (y1 < y2) {
        for (int x = x1; x < x2; x++) {
            pw.writePixel(x, y1);
        }
        y1++;
    }
}
 
Example 7
Source File: Blit.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void Blit(SurfaceData srcData,
                 SurfaceData dstData,
                 Composite comp,
                 Region clip,
                 int srcx, int srcy,
                 int dstx, int dsty,
                 int width, int height)
{
    ColorModel srcCM = srcData.getColorModel();
    ColorModel dstCM = dstData.getColorModel();
    // REMIND: Should get RenderingHints from sg2d
    CompositeContext ctx = comp.createContext(srcCM, dstCM,
                                              new RenderingHints(null));
    Raster srcRas = srcData.getRaster(srcx, srcy, width, height);
    WritableRaster dstRas =
        (WritableRaster) dstData.getRaster(dstx, dsty, width, height);

    if (clip == null) {
        clip = Region.getInstanceXYWH(dstx, dsty, width, height);
    }
    int span[] = {dstx, dsty, dstx+width, dsty+height};
    SpanIterator si = clip.getSpanIterator(span);
    srcx -= dstx;
    srcy -= dsty;
    while (si.nextSpan(span)) {
        int w = span[2] - span[0];
        int h = span[3] - span[1];
        Raster tmpSrcRas = srcRas.createChild(srcx + span[0], srcy + span[1],
                                              w, h, 0, 0, null);
        WritableRaster tmpDstRas = dstRas.createWritableChild(span[0], span[1],
                                                              w, h, 0, 0, null);
        ctx.compose(tmpSrcRas, tmpDstRas, tmpDstRas);
    }
    ctx.dispose();
}
 
Example 8
Source File: GeneralRenderer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void doSetRect(SurfaceData sData, PixelWriter pw,
                      int x1, int y1, int x2, int y2) {
    WritableRaster dstRast =
        (WritableRaster) sData.getRaster(x1, y1, x2-x1, y2-y1);
    pw.setRaster(dstRast);

    while (y1 < y2) {
        for (int x = x1; x < x2; x++) {
            pw.writePixel(x, y1);
        }
        y1++;
    }
}
 
Example 9
Source File: Blit.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void Blit(SurfaceData srcData,
                 SurfaceData dstData,
                 Composite comp,
                 Region clip,
                 int srcx, int srcy,
                 int dstx, int dsty,
                 int width, int height)
{
    ColorModel srcCM = srcData.getColorModel();
    ColorModel dstCM = dstData.getColorModel();
    // REMIND: Should get RenderingHints from sg2d
    CompositeContext ctx = comp.createContext(srcCM, dstCM,
                                              new RenderingHints(null));
    Raster srcRas = srcData.getRaster(srcx, srcy, width, height);
    WritableRaster dstRas =
        (WritableRaster) dstData.getRaster(dstx, dsty, width, height);

    if (clip == null) {
        clip = Region.getInstanceXYWH(dstx, dsty, width, height);
    }
    int span[] = {dstx, dsty, dstx+width, dsty+height};
    SpanIterator si = clip.getSpanIterator(span);
    srcx -= dstx;
    srcy -= dsty;
    while (si.nextSpan(span)) {
        int w = span[2] - span[0];
        int h = span[3] - span[1];
        Raster tmpSrcRas = srcRas.createChild(srcx + span[0], srcy + span[1],
                                              w, h, 0, 0, null);
        WritableRaster tmpDstRas = dstRas.createWritableChild(span[0], span[1],
                                                              w, h, 0, 0, null);
        ctx.compose(tmpSrcRas, tmpDstRas, tmpDstRas);
    }
    ctx.dispose();
}
 
Example 10
Source File: GeneralRenderer.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
static void doDrawGlyphList(SurfaceData sData, PixelWriter pw,
                            GlyphList gl, Region clip)
{
    int[] bounds = gl.getBounds();
    clip.clipBoxToBounds(bounds);
    int cx1 = bounds[0];
    int cy1 = bounds[1];
    int cx2 = bounds[2];
    int cy2 = bounds[3];

    WritableRaster dstRast =
        (WritableRaster) sData.getRaster(cx1, cy1, cx2 - cx1, cy2 - cy1);
    pw.setRaster(dstRast);

    int num = gl.getNumGlyphs();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int metrics[] = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte alpha[] = gl.getGrayBits();
            w -= (gx2 - gx1);
            for (int y = gy1; y < gy2; y++) {
                for (int x = gx1; x < gx2; x++) {
                    if (alpha[off++] < 0) {
                        pw.writePixel(x, y);
                    }
                }
                off += w;
            }
        }
    }
}
 
Example 11
Source File: CustomComponent.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
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);
}
 
Example 12
Source File: CustomComponent.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
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);
}
 
Example 13
Source File: GeneralRenderer.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
static void doDrawGlyphList(SurfaceData sData, PixelWriter pw,
                            GlyphList gl, Region clip)
{
    int[] bounds = gl.getBounds();
    clip.clipBoxToBounds(bounds);
    int cx1 = bounds[0];
    int cy1 = bounds[1];
    int cx2 = bounds[2];
    int cy2 = bounds[3];

    WritableRaster dstRast =
        (WritableRaster) sData.getRaster(cx1, cy1, cx2 - cx1, cy2 - cy1);
    pw.setRaster(dstRast);

    int num = gl.getNumGlyphs();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int[] metrics = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte[] alpha = gl.getGrayBits();
            w -= (gx2 - gx1);
            for (int y = gy1; y < gy2; y++) {
                for (int x = gx1; x < gx2; x++) {
                    if (alpha[off++] < 0) {
                        pw.writePixel(x, y);
                    }
                }
                off += w;
            }
        }
    }
}
 
Example 14
Source File: GeneralRenderer.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
static void doDrawGlyphList(SurfaceData sData, PixelWriter pw,
                            GlyphList gl, Region clip)
{
    int[] bounds = gl.getBounds();
    clip.clipBoxToBounds(bounds);
    int cx1 = bounds[0];
    int cy1 = bounds[1];
    int cx2 = bounds[2];
    int cy2 = bounds[3];

    WritableRaster dstRast =
        (WritableRaster) sData.getRaster(cx1, cy1, cx2 - cx1, cy2 - cy1);
    pw.setRaster(dstRast);

    int num = gl.getNumGlyphs();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int metrics[] = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte alpha[] = gl.getGrayBits();
            w -= (gx2 - gx1);
            for (int y = gy1; y < gy2; y++) {
                for (int x = gx1; x < gx2; x++) {
                    if (alpha[off++] < 0) {
                        pw.writePixel(x, y);
                    }
                }
                off += w;
            }
        }
    }
}
 
Example 15
Source File: CustomComponent.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
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);
    IntegerComponentRaster icr = (IntegerComponentRaster) srcRast;
    int[] srcPix = icr.getDataStorage();

    WritableRaster dstRast =
        (WritableRaster) dst.getRaster(dstx, dsty, w, h);
    ColorModel dstCM = dst.getColorModel();

    Region roi = CustomComponent.getRegionOfInterest(src, dst, clip,
                                                     srcx, srcy,
                                                     dstx, dsty, w, h);
    SpanIterator si = roi.getSpanIterator();

    Object dstPix = null;

    int srcScan = icr.getScanlineStride();
    // assert(icr.getPixelStride() == 1);
    srcx -= dstx;
    srcy -= dsty;
    int span[] = new int[4];
    while (si.nextSpan(span)) {
        int rowoff = (icr.getDataOffset(0) +
                      (srcy + span[1]) * srcScan +
                      (srcx + span[0]));
        for (int y = span[1]; y < span[3]; y++) {
            int off = rowoff;
            for (int x = span[0]; x < span[2]; x++) {
                dstPix = dstCM.getDataElements(srcPix[off++], dstPix);
                dstRast.setDataElements(x, y, dstPix);
            }
            rowoff += srcScan;
        }
    }
    // 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);
}
 
Example 16
Source File: CustomComponent.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
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);
    IntegerComponentRaster icr = (IntegerComponentRaster) srcRast;
    int[] srcPix = icr.getDataStorage();

    WritableRaster dstRast =
        (WritableRaster) dst.getRaster(dstx, dsty, w, h);
    ColorModel dstCM = dst.getColorModel();

    Region roi = CustomComponent.getRegionOfInterest(src, dst, clip,
                                                     srcx, srcy,
                                                     dstx, dsty, w, h);
    SpanIterator si = roi.getSpanIterator();

    Object dstPix = null;

    int srcScan = icr.getScanlineStride();
    // assert(icr.getPixelStride() == 1);
    srcx -= dstx;
    srcy -= dsty;
    int span[] = new int[4];
    while (si.nextSpan(span)) {
        int rowoff = (icr.getDataOffset(0) +
                      (srcy + span[1]) * srcScan +
                      (srcx + span[0]));
        for (int y = span[1]; y < span[3]; y++) {
            int off = rowoff;
            for (int x = span[0]; x < span[2]; x++) {
                dstPix = dstCM.getDataElements(srcPix[off++], dstPix);
                dstRast.setDataElements(x, y, dstPix);
            }
            rowoff += srcScan;
        }
    }
    // 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);
}
 
Example 17
Source File: GeneralRenderer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
static void doDrawGlyphList(SurfaceData sData, PixelWriter pw,
                            GlyphList gl, Region clip)
{
    int[] bounds = gl.getBounds();
    clip.clipBoxToBounds(bounds);
    int cx1 = bounds[0];
    int cy1 = bounds[1];
    int cx2 = bounds[2];
    int cy2 = bounds[3];

    WritableRaster dstRast =
        (WritableRaster) sData.getRaster(cx1, cy1, cx2 - cx1, cy2 - cy1);
    pw.setRaster(dstRast);

    int num = gl.getNumGlyphs();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int metrics[] = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte alpha[] = gl.getGrayBits();
            w -= (gx2 - gx1);
            for (int y = gy1; y < gy2; y++) {
                for (int x = gx1; x < gx2; x++) {
                    if (alpha[off++] < 0) {
                        pw.writePixel(x, y);
                    }
                }
                off += w;
            }
        }
    }
}
 
Example 18
Source File: CustomComponent.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
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);
    IntegerComponentRaster icr = (IntegerComponentRaster) srcRast;
    int[] srcPix = icr.getDataStorage();

    WritableRaster dstRast =
        (WritableRaster) dst.getRaster(dstx, dsty, w, h);
    ColorModel dstCM = dst.getColorModel();

    Region roi = CustomComponent.getRegionOfInterest(src, dst, clip,
                                                     srcx, srcy,
                                                     dstx, dsty, w, h);
    SpanIterator si = roi.getSpanIterator();

    Object dstPix = null;

    int srcScan = icr.getScanlineStride();
    // assert(icr.getPixelStride() == 1);
    srcx -= dstx;
    srcy -= dsty;
    int span[] = new int[4];
    while (si.nextSpan(span)) {
        int rowoff = (icr.getDataOffset(0) +
                      (srcy + span[1]) * srcScan +
                      (srcx + span[0]));
        for (int y = span[1]; y < span[3]; y++) {
            int off = rowoff;
            for (int x = span[0]; x < span[2]; x++) {
                dstPix = dstCM.getDataElements(srcPix[off++], dstPix);
                dstRast.setDataElements(x, y, dstPix);
            }
            rowoff += srcScan;
        }
    }
    // 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);
}
 
Example 19
Source File: GeneralRenderer.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
static void doDrawGlyphList(SurfaceData sData, PixelWriter pw,
                            GlyphList gl, Region clip)
{
    int[] bounds = gl.getBounds();
    clip.clipBoxToBounds(bounds);
    int cx1 = bounds[0];
    int cy1 = bounds[1];
    int cx2 = bounds[2];
    int cy2 = bounds[3];

    WritableRaster dstRast =
        (WritableRaster) sData.getRaster(cx1, cy1, cx2 - cx1, cy2 - cy1);
    pw.setRaster(dstRast);

    int num = gl.getNumGlyphs();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int metrics[] = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte alpha[] = gl.getGrayBits();
            w -= (gx2 - gx1);
            for (int y = gy1; y < gy2; y++) {
                for (int x = gx1; x < gx2; x++) {
                    if (alpha[off++] < 0) {
                        pw.writePixel(x, y);
                    }
                }
                off += w;
            }
        }
    }
}
 
Example 20
Source File: CustomComponent.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
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);
}