@Override protected final void updateGLXProcAddressTable() { final AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration(); final AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); final String key = "EGL-" + adevice.getUniqueID(); if (DEBUG) { System.err.println(getThreadName() + ": Initializing EGLextension address table: " + key); } eglQueryStringInitialized = false; eglQueryStringAvailable = false; ProcAddressTable table = null; synchronized (mappedContextTypeObjectLock) { table = mappedGLXProcAddress.get(key); } if (null != table) { eglExtProcAddressTable = (EGLExtProcAddressTable) table; if (DEBUG) { System.err.println( getThreadName() + ": GLContext EGL ProcAddressTable reusing key(" + key + ") -> " + toHexString(table.hashCode())); } } else { eglExtProcAddressTable = new EGLExtProcAddressTable(new GLProcAddressResolver()); resetProcAddressTable(getEGLExtProcAddressTable()); synchronized (mappedContextTypeObjectLock) { mappedGLXProcAddress.put(key, getEGLExtProcAddressTable()); if (DEBUG) { System.err.println( getThreadName() + ": GLContext EGL ProcAddressTable mapping key(" + key + ") -> " + toHexString(getEGLExtProcAddressTable().hashCode())); } } } }
@Override protected final SharedResource getOrCreateSharedResourceImpl(AbstractGraphicsDevice adevice) { if (null == sharedMap) { // null == eglES1DynamicLookupHelper && null == eglES2DynamicLookupHelper return null; } if (needsToCreateSharedResource(defaultDevice.getUniqueID(), null)) { if (DEBUG) { System.err.println( "EGLDrawableFactory.createShared: (defaultDevice): req. device: " + adevice + ", defaultDevice " + defaultDevice); Thread.dumpStack(); } if (null != defaultSharedResource) { dumpMap(); throw new InternalError("defaultSharedResource already exist: " + defaultSharedResource); } defaultSharedResource = createEGLSharedResourceImpl(defaultDevice); } final String key = adevice.getUniqueID(); if (defaultDevice.getUniqueID().equals(key)) { return defaultSharedResource; } else { if (null == defaultSharedResource) { // defaultDevice must be initialized before host-device dumpMap(); throw new InternalError("defaultSharedResource does not exist"); } final SharedResource[] existing = new SharedResource[] {null}; if (!needsToCreateSharedResource(key, existing)) { return existing[0]; } return createEGLSharedResourceImpl(adevice); } }
private SharedResource createEGLSharedResourceImpl(AbstractGraphicsDevice adevice) { final boolean madeCurrentES1; final boolean madeCurrentES2; final boolean madeCurrentES3; boolean[] hasPBufferES1 = new boolean[] {false}; boolean[] hasPBufferES3ES2 = new boolean[] {false}; // EGLContext[] eglCtxES1 = new EGLContext[] { null }; // EGLContext[] eglCtxES2 = new EGLContext[] { null }; GLRendererQuirks[] rendererQuirksES1 = new GLRendererQuirks[] {null}; GLRendererQuirks[] rendererQuirksES3ES2 = new GLRendererQuirks[] {null}; int[] ctpES1 = new int[] {-1}; int[] ctpES3ES2 = new int[] {-1}; if (DEBUG) { System.err.println("EGLDrawableFactory.createShared(): device " + adevice); } if (null != eglES1DynamicLookupHelper) { madeCurrentES1 = mapAvailableEGLESConfig(adevice, 1, hasPBufferES1, rendererQuirksES1, ctpES1); } else { madeCurrentES1 = false; } if (null != eglES2DynamicLookupHelper) { madeCurrentES3 = mapAvailableEGLESConfig(adevice, 3, hasPBufferES3ES2, rendererQuirksES3ES2, ctpES3ES2); if (madeCurrentES3) { // Only support highest - FIXME: Proper ES2/ES3 profile selection madeCurrentES2 = false; } else { madeCurrentES2 = mapAvailableEGLESConfig(adevice, 2, hasPBufferES3ES2, rendererQuirksES3ES2, ctpES3ES2); } } else { madeCurrentES2 = false; madeCurrentES3 = false; } if (!EGLContext.getAvailableGLVersionsSet(adevice)) { // Even though we override the non EGL native mapping intentionally, // avoid exception due to double 'set' - carefull exception of the rule. EGLContext.setAvailableGLVersionsSet(adevice); } if (hasX11) { handleDontCloseX11DisplayQuirk(rendererQuirksES1[0]); handleDontCloseX11DisplayQuirk(rendererQuirksES3ES2[0]); } final SharedResource sr = new SharedResource( defaultDevice, madeCurrentES1, hasPBufferES1[0], rendererQuirksES1[0], ctpES1[0], madeCurrentES2, madeCurrentES3, hasPBufferES3ES2[0], rendererQuirksES3ES2[0], ctpES3ES2[0]); synchronized (sharedMap) { sharedMap.put(adevice.getUniqueID(), sr); } if (DEBUG) { System.err.println( "EGLDrawableFactory.createShared: devices: queried nativeTK " + QUERY_EGL_ES_NATIVE_TK + ", adevice " + adevice + ", defaultDevice " + defaultDevice); System.err.println( "EGLDrawableFactory.createShared: context ES1: " + madeCurrentES1 + ", hasPBuffer " + hasPBufferES1[0]); System.err.println( "EGLDrawableFactory.createShared: context ES2: " + madeCurrentES2 + ", hasPBuffer " + hasPBufferES3ES2[0]); System.err.println( "EGLDrawableFactory.createShared: context ES3: " + madeCurrentES3 + ", hasPBuffer " + hasPBufferES3ES2[0]); dumpMap(); } return sr; }