Merge mozilla-central and mozilla-inbound

This commit is contained in:
Ehsan Akhgari 2012-05-02 23:59:08 -04:00
commit cb1754a1ce

View File

@ -79,7 +79,7 @@ static android::FramebufferNativeWindow *gNativeWindow = nsnull;
static bool sFramebufferOpen;
static bool sUsingOMTC;
static nsRefPtr<gfxASurface> sOMTCSurface;
static nsCOMPtr<nsIThread> sFramebufferWatchThread;
static pthread_t sFramebufferWatchThread;
namespace {
@ -112,17 +112,15 @@ private:
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 *) {
NS_IMETHOD Run() {
int len = 0;
char buf;
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.
{
@ -142,17 +140,10 @@ public:
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
@ -162,8 +153,11 @@ nsWindow::nsWindow()
// 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);