Switch SurfaceFlinger to HWC 2.0
Enables SurfaceFlinger to speak to version 2.0 of the Hardware Composer
HAL instead of version 1.x (also removing support for the framebuffer
HAL). By default, however, this functionality is disabled. In order to
enable it, USE_HWC2 must be set to true in Android.mk.
Change-Id: I4589e02ac2165236b10ff2f7cb772f87e0d3daab
diff --git a/services/surfaceflinger/DisplayHardware/FramebufferSurface.h b/services/surfaceflinger/DisplayHardware/FramebufferSurface.h
index 3d17840..0605602 100644
--- a/services/surfaceflinger/DisplayHardware/FramebufferSurface.h
+++ b/services/surfaceflinger/DisplayHardware/FramebufferSurface.h
@@ -41,7 +41,9 @@
virtual status_t beginFrame(bool mustRecompose);
virtual status_t prepareFrame(CompositionType compositionType);
+#ifndef USE_HWC2
virtual status_t compositionComplete();
+#endif
virtual status_t advanceFrame();
virtual void onFrameCommitted();
virtual void dumpAsString(String8& result) const;
@@ -50,10 +52,16 @@
// displays.
virtual void resizeBuffers(const uint32_t /*w*/, const uint32_t /*h*/) { };
+#ifdef USE_HWC2
+ virtual const sp<Fence>& getClientTargetAcquireFence() const override;
+#endif
+
private:
virtual ~FramebufferSurface() { }; // this class cannot be overloaded
+#ifndef USE_HWC2
virtual void onFrameAvailable(const BufferItem& item);
+#endif
virtual void freeBufferLocked(int slotIndex);
virtual void dumpLocked(String8& result, const char* prefix) const;
@@ -61,7 +69,12 @@
// 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.
+#ifdef USE_HWC2
+ status_t nextBuffer(sp<GraphicBuffer>& outBuffer, sp<Fence>& outFence,
+ android_dataspace_t& outDataspace);
+#else
status_t nextBuffer(sp<GraphicBuffer>& outBuffer, sp<Fence>& outFence);
+#endif
// mDisplayType must match one of the HWC display types
int mDisplayType;
@@ -75,8 +88,20 @@
// no current buffer.
sp<GraphicBuffer> mCurrentBuffer;
+#ifdef USE_HWC2
+ // mCurrentFence is the current buffer's acquire fence
+ sp<Fence> mCurrentFence;
+#endif
+
// Hardware composer, owned by SurfaceFlinger.
HWComposer& mHwc;
+
+#ifdef USE_HWC2
+ // Previous buffer to release after getting an updated retire fence
+ bool mHasPendingRelease;
+ int mPreviousBufferSlot;
+ sp<GraphicBuffer> mPreviousBuffer;
+#endif
};
// ---------------------------------------------------------------------------