Bug 1144515 - ConsumerListener interface changes. r=mwu,sotaro.ikeda.g
authorMichael Vines <mvines@codeaurora.org>
Wed, 18 Mar 2015 15:03:15 -0700
changeset 236507 7bd2bc8251bf1009c9b8334cae232b7419206411
parent 236506 256daeb9f1af320c26f5a61875234cec189d0708
child 236508 7ee219636f2213261d2390b99c3a05b36aee9ade
push id28511
push userkwierso@gmail.com
push dateTue, 31 Mar 2015 02:34:53 +0000
treeherdermozilla-central@8af276ab8636 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmwu, sotaro.ikeda.g
bugs1144515
milestone39.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 1144515 - ConsumerListener interface changes. r=mwu,sotaro.ikeda.g From ae4139a7b5dfb0b0326c84070e52fa58e43a54fe Mon Sep 17 00:00:00 2001 Change-Id: I3a3e4d6f58a42576197356ba4b7301c670298c74 --- widget/gonk/libdisplay/FramebufferSurface.cpp | 4 ++++ widget/gonk/libdisplay/FramebufferSurface.h | 4 ++++ .../nativewindow/GonkBufferQueueLL/GonkBufferQueueLL.cpp | 16 ++++++++++++++++ .../nativewindow/GonkBufferQueueLL/GonkBufferQueueLL.h | 5 +++++ .../GonkBufferQueueLL/GonkBufferQueueProducer.cpp | 9 ++++++++- widget/gonk/nativewindow/GonkConsumerBaseLL.cpp | 4 ++++ widget/gonk/nativewindow/GonkConsumerBaseLL.h | 5 +++++ widget/gonk/nativewindow/GonkNativeWindowLL.cpp | 5 +++++ widget/gonk/nativewindow/GonkNativeWindowLL.h | 4 ++++ 9 files changed, 55 insertions(+), 1 deletion(-)
widget/gonk/libdisplay/FramebufferSurface.cpp
widget/gonk/libdisplay/FramebufferSurface.h
widget/gonk/nativewindow/GonkBufferQueueLL/GonkBufferQueueLL.cpp
widget/gonk/nativewindow/GonkBufferQueueLL/GonkBufferQueueLL.h
widget/gonk/nativewindow/GonkBufferQueueLL/GonkBufferQueueProducer.cpp
widget/gonk/nativewindow/GonkConsumerBaseLL.cpp
widget/gonk/nativewindow/GonkConsumerBaseLL.h
widget/gonk/nativewindow/GonkNativeWindowLL.cpp
widget/gonk/nativewindow/GonkNativeWindowLL.h
--- a/widget/gonk/libdisplay/FramebufferSurface.cpp
+++ b/widget/gonk/libdisplay/FramebufferSurface.cpp
@@ -124,17 +124,21 @@ status_t FramebufferSurface::nextBuffer(
     mCurrentBufferSlot = item.mBuf;
     mCurrentBuffer = mSlots[mCurrentBufferSlot].mGraphicBuffer;
     outFence = item.mFence;
     outBuffer = mCurrentBuffer;
     return NO_ERROR;
 }
 
 // Overrides ConsumerBase::onFrameAvailable(), does not call base class impl.
+#if ANDROID_VERSION >= 22
+void FramebufferSurface::onFrameAvailable(const ::android::BufferItem &item) {
+#else
 void FramebufferSurface::onFrameAvailable() {
+#endif
     sp<GraphicBuffer> buf;
     sp<Fence> acquireFence;
     status_t err = nextBuffer(buf, acquireFence);
     if (err != NO_ERROR) {
         ALOGE("error latching nnext FramebufferSurface buffer: %s (%d)",
                 strerror(-err), err);
         return;
     }
--- a/widget/gonk/libdisplay/FramebufferSurface.h
+++ b/widget/gonk/libdisplay/FramebufferSurface.h
@@ -58,17 +58,21 @@ public:
     status_t setReleaseFenceFd(int fenceFd);
 
     virtual int GetPrevFBAcquireFd();
 
     buffer_handle_t lastHandle;
 private:
     virtual ~FramebufferSurface() { }; // this class cannot be overloaded
 
+#if ANDROID_VERSION >= 22
+    virtual void onFrameAvailable(const ::android::BufferItem &item);
+#else
     virtual void onFrameAvailable();
+#endif
     virtual void freeBufferLocked(int slotIndex);
 
     // nextBuffer waits for and then latches the next buffer from the
     // BufferQueue and releases the previously latched buffer to the
     // BufferQueue.  The new buffer is returned in the 'buffer' argument.
     status_t nextBuffer(sp<GraphicBuffer>& outBuffer, sp<Fence>& outFence);
 
     // mDisplayType must match one of the HWC display types
--- a/widget/gonk/nativewindow/GonkBufferQueueLL/GonkBufferQueueLL.cpp
+++ b/widget/gonk/nativewindow/GonkBufferQueueLL/GonkBufferQueueLL.cpp
@@ -27,22 +27,38 @@
 namespace android {
 
 GonkBufferQueue::ProxyConsumerListener::ProxyConsumerListener(
         const wp<ConsumerListener>& consumerListener):
         mConsumerListener(consumerListener) {}
 
 GonkBufferQueue::ProxyConsumerListener::~ProxyConsumerListener() {}
 
+#if ANDROID_VERSION == 21
 void GonkBufferQueue::ProxyConsumerListener::onFrameAvailable() {
     sp<ConsumerListener> listener(mConsumerListener.promote());
     if (listener != NULL) {
         listener->onFrameAvailable();
     }
 }
+#else
+void GonkBufferQueue::ProxyConsumerListener::onFrameAvailable(const ::android::BufferItem& item) {
+    sp<ConsumerListener> listener(mConsumerListener.promote());
+    if (listener != NULL) {
+        listener->onFrameAvailable(item);
+    }
+}
+
+void GonkBufferQueue::ProxyConsumerListener::onFrameReplaced(const ::android::BufferItem& item) {
+    sp<ConsumerListener> listener(mConsumerListener.promote());
+    if (listener != NULL) {
+        listener->onFrameReplaced(item);
+    }
+}
+#endif
 
 void GonkBufferQueue::ProxyConsumerListener::onBuffersReleased() {
     sp<ConsumerListener> listener(mConsumerListener.promote());
     if (listener != NULL) {
         listener->onBuffersReleased();
     }
 }
 
--- a/widget/gonk/nativewindow/GonkBufferQueueLL/GonkBufferQueueLL.h
+++ b/widget/gonk/nativewindow/GonkBufferQueueLL/GonkBufferQueueLL.h
@@ -58,17 +58,22 @@ public:
     // GonkBufferQueue object and the consumer object.  The reason this can't be a weak
     // reference in the GonkBufferQueue class is because we're planning to expose the
     // consumer side of a GonkBufferQueue as a binder interface, which doesn't support
     // weak references.
     class ProxyConsumerListener : public BnConsumerListener {
     public:
         ProxyConsumerListener(const wp<ConsumerListener>& consumerListener);
         virtual ~ProxyConsumerListener();
+#if ANDROID_VERSION == 21
         virtual void onFrameAvailable();
+#else
+        virtual void onFrameAvailable(const ::android::BufferItem& item);
+        virtual void onFrameReplaced(const ::android::BufferItem& item);
+#endif
         virtual void onBuffersReleased();
         virtual void onSidebandStreamChanged();
     private:
         // mConsumerListener is a weak reference to the IConsumerListener.  This is
         // the raison d'etre of ProxyConsumerListener.
         wp<ConsumerListener> mConsumerListener;
     };
 
--- a/widget/gonk/nativewindow/GonkBufferQueueLL/GonkBufferQueueProducer.cpp
+++ b/widget/gonk/nativewindow/GonkBufferQueueLL/GonkBufferQueueProducer.cpp
@@ -549,16 +549,17 @@ status_t GonkBufferQueueProducer::queueB
         case NATIVE_WINDOW_SCALING_MODE_SCALE_CROP:
         case NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP:
             break;
         default:
             ALOGE("queueBuffer: unknown scaling mode %d", scalingMode);
             return BAD_VALUE;
     }
 
+    GonkBufferItem item;
     sp<IConsumerListener> listener;
     { // Autolock scope
         Mutex::Autolock lock(mCore->mMutex);
 
         if (mCore->mIsAbandoned) {
             ALOGE("queueBuffer: GonkBufferQueue has been abandoned");
             return NO_INIT;
         }
@@ -605,17 +606,16 @@ status_t GonkBufferQueueProducer::queueB
             return BAD_VALUE;
         }
 
         mSlots[slot].mFence = fence;
         mSlots[slot].mBufferState = GonkBufferSlot::QUEUED;
         ++mCore->mFrameCounter;
         mSlots[slot].mFrameNumber = mCore->mFrameCounter;
 
-        GonkBufferItem item;
         item.mAcquireCalled = mSlots[slot].mAcquireCalled;
         item.mGraphicBuffer = mSlots[slot].mGraphicBuffer;
         item.mCrop = crop;
         item.mTransform = transform & ~NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY;
         item.mTransformToDisplayInverse =
                 bool(transform & NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY);
         item.mScalingMode = scalingMode;
         item.mTimestamp = timestamp;
@@ -654,21 +654,28 @@ status_t GonkBufferQueueProducer::queueB
             }
         }
 
         mCore->mBufferHasBeenQueued = true;
         mCore->mDequeueCondition.broadcast();
 
         output->inflate(mCore->mDefaultWidth, mCore->mDefaultHeight,
                 mCore->mTransformHint, mCore->mQueue.size());
+
+        item.mGraphicBuffer.clear();
+        item.mSlot = GonkBufferItem::INVALID_BUFFER_SLOT;
     } // Autolock scope
 
     // Call back without lock held
     if (listener != NULL) {
+#if ANDROID_VERSION == 21
         listener->onFrameAvailable();
+#else
+        listener->onFrameAvailable(reinterpret_cast<::android::BufferItem&>(item));
+#endif
     }
 
     return NO_ERROR;
 }
 
 void GonkBufferQueueProducer::cancelBuffer(int slot, const sp<Fence>& fence) {
     ATRACE_CALL();
     ALOGV("cancelBuffer: slot %d", slot);
--- a/widget/gonk/nativewindow/GonkConsumerBaseLL.cpp
+++ b/widget/gonk/nativewindow/GonkConsumerBaseLL.cpp
@@ -80,17 +80,21 @@ void GonkConsumerBase::onLastStrongRef(c
 
 void GonkConsumerBase::freeBufferLocked(int slotIndex) {
     ALOGV("freeBufferLocked: slotIndex=%d", slotIndex);
     mSlots[slotIndex].mGraphicBuffer = 0;
     mSlots[slotIndex].mFence = Fence::NO_FENCE;
     mSlots[slotIndex].mFrameNumber = 0;
 }
 
+#if ANDROID_VERSION == 21
 void GonkConsumerBase::onFrameAvailable() {
+#else
+void GonkConsumerBase::onFrameAvailable(const ::android::BufferItem& item) {
+#endif
     ALOGV("onFrameAvailable");
 
     sp<FrameAvailableListener> listener;
     { // scope for the lock
         Mutex::Autolock lock(mMutex);
         listener = mFrameAvailableListener.promote();
     }
 
--- a/widget/gonk/nativewindow/GonkConsumerBaseLL.h
+++ b/widget/gonk/nativewindow/GonkConsumerBaseLL.h
@@ -102,17 +102,22 @@ protected:
 
     // Implementation of the IConsumerListener interface.  These
     // calls are used to notify the GonkConsumerBase of asynchronous events in the
     // GonkBufferQueue.  The onFrameAvailable and onBuffersReleased methods should
     // not need to be overridden by derived classes, but if they are overridden
     // the GonkConsumerBase implementation must be called from the derived class.
     // The GonkConsumerBase version of onSidebandStreamChanged does nothing and can
     // be overriden by derived classes if they want the notification.
+#if ANDROID_VERSION == 21
     virtual void onFrameAvailable();
+#else
+    virtual void onFrameAvailable(const ::android::BufferItem& item);
+    virtual void onFrameReplaced(const ::android::BufferItem& item) {};
+#endif
     virtual void onBuffersReleased();
     virtual void onSidebandStreamChanged();
 
     // freeBufferLocked frees up the given buffer slot.  If the slot has been
     // initialized this will release the reference to the GraphicBuffer in that
     // slot.  Otherwise it has no effect.
     //
     // Derived classes should override this method to clean up any state they
--- a/widget/gonk/nativewindow/GonkNativeWindowLL.cpp
+++ b/widget/gonk/nativewindow/GonkNativeWindowLL.cpp
@@ -183,17 +183,22 @@ GonkNativeWindow::getTextureClientFromBu
 
 void GonkNativeWindow::setNewFrameCallback(
         GonkNativeWindowNewFrameCallback* callback) {
     ALOGD("setNewFrameCallback");
     Mutex::Autolock lock(mMutex);
     mNewFrameCallback = callback;
 }
 
+#if ANDROID_VERSION == 21
 void GonkNativeWindow::onFrameAvailable() {
     GonkConsumerBase::onFrameAvailable();
+#else
+void GonkNativeWindow::onFrameAvailable(const ::android::BufferItem &item) {
+    GonkConsumerBase::onFrameAvailable(item);
+#endif
 
     if (mNewFrameCallback) {
         mNewFrameCallback->OnNewFrame();
     }
 }
 
 } // namespace android
--- a/widget/gonk/nativewindow/GonkNativeWindowLL.h
+++ b/widget/gonk/nativewindow/GonkNativeWindowLL.h
@@ -113,17 +113,21 @@ class GonkNativeWindow: public GonkConsu
 
     mozilla::TemporaryRef<TextureClient> getTextureClientFromBuffer(ANativeWindowBuffer* buffer);
 
     void setNewFrameCallback(GonkNativeWindowNewFrameCallback* callback);
 
     static void RecycleCallback(TextureClient* client, void* closure);
 
 protected:
+#if ANDROID_VERSION == 21
     virtual void onFrameAvailable();
+#else
+    virtual void onFrameAvailable(const ::android::BufferItem &item);
+#endif
 
 private:
     GonkNativeWindowNewFrameCallback* mNewFrameCallback;
 };
 
 } // namespace android
 
 #endif // NATIVEWINDOW_GONKNATIVEWINDOW_LL_H