Removing this awesome template code because it causes library load crashes :(
authorBenoit Girard <b56girard@gmail.com>
Thu, 02 Feb 2012 11:17:50 -0500
changeset 89056 b495033168e2e12696cf9f321d8e17107303dd00
parent 89055 7badecd0693f76844bc66d6206eabbc5dad8ab68
child 89057 2b39cf557ab439b5d5c33c3a729e652025497ae3
push id22242
push userkgupta@mozilla.com
push dateWed, 14 Mar 2012 15:19:09 +0000
treeherdermozilla-central@936ef50fa498 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone12.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Removing this awesome template code because it causes library load crashes :(
widget/android/AndroidBridge.cpp
widget/android/AndroidFlexViewWrapper.cpp
widget/android/AndroidFlexViewWrapper.h
widget/android/AndroidJavaWrappers.cpp
--- a/widget/android/AndroidBridge.cpp
+++ b/widget/android/AndroidBridge.cpp
@@ -172,20 +172,17 @@ AndroidBridge::Init(JNIEnv *jEnv,
     jEGLSurfaceImplClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("com/google/android/gles_jni/EGLSurfaceImpl"));
     jEGLContextImplClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("com/google/android/gles_jni/EGLContextImpl"));
     jEGLConfigImplClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("com/google/android/gles_jni/EGLConfigImpl"));
     jEGLDisplayImplClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("com/google/android/gles_jni/EGLDisplayImpl"));
 
     jFlexSurfaceView = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("org/mozilla/gecko/gfx/FlexibleGLSurfaceView"));
 
     AndroidGLController::Init(jEnv);
-    AndroidEGLObject<AndroidEGLDisplayInfo>::Init(jEnv);
-    AndroidEGLObject<AndroidEGLConfigInfo>::Init(jEnv);
-    AndroidEGLObject<AndroidEGLContextInfo>::Init(jEnv);
-    AndroidEGLObject<AndroidEGLSurfaceInfo>::Init(jEnv);
+    AndroidEGLObject::Init(jEnv);
     InitAndroidJavaWrappers(jEnv);
 
     // jEnv should NOT be cached here by anything -- the jEnv here
     // is not valid for the real gecko main thread, which is set
     // at SetMainThread time.
 
     return true;
 }
--- a/widget/android/AndroidFlexViewWrapper.cpp
+++ b/widget/android/AndroidFlexViewWrapper.cpp
@@ -35,40 +35,47 @@
 *
 * ***** END LICENSE BLOCK ***** */
 
 #include "AndroidFlexViewWrapper.h"
 
 
 static AndroidGLController sController;
 
-template<>
-const char *AndroidEGLDisplay::sClassName = "com/google/android/gles_jni/EGLDisplayImpl";
-template<>
-const char *AndroidEGLDisplay::sPointerFieldName = "mEGLDisplay";
-template<>
-jfieldID AndroidEGLDisplay::jPointerField = 0;
-template<>
-const char *AndroidEGLConfig::sClassName = "com/google/android/gles_jni/EGLConfigImpl";
-template<>
-const char *AndroidEGLConfig::sPointerFieldName = "mEGLConfig";
-template<>
-jfieldID AndroidEGLConfig::jPointerField = 0;
-template<>
-const char *AndroidEGLContext::sClassName = "com/google/android/gles_jni/EGLContextImpl";
-template<>
-const char *AndroidEGLContext::sPointerFieldName = "mEGLContext";
-template<>
-jfieldID AndroidEGLContext::jPointerField = 0;
-template<>
-const char *AndroidEGLSurface::sClassName = "com/google/android/gles_jni/EGLSurfaceImpl";
-template<>
-const char *AndroidEGLSurface::sPointerFieldName = "mEGLSurface";
-template<>
-jfieldID AndroidEGLSurface::jPointerField = 0;
+static const char *sEGLDisplayClassName = "com/google/android/gles_jni/EGLDisplayImpl";
+static const char *sEGLDisplayPointerFieldName = "mEGLDisplay";
+static jfieldID jEGLDisplayPointerField = 0;
+
+static const char *sEGLConfigClassName = "com/google/android/gles_jni/EGLConfigImpl";
+static const char *sEGLConfigPointerFieldName = "mEGLConfig";
+static jfieldID jEGLConfigPointerField = 0;
+
+static const char *sEGLContextClassName = "com/google/android/gles_jni/EGLContextImpl";
+static const char *sEGLContextPointerFieldName = "mEGLContext";
+static jfieldID jEGLContextPointerField = 0;
+
+static const char *sEGLSurfaceClassName = "com/google/android/gles_jni/EGLSurfaceImpl";
+static const char *sEGLSurfacePointerFieldName = "mEGLSurface";
+static jfieldID jEGLSurfacePointerField = 0;
+
+void AndroidEGLObject::Init(JNIEnv* aJEnv) {
+    jclass jClass;
+    jClass = reinterpret_cast<jclass>
+        (aJEnv->NewGlobalRef(aJEnv->FindClass(sEGLDisplayClassName)));
+    jEGLDisplayPointerField = aJEnv->GetFieldID(jClass, sEGLDisplayPointerFieldName, "I");
+    jClass = reinterpret_cast<jclass>
+        (aJEnv->NewGlobalRef(aJEnv->FindClass(sEGLConfigClassName)));
+    jEGLConfigPointerField = aJEnv->GetFieldID(jClass, sEGLConfigPointerFieldName, "I");
+    jClass = reinterpret_cast<jclass>
+        (aJEnv->NewGlobalRef(aJEnv->FindClass(sEGLContextClassName)));
+    jEGLContextPointerField = aJEnv->GetFieldID(jClass, sEGLContextPointerFieldName, "I");
+    jClass = reinterpret_cast<jclass>
+        (aJEnv->NewGlobalRef(aJEnv->FindClass(sEGLSurfaceClassName)));
+    jEGLSurfacePointerField = aJEnv->GetFieldID(jClass, sEGLSurfacePointerFieldName, "I");
+}
 
 jmethodID AndroidGLController::jSetGLVersionMethod = 0;
 jmethodID AndroidGLController::jInitGLContextMethod = 0;
 jmethodID AndroidGLController::jDisposeGLContextMethod = 0;
 jmethodID AndroidGLController::jGetEGLDisplayMethod = 0;
 jmethodID AndroidGLController::jGetEGLConfigMethod = 0;
 jmethodID AndroidGLController::jGetEGLContextMethod = 0;
 jmethodID AndroidGLController::jGetEGLSurfaceMethod = 0;
@@ -144,39 +151,39 @@ void
 AndroidGLController::DisposeGLContext()
 {
     mJEnv->CallVoidMethod(mJObj, jDisposeGLContextMethod);
 }
 
 EGLDisplay
 AndroidGLController::GetEGLDisplay()
 {
-    AndroidEGLDisplay jEGLDisplay(mJEnv, mJEnv->CallObjectMethod(mJObj, jGetEGLDisplayMethod));
-    return *jEGLDisplay;
+    jobject jObj = mJEnv->CallObjectMethod(mJObj, jGetEGLDisplayMethod);
+    return reinterpret_cast<EGLDisplay>(mJEnv->GetIntField(jObj, jEGLDisplayPointerField));
 }
 
 EGLConfig
 AndroidGLController::GetEGLConfig()
 {
-    AndroidEGLConfig jEGLConfig(mJEnv, mJEnv->CallObjectMethod(mJObj, jGetEGLConfigMethod));
-    return *jEGLConfig;
+    jobject jObj = mJEnv->CallObjectMethod(mJObj, jGetEGLConfigMethod);
+    return reinterpret_cast<EGLConfig>(mJEnv->GetIntField(jObj, jEGLConfigPointerField));
 }
 
 EGLContext
 AndroidGLController::GetEGLContext()
 {
-    AndroidEGLContext jEGLContext(mJEnv, mJEnv->CallObjectMethod(mJObj, jGetEGLContextMethod));
-    return *jEGLContext;
+    jobject jObj = mJEnv->CallObjectMethod(mJObj, jGetEGLContextMethod);
+    return reinterpret_cast<EGLContext>(mJEnv->GetIntField(jObj, jEGLContextPointerField));
 }
 
 EGLSurface
 AndroidGLController::GetEGLSurface()
 {
-    AndroidEGLSurface jEGLSurface(mJEnv, mJEnv->CallObjectMethod(mJObj, jGetEGLSurfaceMethod));
-    return *jEGLSurface;
+    jobject jObj = mJEnv->CallObjectMethod(mJObj, jGetEGLSurfaceMethod);
+    return reinterpret_cast<EGLSurface>(mJEnv->GetIntField(jObj, jEGLSurfacePointerField));
 }
 
 bool
 AndroidGLController::HasSurface()
 {
     return mJEnv->CallBooleanMethod(mJObj, jHasSurfaceMethod);
 }
 
--- a/widget/android/AndroidFlexViewWrapper.h
+++ b/widget/android/AndroidFlexViewWrapper.h
@@ -41,78 +41,42 @@
 #include <jni.h>
 //#include <GLES/gl.h>
 //#include <GLES/glext.h>
 #include <cassert>
 #include <cstdlib>
 #include <pthread.h>
 #include <android/log.h>
 
-template<typename T>
+typedef void *NativeType;
+
 class AndroidEGLObject {
 public:
     AndroidEGLObject(JNIEnv* aJEnv, jobject aJObj)
-    : mPtr(reinterpret_cast<typename T::NativeType>(aJEnv->GetIntField(aJObj, jPointerField))) {}
+    : mPtr(reinterpret_cast<NativeType>(aJEnv->GetIntField(aJObj, jPointerField))) {}
 
-    static void Init(JNIEnv* aJEnv) {
-        jclass jClass = reinterpret_cast<jclass>
-            (aJEnv->NewGlobalRef(aJEnv->FindClass(sClassName)));
-        jPointerField = aJEnv->GetFieldID(jClass, sPointerFieldName, "I");
-    }
+    static void Init(JNIEnv* aJEnv);
 
-    typename T::NativeType const& operator*() const {
+    NativeType const& operator*() const {
         return mPtr;
     }
 
 private:
     static jfieldID jPointerField;
     static const char* sClassName;
     static const char* sPointerFieldName;
 
-    const typename T::NativeType mPtr;
+    const NativeType mPtr;
 };
 
 typedef void *EGLConfig;
 typedef void *EGLContext;
 typedef void *EGLDisplay;
 typedef void *EGLSurface;
 
-class AndroidEGLDisplayInfo {
-public:
-    typedef EGLDisplay NativeType;
-private:
-    AndroidEGLDisplayInfo() {}
-};
-
-class AndroidEGLConfigInfo {
-public:
-    typedef EGLConfig NativeType;
-private:
-    AndroidEGLConfigInfo() {}
-};
-
-class AndroidEGLContextInfo {
-public:
-    typedef EGLContext NativeType;
-private:
-    AndroidEGLContextInfo() {}
-};
-
-class AndroidEGLSurfaceInfo {
-public:
-    typedef EGLSurface NativeType;
-private:
-    AndroidEGLSurfaceInfo() {}
-};
-
-typedef AndroidEGLObject<AndroidEGLDisplayInfo> AndroidEGLDisplay;
-typedef AndroidEGLObject<AndroidEGLConfigInfo> AndroidEGLConfig;
-typedef AndroidEGLObject<AndroidEGLContextInfo> AndroidEGLContext;
-typedef AndroidEGLObject<AndroidEGLSurfaceInfo> AndroidEGLSurface;
-
 class AndroidGLController {
 public:
     static void Init(JNIEnv* aJEnv);
 
     void Acquire(JNIEnv *aJEnv, jobject aJObj);
     void Acquire(JNIEnv *aJEnv);
     void Release();
 
--- a/widget/android/AndroidJavaWrappers.cpp
+++ b/widget/android/AndroidJavaWrappers.cpp
@@ -204,18 +204,16 @@ AndroidGeckoSurfaceView::InitGeckoSurfac
     jEndDrawingMethod = getMethod("endDrawing", "()V");
     jDraw2DBitmapMethod = getMethod("draw2D", "(Landroid/graphics/Bitmap;II)V");
     jDraw2DBufferMethod = getMethod("draw2D", "(Ljava/nio/ByteBuffer;I)V");
     jGetSurfaceMethod = getMethod("getSurface", "()Landroid/view/Surface;");
     jGetHolderMethod = getMethod("getHolder", "()Landroid/view/SurfaceHolder;");
 #else
     initInit();
 
-    jGeckoSurfaceViewClass = getClassGlobalRef("org/mozilla/gecko/gfx/layers/OGLSurfaceView");
-
     jGetHolderMethod = getMethod("getHolder", "()Landroid/view/SurfaceHolder;");
 
 
 #endif
 }
 
 void
 AndroidLocation::InitLocationClass(JNIEnv *jEnv)