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

The following examples show how to use sun.java2d.pipe.Region#getHeight() . 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: OGLUtilities.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the Rectangle describing the OpenGL scissor box on the
 * Java 2D surface associated with the given Graphics object.  When a
 * third-party library is performing OpenGL rendering directly
 * into the visible region of the associated surface, this scissor box
 * must be set to avoid drawing over existing rendering results.
 *
 * Note that the x/y values in the returned Rectangle object represent
 * the lower-left corner of the scissor region, relative to the
 * lower-left corner of the given surface.
 *
 * @param g the Graphics object for the corresponding destination surface;
 * cannot be null
 * @return a Rectangle describing the OpenGL scissor box for the given
 * Graphics object and corresponding destination surface, or null if the
 * given Graphics object is invalid or the clip region is non-rectangular
 */
public static Rectangle getOGLScissorBox(Graphics g) {
    if (!(g instanceof SunGraphics2D)) {
        return null;
    }

    SunGraphics2D sg2d = (SunGraphics2D)g;
    SurfaceData sData = (SurfaceData)sg2d.surfaceData;
    Region r = sg2d.getCompClip();
    if (!r.isRectangular()) {
        // caller probably doesn't know how to handle shape clip
        // appropriately, so just return null (Swing currently never
        // sets a shape clip, but that could change in the future)
        return null;
    }

    // this is the upper-left origin of the scissor box relative to the
    // upper-left origin of the surface (in Java 2D coordinates)
    int x0 = r.getLoX();
    int y0 = r.getLoY();

    // this is the width and height of the scissor region
    int w = r.getWidth();
    int h = r.getHeight();

    // this is the lower-left origin of the scissor box relative to the
    // lower-left origin of the surface (in OpenGL coordinates)
    Rectangle surfaceBounds = sData.getBounds();
    int x1 = x0;
    int y1 = surfaceBounds.height - (y0 + h);

    return new Rectangle(x1, y1, w, h);
}
 
Example 2
Source File: OGLUtilities.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the Rectangle describing the OpenGL scissor box on the
 * Java 2D surface associated with the given Graphics object.  When a
 * third-party library is performing OpenGL rendering directly
 * into the visible region of the associated surface, this scissor box
 * must be set to avoid drawing over existing rendering results.
 *
 * Note that the x/y values in the returned Rectangle object represent
 * the lower-left corner of the scissor region, relative to the
 * lower-left corner of the given surface.
 *
 * @param g the Graphics object for the corresponding destination surface;
 * cannot be null
 * @return a Rectangle describing the OpenGL scissor box for the given
 * Graphics object and corresponding destination surface, or null if the
 * given Graphics object is invalid or the clip region is non-rectangular
 */
public static Rectangle getOGLScissorBox(Graphics g) {
    if (!(g instanceof SunGraphics2D)) {
        return null;
    }

    SunGraphics2D sg2d = (SunGraphics2D)g;
    SurfaceData sData = (SurfaceData)sg2d.surfaceData;
    Region r = sg2d.getCompClip();
    if (!r.isRectangular()) {
        // caller probably doesn't know how to handle shape clip
        // appropriately, so just return null (Swing currently never
        // sets a shape clip, but that could change in the future)
        return null;
    }

    // this is the upper-left origin of the scissor box relative to the
    // upper-left origin of the surface (in Java 2D coordinates)
    int x0 = r.getLoX();
    int y0 = r.getLoY();

    // this is the width and height of the scissor region
    int w = r.getWidth();
    int h = r.getHeight();

    // this is the lower-left origin of the scissor box relative to the
    // lower-left origin of the surface (in OpenGL coordinates)
    Rectangle surfaceBounds = sData.getBounds();
    int x1 = x0;
    int y1 = surfaceBounds.height - (y0 + h);

    return new Rectangle(x1, y1, w, h);
}
 
Example 3
Source File: OGLUtilities.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the Rectangle describing the OpenGL scissor box on the
 * Java 2D surface associated with the given Graphics object.  When a
 * third-party library is performing OpenGL rendering directly
 * into the visible region of the associated surface, this scissor box
 * must be set to avoid drawing over existing rendering results.
 *
 * Note that the x/y values in the returned Rectangle object represent
 * the lower-left corner of the scissor region, relative to the
 * lower-left corner of the given surface.
 *
 * @param g the Graphics object for the corresponding destination surface;
 * cannot be null
 * @return a Rectangle describing the OpenGL scissor box for the given
 * Graphics object and corresponding destination surface, or null if the
 * given Graphics object is invalid or the clip region is non-rectangular
 */
public static Rectangle getOGLScissorBox(Graphics g) {
    if (!(g instanceof SunGraphics2D)) {
        return null;
    }

    SunGraphics2D sg2d = (SunGraphics2D)g;
    SurfaceData sData = (SurfaceData)sg2d.surfaceData;
    Region r = sg2d.getCompClip();
    if (!r.isRectangular()) {
        // caller probably doesn't know how to handle shape clip
        // appropriately, so just return null (Swing currently never
        // sets a shape clip, but that could change in the future)
        return null;
    }

    // this is the upper-left origin of the scissor box relative to the
    // upper-left origin of the surface (in Java 2D coordinates)
    int x0 = r.getLoX();
    int y0 = r.getLoY();

    // this is the width and height of the scissor region
    int w = r.getWidth();
    int h = r.getHeight();

    // this is the lower-left origin of the scissor box relative to the
    // lower-left origin of the surface (in OpenGL coordinates)
    Rectangle surfaceBounds = sData.getBounds();
    int x1 = x0;
    int y1 = surfaceBounds.height - (y0 + h);

    return new Rectangle(x1, y1, w, h);
}
 
Example 4
Source File: OGLUtilities.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the Rectangle describing the OpenGL scissor box on the
 * Java 2D surface associated with the given Graphics object.  When a
 * third-party library is performing OpenGL rendering directly
 * into the visible region of the associated surface, this scissor box
 * must be set to avoid drawing over existing rendering results.
 *
 * Note that the x/y values in the returned Rectangle object represent
 * the lower-left corner of the scissor region, relative to the
 * lower-left corner of the given surface.
 *
 * @param g the Graphics object for the corresponding destination surface;
 * cannot be null
 * @return a Rectangle describing the OpenGL scissor box for the given
 * Graphics object and corresponding destination surface, or null if the
 * given Graphics object is invalid or the clip region is non-rectangular
 */
public static Rectangle getOGLScissorBox(Graphics g) {
    if (!(g instanceof SunGraphics2D)) {
        return null;
    }

    SunGraphics2D sg2d = (SunGraphics2D)g;
    SurfaceData sData = (SurfaceData)sg2d.surfaceData;
    Region r = sg2d.getCompClip();
    if (!r.isRectangular()) {
        // caller probably doesn't know how to handle shape clip
        // appropriately, so just return null (Swing currently never
        // sets a shape clip, but that could change in the future)
        return null;
    }

    // this is the upper-left origin of the scissor box relative to the
    // upper-left origin of the surface (in Java 2D coordinates)
    int x0 = r.getLoX();
    int y0 = r.getLoY();

    // this is the width and height of the scissor region
    int w = r.getWidth();
    int h = r.getHeight();

    // this is the lower-left origin of the scissor box relative to the
    // lower-left origin of the surface (in OpenGL coordinates)
    Rectangle surfaceBounds = sData.getBounds();
    int x1 = x0;
    int y1 = surfaceBounds.height - (y0 + h);

    return new Rectangle(x1, y1, w, h);
}
 
Example 5
Source File: OGLUtilities.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the Rectangle describing the OpenGL scissor box on the
 * Java 2D surface associated with the given Graphics object.  When a
 * third-party library is performing OpenGL rendering directly
 * into the visible region of the associated surface, this scissor box
 * must be set to avoid drawing over existing rendering results.
 *
 * Note that the x/y values in the returned Rectangle object represent
 * the lower-left corner of the scissor region, relative to the
 * lower-left corner of the given surface.
 *
 * @param g the Graphics object for the corresponding destination surface;
 * cannot be null
 * @return a Rectangle describing the OpenGL scissor box for the given
 * Graphics object and corresponding destination surface, or null if the
 * given Graphics object is invalid or the clip region is non-rectangular
 */
public static Rectangle getOGLScissorBox(Graphics g) {
    if (!(g instanceof SunGraphics2D)) {
        return null;
    }

    SunGraphics2D sg2d = (SunGraphics2D)g;
    SurfaceData sData = (SurfaceData)sg2d.surfaceData;
    Region r = sg2d.getCompClip();
    if (!r.isRectangular()) {
        // caller probably doesn't know how to handle shape clip
        // appropriately, so just return null (Swing currently never
        // sets a shape clip, but that could change in the future)
        return null;
    }

    // this is the upper-left origin of the scissor box relative to the
    // upper-left origin of the surface (in Java 2D coordinates)
    int x0 = r.getLoX();
    int y0 = r.getLoY();

    // this is the width and height of the scissor region
    int w = r.getWidth();
    int h = r.getHeight();

    // this is the lower-left origin of the scissor box relative to the
    // lower-left origin of the surface (in OpenGL coordinates)
    Rectangle surfaceBounds = sData.getBounds();
    int x1 = x0;
    int y1 = surfaceBounds.height - (y0 + h);

    return new Rectangle(x1, y1, w, h);
}
 
Example 6
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 7
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 8
Source File: OGLBlitLoops.java    From openjdk-jdk8u 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 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 9
Source File: OGLBlitLoops.java    From jdk8u-jdk 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 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 10
Source File: OGLBlitLoops.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 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 11
Source File: OGLBlitLoops.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 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 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 13
Source File: PiscesRenderingEngine.java    From openjdk-8 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 14
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 15
Source File: PiscesRenderingEngine.java    From openjdk-8-source 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 16
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;
}
 
Example 17
Source File: PiscesRenderingEngine.java    From openjdk-jdk8u-backup 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 18
Source File: PiscesRenderingEngine.java    From jdk8u-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 19
Source File: PiscesRenderingEngine.java    From jdk8u_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 dragonwell8_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;
}