Bug 1163681 - Fix fence handling. r=mwu, a=jocheng
authorSotaro Ikeda <sikeda@mozilla.com>
Tue, 12 May 2015 06:32:00 -0400
changeset 238405 3e7681d6115138ebe6d7817e78ed8c5624c3284d
parent 238404 4ec144c1957be4fff76f11c4ca7aaa1ddd93208a
child 238406 da5919916ba7ecbfc29296d5394aff907c244388
push id610
push userryanvm@gmail.com
push dateTue, 19 May 2015 01:50:15 +0000
treeherdermozilla-b2g37_v2_2@d50110422703 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmwu, jocheng
bugs1163681
milestone37.0
Bug 1163681 - Fix fence handling. r=mwu, a=jocheng
widget/gonk/libdisplay/GonkDisplayJB.cpp
widget/gonk/libdisplay/GonkDisplayJB.h
--- a/widget/gonk/libdisplay/GonkDisplayJB.cpp
+++ b/widget/gonk/libdisplay/GonkDisplayJB.cpp
@@ -310,26 +310,34 @@ GonkDisplayJB::Post(buffer_handle_t buf,
         close(mList->retireFenceFd);
     return !err;
 }
 
 ANativeWindowBuffer*
 GonkDisplayJB::DequeueBuffer()
 {
     ANativeWindowBuffer *buf;
-    mSTClient->dequeueBuffer(mSTClient.get(), &buf, &mFence);
+    int fenceFd = -1;
+    mSTClient->dequeueBuffer(mSTClient.get(), &buf, &fenceFd);
+    sp<Fence> fence(new Fence(fenceFd));
+#if ANDROID_VERSION == 17
+    fence->waitForever(1000, "GonkDisplayJB_DequeueBuffer");
+    // 1000 is what Android uses. It is a warning timeout in ms.
+    // This timeout was removed in ANDROID_VERSION 18.
+#else
+    fence->waitForever("GonkDisplayJB_DequeueBuffer");
+#endif
     return buf;
 }
 
 bool
 GonkDisplayJB::QueueBuffer(ANativeWindowBuffer* buf)
 {
-    bool success = Post(buf->handle, -1);
-    int error = mSTClient->queueBuffer(mSTClient.get(), buf, mFence);
-
+    int error = mSTClient->queueBuffer(mSTClient.get(), buf, -1);
+    bool success = Post(mFBSurface->lastHandle, mFBSurface->GetPrevFBAcquireFd());
     return error == 0 && success;
 }
 
 void
 GonkDisplayJB::UpdateFBSurface(EGLDisplay dpy, EGLSurface sur)
 {
     eglSwapBuffers(dpy, sur);
 }
--- a/widget/gonk/libdisplay/GonkDisplayJB.h
+++ b/widget/gonk/libdisplay/GonkDisplayJB.h
@@ -58,17 +58,16 @@ private:
     hw_module_t const*        mModule;
     hw_module_t const*        mFBModule;
     hwc_composer_device_1_t*  mHwc;
     framebuffer_device_t*     mFBDevice;
     power_module_t*           mPowerModule;
     android::sp<android::FramebufferSurface> mFBSurface;
     android::sp<ANativeWindow> mSTClient;
     android::sp<android::IGraphicBufferAlloc> mAlloc;
-    int mFence;
     hwc_display_contents_1_t* mList;
     uint32_t mWidth;
     uint32_t mHeight;
     OnEnabledCallbackType mEnabledCallback;
 };
 
 }