Bug 1232456 - Create EGL surface through widget; r=snorp

This patch makes GLContextProviderEGL create EGL surfaces through
nsWindow/nsIWidget on Android. nsWindow then calls GLController in Java
to actually create the surface.
This commit is contained in:
Jim Chen
2015-12-23 22:03:34 -05:00
parent 6032b19e9b
commit 02fea99837
9 changed files with 44 additions and 109 deletions

View File

@@ -208,7 +208,6 @@ AndroidBridge::AndroidBridge()
mMessageQueueMessages = jEnv->GetFieldID(
msgQueueClass.Get(), "mMessages", "Landroid/os/Message;");
mGLControllerObj = nullptr;
mOpenedGraphicsLibraries = false;
mHasNativeBitmapAccess = false;
mHasNativeWindowAccess = false;
@@ -238,16 +237,6 @@ AndroidBridge::AndroidBridge()
jSurfacePointerField = 0;
}
AutoJNIClass egl(jEnv, "com/google/android/gles_jni/EGLSurfaceImpl");
jclass eglClass = egl.getGlobalRef();
if (eglClass) {
// The pointer type moved to a 'long' in Android L, API version 20
const char* jniType = mAPIVersion >= 20 ? "J" : "I";
jEGLSurfacePointerField = egl.getField("mEGLSurface", jniType);
} else {
jEGLSurfacePointerField = 0;
}
AutoJNIClass channels(jEnv, "java/nio/channels/Channels");
jChannels = channels.getGlobalRef();
jChannelCreate = channels.getStaticMethod("newChannel", "(Ljava/io/InputStream;)Ljava/nio/channels/ReadableByteChannel;");
@@ -688,37 +677,6 @@ AndroidBridge::SetLayerClient(GeckoLayerClient::Param jobj)
mLayerClient = jobj;
}
void
AndroidBridge::RegisterCompositor(JNIEnv *env)
{
if (mGLControllerObj != nullptr) {
// we already have this set up, no need to do it again
return;
}
mGLControllerObj = GLController::LocalRef(
LayerView::RegisterCompositorWrapper());
}
EGLSurface
AndroidBridge::CreateEGLSurfaceForCompositor()
{
if (!jEGLSurfacePointerField) {
return nullptr;
}
MOZ_ASSERT(mGLControllerObj, "AndroidBridge::CreateEGLSurfaceForCompositor called with a null GL controller ref");
auto eglSurface = mGLControllerObj->CreateEGLSurfaceForCompositorWrapper();
if (!eglSurface) {
return nullptr;
}
JNIEnv* const env = GetEnvForThread(); // called on the compositor thread
return reinterpret_cast<EGLSurface>(mAPIVersion >= 20 ?
env->GetLongField(eglSurface.Get(), jEGLSurfacePointerField) :
env->GetIntField(eglSurface.Get(), jEGLSurfacePointerField));
}
bool
AndroidBridge::GetStaticIntField(const char *className, const char *fieldName, int32_t* aInt, JNIEnv* jEnv /* = nullptr */)
{