sun.awt.CGraphicsDevice Java Examples

The following examples show how to use sun.awt.CGraphicsDevice. 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: CPlatformLWWindow.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public GraphicsDevice getGraphicsDevice() {
    CGraphicsEnvironment ge = (CGraphicsEnvironment)GraphicsEnvironment.
                              getLocalGraphicsEnvironment();

    LWLightweightFramePeer peer = (LWLightweightFramePeer)getPeer();
    int scale = ((LightweightFrame)peer.getTarget()).getScaleFactor();

    Rectangle bounds = ((LightweightFrame)peer.getTarget()).getHostBounds();
    for (GraphicsDevice d : ge.getScreenDevices()) {
        if (d.getDefaultConfiguration().getBounds().intersects(bounds) &&
            ((CGraphicsDevice)d).getScaleFactor() == scale)
        {
            return d;
        }
    }
    // We shouldn't be here...
    return ge.getDefaultScreenDevice();
}
 
Example #2
Source File: CPlatformLWWindow.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
public GraphicsDevice getGraphicsDevice() {
    CGraphicsEnvironment ge = (CGraphicsEnvironment)GraphicsEnvironment.
                              getLocalGraphicsEnvironment();

    LWLightweightFramePeer peer = (LWLightweightFramePeer)getPeer();
    int scale = ((LightweightFrame)peer.getTarget()).getScaleFactor();

    Rectangle bounds = ((LightweightFrame)peer.getTarget()).getHostBounds();
    for (GraphicsDevice d : ge.getScreenDevices()) {
        if (d.getDefaultConfiguration().getBounds().intersects(bounds) &&
            ((CGraphicsDevice)d).getScaleFactor() == scale)
        {
            return d;
        }
    }
    // We shouldn't be here...
    return ge.getDefaultScreenDevice();
}
 
Example #3
Source File: CGLGraphicsConfig.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
                          long configInfo, int maxTextureSize,
                          ContextCapabilities oglCaps) {
    super(device);

    this.pixfmt = pixfmt;
    this.pConfigInfo = configInfo;
    this.oglCaps = oglCaps;
    this.maxTextureSize = maxTextureSize;
    context = new OGLContext(OGLRenderQueue.getInstance(), this);

    // add a record to the Disposer so that we destroy the native
    // CGLGraphicsConfigInfo data when this object goes away
    Disposer.addRecord(disposerReferent,
                       new CGLGCDisposerRecord(pConfigInfo));
}
 
Example #4
Source File: CPlatformLWWindow.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public GraphicsDevice getGraphicsDevice() {
    CGraphicsEnvironment ge = (CGraphicsEnvironment)GraphicsEnvironment.
                              getLocalGraphicsEnvironment();

    LWLightweightFramePeer peer = (LWLightweightFramePeer)getPeer();
    int scale = ((LightweightFrame)peer.getTarget()).getScaleFactor();

    Rectangle bounds = ((LightweightFrame)peer.getTarget()).getHostBounds();
    for (GraphicsDevice d : ge.getScreenDevices()) {
        if (d.getDefaultConfiguration().getBounds().intersects(bounds) &&
            ((CGraphicsDevice)d).getScaleFactor() == scale)
        {
            return d;
        }
    }
    // We shouldn't be here...
    return ge.getDefaultScreenDevice();
}
 
Example #5
Source File: CGLGraphicsConfig.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
                          long configInfo, int maxTextureSize,
                          ContextCapabilities oglCaps) {
    super(device);

    this.pixfmt = pixfmt;
    this.pConfigInfo = configInfo;
    this.oglCaps = oglCaps;
    this.maxTextureSize = maxTextureSize;
    context = new OGLContext(OGLRenderQueue.getInstance(), this);

    // add a record to the Disposer so that we destroy the native
    // CGLGraphicsConfigInfo data when this object goes away
    Disposer.addRecord(disposerReferent,
                       new CGLGCDisposerRecord(pConfigInfo));
}
 
Example #6
Source File: CGLGraphicsConfig.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
                          long configInfo, int maxTextureSize,
                          ContextCapabilities oglCaps) {
    super(device);

    this.pixfmt = pixfmt;
    this.pConfigInfo = configInfo;
    this.oglCaps = oglCaps;
    this.maxTextureSize = maxTextureSize;
    context = new OGLContext(OGLRenderQueue.getInstance(), this);

    // add a record to the Disposer so that we destroy the native
    // CGLGraphicsConfigInfo data when this object goes away
    Disposer.addRecord(disposerReferent,
                       new CGLGCDisposerRecord(pConfigInfo));
}
 
Example #7
Source File: CPlatformLWWindow.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public GraphicsDevice getGraphicsDevice() {
    CGraphicsEnvironment ge = (CGraphicsEnvironment)GraphicsEnvironment.
                              getLocalGraphicsEnvironment();

    LWLightweightFramePeer peer = (LWLightweightFramePeer)getPeer();
    int scale =(int) Math.round(((LightweightFrame)peer.getTarget())
                                                        .getScaleFactorX());

    Rectangle bounds = ((LightweightFrame)peer.getTarget()).getHostBounds();
    for (GraphicsDevice d : ge.getScreenDevices()) {
        if (d.getDefaultConfiguration().getBounds().intersects(bounds) &&
            ((CGraphicsDevice)d).getScaleFactor() == scale)
        {
            return d;
        }
    }
    // We shouldn't be here...
    return ge.getDefaultScreenDevice();
}
 
Example #8
Source File: CGLGraphicsConfig.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
                          long configInfo, int maxTextureSize,
                          ContextCapabilities oglCaps) {
    super(device);

    this.pixfmt = pixfmt;
    this.pConfigInfo = configInfo;
    this.oglCaps = oglCaps;
    this.maxTextureSize = maxTextureSize;
    context = new OGLContext(OGLRenderQueue.getInstance(), this);

    // add a record to the Disposer so that we destroy the native
    // CGLGraphicsConfigInfo data when this object goes away
    Disposer.addRecord(disposerReferent,
                       new CGLGCDisposerRecord(pConfigInfo));
}
 
Example #9
Source File: CGLGraphicsConfig.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
                          long configInfo, int maxTextureSize,
                          ContextCapabilities oglCaps) {
    super(device);

    this.pixfmt = pixfmt;
    this.pConfigInfo = configInfo;
    this.oglCaps = oglCaps;
    this.maxTextureSize = maxTextureSize;
    context = new OGLContext(OGLRenderQueue.getInstance(), this);

    // add a record to the Disposer so that we destroy the native
    // CGLGraphicsConfigInfo data when this object goes away
    Disposer.addRecord(disposerReferent,
                       new CGLGCDisposerRecord(pConfigInfo));
}
 
Example #10
Source File: CPlatformLWWindow.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public GraphicsDevice getGraphicsDevice() {
    CGraphicsEnvironment ge = (CGraphicsEnvironment)GraphicsEnvironment.
                              getLocalGraphicsEnvironment();

    LWLightweightFramePeer peer = (LWLightweightFramePeer)getPeer();
    int scale = ((LightweightFrame)peer.getTarget()).getScaleFactor();

    Rectangle bounds = ((LightweightFrame)peer.getTarget()).getHostBounds();
    for (GraphicsDevice d : ge.getScreenDevices()) {
        if (d.getDefaultConfiguration().getBounds().intersects(bounds) &&
            ((CGraphicsDevice)d).getScaleFactor() == scale)
        {
            return d;
        }
    }
    // We shouldn't be here...
    return ge.getDefaultScreenDevice();
}
 
Example #11
Source File: CPlatformLWWindow.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public GraphicsDevice getGraphicsDevice() {
    CGraphicsEnvironment ge = (CGraphicsEnvironment)GraphicsEnvironment.
                              getLocalGraphicsEnvironment();

    LWLightweightFramePeer peer = (LWLightweightFramePeer)getPeer();
    int scale = ((LightweightFrame)peer.getTarget()).getScaleFactor();

    Rectangle bounds = ((LightweightFrame)peer.getTarget()).getHostBounds();
    for (GraphicsDevice d : ge.getScreenDevices()) {
        if (d.getDefaultConfiguration().getBounds().intersects(bounds) &&
            ((CGraphicsDevice)d).getScaleFactor() == scale)
        {
            return d;
        }
    }
    // We shouldn't be here...
    return ge.getDefaultScreenDevice();
}
 
Example #12
Source File: CGLGraphicsConfig.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
                          long configInfo, int maxTextureSize,
                          ContextCapabilities oglCaps) {
    super(device);

    this.pixfmt = pixfmt;
    this.pConfigInfo = configInfo;
    this.oglCaps = oglCaps;
    this.maxTextureSize = maxTextureSize;
    context = new OGLContext(OGLRenderQueue.getInstance(), this);

    // add a record to the Disposer so that we destroy the native
    // CGLGraphicsConfigInfo data when this object goes away
    Disposer.addRecord(disposerReferent,
                       new CGLGCDisposerRecord(pConfigInfo));
}
 
Example #13
Source File: CPlatformLWWindow.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public GraphicsDevice getGraphicsDevice() {
    CGraphicsEnvironment ge = (CGraphicsEnvironment)GraphicsEnvironment.
                              getLocalGraphicsEnvironment();

    LWLightweightFramePeer peer = (LWLightweightFramePeer)getPeer();
    int scale = ((LightweightFrame)peer.getTarget()).getScaleFactor();

    Rectangle bounds = ((LightweightFrame)peer.getTarget()).getHostBounds();
    for (GraphicsDevice d : ge.getScreenDevices()) {
        if (d.getDefaultConfiguration().getBounds().intersects(bounds) &&
            ((CGraphicsDevice)d).getScaleFactor() == scale)
        {
            return d;
        }
    }
    // We shouldn't be here...
    return ge.getDefaultScreenDevice();
}
 
Example #14
Source File: CGLGraphicsConfig.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
                          long configInfo, int maxTextureSize,
                          ContextCapabilities oglCaps) {
    super(device);

    this.pixfmt = pixfmt;
    this.pConfigInfo = configInfo;
    this.oglCaps = oglCaps;
    this.maxTextureSize = maxTextureSize;
    context = new OGLContext(OGLRenderQueue.getInstance(), this);

    // add a record to the Disposer so that we destroy the native
    // CGLGraphicsConfigInfo data when this object goes away
    Disposer.addRecord(disposerReferent,
                       new CGLGCDisposerRecord(pConfigInfo));
}
 
Example #15
Source File: CGLGraphicsConfig.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
                          long configInfo, int maxTextureSize,
                          ContextCapabilities oglCaps) {
    super(device);

    this.pixfmt = pixfmt;
    this.pConfigInfo = configInfo;
    this.oglCaps = oglCaps;
    this.maxTextureSize = maxTextureSize;
    context = new OGLContext(OGLRenderQueue.getInstance(), this);

    // add a record to the Disposer so that we destroy the native
    // CGLGraphicsConfigInfo data when this object goes away
    Disposer.addRecord(disposerReferent,
                       new CGLGCDisposerRecord(pConfigInfo));
}
 
Example #16
Source File: CPlatformLWWindow.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public GraphicsDevice getGraphicsDevice() {
    CGraphicsEnvironment ge = (CGraphicsEnvironment)GraphicsEnvironment.
                              getLocalGraphicsEnvironment();

    LWLightweightFramePeer peer = (LWLightweightFramePeer)getPeer();
    int scale = ((LightweightFrame)peer.getTarget()).getScaleFactor();

    Rectangle bounds = ((LightweightFrame)peer.getTarget()).getHostBounds();
    for (GraphicsDevice d : ge.getScreenDevices()) {
        if (d.getDefaultConfiguration().getBounds().intersects(bounds) &&
            ((CGraphicsDevice)d).getScaleFactor() == scale)
        {
            return d;
        }
    }
    // We shouldn't be here...
    return ge.getDefaultScreenDevice();
}
 
Example #17
Source File: CPlatformLWWindow.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public GraphicsDevice getGraphicsDevice() {
    CGraphicsEnvironment ge = (CGraphicsEnvironment)GraphicsEnvironment.
                              getLocalGraphicsEnvironment();

    LWLightweightFramePeer peer = (LWLightweightFramePeer)getPeer();
    int scale = ((LightweightFrame)peer.getTarget()).getScaleFactor();

    Rectangle bounds = ((LightweightFrame)peer.getTarget()).getHostBounds();
    for (GraphicsDevice d : ge.getScreenDevices()) {
        if (d.getDefaultConfiguration().getBounds().intersects(bounds) &&
            ((CGraphicsDevice)d).getScaleFactor() == scale)
        {
            return d;
        }
    }
    // We shouldn't be here...
    return ge.getDefaultScreenDevice();
}
 
Example #18
Source File: CGLGraphicsConfig.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
                          long configInfo, int maxTextureSize,
                          ContextCapabilities oglCaps) {
    super(device);

    this.pixfmt = pixfmt;
    this.pConfigInfo = configInfo;
    this.oglCaps = oglCaps;
    this.maxTextureSize = maxTextureSize;
    context = new OGLContext(OGLRenderQueue.getInstance(), this);

    // add a record to the Disposer so that we destroy the native
    // CGLGraphicsConfigInfo data when this object goes away
    Disposer.addRecord(disposerReferent,
                       new CGLGCDisposerRecord(pConfigInfo));
}
 
Example #19
Source File: CPlatformLWWindow.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public GraphicsDevice getGraphicsDevice() {
    CGraphicsEnvironment ge = (CGraphicsEnvironment)GraphicsEnvironment.
                              getLocalGraphicsEnvironment();

    LWLightweightFramePeer peer = (LWLightweightFramePeer)getPeer();
    int scale = ((LightweightFrame)peer.getTarget()).getScaleFactor();

    Rectangle bounds = ((LightweightFrame)peer.getTarget()).getHostBounds();
    for (GraphicsDevice d : ge.getScreenDevices()) {
        if (d.getDefaultConfiguration().getBounds().intersects(bounds) &&
            ((CGraphicsDevice)d).getScaleFactor() == scale)
        {
            return d;
        }
    }
    // We shouldn't be here...
    return ge.getDefaultScreenDevice();
}
 
Example #20
Source File: CGLGraphicsConfig.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
                          long configInfo, int maxTextureSize,
                          ContextCapabilities oglCaps) {
    super(device);

    this.pixfmt = pixfmt;
    this.pConfigInfo = configInfo;
    this.oglCaps = oglCaps;
    this.maxTextureSize = maxTextureSize;
    context = new OGLContext(OGLRenderQueue.getInstance(), this);

    // add a record to the Disposer so that we destroy the native
    // CGLGraphicsConfigInfo data when this object goes away
    Disposer.addRecord(disposerReferent,
                       new CGLGCDisposerRecord(pConfigInfo));
}
 
Example #21
Source File: CPlatformLWWindow.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public GraphicsDevice getGraphicsDevice() {
    CGraphicsEnvironment ge = (CGraphicsEnvironment)GraphicsEnvironment.
                              getLocalGraphicsEnvironment();

    LWLightweightFramePeer peer = (LWLightweightFramePeer)getPeer();
    int scale = ((LightweightFrame)peer.getTarget()).getScaleFactor();

    Rectangle bounds = ((LightweightFrame)peer.getTarget()).getHostBounds();
    for (GraphicsDevice d : ge.getScreenDevices()) {
        if (d.getDefaultConfiguration().getBounds().intersects(bounds) &&
            ((CGraphicsDevice)d).getScaleFactor() == scale)
        {
            return d;
        }
    }
    // We shouldn't be here...
    return ge.getDefaultScreenDevice();
}
 
Example #22
Source File: CGLGraphicsConfig.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
                          long configInfo, int maxTextureSize,
                          ContextCapabilities oglCaps) {
    super(device);

    this.pixfmt = pixfmt;
    this.pConfigInfo = configInfo;
    this.oglCaps = oglCaps;
    this.maxTextureSize = maxTextureSize;
    context = new OGLContext(OGLRenderQueue.getInstance(), this);

    // add a record to the Disposer so that we destroy the native
    // CGLGraphicsConfigInfo data when this object goes away
    Disposer.addRecord(disposerReferent,
                       new CGLGCDisposerRecord(pConfigInfo));
}
 
Example #23
Source File: CGLGraphicsConfig.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static CGLGraphicsConfig getConfig(CGraphicsDevice device,
                                          int pixfmt)
{
    if (!cglAvailable) {
        return null;
    }

    long cfginfo = 0;
    final String ids[] = new String[1];
    OGLRenderQueue rq = OGLRenderQueue.getInstance();
    rq.lock();
    try {
        // getCGLConfigInfo() creates and destroys temporary
        // surfaces/contexts, so we should first invalidate the current
        // Java-level context and flush the queue...
        OGLContext.invalidateCurrentContext();

        cfginfo = getCGLConfigInfo(device.getCGDisplayID(), pixfmt,
                                   kOpenGLSwapInterval);
        if (cfginfo != 0L) {
            OGLContext.setScratchSurface(cfginfo);
            rq.flushAndInvokeNow(new Runnable() {
                public void run() {
                    ids[0] = OGLContext.getOGLIdString();
                }
            });
        }
    } finally {
        rq.unlock();
    }
    if (cfginfo == 0) {
        return null;
    }

    int oglCaps = getOGLCapabilities(cfginfo);
    ContextCapabilities caps = new OGLContextCaps(oglCaps, ids[0]);

    return new CGLGraphicsConfig(device, pixfmt, cfginfo, caps);
}
 
Example #24
Source File: CGLGraphicsConfig.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
                            long configInfo, ContextCapabilities oglCaps)
{
    super(device);

    this.pixfmt = pixfmt;
    this.pConfigInfo = configInfo;
    this.oglCaps = oglCaps;
    context = new OGLContext(OGLRenderQueue.getInstance(), this);

    // add a record to the Disposer so that we destroy the native
    // CGLGraphicsConfigInfo data when this object goes away
    Disposer.addRecord(disposerReferent,
                       new CGLGCDisposerRecord(pConfigInfo));
}
 
Example #25
Source File: CGLGraphicsConfig.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
                            long configInfo, ContextCapabilities oglCaps)
{
    super(device);

    this.pixfmt = pixfmt;
    this.pConfigInfo = configInfo;
    this.oglCaps = oglCaps;
    context = new OGLContext(OGLRenderQueue.getInstance(), this);

    // add a record to the Disposer so that we destroy the native
    // CGLGraphicsConfigInfo data when this object goes away
    Disposer.addRecord(disposerReferent,
                       new CGLGCDisposerRecord(pConfigInfo));
}
 
Example #26
Source File: CGLGraphicsConfig.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static CGLGraphicsConfig getConfig(CGraphicsDevice device,
                                          int pixfmt)
{
    if (!cglAvailable) {
        return null;
    }

    long cfginfo = 0;
    final String ids[] = new String[1];
    OGLRenderQueue rq = OGLRenderQueue.getInstance();
    rq.lock();
    try {
        // getCGLConfigInfo() creates and destroys temporary
        // surfaces/contexts, so we should first invalidate the current
        // Java-level context and flush the queue...
        OGLContext.invalidateCurrentContext();

        cfginfo = getCGLConfigInfo(device.getCGDisplayID(), pixfmt,
                                   kOpenGLSwapInterval);
        if (cfginfo != 0L) {
            OGLContext.setScratchSurface(cfginfo);
            rq.flushAndInvokeNow(new Runnable() {
                public void run() {
                    ids[0] = OGLContext.getOGLIdString();
                }
            });
        }
    } finally {
        rq.unlock();
    }
    if (cfginfo == 0) {
        return null;
    }

    int oglCaps = getOGLCapabilities(cfginfo);
    ContextCapabilities caps = new OGLContextCaps(oglCaps, ids[0]);

    return new CGLGraphicsConfig(device, pixfmt, cfginfo, caps);
}
 
Example #27
Source File: CRobot.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Uses the given GraphicsDevice as the coordinate system for subsequent
 * coordinate calls.
 */
public CRobot(Robot r, CGraphicsDevice d) {
    fDevice = d;
    initRobot();
}
 
Example #28
Source File: CGLGraphicsConfig.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static CGLGraphicsConfig getConfig(CGraphicsDevice device,
                                          int pixfmt)
{
    if (!cglAvailable) {
        return null;
    }

    long cfginfo = 0;
    int textureSize = 0;
    final String ids[] = new String[1];
    OGLRenderQueue rq = OGLRenderQueue.getInstance();
    rq.lock();
    try {
        // getCGLConfigInfo() creates and destroys temporary
        // surfaces/contexts, so we should first invalidate the current
        // Java-level context and flush the queue...
        OGLContext.invalidateCurrentContext();

        cfginfo = getCGLConfigInfo(device.getCGDisplayID(), pixfmt,
                                   kOpenGLSwapInterval);
        if (cfginfo != 0L) {
            textureSize = nativeGetMaxTextureSize();
            // 7160609: GL still fails to create a square texture of this
            // size. Half should be safe enough.
            // Explicitly not support a texture more than 2^14, see 8010999.
            textureSize = textureSize <= 16384 ? textureSize / 2 : 8192;
            OGLContext.setScratchSurface(cfginfo);
            rq.flushAndInvokeNow(() -> {
                ids[0] = OGLContext.getOGLIdString();
            });
        }
    } finally {
        rq.unlock();
    }
    if (cfginfo == 0) {
        return null;
    }

    int oglCaps = getOGLCapabilities(cfginfo);
    ContextCapabilities caps = new OGLContextCaps(oglCaps, ids[0]);
    return new CGLGraphicsConfig(device, pixfmt, cfginfo, textureSize, caps);
}
 
Example #29
Source File: CRobot.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Uses the given GraphicsDevice as the coordinate system for subsequent
 * coordinate calls.
 */
public CRobot(Robot r, CGraphicsDevice d) {
    fDevice = d;
    initRobot();
}
 
Example #30
Source File: CGLGraphicsConfig.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static CGLGraphicsConfig getConfig(CGraphicsDevice device,
                                          int pixfmt)
{
    if (!cglAvailable) {
        return null;
    }

    // Move CGLGraphicsConfig creation code to AppKit thread in order to avoid the
    // following deadlock:
    // 1) CGLGraphicsConfig.getCGLConfigInfo (called from EDT) takes RenderQueue.lock
    // 2) CGLLayer.drawInCGLContext is invoked on AppKit thread and
    //    blocked on RenderQueue.lock
    // 1) invokes native block on AppKit and wait

    Callable<CGLGraphicsConfig> command = () -> {
        long cfginfo;
        int textureSize = 0;
        final String ids[] = new String[1];
        OGLRenderQueue rq = OGLRenderQueue.getInstance();
        rq.lock();
        try {
            // getCGLConfigInfo() creates and destroys temporary
            // surfaces/contexts, so we should first invalidate the current
            // Java-level context and flush the queue...
            OGLContext.invalidateCurrentContext();

            cfginfo = getCGLConfigInfo(device.getCGDisplayID(), pixfmt,
                    kOpenGLSwapInterval);
            if (cfginfo != 0L) {
                textureSize = nativeGetMaxTextureSize();
                // 7160609: GL still fails to create a square texture of this
                // size. Half should be safe enough.
                // Explicitly not support a texture more than 2^14, see 8010999.
                textureSize = textureSize <= 16384 ? textureSize / 2 : 8192;
                OGLContext.setScratchSurface(cfginfo);
                rq.flushAndInvokeNow(() -> ids[0] = OGLContext.getOGLIdString());
            }
        } finally {
            rq.unlock();
        }
        if (cfginfo == 0) {
            return null;
        }

        int oglCaps = getOGLCapabilities(cfginfo);
        ContextCapabilities caps = new OGLContextCaps(oglCaps, ids[0]);
        return new CGLGraphicsConfig(
                device, pixfmt, cfginfo, textureSize, caps);
    };

    return java.security.AccessController.doPrivileged(
            (PrivilegedAction<CGLGraphicsConfig>) () -> {
                try {
                    return CThreading.executeOnAppKit(command);
                } catch (Throwable throwable) {
                    throw new AWTError(throwable.getMessage());
                }
            });
}