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)); }
@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(); }
@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(); }
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); refPConfigInfo(pConfigInfo); // 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)); }
protected 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)); // 7200762: Workaround a deadlock by caching the value // A fix for JDK 8 will remove the workaround this.cachedMaxTextureSize = _getMaxTextureSize(); }
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)); }
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); }
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); }
/** * Uses the given GraphicsDevice as the coordinate system for subsequent * coordinate calls. */ public CRobot(Robot r, CGraphicsDevice d) { fDevice = d; initRobot(); }
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(); // Looks like it is outdated info, moreover on OSX in 4K resolution // reducing max size of the texture leads to performance degradation // in scrolling // // 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()); } }); }