Java Code Examples for sun.java2d.pipe.Region#clipBoxToBounds()

The following examples show how to use sun.java2d.pipe.Region#clipBoxToBounds() . 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: DuctusRenderingEngine.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public AATileGenerator getAATileGenerator(double x, double y,
                                          double dx1, double dy1,
                                          double dx2, double dy2,
                                          double lw1, double lw2,
                                          Region clip,
                                          int bbox[])
{
    // REMIND: Deal with large coordinates!
    double ldx1, ldy1, ldx2, ldy2;
    boolean innerpgram = (lw1 > 0 && lw2 > 0);

    if (innerpgram) {
        ldx1 = dx1 * lw1;
        ldy1 = dy1 * lw1;
        ldx2 = dx2 * lw2;
        ldy2 = dy2 * lw2;
        x -= (ldx1 + ldx2) / 2.0;
        y -= (ldy1 + ldy2) / 2.0;
        dx1 += ldx1;
        dy1 += ldy1;
        dx2 += ldx2;
        dy2 += ldy2;
        if (lw1 > 1 && lw2 > 1) {
            // Inner parallelogram was entirely consumed by stroke...
            innerpgram = false;
        }
    } else {
        ldx1 = ldy1 = ldx2 = ldy2 = 0;
    }

    Rasterizer r = getRasterizer();

    r.setUsage(Rasterizer.EOFILL);

    r.beginPath();
    r.beginSubpath((float) x, (float) y);
    r.appendLine((float) (x+dx1), (float) (y+dy1));
    r.appendLine((float) (x+dx1+dx2), (float) (y+dy1+dy2));
    r.appendLine((float) (x+dx2), (float) (y+dy2));
    r.closedSubpath();
    if (innerpgram) {
        x += ldx1 + ldx2;
        y += ldy1 + ldy2;
        dx1 -= 2.0 * ldx1;
        dy1 -= 2.0 * ldy1;
        dx2 -= 2.0 * ldx2;
        dy2 -= 2.0 * ldy2;
        r.beginSubpath((float) x, (float) y);
        r.appendLine((float) (x+dx1), (float) (y+dy1));
        r.appendLine((float) (x+dx1+dx2), (float) (y+dy1+dy2));
        r.appendLine((float) (x+dx2), (float) (y+dy2));
        r.closedSubpath();
    }

    try {
        r.endPath();
        r.getAlphaBox(bbox);
        clip.clipBoxToBounds(bbox);
        if (bbox[0] >= bbox[2] || bbox[1] >= bbox[3]) {
            dropRasterizer(r);
            return null;
        }
        r.setOutputArea(bbox[0], bbox[1],
                        bbox[2] - bbox[0],
                        bbox[3] - bbox[1]);
    } catch (PRException e) {
        /*
         * This exeption is thrown from the native part of the Ductus
         * (only in case of a debug build) to indicate that some
         * segments of the path have very large coordinates.
         * See 4485298 for more info.
         */
        System.err.println("DuctusRenderingEngine.getAATileGenerator: "+e);
    }

    return r;
}
 
Example 2
Source File: DuctusRenderingEngine.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public AATileGenerator getAATileGenerator(double x, double y,
                                          double dx1, double dy1,
                                          double dx2, double dy2,
                                          double lw1, double lw2,
                                          Region clip,
                                          int bbox[])
{
    // REMIND: Deal with large coordinates!
    double ldx1, ldy1, ldx2, ldy2;
    boolean innerpgram = (lw1 > 0 && lw2 > 0);

    if (innerpgram) {
        ldx1 = dx1 * lw1;
        ldy1 = dy1 * lw1;
        ldx2 = dx2 * lw2;
        ldy2 = dy2 * lw2;
        x -= (ldx1 + ldx2) / 2.0;
        y -= (ldy1 + ldy2) / 2.0;
        dx1 += ldx1;
        dy1 += ldy1;
        dx2 += ldx2;
        dy2 += ldy2;
        if (lw1 > 1 && lw2 > 1) {
            // Inner parallelogram was entirely consumed by stroke...
            innerpgram = false;
        }
    } else {
        ldx1 = ldy1 = ldx2 = ldy2 = 0;
    }

    Rasterizer r = getRasterizer();

    r.setUsage(Rasterizer.EOFILL);

    r.beginPath();
    r.beginSubpath((float) x, (float) y);
    r.appendLine((float) (x+dx1), (float) (y+dy1));
    r.appendLine((float) (x+dx1+dx2), (float) (y+dy1+dy2));
    r.appendLine((float) (x+dx2), (float) (y+dy2));
    r.closedSubpath();
    if (innerpgram) {
        x += ldx1 + ldx2;
        y += ldy1 + ldy2;
        dx1 -= 2.0 * ldx1;
        dy1 -= 2.0 * ldy1;
        dx2 -= 2.0 * ldx2;
        dy2 -= 2.0 * ldy2;
        r.beginSubpath((float) x, (float) y);
        r.appendLine((float) (x+dx1), (float) (y+dy1));
        r.appendLine((float) (x+dx1+dx2), (float) (y+dy1+dy2));
        r.appendLine((float) (x+dx2), (float) (y+dy2));
        r.closedSubpath();
    }

    try {
        r.endPath();
        r.getAlphaBox(bbox);
        clip.clipBoxToBounds(bbox);
        if (bbox[0] >= bbox[2] || bbox[1] >= bbox[3]) {
            dropRasterizer(r);
            return null;
        }
        r.setOutputArea(bbox[0], bbox[1],
                        bbox[2] - bbox[0],
                        bbox[3] - bbox[1]);
    } catch (PRException e) {
        /*
         * This exeption is thrown from the native part of the Ductus
         * (only in case of a debug build) to indicate that some
         * segments of the path have very large coordinates.
         * See 4485298 for more info.
         */
        System.err.println("DuctusRenderingEngine.getAATileGenerator: "+e);
    }

    return r;
}
 
Example 3
Source File: GeneralRenderer.java    From openjdk-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 4
Source File: DuctusRenderingEngine.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public AATileGenerator getAATileGenerator(double x, double y,
                                          double dx1, double dy1,
                                          double dx2, double dy2,
                                          double lw1, double lw2,
                                          Region clip,
                                          int bbox[])
{
    // REMIND: Deal with large coordinates!
    double ldx1, ldy1, ldx2, ldy2;
    boolean innerpgram = (lw1 > 0 && lw2 > 0);

    if (innerpgram) {
        ldx1 = dx1 * lw1;
        ldy1 = dy1 * lw1;
        ldx2 = dx2 * lw2;
        ldy2 = dy2 * lw2;
        x -= (ldx1 + ldx2) / 2.0;
        y -= (ldy1 + ldy2) / 2.0;
        dx1 += ldx1;
        dy1 += ldy1;
        dx2 += ldx2;
        dy2 += ldy2;
        if (lw1 > 1 && lw2 > 1) {
            // Inner parallelogram was entirely consumed by stroke...
            innerpgram = false;
        }
    } else {
        ldx1 = ldy1 = ldx2 = ldy2 = 0;
    }

    Rasterizer r = getRasterizer();

    r.setUsage(Rasterizer.EOFILL);

    r.beginPath();
    r.beginSubpath((float) x, (float) y);
    r.appendLine((float) (x+dx1), (float) (y+dy1));
    r.appendLine((float) (x+dx1+dx2), (float) (y+dy1+dy2));
    r.appendLine((float) (x+dx2), (float) (y+dy2));
    r.closedSubpath();
    if (innerpgram) {
        x += ldx1 + ldx2;
        y += ldy1 + ldy2;
        dx1 -= 2.0 * ldx1;
        dy1 -= 2.0 * ldy1;
        dx2 -= 2.0 * ldx2;
        dy2 -= 2.0 * ldy2;
        r.beginSubpath((float) x, (float) y);
        r.appendLine((float) (x+dx1), (float) (y+dy1));
        r.appendLine((float) (x+dx1+dx2), (float) (y+dy1+dy2));
        r.appendLine((float) (x+dx2), (float) (y+dy2));
        r.closedSubpath();
    }

    try {
        r.endPath();
        r.getAlphaBox(bbox);
        clip.clipBoxToBounds(bbox);
        if (bbox[0] >= bbox[2] || bbox[1] >= bbox[3]) {
            dropRasterizer(r);
            return null;
        }
        r.setOutputArea(bbox[0], bbox[1],
                        bbox[2] - bbox[0],
                        bbox[3] - bbox[1]);
    } catch (PRException e) {
        /*
         * This exeption is thrown from the native part of the Ductus
         * (only in case of a debug build) to indicate that some
         * segments of the path have very large coordinates.
         * See 4485298 for more info.
         */
        System.err.println("DuctusRenderingEngine.getAATileGenerator: "+e);
    }

    return r;
}
 
Example 5
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 6
Source File: DuctusRenderingEngine.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public AATileGenerator getAATileGenerator(double x, double y,
                                          double dx1, double dy1,
                                          double dx2, double dy2,
                                          double lw1, double lw2,
                                          Region clip,
                                          int bbox[])
{
    // REMIND: Deal with large coordinates!
    double ldx1, ldy1, ldx2, ldy2;
    boolean innerpgram = (lw1 > 0 && lw2 > 0);

    if (innerpgram) {
        ldx1 = dx1 * lw1;
        ldy1 = dy1 * lw1;
        ldx2 = dx2 * lw2;
        ldy2 = dy2 * lw2;
        x -= (ldx1 + ldx2) / 2.0;
        y -= (ldy1 + ldy2) / 2.0;
        dx1 += ldx1;
        dy1 += ldy1;
        dx2 += ldx2;
        dy2 += ldy2;
        if (lw1 > 1 && lw2 > 1) {
            // Inner parallelogram was entirely consumed by stroke...
            innerpgram = false;
        }
    } else {
        ldx1 = ldy1 = ldx2 = ldy2 = 0;
    }

    Rasterizer r = getRasterizer();

    r.setUsage(Rasterizer.EOFILL);

    r.beginPath();
    r.beginSubpath((float) x, (float) y);
    r.appendLine((float) (x+dx1), (float) (y+dy1));
    r.appendLine((float) (x+dx1+dx2), (float) (y+dy1+dy2));
    r.appendLine((float) (x+dx2), (float) (y+dy2));
    r.closedSubpath();
    if (innerpgram) {
        x += ldx1 + ldx2;
        y += ldy1 + ldy2;
        dx1 -= 2.0 * ldx1;
        dy1 -= 2.0 * ldy1;
        dx2 -= 2.0 * ldx2;
        dy2 -= 2.0 * ldy2;
        r.beginSubpath((float) x, (float) y);
        r.appendLine((float) (x+dx1), (float) (y+dy1));
        r.appendLine((float) (x+dx1+dx2), (float) (y+dy1+dy2));
        r.appendLine((float) (x+dx2), (float) (y+dy2));
        r.closedSubpath();
    }

    try {
        r.endPath();
        r.getAlphaBox(bbox);
        clip.clipBoxToBounds(bbox);
        if (bbox[0] >= bbox[2] || bbox[1] >= bbox[3]) {
            dropRasterizer(r);
            return null;
        }
        r.setOutputArea(bbox[0], bbox[1],
                        bbox[2] - bbox[0],
                        bbox[3] - bbox[1]);
    } catch (PRException e) {
        /*
         * This exeption is thrown from the native part of the Ductus
         * (only in case of a debug build) to indicate that some
         * segments of the path have very large coordinates.
         * See 4485298 for more info.
         */
        System.err.println("DuctusRenderingEngine.getAATileGenerator: "+e);
    }

    return r;
}
 
Example 7
Source File: GeneralRenderer.java    From hottub 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 8
Source File: DuctusRenderingEngine.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public AATileGenerator getAATileGenerator(double x, double y,
                                          double dx1, double dy1,
                                          double dx2, double dy2,
                                          double lw1, double lw2,
                                          Region clip,
                                          int bbox[])
{
    // REMIND: Deal with large coordinates!
    double ldx1, ldy1, ldx2, ldy2;
    boolean innerpgram = (lw1 > 0 && lw2 > 0);

    if (innerpgram) {
        ldx1 = dx1 * lw1;
        ldy1 = dy1 * lw1;
        ldx2 = dx2 * lw2;
        ldy2 = dy2 * lw2;
        x -= (ldx1 + ldx2) / 2.0;
        y -= (ldy1 + ldy2) / 2.0;
        dx1 += ldx1;
        dy1 += ldy1;
        dx2 += ldx2;
        dy2 += ldy2;
        if (lw1 > 1 && lw2 > 1) {
            // Inner parallelogram was entirely consumed by stroke...
            innerpgram = false;
        }
    } else {
        ldx1 = ldy1 = ldx2 = ldy2 = 0;
    }

    Rasterizer r = getRasterizer();

    r.setUsage(Rasterizer.EOFILL);

    r.beginPath();
    r.beginSubpath((float) x, (float) y);
    r.appendLine((float) (x+dx1), (float) (y+dy1));
    r.appendLine((float) (x+dx1+dx2), (float) (y+dy1+dy2));
    r.appendLine((float) (x+dx2), (float) (y+dy2));
    r.closedSubpath();
    if (innerpgram) {
        x += ldx1 + ldx2;
        y += ldy1 + ldy2;
        dx1 -= 2.0 * ldx1;
        dy1 -= 2.0 * ldy1;
        dx2 -= 2.0 * ldx2;
        dy2 -= 2.0 * ldy2;
        r.beginSubpath((float) x, (float) y);
        r.appendLine((float) (x+dx1), (float) (y+dy1));
        r.appendLine((float) (x+dx1+dx2), (float) (y+dy1+dy2));
        r.appendLine((float) (x+dx2), (float) (y+dy2));
        r.closedSubpath();
    }

    try {
        r.endPath();
        r.getAlphaBox(bbox);
        clip.clipBoxToBounds(bbox);
        if (bbox[0] >= bbox[2] || bbox[1] >= bbox[3]) {
            dropRasterizer(r);
            return null;
        }
        r.setOutputArea(bbox[0], bbox[1],
                        bbox[2] - bbox[0],
                        bbox[3] - bbox[1]);
    } catch (PRException e) {
        /*
         * This exeption is thrown from the native part of the Ductus
         * (only in case of a debug build) to indicate that some
         * segments of the path have very large coordinates.
         * See 4485298 for more info.
         */
        System.err.println("DuctusRenderingEngine.getAATileGenerator: "+e);
    }

    return r;
}
 
Example 9
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 10
Source File: GeneralRenderer.java    From openjdk-jdk9 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: GeneralRenderer.java    From dragonwell8_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 12
Source File: DuctusRenderingEngine.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public AATileGenerator getAATileGenerator(double x, double y,
                                          double dx1, double dy1,
                                          double dx2, double dy2,
                                          double lw1, double lw2,
                                          Region clip,
                                          int bbox[])
{
    // REMIND: Deal with large coordinates!
    double ldx1, ldy1, ldx2, ldy2;
    boolean innerpgram = (lw1 > 0 && lw2 > 0);

    if (innerpgram) {
        ldx1 = dx1 * lw1;
        ldy1 = dy1 * lw1;
        ldx2 = dx2 * lw2;
        ldy2 = dy2 * lw2;
        x -= (ldx1 + ldx2) / 2.0;
        y -= (ldy1 + ldy2) / 2.0;
        dx1 += ldx1;
        dy1 += ldy1;
        dx2 += ldx2;
        dy2 += ldy2;
        if (lw1 > 1 && lw2 > 1) {
            // Inner parallelogram was entirely consumed by stroke...
            innerpgram = false;
        }
    } else {
        ldx1 = ldy1 = ldx2 = ldy2 = 0;
    }

    Rasterizer r = getRasterizer();

    r.setUsage(Rasterizer.EOFILL);

    r.beginPath();
    r.beginSubpath((float) x, (float) y);
    r.appendLine((float) (x+dx1), (float) (y+dy1));
    r.appendLine((float) (x+dx1+dx2), (float) (y+dy1+dy2));
    r.appendLine((float) (x+dx2), (float) (y+dy2));
    r.closedSubpath();
    if (innerpgram) {
        x += ldx1 + ldx2;
        y += ldy1 + ldy2;
        dx1 -= 2.0 * ldx1;
        dy1 -= 2.0 * ldy1;
        dx2 -= 2.0 * ldx2;
        dy2 -= 2.0 * ldy2;
        r.beginSubpath((float) x, (float) y);
        r.appendLine((float) (x+dx1), (float) (y+dy1));
        r.appendLine((float) (x+dx1+dx2), (float) (y+dy1+dy2));
        r.appendLine((float) (x+dx2), (float) (y+dy2));
        r.closedSubpath();
    }

    try {
        r.endPath();
        r.getAlphaBox(bbox);
        clip.clipBoxToBounds(bbox);
        if (bbox[0] >= bbox[2] || bbox[1] >= bbox[3]) {
            dropRasterizer(r);
            return null;
        }
        r.setOutputArea(bbox[0], bbox[1],
                        bbox[2] - bbox[0],
                        bbox[3] - bbox[1]);
    } catch (PRException e) {
        /*
         * This exeption is thrown from the native part of the Ductus
         * (only in case of a debug build) to indicate that some
         * segments of the path have very large coordinates.
         * See 4485298 for more info.
         */
        System.err.println("DuctusRenderingEngine.getAATileGenerator: "+e);
    }

    return r;
}
 
Example 13
Source File: GeneralRenderer.java    From openjdk-jdk8u-backup 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 14
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, int fromGlyph, int toGlyph, 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);

    gl.startGlyphIteration();
    for (int i = fromGlyph; i < toGlyph; 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: 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 16
Source File: DuctusRenderingEngine.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public AATileGenerator getAATileGenerator(double x, double y,
                                          double dx1, double dy1,
                                          double dx2, double dy2,
                                          double lw1, double lw2,
                                          Region clip,
                                          int bbox[])
{
    // REMIND: Deal with large coordinates!
    double ldx1, ldy1, ldx2, ldy2;
    boolean innerpgram = (lw1 > 0 && lw2 > 0);

    if (innerpgram) {
        ldx1 = dx1 * lw1;
        ldy1 = dy1 * lw1;
        ldx2 = dx2 * lw2;
        ldy2 = dy2 * lw2;
        x -= (ldx1 + ldx2) / 2.0;
        y -= (ldy1 + ldy2) / 2.0;
        dx1 += ldx1;
        dy1 += ldy1;
        dx2 += ldx2;
        dy2 += ldy2;
        if (lw1 > 1 && lw2 > 1) {
            // Inner parallelogram was entirely consumed by stroke...
            innerpgram = false;
        }
    } else {
        ldx1 = ldy1 = ldx2 = ldy2 = 0;
    }

    Rasterizer r = getRasterizer();

    r.setUsage(Rasterizer.EOFILL);

    r.beginPath();
    r.beginSubpath((float) x, (float) y);
    r.appendLine((float) (x+dx1), (float) (y+dy1));
    r.appendLine((float) (x+dx1+dx2), (float) (y+dy1+dy2));
    r.appendLine((float) (x+dx2), (float) (y+dy2));
    r.closedSubpath();
    if (innerpgram) {
        x += ldx1 + ldx2;
        y += ldy1 + ldy2;
        dx1 -= 2.0 * ldx1;
        dy1 -= 2.0 * ldy1;
        dx2 -= 2.0 * ldx2;
        dy2 -= 2.0 * ldy2;
        r.beginSubpath((float) x, (float) y);
        r.appendLine((float) (x+dx1), (float) (y+dy1));
        r.appendLine((float) (x+dx1+dx2), (float) (y+dy1+dy2));
        r.appendLine((float) (x+dx2), (float) (y+dy2));
        r.closedSubpath();
    }

    try {
        r.endPath();
        r.getAlphaBox(bbox);
        clip.clipBoxToBounds(bbox);
        if (bbox[0] >= bbox[2] || bbox[1] >= bbox[3]) {
            dropRasterizer(r);
            return null;
        }
        r.setOutputArea(bbox[0], bbox[1],
                        bbox[2] - bbox[0],
                        bbox[3] - bbox[1]);
    } catch (PRException e) {
        /*
         * This exeption is thrown from the native part of the Ductus
         * (only in case of a debug build) to indicate that some
         * segments of the path have very large coordinates.
         * See 4485298 for more info.
         */
        System.err.println("DuctusRenderingEngine.getAATileGenerator: "+e);
    }

    return r;
}
 
Example 17
Source File: GeneralRenderer.java    From jdk8u60 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: 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 19
Source File: GeneralRenderer.java    From jdk8u-dev-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 20
Source File: DuctusRenderingEngine.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public AATileGenerator getAATileGenerator(double x, double y,
                                          double dx1, double dy1,
                                          double dx2, double dy2,
                                          double lw1, double lw2,
                                          Region clip,
                                          int bbox[])
{
    // REMIND: Deal with large coordinates!
    double ldx1, ldy1, ldx2, ldy2;
    boolean innerpgram = (lw1 > 0 && lw2 > 0);

    if (innerpgram) {
        ldx1 = dx1 * lw1;
        ldy1 = dy1 * lw1;
        ldx2 = dx2 * lw2;
        ldy2 = dy2 * lw2;
        x -= (ldx1 + ldx2) / 2.0;
        y -= (ldy1 + ldy2) / 2.0;
        dx1 += ldx1;
        dy1 += ldy1;
        dx2 += ldx2;
        dy2 += ldy2;
        if (lw1 > 1 && lw2 > 1) {
            // Inner parallelogram was entirely consumed by stroke...
            innerpgram = false;
        }
    } else {
        ldx1 = ldy1 = ldx2 = ldy2 = 0;
    }

    Rasterizer r = getRasterizer();

    r.setUsage(Rasterizer.EOFILL);

    r.beginPath();
    r.beginSubpath((float) x, (float) y);
    r.appendLine((float) (x+dx1), (float) (y+dy1));
    r.appendLine((float) (x+dx1+dx2), (float) (y+dy1+dy2));
    r.appendLine((float) (x+dx2), (float) (y+dy2));
    r.closedSubpath();
    if (innerpgram) {
        x += ldx1 + ldx2;
        y += ldy1 + ldy2;
        dx1 -= 2.0 * ldx1;
        dy1 -= 2.0 * ldy1;
        dx2 -= 2.0 * ldx2;
        dy2 -= 2.0 * ldy2;
        r.beginSubpath((float) x, (float) y);
        r.appendLine((float) (x+dx1), (float) (y+dy1));
        r.appendLine((float) (x+dx1+dx2), (float) (y+dy1+dy2));
        r.appendLine((float) (x+dx2), (float) (y+dy2));
        r.closedSubpath();
    }

    try {
        r.endPath();
        r.getAlphaBox(bbox);
        clip.clipBoxToBounds(bbox);
        if (bbox[0] >= bbox[2] || bbox[1] >= bbox[3]) {
            dropRasterizer(r);
            return null;
        }
        r.setOutputArea(bbox[0], bbox[1],
                        bbox[2] - bbox[0],
                        bbox[3] - bbox[1]);
    } catch (PRException e) {
        /*
         * This exeption is thrown from the native part of the Ductus
         * (only in case of a debug build) to indicate that some
         * segments of the path have very large coordinates.
         * See 4485298 for more info.
         */
        System.err.println("DuctusRenderingEngine.getAATileGenerator: "+e);
    }

    return r;
}