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

The following examples show how to use sun.awt.SunToolkit#awtLock() . 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: XRRenderer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
protected void fillSpans(SunGraphics2D sg2d, SpanIterator si,
                         int transx, int transy) {
    SunToolkit.awtLock();
    try {
        validateSurface(sg2d);
        int[] spanBox = new int[4];
        while (si.nextSpan(spanBox)) {
            rectBuffer.pushRectValues(spanBox[0] + transx,
                                spanBox[1] + transy,
                                spanBox[2] - spanBox[0],
                                spanBox[3] - spanBox[1]);
        }
        tileManager.fillMask(((XRSurfaceData) sg2d.surfaceData));
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 2
Source File: XRPMBlitLoops.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) {
    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 3
Source File: XRPMBlitLoops.java    From jdk8u-dev-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) {
    // If the blit is write-only (putimge), no need for a temporary VI.
    if (CompositeType.SrcOverNoEa.equals(comp) && (src.getTransparency() == Transparency.OPAQUE)) {
        Blit opaqueSwToSurfaceBlit = Blit.getFromCache(src.getSurfaceType(), CompositeType.SrcNoEa, dst.getSurfaceType());
        opaqueSwToSurfaceBlit.Blit(src, dst, comp, clip, sx, sy, dx, dy, w, h);
    } else {
        try {
            SunToolkit.awtLock();

            XRSurfaceData vImgSurface = XRPMBlitLoops.cacheToTmpSurface(src, (XRSurfaceData) dst, w, h, sx, sy);
            pmToSurfaceBlit.Blit(vImgSurface, dst, comp, clip, 0, 0, dx, dy, w, h);
        } finally {
            SunToolkit.awtUnlock();
        }
    }
}
 
Example 4
Source File: XRPMBlitLoops.java    From hottub 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) {
    try {
        SunToolkit.awtLock();

        XRSurfaceData x11sdDst = (XRSurfaceData) dst;
        x11sdDst.validateAsDestination(null, clip);
        XRSurfaceData x11sdSrc = (XRSurfaceData) src;
        x11sdDst.maskBuffer.validateCompositeState(comp, null, null, null);

        double xScale = (dx2 - dx1) / (sx2 - sx1);
        double yScale = (dy2 - dy1) / (sy2 - sy1);

        sx1 *= xScale;
        sx2 *= xScale;
        sy1 *= yScale;
        sy2 *= yScale;

        dx1 = Math.ceil(dx1 - 0.5);
        dy1 = Math.ceil(dy1 - 0.5);
        dx2 = Math.ceil(dx2 - 0.5);
        dy2 = Math.ceil(dy2 - 0.5);

        AffineTransform xForm = AffineTransform.getScaleInstance(1 / xScale, 1 / yScale);

        x11sdSrc.validateAsSource(xForm, XRUtils.RepeatNone, XRUtils.FAST);
        x11sdDst.maskBuffer.compositeBlit(x11sdSrc, x11sdDst, (int) sx1, (int) sy1, (int) dx1, (int) dy1, (int) (dx2 - dx1), (int) (dy2 - dy1));
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 5
Source File: X11SurfaceData.java    From jdk8u-dev-jdk 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)
{
    if (x11pipe == null) {
        if (!isDrawableValid()) {
            return true;
        }
        makePipes();
    }
    CompositeType comptype = sg2d.imageComp;
    if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE &&
        (CompositeType.SrcOverNoEa.equals(comptype) ||
         CompositeType.SrcNoEa.equals(comptype)))
    {
        x += sg2d.transX;
        y += sg2d.transY;
        SunToolkit.awtLock();
        try {
            boolean needExposures = canSourceSendExposures(x, y, w, h);
            long xgc = getBlitGC(sg2d.getCompClip(), needExposures);
            x11pipe.devCopyArea(getNativeOps(), xgc,
                                x, y,
                                x + dx, y + dy,
                                w, h);
        } finally {
            SunToolkit.awtUnlock();
        }
        return true;
    }
    return false;
}
 
Example 6
Source File: X11Renderer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void drawPolygon(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, true);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 7
Source File: XRRenderer.java    From openjdk-jdk9 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 8
Source File: XRRenderer.java    From jdk8u-dev-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 9
Source File: XRPMBlitLoops.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void Transform(SurfaceData src, SurfaceData dst, Composite comp, Region clip, AffineTransform xform, int hint, int sx, int sy, int dstx,
        int dsty, int w, int h) {
    try {
        SunToolkit.awtLock();

        XRSurfaceData vImgSurface = XRPMBlitLoops.cacheToTmpSurface(src, (XRSurfaceData) dst, w, h, sx, sy);
        pmToSurfaceBlit.Transform(vImgSurface, dst, comp, clip, xform, hint, 0, 0, dstx, dsty, w, h);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 10
Source File: XErrorHandlerUtil.java    From openjdk-8 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 11
Source File: XRPMBlitLoops.java    From openjdk-jdk8u-backup 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 12
Source File: X11Renderer.java    From openjdk-jdk9 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 13
Source File: X11Renderer.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void fillPolygon(SunGraphics2D sg2d,
                        int xpoints[], int ypoints[],
                        int npoints)
{
    SunToolkit.awtLock();
    try {
        long xgc = validate(sg2d);
        XFillPoly(sg2d.surfaceData.getNativeOps(), xgc,
                  sg2d.transX, sg2d.transY, xpoints, ypoints, npoints);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 14
Source File: X11SurfaceData.java    From openjdk-8-source 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)
{
    if (x11pipe == null) {
        if (!isDrawableValid()) {
            return true;
        }
        makePipes();
    }
    CompositeType comptype = sg2d.imageComp;
    if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE &&
        (CompositeType.SrcOverNoEa.equals(comptype) ||
         CompositeType.SrcNoEa.equals(comptype)))
    {
        x += sg2d.transX;
        y += sg2d.transY;
        SunToolkit.awtLock();
        try {
            boolean needExposures = canSourceSendExposures(x, y, w, h);
            long xgc = getBlitGC(sg2d.getCompClip(), needExposures);
            x11pipe.devCopyArea(getNativeOps(), xgc,
                                x, y,
                                x + dx, y + dy,
                                w, h);
        } finally {
            SunToolkit.awtUnlock();
        }
        return true;
    }
    return false;
}
 
Example 15
Source File: X11Renderer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void fillArc(SunGraphics2D sg2d,
                    int x, int y, int width, int height,
                    int startAngle, int arcAngle)
{
    SunToolkit.awtLock();
    try {
        long xgc = validate(sg2d);
        XFillArc(sg2d.surfaceData.getNativeOps(), xgc,
                 x+sg2d.transX, y+sg2d.transY, width, height,
                 startAngle, arcAngle);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 16
Source File: X11SurfaceData.java    From TencentKona-8 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)
{
    if (x11pipe == null) {
        if (!isDrawableValid()) {
            return true;
        }
        makePipes();
    }
    CompositeType comptype = sg2d.imageComp;
    if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE &&
        (CompositeType.SrcOverNoEa.equals(comptype) ||
         CompositeType.SrcNoEa.equals(comptype)))
    {
        x += sg2d.transX;
        y += sg2d.transY;
        SunToolkit.awtLock();
        try {
            boolean needExposures = canSourceSendExposures(x, y, w, h);
            long xgc = getBlitGC(sg2d.getCompClip(), needExposures);
            x11pipe.devCopyArea(getNativeOps(), xgc,
                                x, y,
                                x + dx, y + dy,
                                w, h);
        } finally {
            SunToolkit.awtUnlock();
        }
        return true;
    }
    return false;
}
 
Example 17
Source File: X11TextRenderer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
    SunToolkit.awtLock();
    try {
        X11SurfaceData x11sd = (X11SurfaceData)sg2d.surfaceData;
        Region clip = sg2d.getCompClip();
        long xgc = x11sd.getRenderGC(clip, SunGraphics2D.COMP_ISCOPY,
                                     null, sg2d.pixel);
        doDrawGlyphList(x11sd.getNativeOps(), xgc, clip, gl);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 18
Source File: X11SurfaceData.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public synchronized void makePipes() {
    if (x11pipe == null) {
        SunToolkit.awtLock();
        try {
            xgc = XCreateGC(getNativeOps());
        } finally {
            SunToolkit.awtUnlock();
        }
        x11pipe = X11Renderer.getInstance();
        x11txpipe = new PixelToShapeConverter(x11pipe);
    }
}
 
Example 19
Source File: XRRenderer.java    From dragonwell8_jdk 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 20
Source File: XWindowPeer.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
void preInit(XCreateWindowParams params) {
    target = (Component)params.get(TARGET);
    windowType = ((Window)target).getType();
    params.put(REPARENTED,
               Boolean.valueOf(isOverrideRedirect() || isSimpleWindow()));
    super.preInit(params);
    params.putIfNull(BIT_GRAVITY, Integer.valueOf(XConstants.NorthWestGravity));

    long eventMask = 0;
    if (params.containsKey(EVENT_MASK)) {
        eventMask = ((Long)params.get(EVENT_MASK));
    }
    eventMask |= XConstants.VisibilityChangeMask;
    params.put(EVENT_MASK, eventMask);

    XA_NET_WM_STATE = XAtom.get("_NET_WM_STATE");


    params.put(OVERRIDE_REDIRECT, Boolean.valueOf(isOverrideRedirect()));

    SunToolkit.awtLock();
    try {
        windows.add(this);
    } finally {
        SunToolkit.awtUnlock();
    }

    cachedFocusableWindow = isFocusableWindow();

    Font f = target.getFont();
    if (f == null) {
        f = XWindow.getDefaultFont();
        target.setFont(f);
        // we should not call setFont because it will call a repaint
        // which the peer may not be ready to do yet.
    }
    Color c = target.getBackground();
    if (c == null) {
        Color background = SystemColor.window;
        target.setBackground(background);
        // we should not call setBackGround because it will call a repaint
        // which the peer may not be ready to do yet.
    }
    c = target.getForeground();
    if (c == null) {
        target.setForeground(SystemColor.windowText);
        // we should not call setForeGround because it will call a repaint
        // which the peer may not be ready to do yet.
    }

    alwaysOnTop = ((Window)target).isAlwaysOnTop() && ((Window)target).isAlwaysOnTopSupported();

    GraphicsConfiguration gc = getGraphicsConfiguration();
    ((X11GraphicsDevice)gc.getDevice()).addDisplayChangedListener(this);
}