Bug 844275 - Fold the carcass of AndroidLayerView* into AndroidBridge. r=Cwiiis

This commit is contained in:
Kartikaya Gupta
2013-02-28 13:28:24 -05:00
parent ef9f26fb84
commit f103a43e08
5 changed files with 40 additions and 111 deletions

View File

@@ -94,6 +94,7 @@ AndroidBridge::Init(JNIEnv *jEnv,
mJNIEnv = nullptr;
mThread = nullptr;
mGLControllerObj = nullptr;
mOpenedGraphicsLibraries = false;
mHasNativeBitmapAccess = false;
mHasNativeWindowAccess = false;
@@ -215,8 +216,16 @@ AndroidBridge::Init(JNIEnv *jEnv,
jLayerView = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("org/mozilla/gecko/gfx/LayerView"));
AndroidGLController::Init(jEnv);
AndroidEGLObject::Init(jEnv);
jclass glControllerClass = jEnv->FindClass("org/mozilla/gecko/gfx/GLController");
jProvideEGLSurfaceMethod = jEnv->GetMethodID(glControllerClass, "provideEGLSurface",
"()Ljavax/microedition/khronos/egl/EGLSurface;");
jclass eglClass = jEnv->FindClass("com/google/android/gles_jni/EGLSurfaceImpl");
if (eglClass) {
jEGLSurfacePointerField = jEnv->GetFieldID(eglClass, "mEGLSurface", "I");
} else {
jEGLSurfacePointerField = 0;
}
InitAndroidJavaWrappers(jEnv);
@@ -1119,16 +1128,21 @@ AndroidBridge::ShowInputMethodPicker()
env->CallStaticVoidMethod(mGeckoAppShellClass, jShowInputMethodPicker);
}
static AndroidGLController sController;
void
AndroidBridge::RegisterCompositor(JNIEnv *env)
{
ALOG_BRIDGE("AndroidBridge::RegisterCompositor");
if (!env)
env = GetJNIForThread(); // called on the compositor thread
if (!env)
if (mGLControllerObj) {
// we already have this set up, no need to do it again
return;
}
if (!env) {
env = GetJNIForThread(); // called on the compositor thread
}
if (!env) {
return;
}
AutoLocalJNIFrame jniFrame(env);
@@ -1138,13 +1152,24 @@ AndroidBridge::RegisterCompositor(JNIEnv *env)
if (jniFrame.CheckForException())
return;
sController.Acquire(env, glController);
mGLControllerObj = env->NewGlobalRef(glController);
}
EGLSurface
AndroidBridge::ProvideEGLSurface()
{
return sController.ProvideEGLSurface();
if (!jEGLSurfacePointerField) {
return NULL;
}
MOZ_ASSERT(mGLControllerObj, "AndroidBridge::ProvideEGLSurface called with a null GL controller ref");
JNIEnv* env = GetJNIForThread(); // called on the compositor thread
AutoLocalJNIFrame jniFrame(env);
jobject eglSurface = env->CallObjectMethod(mGLControllerObj, jProvideEGLSurfaceMethod);
if (jniFrame.CheckForException() || !eglSurface)
return NULL;
return reinterpret_cast<EGLSurface>(env->GetIntField(eglSurface, jEGLSurfacePointerField));
}
bool