Java Code Examples for sun.awt.SunToolkit#awtUnlock()

The following examples show how to use sun.awt.SunToolkit#awtUnlock() . 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: XRPMBlitLoops.java    From openjdk-jdk8u with GNU General Public License v2.0 6 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) {
    try {
        SunToolkit.awtLock();

        XRSurfaceData x11sdDst = (XRSurfaceData) dst;
        x11sdDst.validateAsDestination(null, clip);
        XRSurfaceData x11sdSrc = (XRSurfaceData) src;
        x11sdSrc.validateAsSource(null, XRUtils.RepeatNone, XRUtils.FAST);

        x11sdDst.maskBuffer.validateCompositeState(comp, null, null, null);

        x11sdDst.maskBuffer.compositeBlit(x11sdSrc, x11sdDst, sx, sy, dx, dy, w, h);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 2
Source File: X11Renderer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private void doPath(SunGraphics2D sg2d, Shape s, boolean isFill) {
    Path2D.Float p2df;
    int transx, transy;
    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;
    }
    SunToolkit.awtLock();
    try {
        long xgc = validate(sg2d);
        XDoPath(sg2d, sg2d.surfaceData.getNativeOps(), xgc,
                transx, transy, p2df, isFill);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 3
Source File: XRPMBlitLoops.java    From dragonwell8_jdk with GNU General Public License v2.0 6 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) {
    try {
        SunToolkit.awtLock();

        XRSurfaceData x11sdDst = (XRSurfaceData) dst;
        x11sdDst.validateAsDestination(null, clip);
        XRSurfaceData x11sdSrc = (XRSurfaceData) src;
        x11sdSrc.validateAsSource(null, XRUtils.RepeatNone, XRUtils.FAST);

        x11sdDst.maskBuffer.validateCompositeState(comp, null, null, null);

        x11sdDst.maskBuffer.compositeBlit(x11sdSrc, x11sdDst, sx, sy, dx, dy, w, h);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 4
Source File: X11PMBlitLoops.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 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)
{
    SunToolkit.awtLock();
    try {
        X11SurfaceData x11sd = (X11SurfaceData)dst;
        // pass null clip region here since we clip manually in native code
        // also use false for needExposures since we clip to the pixmap
        long xgc = x11sd.getBlitGC(null, false);
        nativeBlit(src.getNativeOps(), dst.getNativeOps(), xgc, clip,
                   sx, sy, dx, dy, w, h);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 5
Source File: XErrorHandlerUtil.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the toolkit global error handler, stores the connection to X11 server,
 * which will be used during an error handling process. This method is called
 * once from {@code awt_init_Display} function defined in {@code awt_GraphicsEnv.c}
 * file immediately after the connection to X11 window server is opened.
 * @param display the connection to X11 server which should be stored
 */
private static void init(long display) {
    SunToolkit.awtLock();
    try {
        if (!initPassed) {
            XErrorHandlerUtil.display = display;
            saved_error_handler = XlibWrapper.SetToolkitErrorHandler();
            initPassed = true;
        }
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 6
Source File: X11Renderer.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void drawArc(SunGraphics2D sg2d,
                    int x, int y, int width, int height,
                    int startAngle, int arcAngle)
{
    SunToolkit.awtLock();
    try {
        long xgc = validate(sg2d);
        XDrawArc(sg2d.surfaceData.getNativeOps(), xgc,
                 x+sg2d.transX, y+sg2d.transY, width, height,
                 startAngle, arcAngle);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 7
Source File: X11Renderer.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void drawArc(SunGraphics2D sg2d,
                    int x, int y, int width, int height,
                    int startAngle, int arcAngle)
{
    SunToolkit.awtLock();
    try {
        long xgc = validate(sg2d);
        XDrawArc(sg2d.surfaceData.getNativeOps(), xgc,
                 x+sg2d.transX, y+sg2d.transY, width, height,
                 startAngle, arcAngle);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 8
Source File: X11Renderer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void fillOval(SunGraphics2D sg2d,
                     int x, int y, int width, int height)
{
    SunToolkit.awtLock();
    try {
        long xgc = validate(sg2d);
        XFillOval(sg2d.surfaceData.getNativeOps(), xgc,
                  x+sg2d.transX, y+sg2d.transY, width, height);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 9
Source File: X11Renderer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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));
    }
}
 
Example 10
Source File: X11Renderer.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void drawRect(SunGraphics2D sg2d,
                     int x, int y, int width, int height)
{
    SunToolkit.awtLock();
    try {
        long xgc = validate(sg2d);
        XDrawRect(sg2d.surfaceData.getNativeOps(), xgc,
                  x+sg2d.transX, y+sg2d.transY, width, height);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 11
Source File: XRRenderer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void fillRect(SunGraphics2D sg2d, int x, int y, int width, int height) {
    x = Region.clipAdd(x, sg2d.transX);
    y = Region.clipAdd(y, sg2d.transY);

    /*
     * Limit x/y to signed short, width/height to unsigned short,
     * to match the X11 coordinate limits for rectangles.
     * Correct width/height in case x/y have been modified by clipping.
     */
    if (x > Short.MAX_VALUE || y > Short.MAX_VALUE) {
        return;
    }

    int x2 = Region.dimAdd(x, width);
    int y2 = Region.dimAdd(y, height);

    if (x2 < Short.MIN_VALUE || y2 < Short.MIN_VALUE) {
        return;
    }

    x = clampToShort(x);
    y = clampToShort(y);
    width = clampToUShort(x2 - x);
    height = clampToUShort(y2 - y);

    if (width == 0 || height == 0) {
        return;
    }

    SunToolkit.awtLock();
    try {
        validateSurface(sg2d);
        rectBuffer.pushRectValues(x, y, width, height);
        tileManager.fillMask((XRSurfaceData) sg2d.surfaceData);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 12
Source File: XRRenderer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected void drawPath(SunGraphics2D sg2d, Path2D.Float p2df,
                        int transx, int transy) {
    SunToolkit.awtLock();
    try {
        validateSurface(sg2d);
        drawHandler.validate(sg2d);
        ProcessPath.drawPath(drawHandler, p2df, transx, transy);
        tileManager.fillMask(((XRSurfaceData) sg2d.surfaceData));
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 13
Source File: XRRenderer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
protected void fillPath(SunGraphics2D sg2d, Path2D.Float p2df,
                        int transx, int transy) {
    SunToolkit.awtLock();
    try {
        validateSurface(sg2d);
        drawHandler.validate(sg2d);
        ProcessPath.fillPath(drawHandler, p2df, transx, transy);
        tileManager.fillMask(((XRSurfaceData) sg2d.surfaceData));
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 14
Source File: XRPMBlitLoops.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void Scale(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx1, int sy1, int sx2, int sy2, double dx1, double dy1,
        double dx2, double dy2) {
    {
        int w = sx2 - sx1;
        int h = sy2 - sy1;

        try {
            SunToolkit.awtLock();
            XRSurfaceData vImgSurface = XRPMBlitLoops.cacheToTmpSurface(src, (XRSurfaceData) dst, w, h, sx1, sy1);
            pmToSurfaceBlit.Scale(vImgSurface, dst, comp, clip, 0, 0, w, h, dx1, dy1, dx2, dy2);
        } finally {
            SunToolkit.awtUnlock();
        }
    }
}
 
Example 15
Source File: XErrorHandlerUtil.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static void XSync() {
    SunToolkit.awtLock();
    try {
        XlibWrapper.XSync(display, 0);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 16
Source File: X11Renderer.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void drawRoundRect(SunGraphics2D sg2d,
                          int x, int y, int width, int height,
                          int arcWidth, int arcHeight)
{
    SunToolkit.awtLock();
    try {
        long xgc = validate(sg2d);
        XDrawRoundRect(sg2d.surfaceData.getNativeOps(), xgc,
                       x+sg2d.transX, y+sg2d.transY, width, height,
                       arcWidth, arcHeight);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 17
Source File: X11Renderer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void drawPolyline(SunGraphics2D sg2d,
                         int xpoints[], int ypoints[],
                         int npoints)
{
    SunToolkit.awtLock();
    try {
        long xgc = validate(sg2d);
        XDrawPoly(sg2d.surfaceData.getNativeOps(), xgc,
                  sg2d.transX, sg2d.transY,
                  xpoints, ypoints, npoints, false);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 18
Source File: X11Renderer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
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();
    }
}
 
Example 19
Source File: XRPMBlitLoops.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void Transform(SurfaceData src, SurfaceData dst, Composite comp, Region clip, AffineTransform xform,
        int hint, int srcx, int srcy, int dstx, int dsty, int width, int height) {
    try {
        SunToolkit.awtLock();

        XRSurfaceData x11sdDst = (XRSurfaceData) dst;
        XRSurfaceData x11sdSrc = (XRSurfaceData) src;
        XRCompositeManager xrMgr = XRCompositeManager.getInstance(x11sdSrc);

        float extraAlpha = ((AlphaComposite) comp).getAlpha();
        int filter = XRUtils.ATransOpToXRQuality(hint);
        boolean isQuadrantRotated = XRUtils.isTransformQuadrantRotated(xform);

        adjustCompositeBounds(isQuadrantRotated, xform, dstx, dsty, width, height);

        x11sdDst.validateAsDestination(null, clip);
        x11sdDst.maskBuffer.validateCompositeState(comp, null, null, null);

        AffineTransform trx = AffineTransform.getTranslateInstance(-compositeBounds.x, -compositeBounds.y);
        trx.concatenate(xform);
        AffineTransform maskTX = (AffineTransform) trx.clone();
        trx.translate(-srcx, -srcy);

        try {
            trx.invert();
        } catch (NoninvertibleTransformException ex) {
            trx.setToIdentity();
        }

        if (filter != XRUtils.FAST && (!isQuadrantRotated || extraAlpha != 1.0f)) {
            XRMaskImage mask = x11sdSrc.maskBuffer.getMaskImage();

            // For quadrant-transformed blits geometry is not stored inside the mask
            // therefore we can use a repeating 1x1 mask for applying extra alpha.
            int maskPicture = isQuadrantRotated ? xrMgr.getExtraAlphaMask()
                    : mask.prepareBlitMask(x11sdDst, maskTX, width, height);

            x11sdSrc.validateAsSource(trx, XRUtils.RepeatPad, filter);
            x11sdDst.maskBuffer.con.renderComposite(xrMgr.getCompRule(), x11sdSrc.picture,
                    maskPicture, x11sdDst.picture, 0, 0, 0, 0, compositeBounds.x, compositeBounds.y,
                    compositeBounds.width, compositeBounds.height);
        } else {
            int repeat = filter == XRUtils.FAST ? XRUtils.RepeatNone : XRUtils.RepeatPad;

            x11sdSrc.validateAsSource(trx, repeat, filter);

            // compositeBlit takes care of extra alpha
            x11sdDst.maskBuffer.compositeBlit(x11sdSrc, x11sdDst, 0, 0, compositeBounds.x,
                    compositeBounds.y, compositeBounds.width, compositeBounds.height);
        }
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 20
Source File: RenderQueue.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Unlocks the queue.
 */
public final void unlock() {
    SunToolkit.awtUnlock();
}