Turn on OMTC by default; fix crash when acquiring EGL surface
authorPatrick Walton <pwalton@mozilla.com>
Wed, 01 Feb 2012 23:54:01 -0800
changeset 89055 7badecd0693f76844bc66d6206eabbc5dad8ab68
parent 89054 63a79df01001407f54fffb4851d4d93f5635b80c
child 89056 b495033168e2e12696cf9f321d8e17107303dd00
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
Turn on OMTC by default; fix crash when acquiring EGL surface
mobile/android/app/mobile.js
widget/android/AndroidBridge.cpp
widget/android/AndroidFlexViewWrapper.h
widget/android/nsWindow.cpp
--- a/mobile/android/app/mobile.js
+++ b/mobile/android/app/mobile.js
@@ -589,16 +589,18 @@ pref("ui.dragThresholdY", 25);
 #if MOZ_PLATFORM_MAEMO == 6
 pref("layers.acceleration.disabled", false);
 #elifdef ANDROID
 pref("layers.acceleration.disabled", false);
 #else
 pref("layers.acceleration.disabled", true);
 #endif
 
+pref("layers.offmainthreadcomposition.enabled", true);
+
 pref("notification.feature.enabled", true);
 
 // prevent tooltips from showing up
 pref("browser.chrome.toolbar_tips", false);
 pref("indexedDB.feature.enabled", true);
 pref("dom.indexedDB.warningQuota", 5);
 
 // prevent video elements from preloading too much data
--- a/widget/android/AndroidBridge.cpp
+++ b/widget/android/AndroidBridge.cpp
@@ -1031,22 +1031,27 @@ EGLSurface
 AndroidBridge::RegisterCompositor()
 {
     ALOG_BRIDGE("AndroidBridge::RegisterCompositor");
     JNIEnv *env = GetJNIForThread();
     if (!env)
         return NULL;
 
     AutoLocalJNIFrame jniFrame(env, 3);
+
     jmethodID registerCompositor = env->GetStaticMethodID(jFlexSurfaceView, "registerCxxCompositor", "()Lorg/mozilla/gecko/gfx/GLController;");
 
     jobject glController = env->CallStaticObjectMethod(jFlexSurfaceView, registerCompositor);
 
     sController.Acquire(env, glController);
+    sController.WaitForValidSurface();
+    sController.SetGLVersion(2);
+    sController.InitGLContext();
 
+    sController.WaitForValidSurface();
     return sController.GetEGLSurface();
 }
 
 bool
 AndroidBridge::GetStaticIntField(const char *className, const char *fieldName, PRInt32* aInt)
 {
     ALOG_BRIDGE("AndroidBridge::GetStaticIntField %s", fieldName);
     JNIEnv *env = GetJNIEnv();
--- a/widget/android/AndroidFlexViewWrapper.h
+++ b/widget/android/AndroidFlexViewWrapper.h
@@ -39,16 +39,17 @@
 #define AndroidFlexViewWrapper_h__
 
 #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>
 class AndroidEGLObject {
 public:
     AndroidEGLObject(JNIEnv* aJEnv, jobject aJObj)
     : mPtr(reinterpret_cast<typename T::NativeType>(aJEnv->GetIntField(aJObj, jPointerField))) {}
 
     static void Init(JNIEnv* aJEnv) {
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1194,16 +1194,39 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
     }
 
     AndroidBridge::AutoLocalJNIFrame jniFrame;
 #ifdef MOZ_JAVA_COMPOSITOR
     // We haven't been given a window-size yet, so do nothing
     if (gAndroidBounds.width <= 0 || gAndroidBounds.height <= 0)
         return;
 
+#if 0
+    // BEGIN HACK: gl layers
+    nsPaintEvent event(true, NS_PAINT, this);
+    nsIntRect tileRect(0, 0, gAndroidBounds.width, gAndroidBounds.height);
+    event.region = tileRect;
+
+    unsigned char *bits2 = new unsigned char[gAndroidBounds.width * gAndroidBounds.height * 2];
+    nsRefPtr<gfxImageSurface> targetSurface =
+        new gfxImageSurface(bits2,
+                            gfxIntSize(gAndroidBounds.width, gAndroidBounds.height),
+                            gAndroidBounds.width * 2,
+                            gfxASurface::ImageFormatRGB16_565);
+
+    nsRefPtr<gfxContext> ctx = new gfxContext(targetSurface);
+    AutoLayerManagerSetup
+      setupLayerManager(this, ctx, BasicLayerManager::BUFFER_NONE);
+    DispatchEvent(&event);
+
+    delete[] bits2;
+    return;
+    // END HACK: gl layers
+#endif
+
     /*
      * Check to see whether the presentation shell corresponding to the document on the screen
      * is suppressing painting. If it is, we bail out, as continuing would result in a mismatch
      * between the content on the screen and the current viewport metrics.
      */
     nsCOMPtr<nsIAndroidDrawMetadataProvider> metadataProvider =
         AndroidBridge::Bridge()->GetDrawMetadataProvider();