Merge mozilla-central and mozilla-inbound
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 02 May 2012 23:59:08 -0400
changeset 92894 807403a04a6a054b23edeef64d076bf496e18b12
parent 92892 025285f5761607093f29ba1793edeaf233a1336b (current diff)
parent 92893 a8c16e7b819be4aefe6cb378c86412b68fe5a8a6 (diff)
child 92895 24f9b828d28a9ed6a6c356864f520461e463d76a
child 92998 b4d2343fff9d5bfef28dcb2a00c6358cc65a4d30
child 93197 c12f78208ae1a076a30537257395669396b7709d
push id8901
push usereakhgari@mozilla.com
push dateThu, 03 May 2012 04:00:23 +0000
treeherdermozilla-inbound@807403a04a6a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone15.0a1
first release with
nightly linux32
807403a04a6a / 15.0a1 / 20120503030512 / files
nightly linux64
807403a04a6a / 15.0a1 / 20120503030512 / files
nightly mac
807403a04a6a / 15.0a1 / 20120503030512 / files
nightly win32
807403a04a6a / 15.0a1 / 20120503030512 / files
nightly win64
807403a04a6a / 15.0a1 / 20120503030512 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge mozilla-central and mozilla-inbound
--- a/widget/gonk/nsWindow.cpp
+++ b/widget/gonk/nsWindow.cpp
@@ -74,17 +74,17 @@ static gfxMatrix sRotationMatrix;
 static nsRefPtr<GLContext> sGLContext;
 static nsTArray<nsWindow *> sTopWindows;
 static nsWindow *gWindowToRedraw = nsnull;
 static nsWindow *gFocusedWindow = nsnull;
 static android::FramebufferNativeWindow *gNativeWindow = nsnull;
 static bool sFramebufferOpen;
 static bool sUsingOMTC;
 static nsRefPtr<gfxASurface> sOMTCSurface;
-static nsCOMPtr<nsIThread> sFramebufferWatchThread;
+static pthread_t sFramebufferWatchThread;
 
 namespace {
 
 class ScreenOnOffEvent : public nsRunnable {
 public:
     ScreenOnOffEvent(bool on)
         : mIsOn(on)
     {}
@@ -107,27 +107,25 @@ public:
 
 private:
     bool mIsOn;
 };
 
 static const char* kSleepFile = "/sys/power/wait_for_fb_sleep";
 static const char* kWakeFile = "/sys/power/wait_for_fb_wake";
 
-class FramebufferWatcher : public nsRunnable {
-public:
-    FramebufferWatcher()
-        : mScreenOnEvent(new ScreenOnOffEvent(true))
-        , mScreenOffEvent(new ScreenOnOffEvent(false))
-    {}
+static void *frameBufferWatcher(void *) {
+
+    int len = 0;
+    char buf;
 
-    NS_IMETHOD Run() {
-        int len = 0;
-        char buf;
+    nsRefPtr<ScreenOnOffEvent> mScreenOnEvent = new ScreenOnOffEvent(true);
+    nsRefPtr<ScreenOnOffEvent> mScreenOffEvent = new ScreenOnOffEvent(false);
 
+    while (true) {
         // Cannot use epoll here because kSleepFile and kWakeFile are
         // always ready to read and blocking.
         {
             ScopedClose fd(open(kSleepFile, O_RDONLY, 0));
             do {
                 len = read(fd.get(), &buf, 1);
             } while (len < 0 && errno == EINTR);
             NS_WARN_IF_FALSE(len >= 0, "WAIT_FOR_FB_SLEEP failed");
@@ -137,38 +135,34 @@ public:
         {
             ScopedClose fd(open(kWakeFile, O_RDONLY, 0));
             do {
                 len = read(fd.get(), &buf, 1);
             } while (len < 0 && errno == EINTR);
             NS_WARN_IF_FALSE(len >= 0, "WAIT_FOR_FB_WAKE failed");
             NS_DispatchToMainThread(mScreenOnEvent);
         }
-
-        // Dispatch to ourself.
-        NS_DispatchToCurrentThread(this);
-
-        return NS_OK;
     }
-
-private:
-    nsRefPtr<ScreenOnOffEvent> mScreenOnEvent;
-    nsRefPtr<ScreenOnOffEvent> mScreenOffEvent;
-};
+    
+    return NULL;
+}
 
 } // anonymous namespace
 
 nsWindow::nsWindow()
 {
     if (!sGLContext && !sFramebufferOpen && !sUsingOMTC) {
         // workaround Bug 725143
         hal::SetScreenEnabled(true);
 
-        // Watching screen on/off state
-        NS_NewThread(getter_AddRefs(sFramebufferWatchThread), new FramebufferWatcher());
+        // Watching screen on/off state by using a pthread
+        // which implicitly calls exit() when the main thread ends
+        if (pthread_create(&sFramebufferWatchThread, NULL, frameBufferWatcher, NULL)) {
+            NS_RUNTIMEABORT("Failed to create framebufferWatcherThread, aborting...");
+        }
 
         sUsingOMTC = Preferences::GetBool("layers.offmainthreadcomposition.enabled", false);
 
         // We (apparently) don't have a way to tell if allocating the
         // fbs succeeded or failed.
         gNativeWindow = new android::FramebufferNativeWindow();
         if (sUsingOMTC) {
             nsIntSize screenSize;