Search in sources :

Example 1 with ShapeSpanIterator

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

the class SunGraphics2D method validateCompClip.

protected void validateCompClip() {
    int origClipState = clipState;
    if (usrClip == null) {
        clipState = CLIP_DEVICE;
        clipRegion = devClip;
    } else if (usrClip instanceof Rectangle2D) {
        clipState = CLIP_RECTANGULAR;
        if (usrClip instanceof Rectangle) {
            clipRegion = devClip.getIntersection((Rectangle) usrClip);
        } else {
            clipRegion = devClip.getIntersection(usrClip.getBounds());
        }
    } else {
        PathIterator cpi = usrClip.getPathIterator(null);
        int[] box = new int[4];
        ShapeSpanIterator sr = LoopPipe.getFillSSI(this);
        try {
            sr.setOutputArea(devClip);
            sr.appendPath(cpi);
            sr.getPathBox(box);
            Region r = Region.getInstance(box);
            r.appendSpans(sr);
            clipRegion = r;
            clipState = r.isRectangular() ? CLIP_RECTANGULAR : CLIP_SHAPE;
        } finally {
            sr.dispose();
        }
    }
    if (origClipState != clipState && (clipState == CLIP_SHAPE || origClipState == CLIP_SHAPE)) {
        validFontInfo = false;
        invalidatePipe();
    }
}
Also used : ShapeSpanIterator(sun.java2d.pipe.ShapeSpanIterator) PathIterator(java.awt.geom.PathIterator) Rectangle2D(java.awt.geom.Rectangle2D) Rectangle(java.awt.Rectangle) Region(sun.java2d.pipe.Region) RadialGradientPaint(java.awt.RadialGradientPaint) Paint(java.awt.Paint) TexturePaint(java.awt.TexturePaint) LinearGradientPaint(java.awt.LinearGradientPaint) GradientPaint(java.awt.GradientPaint)

Example 2 with ShapeSpanIterator

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

the class X11Renderer method draw.

public void draw(SunGraphics2D sg2d, Shape s) {
    if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
        // Delegate to drawPolygon() if possible...
        if (s instanceof Polygon && sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
            Polygon p = (Polygon) s;
            drawPolygon(sg2d, p.xpoints, p.ypoints, p.npoints);
            return;
        }
        // Otherwise we will use drawPath() for
        // high-quality thin paths.
        doPath(sg2d, s, false);
    } else if (sg2d.strokeState < SunGraphics2D.STROKE_CUSTOM) {
        // REMIND: X11 can handle uniform scaled wide lines
        // and dashed lines itself if we set the appropriate
        // XGC attributes (TBD).
        ShapeSpanIterator si = LoopPipe.getStrokeSpans(sg2d, s);
        try {
            SunToolkit.awtLock();
            try {
                long xgc = validate(sg2d);
                XFillSpans(sg2d.surfaceData.getNativeOps(), xgc, si, si.getNativeIterator(), 0, 0);
            } finally {
                SunToolkit.awtUnlock();
            }
        } finally {
            si.dispose();
        }
    } else {
        fill(sg2d, sg2d.stroke.createStrokedShape(s));
    }
}
Also used : ShapeSpanIterator(sun.java2d.pipe.ShapeSpanIterator) Polygon(java.awt.Polygon)

Example 3 with ShapeSpanIterator

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

the class XRRenderer method fill.

public void fill(SunGraphics2D sg2d, Shape s) {
    int transx, transy;
    if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
        // Here we are able to use fillPath() for
        // high-quality fills.
        Path2D.Float p2df;
        if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
            if (s instanceof Path2D.Float) {
                p2df = (Path2D.Float) s;
            } else {
                p2df = new Path2D.Float(s);
            }
            transx = sg2d.transX;
            transy = sg2d.transY;
        } else {
            p2df = new Path2D.Float(s, sg2d.transform);
            transx = 0;
            transy = 0;
        }
        fillPath(sg2d, p2df, transx, transy);
        return;
    }
    AffineTransform at;
    if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
        // Transform (translation) will be done by FillSpans
        at = null;
        transx = sg2d.transX;
        transy = sg2d.transY;
    } else {
        // Transform will be done by the PathIterator
        at = sg2d.transform;
        transx = transy = 0;
    }
    ShapeSpanIterator ssi = LoopPipe.getFillSSI(sg2d);
    try {
        // Subtract transx/y from the SSI clip to match the
        // (potentially untranslated) geometry fed to it
        Region clip = sg2d.getCompClip();
        ssi.setOutputAreaXYXY(clip.getLoX() - transx, clip.getLoY() - transy, clip.getHiX() - transx, clip.getHiY() - transy);
        ssi.appendPath(s.getPathIterator(at));
        fillSpans(sg2d, ssi, transx, transy);
    } finally {
        ssi.dispose();
    }
}
Also used : ShapeSpanIterator(sun.java2d.pipe.ShapeSpanIterator) Region(sun.java2d.pipe.Region)

Example 4 with ShapeSpanIterator

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

the class X11Renderer method fill.

public void fill(SunGraphics2D sg2d, Shape s) {
    if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
        // Delegate to fillPolygon() if possible...
        if (s instanceof Polygon && sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
            Polygon p = (Polygon) s;
            fillPolygon(sg2d, p.xpoints, p.ypoints, p.npoints);
            return;
        }
        // Otherwise we will use fillPath() for
        // high-quality fills.
        doPath(sg2d, s, true);
        return;
    }
    AffineTransform at;
    int transx, transy;
    if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
        // Transform (translation) will be done by XFillSpans
        at = null;
        transx = sg2d.transX;
        transy = sg2d.transY;
    } else {
        // Transform will be done by the PathIterator
        at = sg2d.transform;
        transx = transy = 0;
    }
    ShapeSpanIterator ssi = LoopPipe.getFillSSI(sg2d);
    try {
        // Subtract transx/y from the SSI clip to match the
        // (potentially untranslated) geometry fed to it
        Region clip = sg2d.getCompClip();
        ssi.setOutputAreaXYXY(clip.getLoX() - transx, clip.getLoY() - transy, clip.getHiX() - transx, clip.getHiY() - transy);
        ssi.appendPath(s.getPathIterator(at));
        SunToolkit.awtLock();
        try {
            long xgc = validate(sg2d);
            XFillSpans(sg2d.surfaceData.getNativeOps(), xgc, ssi, ssi.getNativeIterator(), transx, transy);
        } finally {
            SunToolkit.awtUnlock();
        }
    } finally {
        ssi.dispose();
    }
}
Also used : ShapeSpanIterator(sun.java2d.pipe.ShapeSpanIterator) AffineTransform(java.awt.geom.AffineTransform) Region(sun.java2d.pipe.Region) Polygon(java.awt.Polygon)

Aggregations

ShapeSpanIterator (sun.java2d.pipe.ShapeSpanIterator)4 Region (sun.java2d.pipe.Region)3 Polygon (java.awt.Polygon)2 GradientPaint (java.awt.GradientPaint)1 LinearGradientPaint (java.awt.LinearGradientPaint)1 Paint (java.awt.Paint)1 RadialGradientPaint (java.awt.RadialGradientPaint)1 Rectangle (java.awt.Rectangle)1 TexturePaint (java.awt.TexturePaint)1 AffineTransform (java.awt.geom.AffineTransform)1 PathIterator (java.awt.geom.PathIterator)1 Rectangle2D (java.awt.geom.Rectangle2D)1