Bug 1100727 - Port LL FrameBufferSurface to gonk. r=mwu
authorBoris Chiou <boris.chiou@gmail.com>
Wed, 19 Nov 2014 23:03:00 +0100
changeset 241158 2513d21bbff2bfdca66e7fd6eab236e5aba25445
parent 241157 f1d347872c228919b7f8cb9a51722f8728d1eec8
child 241159 48a024873cbca590c16e325bf45edc64a912471b
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmwu
bugs1100727
milestone36.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
Bug 1100727 - Port LL FrameBufferSurface to gonk. r=mwu Use the new API, BufferQueue::createBufferQueue() to new the consumer and the producer on LL.
widget/gonk/libdisplay/FramebufferSurface.cpp
widget/gonk/libdisplay/FramebufferSurface.h
widget/gonk/libdisplay/GonkDisplayJB.cpp
--- a/widget/gonk/libdisplay/FramebufferSurface.cpp
+++ b/widget/gonk/libdisplay/FramebufferSurface.cpp
@@ -44,27 +44,30 @@
 // ----------------------------------------------------------------------------
 namespace android {
 // ----------------------------------------------------------------------------
 
 /*
  * This implements the (main) framebuffer management. This class
  * was adapted from the version in SurfaceFlinger
  */
-FramebufferSurface::FramebufferSurface(int disp, uint32_t width, uint32_t height, uint32_t format,
-        sp<BufferQueue>& bq) :
+FramebufferSurface::FramebufferSurface(int disp,
+                                       uint32_t width,
+                                       uint32_t height,
+                                       uint32_t format,
+                                       const sp<StreamConsumer>& sc)
 #if ANDROID_VERSION >= 19
-    ConsumerBase(bq, true),
+    : ConsumerBase(sc, true)
 #else
-    ConsumerBase(bq),
+    : ConsumerBase(sc)
 #endif
-    mDisplayType(disp),
-    mCurrentBufferSlot(-1),
-    mCurrentBuffer(0),
-    lastHandle(0)
+    , mDisplayType(disp)
+    , mCurrentBufferSlot(-1)
+    , mCurrentBuffer(0)
+    , lastHandle(0)
 {
     mName = "FramebufferSurface";
 
 #if ANDROID_VERSION >= 19
     sp<IGraphicBufferConsumer> consumer = mConsumer;
 #else
     sp<BufferQueue> consumer = mBufferQueue;
     consumer->setSynchronousMode(true);
@@ -108,17 +111,17 @@ status_t FramebufferSurface::nextBuffer(
         // Release the previous buffer.
 #if ANDROID_VERSION >= 19
         err = releaseBufferLocked(mCurrentBufferSlot, mCurrentBuffer,
                 EGL_NO_DISPLAY, EGL_NO_SYNC_KHR);
 #else
         err = releaseBufferLocked(mCurrentBufferSlot, EGL_NO_DISPLAY,
                 EGL_NO_SYNC_KHR);
 #endif
-        if (err != NO_ERROR && err != BufferQueue::STALE_BUFFER_SLOT) {
+        if (err != NO_ERROR && err != StreamConsumer::STALE_BUFFER_SLOT) {
             ALOGE("error releasing buffer: %s (%d)", strerror(-err), err);
             return err;
         }
     }
     mCurrentBufferSlot = item.mBuf;
     mCurrentBuffer = mSlots[mCurrentBufferSlot].mGraphicBuffer;
     outFence = item.mFence;
     outBuffer = mCurrentBuffer;
--- a/widget/gonk/libdisplay/FramebufferSurface.h
+++ b/widget/gonk/libdisplay/FramebufferSurface.h
@@ -25,21 +25,27 @@
 // ---------------------------------------------------------------------------
 namespace android {
 // ---------------------------------------------------------------------------
 
 class Rect;
 class String8;
 class HWComposer;
 
+#if ANDROID_VERSION >= 21
+typedef IGraphicBufferConsumer StreamConsumer;
+#else
+typedef BufferQueue StreamConsumer;
+#endif
+
 // ---------------------------------------------------------------------------
 
 class FramebufferSurface : public ConsumerBase {
 public:
-    FramebufferSurface(int disp, uint32_t width, uint32_t height, uint32_t format, sp<BufferQueue>& bq);
+    FramebufferSurface(int disp, uint32_t width, uint32_t height, uint32_t format, const sp<StreamConsumer>& sc);
 
     bool isUpdateOnDemand() const { return false; }
     status_t setUpdateRectangle(const Rect& updateRect);
     status_t compositionComplete();
 
     virtual void dump(String8& result);
     virtual void dump(String8& result, const char* prefix);
 
--- a/widget/gonk/libdisplay/GonkDisplayJB.cpp
+++ b/widget/gonk/libdisplay/GonkDisplayJB.cpp
@@ -101,32 +101,43 @@ GonkDisplayJB::GonkDisplayJB()
                                            (hw_module_t const**)&mPowerModule);
     if (!err)
         mPowerModule->init(mPowerModule);
     ALOGW_IF(err, "Couldn't load %s module (%s)", POWER_HARDWARE_MODULE_ID, strerror(-err));
 
     mAlloc = new GraphicBufferAlloc();
 
     status_t error;
-
-#if ANDROID_VERSION >= 19
-    sp<BufferQueue> bq = new BufferQueue(mAlloc);
+#if ANDROID_VERSION >= 21
+    sp<IGraphicBufferProducer> producer;
+    sp<IGraphicBufferConsumer> consumer;
+    BufferQueue::createBufferQueue(&producer, &consumer, mAlloc);
+#elif ANDROID_VERSION >= 19
+    sp<BufferQueue> consumer = new BufferQueue(mAlloc);
+    sp<IGraphicBufferProducer> producer = consumer;
+#elif ANDROID_VERSION >= 18
+    sp<BufferQueue> consumer = new BufferQueue(true, mAlloc);
+    sp<IGraphicBufferProducer> producer = consumer;
 #else
-    sp<BufferQueue> bq = new BufferQueue(true, mAlloc);
+    sp<BufferQueue> consumer = new BufferQueue(true, mAlloc);
 #endif
-    mFBSurface = new FramebufferSurface(0, mWidth, mHeight, surfaceformat, bq);
+    mFBSurface = new FramebufferSurface(0, mWidth, mHeight, surfaceformat, consumer);
 
 #if ANDROID_VERSION == 17
-    sp<SurfaceTextureClient> stc = new SurfaceTextureClient(static_cast<sp<ISurfaceTexture> >(mFBSurface->getBufferQueue()));
+    sp<SurfaceTextureClient> stc = new SurfaceTextureClient(
+        static_cast<sp<ISurfaceTexture> >(mFBSurface->getBufferQueue()));
 #else
-    sp<Surface> stc = new Surface(static_cast<sp<IGraphicBufferProducer> >(bq));
+    sp<Surface> stc = new Surface(producer);
 #endif
     mSTClient = stc;
     mSTClient->perform(mSTClient.get(), NATIVE_WINDOW_SET_BUFFER_COUNT, 2);
-    mSTClient->perform(mSTClient.get(), NATIVE_WINDOW_SET_USAGE, GRALLOC_USAGE_HW_FB | GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_COMPOSER);
+    mSTClient->perform(mSTClient.get(), NATIVE_WINDOW_SET_USAGE,
+                                        GRALLOC_USAGE_HW_FB |
+                                        GRALLOC_USAGE_HW_RENDER |
+                                        GRALLOC_USAGE_HW_COMPOSER);
 
     mList = (hwc_display_contents_1_t *)malloc(sizeof(*mList) + (sizeof(hwc_layer_1_t)*2));
     if (mHwc)
         mHwc->blank(mHwc, HWC_DISPLAY_PRIMARY, 0);
 
     if (error == NO_ERROR) {
         ALOGI("Starting bootanimation with (%d) format framebuffer", surfaceformat);
         StartBootAnimation();