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

The following examples show how to use sun.java2d.pipe.Region#getLoY() . 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: GDIWindowSurfaceData.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public boolean copyArea(SunGraphics2D sg2d,
                        int x, int y, int w, int h, int dx, int dy)
{
    CompositeType comptype = sg2d.imageComp;
    if (sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE &&
        sg2d.clipState != sg2d.CLIP_SHAPE &&
        (CompositeType.SrcOverNoEa.equals(comptype) ||
         CompositeType.SrcNoEa.equals(comptype)))
    {
        x += sg2d.transX;
        y += sg2d.transY;
        int dstx1 = x + dx;
        int dsty1 = y + dy;
        int dstx2 = dstx1 + w;
        int dsty2 = dsty1 + h;
        Region clip = sg2d.getCompClip();
        if (dstx1 < clip.getLoX()) dstx1 = clip.getLoX();
        if (dsty1 < clip.getLoY()) dsty1 = clip.getLoY();
        if (dstx2 > clip.getHiX()) dstx2 = clip.getHiX();
        if (dsty2 > clip.getHiY()) dsty2 = clip.getHiY();
        if (dstx1 < dstx2 && dsty1 < dsty2) {
            gdiPipe.devCopyArea(this, dstx1 - dx, dsty1 - dy,
                                dx, dy,
                                dstx2 - dstx1, dsty2 - dsty1);
        }
        return true;
    }
    return false;
}
 
Example 2
Source File: GDIWindowSurfaceData.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public boolean copyArea(SunGraphics2D sg2d,
                        int x, int y, int w, int h, int dx, int dy)
{
    CompositeType comptype = sg2d.imageComp;
    if (sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE &&
        sg2d.clipState != sg2d.CLIP_SHAPE &&
        (CompositeType.SrcOverNoEa.equals(comptype) ||
         CompositeType.SrcNoEa.equals(comptype)))
    {
        x += sg2d.transX;
        y += sg2d.transY;
        int dstx1 = x + dx;
        int dsty1 = y + dy;
        int dstx2 = dstx1 + w;
        int dsty2 = dsty1 + h;
        Region clip = sg2d.getCompClip();
        if (dstx1 < clip.getLoX()) dstx1 = clip.getLoX();
        if (dsty1 < clip.getLoY()) dsty1 = clip.getLoY();
        if (dstx2 > clip.getHiX()) dstx2 = clip.getHiX();
        if (dsty2 > clip.getHiY()) dsty2 = clip.getHiY();
        if (dstx1 < dstx2 && dsty1 < dsty2) {
            gdiPipe.devCopyArea(this, dstx1 - dx, dsty1 - dy,
                                dx, dy,
                                dstx2 - dstx1, dsty2 - dsty1);
        }
        return true;
    }
    return false;
}
 
Example 3
Source File: DrawGlyphList.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void DrawGlyphList(SunGraphics2D sg2d, SurfaceData dest,
                          GlyphList gl) {

    int strbounds[] = gl.getBounds(); // Don't delete, bug 4895493
    int num = gl.getNumGlyphs();
    Region clip = sg2d.getCompClip();
    int cx1 = clip.getLoX();
    int cy1 = clip.getLoY();
    int cx2 = clip.getHiX();
    int cy2 = clip.getHiY();
    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();
            maskop.MaskFill(sg2d, dest, sg2d.composite,
                            gx1, gy1, gx2 - gx1, gy2 - gy1,
                            alpha, off, w);
        }
    }
}
 
Example 4
Source File: DrawGlyphList.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void DrawGlyphList(SunGraphics2D sg2d, SurfaceData dest,
                          GlyphList gl) {

    int strbounds[] = gl.getBounds(); // Don't delete, bug 4895493
    int num = gl.getNumGlyphs();
    Region clip = sg2d.getCompClip();
    int cx1 = clip.getLoX();
    int cy1 = clip.getLoY();
    int cx2 = clip.getHiX();
    int cy2 = clip.getHiY();
    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();
            maskop.MaskFill(sg2d, dest, sg2d.composite,
                            gx1, gy1, gx2 - gx1, gy2 - gy1,
                            alpha, off, w);
        }
    }
}
 
Example 5
Source File: GeneralRenderer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public PixelWriterDrawHandler(SurfaceData sData, PixelWriter pw,
                              Region clip, int strokeHint) {
    super(clip.getLoX(), clip.getLoY(),
          clip.getHiX(), clip.getHiY(),
          strokeHint);
    this.sData = sData;
    this.pw = pw;
    this.clip = clip;
}
 
Example 6
Source File: GeneralRenderer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void doDrawRect(PixelWriter pw,
                              SunGraphics2D sg2d, SurfaceData sData,
                              int x, int y, int w, int h)
{
    if (w < 0 || h < 0) {
        return;
    }
    int x2 = Region.dimAdd(Region.dimAdd(x, w), 1);
    int y2 = Region.dimAdd(Region.dimAdd(y, h), 1);
    Region r = sg2d.getCompClip().getBoundsIntersectionXYXY(x, y, x2, y2);
    if (r.isEmpty()) {
        return;
    }
    int cx1 = r.getLoX();
    int cy1 = r.getLoY();
    int cx2 = r.getHiX();
    int cy2 = r.getHiY();

    if (w < 2 || h < 2) {
        doSetRect(sData, pw, cx1, cy1, cx2, cy2);
        return;
    }


    if (cy1 == y) {
        doSetRect(sData, pw,   cx1,   cy1,   cx2, cy1+1);
    }
    if (cx1 == x) {
        doSetRect(sData, pw,   cx1, cy1+1, cx1+1, cy2-1);
    }
    if (cx2 == x2) {
        doSetRect(sData, pw, cx2-1, cy1+1,   cx2, cy2-1);
    }
    if (cy2 == y2) {
        doSetRect(sData, pw,   cx1, cy2-1,   cx2,   cy2);
    }
}
 
Example 7
Source File: GeneralRenderer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void doDrawRect(PixelWriter pw,
                              SunGraphics2D sg2d, SurfaceData sData,
                              int x, int y, int w, int h)
{
    if (w < 0 || h < 0) {
        return;
    }
    int x2 = Region.dimAdd(Region.dimAdd(x, w), 1);
    int y2 = Region.dimAdd(Region.dimAdd(y, h), 1);
    Region r = sg2d.getCompClip().getBoundsIntersectionXYXY(x, y, x2, y2);
    if (r.isEmpty()) {
        return;
    }
    int cx1 = r.getLoX();
    int cy1 = r.getLoY();
    int cx2 = r.getHiX();
    int cy2 = r.getHiY();

    if (w < 2 || h < 2) {
        doSetRect(sData, pw, cx1, cy1, cx2, cy2);
        return;
    }


    if (cy1 == y) {
        doSetRect(sData, pw,   cx1,   cy1,   cx2, cy1+1);
    }
    if (cx1 == x) {
        doSetRect(sData, pw,   cx1, cy1+1, cx1+1, cy2-1);
    }
    if (cx2 == x2) {
        doSetRect(sData, pw, cx2-1, cy1+1,   cx2, cy2-1);
    }
    if (cy2 == y2) {
        doSetRect(sData, pw,   cx1, cy2-1,   cx2,   cy2);
    }
}
 
Example 8
Source File: GeneralRenderer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void doDrawRect(PixelWriter pw,
                              SunGraphics2D sg2d, SurfaceData sData,
                              int x, int y, int w, int h)
{
    if (w < 0 || h < 0) {
        return;
    }
    int x2 = Region.dimAdd(Region.dimAdd(x, w), 1);
    int y2 = Region.dimAdd(Region.dimAdd(y, h), 1);
    Region r = sg2d.getCompClip().getBoundsIntersectionXYXY(x, y, x2, y2);
    if (r.isEmpty()) {
        return;
    }
    int cx1 = r.getLoX();
    int cy1 = r.getLoY();
    int cx2 = r.getHiX();
    int cy2 = r.getHiY();

    if (w < 2 || h < 2) {
        doSetRect(sData, pw, cx1, cy1, cx2, cy2);
        return;
    }


    if (cy1 == y) {
        doSetRect(sData, pw,   cx1,   cy1,   cx2, cy1+1);
    }
    if (cx1 == x) {
        doSetRect(sData, pw,   cx1, cy1+1, cx1+1, cy2-1);
    }
    if (cx2 == x2) {
        doSetRect(sData, pw, cx2-1, cy1+1,   cx2, cy2-1);
    }
    if (cy2 == y2) {
        doSetRect(sData, pw,   cx1, cy2-1,   cx2,   cy2);
    }
}
 
Example 9
Source File: SunGraphics2D.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a rectangle in image coordinates that may be required
 * in order to draw the given image into the given clipping region
 * through a pair of AffineTransforms.  In addition, horizontal and
 * vertical padding factors for antialising and interpolation may
 * be used.
 */
private static Rectangle getImageRegion(RenderedImage img,
                                        Region compClip,
                                        AffineTransform transform,
                                        AffineTransform xform,
                                        int padX, int padY) {
    Rectangle imageRect =
        new Rectangle(img.getMinX(), img.getMinY(),
                      img.getWidth(), img.getHeight());

    Rectangle result = null;
    try {
        double p[] = new double[8];
        p[0] = p[2] = compClip.getLoX();
        p[4] = p[6] = compClip.getHiX();
        p[1] = p[5] = compClip.getLoY();
        p[3] = p[7] = compClip.getHiY();

        // Inverse transform the output bounding rect
        transform.inverseTransform(p, 0, p, 0, 4);
        xform.inverseTransform(p, 0, p, 0, 4);

        // Determine a bounding box for the inverse transformed region
        double x0,x1,y0,y1;
        x0 = x1 = p[0];
        y0 = y1 = p[1];

        for (int i = 2; i < 8; ) {
            double pt = p[i++];
            if (pt < x0)  {
                x0 = pt;
            } else if (pt > x1) {
                x1 = pt;
            }
            pt = p[i++];
            if (pt < y0)  {
                y0 = pt;
            } else if (pt > y1) {
                y1 = pt;
            }
        }

        // This is padding for anti-aliasing and such.  It may
        // be more than is needed.
        int x = (int)x0 - padX;
        int w = (int)(x1 - x0 + 2*padX);
        int y = (int)y0 - padY;
        int h = (int)(y1 - y0 + 2*padY);

        Rectangle clipRect = new Rectangle(x,y,w,h);
        result = clipRect.intersection(imageRect);
    } catch (NoninvertibleTransformException nte) {
        // Worst case bounds are the bounds of the image.
        result = imageRect;
    }

    return result;
}
 
Example 10
Source File: SunGraphics2D.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a rectangle in image coordinates that may be required
 * in order to draw the given image into the given clipping region
 * through a pair of AffineTransforms.  In addition, horizontal and
 * vertical padding factors for antialising and interpolation may
 * be used.
 */
private static Rectangle getImageRegion(RenderedImage img,
                                        Region compClip,
                                        AffineTransform transform,
                                        AffineTransform xform,
                                        int padX, int padY) {
    Rectangle imageRect =
        new Rectangle(img.getMinX(), img.getMinY(),
                      img.getWidth(), img.getHeight());

    Rectangle result = null;
    try {
        double p[] = new double[8];
        p[0] = p[2] = compClip.getLoX();
        p[4] = p[6] = compClip.getHiX();
        p[1] = p[5] = compClip.getLoY();
        p[3] = p[7] = compClip.getHiY();

        // Inverse transform the output bounding rect
        transform.inverseTransform(p, 0, p, 0, 4);
        xform.inverseTransform(p, 0, p, 0, 4);

        // Determine a bounding box for the inverse transformed region
        double x0,x1,y0,y1;
        x0 = x1 = p[0];
        y0 = y1 = p[1];

        for (int i = 2; i < 8; ) {
            double pt = p[i++];
            if (pt < x0)  {
                x0 = pt;
            } else if (pt > x1) {
                x1 = pt;
            }
            pt = p[i++];
            if (pt < y0)  {
                y0 = pt;
            } else if (pt > y1) {
                y1 = pt;
            }
        }

        // This is padding for anti-aliasing and such.  It may
        // be more than is needed.
        int x = (int)x0 - padX;
        int w = (int)(x1 - x0 + 2*padX);
        int y = (int)y0 - padY;
        int h = (int)(y1 - y0 + 2*padY);

        Rectangle clipRect = new Rectangle(x,y,w,h);
        result = clipRect.intersection(imageRect);
    } catch (NoninvertibleTransformException nte) {
        // Worst case bounds are the bounds of the image.
        result = imageRect;
    }

    return result;
}
 
Example 11
Source File: OGLBlitLoops.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public void Blit(SurfaceData src, SurfaceData dst,
                 Composite comp, Region clip,
                 int sx, int sy, int dx, int dy,
                 int w, int h)
{
    if (clip != null) {
        clip = clip.getIntersectionXYWH(dx, dy, w, h);
        // At the end this method will flush the RenderQueue, we should exit
        // from it as soon as possible.
        if (clip.isEmpty()) {
            return;
        }
        sx += clip.getLoX() - dx;
        sy += clip.getLoY() - dy;
        dx = clip.getLoX();
        dy = clip.getLoY();
        w = clip.getWidth();
        h = clip.getHeight();

        if (!clip.isRectangular()) {
            complexClipBlit(src, dst, comp, clip, sx, sy, dx, dy, w, h);
            return;
        }
    }

    OGLRenderQueue rq = OGLRenderQueue.getInstance();
    rq.lock();
    try {
        // make sure the RenderQueue keeps a hard reference to the
        // destination (sysmem) SurfaceData to prevent it from being
        // disposed while the operation is processed on the QFT
        rq.addReference(dst);

        RenderBuffer buf = rq.getBuffer();
        OGLContext.validateContext((OGLSurfaceData)src);

        rq.ensureCapacityAndAlignment(48, 32);
        buf.putInt(SURFACE_TO_SW_BLIT);
        buf.putInt(sx).putInt(sy);
        buf.putInt(dx).putInt(dy);
        buf.putInt(w).putInt(h);
        buf.putInt(typeval);
        buf.putLong(src.getNativeOps());
        buf.putLong(dst.getNativeOps());

        // always flush immediately
        rq.flushNow();
    } finally {
        rq.unlock();
    }
}
 
Example 12
Source File: PiscesRenderingEngine.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
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;
    }

    Renderer r = new Renderer(3, 3,
            clip.getLoX(), clip.getLoY(),
            clip.getWidth(), clip.getHeight(),
            PathIterator.WIND_EVEN_ODD);

    r.moveTo((float) x, (float) y);
    r.lineTo((float) (x+dx1), (float) (y+dy1));
    r.lineTo((float) (x+dx1+dx2), (float) (y+dy1+dy2));
    r.lineTo((float) (x+dx2), (float) (y+dy2));
    r.closePath();

    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.moveTo((float) x, (float) y);
        r.lineTo((float) (x+dx1), (float) (y+dy1));
        r.lineTo((float) (x+dx1+dx2), (float) (y+dy1+dy2));
        r.lineTo((float) (x+dx2), (float) (y+dy2));
        r.closePath();
    }

    r.pathDone();

    r.endRendering();
    PiscesTileGenerator ptg = new PiscesTileGenerator(r, r.MAX_AA_ALPHA);
    ptg.getBbox(bbox);
    return ptg;
}
 
Example 13
Source File: SunGraphics2D.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a rectangle in image coordinates that may be required
 * in order to draw the given image into the given clipping region
 * through a pair of AffineTransforms.  In addition, horizontal and
 * vertical padding factors for antialising and interpolation may
 * be used.
 */
private static Rectangle getImageRegion(RenderedImage img,
                                        Region compClip,
                                        AffineTransform transform,
                                        AffineTransform xform,
                                        int padX, int padY) {
    Rectangle imageRect =
        new Rectangle(img.getMinX(), img.getMinY(),
                      img.getWidth(), img.getHeight());

    Rectangle result = null;
    try {
        double p[] = new double[8];
        p[0] = p[2] = compClip.getLoX();
        p[4] = p[6] = compClip.getHiX();
        p[1] = p[5] = compClip.getLoY();
        p[3] = p[7] = compClip.getHiY();

        // Inverse transform the output bounding rect
        transform.inverseTransform(p, 0, p, 0, 4);
        xform.inverseTransform(p, 0, p, 0, 4);

        // Determine a bounding box for the inverse transformed region
        double x0,x1,y0,y1;
        x0 = x1 = p[0];
        y0 = y1 = p[1];

        for (int i = 2; i < 8; ) {
            double pt = p[i++];
            if (pt < x0)  {
                x0 = pt;
            } else if (pt > x1) {
                x1 = pt;
            }
            pt = p[i++];
            if (pt < y0)  {
                y0 = pt;
            } else if (pt > y1) {
                y1 = pt;
            }
        }

        // This is padding for anti-aliasing and such.  It may
        // be more than is needed.
        int x = (int)x0 - padX;
        int w = (int)(x1 - x0 + 2*padX);
        int y = (int)y0 - padY;
        int h = (int)(y1 - y0 + 2*padY);

        Rectangle clipRect = new Rectangle(x,y,w,h);
        result = clipRect.intersection(imageRect);
    } catch (NoninvertibleTransformException nte) {
        // Worst case bounds are the bounds of the image.
        result = imageRect;
    }

    return result;
}
 
Example 14
Source File: SunGraphics2D.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a rectangle in image coordinates that may be required
 * in order to draw the given image into the given clipping region
 * through a pair of AffineTransforms.  In addition, horizontal and
 * vertical padding factors for antialising and interpolation may
 * be used.
 */
private static Rectangle getImageRegion(RenderedImage img,
                                        Region compClip,
                                        AffineTransform transform,
                                        AffineTransform xform,
                                        int padX, int padY) {
    Rectangle imageRect =
        new Rectangle(img.getMinX(), img.getMinY(),
                      img.getWidth(), img.getHeight());

    Rectangle result = null;
    try {
        double p[] = new double[8];
        p[0] = p[2] = compClip.getLoX();
        p[4] = p[6] = compClip.getHiX();
        p[1] = p[5] = compClip.getLoY();
        p[3] = p[7] = compClip.getHiY();

        // Inverse transform the output bounding rect
        transform.inverseTransform(p, 0, p, 0, 4);
        xform.inverseTransform(p, 0, p, 0, 4);

        // Determine a bounding box for the inverse transformed region
        double x0,x1,y0,y1;
        x0 = x1 = p[0];
        y0 = y1 = p[1];

        for (int i = 2; i < 8; ) {
            double pt = p[i++];
            if (pt < x0)  {
                x0 = pt;
            } else if (pt > x1) {
                x1 = pt;
            }
            pt = p[i++];
            if (pt < y0)  {
                y0 = pt;
            } else if (pt > y1) {
                y1 = pt;
            }
        }

        // This is padding for anti-aliasing and such.  It may
        // be more than is needed.
        int x = (int)x0 - padX;
        int w = (int)(x1 - x0 + 2*padX);
        int y = (int)y0 - padY;
        int h = (int)(y1 - y0 + 2*padY);

        Rectangle clipRect = new Rectangle(x,y,w,h);
        result = clipRect.intersection(imageRect);
    } catch (NoninvertibleTransformException nte) {
        // Worst case bounds are the bounds of the image.
        result = imageRect;
    }

    return result;
}
 
Example 15
Source File: PiscesRenderingEngine.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
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;
    }

    Renderer r = new Renderer(3, 3,
            clip.getLoX(), clip.getLoY(),
            clip.getWidth(), clip.getHeight(),
            PathIterator.WIND_EVEN_ODD);

    r.moveTo((float) x, (float) y);
    r.lineTo((float) (x+dx1), (float) (y+dy1));
    r.lineTo((float) (x+dx1+dx2), (float) (y+dy1+dy2));
    r.lineTo((float) (x+dx2), (float) (y+dy2));
    r.closePath();

    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.moveTo((float) x, (float) y);
        r.lineTo((float) (x+dx1), (float) (y+dy1));
        r.lineTo((float) (x+dx1+dx2), (float) (y+dy1+dy2));
        r.lineTo((float) (x+dx2), (float) (y+dy2));
        r.closePath();
    }

    r.pathDone();

    r.endRendering();
    PiscesTileGenerator ptg = new PiscesTileGenerator(r, r.MAX_AA_ALPHA);
    ptg.getBbox(bbox);
    return ptg;
}
 
Example 16
Source File: PiscesRenderingEngine.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
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;
    }

    Renderer r = new Renderer(3, 3,
            clip.getLoX(), clip.getLoY(),
            clip.getWidth(), clip.getHeight(),
            PathIterator.WIND_EVEN_ODD);

    r.moveTo((float) x, (float) y);
    r.lineTo((float) (x+dx1), (float) (y+dy1));
    r.lineTo((float) (x+dx1+dx2), (float) (y+dy1+dy2));
    r.lineTo((float) (x+dx2), (float) (y+dy2));
    r.closePath();

    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.moveTo((float) x, (float) y);
        r.lineTo((float) (x+dx1), (float) (y+dy1));
        r.lineTo((float) (x+dx1+dx2), (float) (y+dy1+dy2));
        r.lineTo((float) (x+dx2), (float) (y+dy2));
        r.closePath();
    }

    r.pathDone();

    r.endRendering();
    PiscesTileGenerator ptg = new PiscesTileGenerator(r, r.MAX_AA_ALPHA);
    ptg.getBbox(bbox);
    return ptg;
}
 
Example 17
Source File: PiscesRenderingEngine.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
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;
    }

    Renderer r = new Renderer(3, 3,
            clip.getLoX(), clip.getLoY(),
            clip.getWidth(), clip.getHeight(),
            PathIterator.WIND_EVEN_ODD);

    r.moveTo((float) x, (float) y);
    r.lineTo((float) (x+dx1), (float) (y+dy1));
    r.lineTo((float) (x+dx1+dx2), (float) (y+dy1+dy2));
    r.lineTo((float) (x+dx2), (float) (y+dy2));
    r.closePath();

    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.moveTo((float) x, (float) y);
        r.lineTo((float) (x+dx1), (float) (y+dy1));
        r.lineTo((float) (x+dx1+dx2), (float) (y+dy1+dy2));
        r.lineTo((float) (x+dx2), (float) (y+dy2));
        r.closePath();
    }

    r.pathDone();

    r.endRendering();
    PiscesTileGenerator ptg = new PiscesTileGenerator(r, r.MAX_AA_ALPHA);
    ptg.getBbox(bbox);
    return ptg;
}
 
Example 18
Source File: PiscesRenderingEngine.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
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;
    }

    Renderer r = new Renderer(3, 3,
            clip.getLoX(), clip.getLoY(),
            clip.getWidth(), clip.getHeight(),
            PathIterator.WIND_EVEN_ODD);

    r.moveTo((float) x, (float) y);
    r.lineTo((float) (x+dx1), (float) (y+dy1));
    r.lineTo((float) (x+dx1+dx2), (float) (y+dy1+dy2));
    r.lineTo((float) (x+dx2), (float) (y+dy2));
    r.closePath();

    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.moveTo((float) x, (float) y);
        r.lineTo((float) (x+dx1), (float) (y+dy1));
        r.lineTo((float) (x+dx1+dx2), (float) (y+dy1+dy2));
        r.lineTo((float) (x+dx2), (float) (y+dy2));
        r.closePath();
    }

    r.pathDone();

    r.endRendering();
    PiscesTileGenerator ptg = new PiscesTileGenerator(r, r.MAX_AA_ALPHA);
    ptg.getBbox(bbox);
    return ptg;
}
 
Example 19
Source File: PiscesRenderingEngine.java    From jdk8u-dev-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Construct an antialiased tile generator for the given shape with
 * the given rendering attributes and store the bounds of the tile
 * iteration in the bbox parameter.
 * The {@code at} parameter specifies a transform that should affect
 * both the shape and the {@code BasicStroke} attributes.
 * The {@code clip} parameter specifies the current clip in effect
 * in device coordinates and can be used to prune the data for the
 * operation, but the renderer is not required to perform any
 * clipping.
 * If the {@code BasicStroke} parameter is null then the shape
 * should be filled as is, otherwise the attributes of the
 * {@code BasicStroke} should be used to specify a draw operation.
 * The {@code thin} parameter indicates whether or not the
 * transformed {@code BasicStroke} represents coordinates smaller
 * than the minimum resolution of the antialiasing rasterizer as
 * specified by the {@code getMinimumAAPenWidth()} method.
 * <p>
 * Upon returning, this method will fill the {@code bbox} parameter
 * with 4 values indicating the bounds of the iteration of the
 * tile generator.
 * The iteration order of the tiles will be as specified by the
 * pseudo-code:
 * <pre>
 *     for (y = bbox[1]; y < bbox[3]; y += tileheight) {
 *         for (x = bbox[0]; x < bbox[2]; x += tilewidth) {
 *         }
 *     }
 * </pre>
 * If there is no output to be rendered, this method may return
 * null.
 *
 * @param s the shape to be rendered (fill or draw)
 * @param at the transform to be applied to the shape and the
 *           stroke attributes
 * @param clip the current clip in effect in device coordinates
 * @param bs if non-null, a {@code BasicStroke} whose attributes
 *           should be applied to this operation
 * @param thin true if the transformed stroke attributes are smaller
 *             than the minimum dropout pen width
 * @param normalize true if the {@code VALUE_STROKE_NORMALIZE}
 *                  {@code RenderingHint} is in effect
 * @param bbox returns the bounds of the iteration
 * @return the {@code AATileGenerator} instance to be consulted
 *         for tile coverages, or null if there is no output to render
 * @since 1.7
 */
public AATileGenerator getAATileGenerator(Shape s,
                                          AffineTransform at,
                                          Region clip,
                                          BasicStroke bs,
                                          boolean thin,
                                          boolean normalize,
                                          int bbox[])
{
    Renderer r;
    NormMode norm = (normalize) ? NormMode.ON_WITH_AA : NormMode.OFF;
    if (bs == null) {
        PathIterator pi;
        if (normalize) {
            pi = new NormalizingPathIterator(s.getPathIterator(at), norm);
        } else {
            pi = s.getPathIterator(at);
        }
        r = new Renderer(3, 3,
                         clip.getLoX(), clip.getLoY(),
                         clip.getWidth(), clip.getHeight(),
                         pi.getWindingRule());
        pathTo(pi, r);
    } else {
        r = new Renderer(3, 3,
                         clip.getLoX(), clip.getLoY(),
                         clip.getWidth(), clip.getHeight(),
                         PathIterator.WIND_NON_ZERO);
        strokeTo(s, at, bs, thin, norm, true, r);
    }
    r.endRendering();
    PiscesTileGenerator ptg = new PiscesTileGenerator(r, r.MAX_AA_ALPHA);
    ptg.getBbox(bbox);
    return ptg;
}
 
Example 20
Source File: PiscesRenderingEngine.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Construct an antialiased tile generator for the given shape with
 * the given rendering attributes and store the bounds of the tile
 * iteration in the bbox parameter.
 * The {@code at} parameter specifies a transform that should affect
 * both the shape and the {@code BasicStroke} attributes.
 * The {@code clip} parameter specifies the current clip in effect
 * in device coordinates and can be used to prune the data for the
 * operation, but the renderer is not required to perform any
 * clipping.
 * If the {@code BasicStroke} parameter is null then the shape
 * should be filled as is, otherwise the attributes of the
 * {@code BasicStroke} should be used to specify a draw operation.
 * The {@code thin} parameter indicates whether or not the
 * transformed {@code BasicStroke} represents coordinates smaller
 * than the minimum resolution of the antialiasing rasterizer as
 * specified by the {@code getMinimumAAPenWidth()} method.
 * <p>
 * Upon returning, this method will fill the {@code bbox} parameter
 * with 4 values indicating the bounds of the iteration of the
 * tile generator.
 * The iteration order of the tiles will be as specified by the
 * pseudo-code:
 * <pre>
 *     for (y = bbox[1]; y < bbox[3]; y += tileheight) {
 *         for (x = bbox[0]; x < bbox[2]; x += tilewidth) {
 *         }
 *     }
 * </pre>
 * If there is no output to be rendered, this method may return
 * null.
 *
 * @param s the shape to be rendered (fill or draw)
 * @param at the transform to be applied to the shape and the
 *           stroke attributes
 * @param clip the current clip in effect in device coordinates
 * @param bs if non-null, a {@code BasicStroke} whose attributes
 *           should be applied to this operation
 * @param thin true if the transformed stroke attributes are smaller
 *             than the minimum dropout pen width
 * @param normalize true if the {@code VALUE_STROKE_NORMALIZE}
 *                  {@code RenderingHint} is in effect
 * @param bbox returns the bounds of the iteration
 * @return the {@code AATileGenerator} instance to be consulted
 *         for tile coverages, or null if there is no output to render
 * @since 1.7
 */
public AATileGenerator getAATileGenerator(Shape s,
                                          AffineTransform at,
                                          Region clip,
                                          BasicStroke bs,
                                          boolean thin,
                                          boolean normalize,
                                          int bbox[])
{
    Renderer r;
    NormMode norm = (normalize) ? NormMode.ON_WITH_AA : NormMode.OFF;
    if (bs == null) {
        PathIterator pi;
        if (normalize) {
            pi = new NormalizingPathIterator(s.getPathIterator(at), norm);
        } else {
            pi = s.getPathIterator(at);
        }
        r = new Renderer(3, 3,
                         clip.getLoX(), clip.getLoY(),
                         clip.getWidth(), clip.getHeight(),
                         pi.getWindingRule());
        pathTo(pi, r);
    } else {
        r = new Renderer(3, 3,
                         clip.getLoX(), clip.getLoY(),
                         clip.getWidth(), clip.getHeight(),
                         PathIterator.WIND_NON_ZERO);
        strokeTo(s, at, bs, thin, norm, true, r);
    }
    r.endRendering();
    PiscesTileGenerator ptg = new PiscesTileGenerator(r, r.MAX_AA_ALPHA);
    ptg.getBbox(bbox);
    return ptg;
}