Search in sources :

Example 11 with Region

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

the class OGLUtilities method getOGLScissorBox.

/**
     * 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()) {
        // 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);
}
Also used : SurfaceData(sun.java2d.SurfaceData) Rectangle(java.awt.Rectangle) Region(sun.java2d.pipe.Region) SunGraphics2D(sun.java2d.SunGraphics2D)

Example 12 with Region

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

the class XorPixelWriter method FillRect.

public void FillRect(SunGraphics2D sg2d, SurfaceData sData, int x, int y, int w, int h) {
    PixelWriter pw = GeneralRenderer.createXorPixelWriter(sg2d, sData);
    Region r = sg2d.getCompClip().getBoundsIntersectionXYWH(x, y, w, h);
    GeneralRenderer.doSetRect(sData, pw, r.getLoX(), r.getLoY(), r.getHiX(), r.getHiY());
}
Also used : Region(sun.java2d.pipe.Region)

Example 13 with Region

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

the class XorCopyArgbToAny method Blit.

public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int srcx, int srcy, int dstx, int dsty, int w, int h) {
    Raster srcRast = src.getRaster(srcx, srcy, w, h);
    ColorModel srcCM = src.getColorModel();
    Raster dstRast = dst.getRaster(dstx, dsty, w, h);
    IntegerComponentRaster icr = (IntegerComponentRaster) dstRast;
    int[] dstPix = icr.getDataStorage();
    Region roi = CustomComponent.getRegionOfInterest(src, dst, clip, srcx, srcy, dstx, dsty, w, h);
    SpanIterator si = roi.getSpanIterator();
    Object srcPix = null;
    int dstScan = icr.getScanlineStride();
    // assert(icr.getPixelStride() == 1);
    srcx -= dstx;
    srcy -= dsty;
    int[] span = new int[4];
    while (si.nextSpan(span)) {
        int rowoff = icr.getDataOffset(0) + span[1] * dstScan + span[0];
        for (int y = span[1]; y < span[3]; y++) {
            int off = rowoff;
            for (int x = span[0]; x < span[2]; x++) {
                srcPix = srcRast.getDataElements(x + srcx, y + srcy, srcPix);
                dstPix[off++] = srcCM.getRGB(srcPix);
            }
            rowoff += dstScan;
        }
    }
    // Pixels in the dest were modified directly, we must
    // manually notify the raster that it was modified
    icr.markDirty();
// REMIND: We need to do something to make sure that dstRast
// is put back to the destination (as in the native Release
// function)
// src.releaseRaster(srcRast);  // NOP?
// dst.releaseRaster(dstRast);
}
Also used : SpanIterator(sun.java2d.pipe.SpanIterator) ColorModel(java.awt.image.ColorModel) Raster(java.awt.image.Raster) IntegerComponentRaster(sun.awt.image.IntegerComponentRaster) WritableRaster(java.awt.image.WritableRaster) IntegerComponentRaster(sun.awt.image.IntegerComponentRaster) Region(sun.java2d.pipe.Region)

Example 14 with Region

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

the class XRRenderer method drawLine.

public void drawLine(SunGraphics2D sg2d, int x1, int y1, int x2, int y2) {
    Region compClip = sg2d.getCompClip();
    int transX1 = Region.clipAdd(x1, sg2d.transX);
    int transY1 = Region.clipAdd(y1, sg2d.transY);
    int transX2 = Region.clipAdd(x2, sg2d.transX);
    int transY2 = Region.clipAdd(y2, sg2d.transY);
    SunToolkit.awtLock();
    try {
        validateSurface(sg2d);
        lineGen.rasterizeLine(rectBuffer, transX1, transY1, transX2, transY2, compClip.getLoX(), compClip.getLoY(), compClip.getHiX(), compClip.getHiY(), true, true);
        tileManager.fillMask((XRSurfaceData) sg2d.surfaceData);
    } finally {
        SunToolkit.awtUnlock();
    }
}
Also used : Region(sun.java2d.pipe.Region)

Example 15 with Region

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

the class XorPixelWriter method doDrawRect.

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);
    }
}
Also used : Region(sun.java2d.pipe.Region)

Aggregations

Region (sun.java2d.pipe.Region)22 Rectangle (java.awt.Rectangle)5 GradientPaint (java.awt.GradientPaint)3 LinearGradientPaint (java.awt.LinearGradientPaint)3 Paint (java.awt.Paint)3 RadialGradientPaint (java.awt.RadialGradientPaint)3 TexturePaint (java.awt.TexturePaint)3 ShapeSpanIterator (sun.java2d.pipe.ShapeSpanIterator)3 Composite (java.awt.Composite)2 AffineTransform (java.awt.geom.AffineTransform)2 ColorModel (java.awt.image.ColorModel)2 Raster (java.awt.image.Raster)2 WritableRaster (java.awt.image.WritableRaster)2 CompositeType (sun.java2d.loops.CompositeType)2 AlphaComposite (java.awt.AlphaComposite)1 Polygon (java.awt.Polygon)1 PathIterator (java.awt.geom.PathIterator)1 Rectangle2D (java.awt.geom.Rectangle2D)1 BufferedImage (java.awt.image.BufferedImage)1 IntegerComponentRaster (sun.awt.image.IntegerComponentRaster)1