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/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h
index 6d380d1..38241d9 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -17,21 +17,31 @@
#ifndef ANDROID_DISPLAY_DEVICE_H
#define ANDROID_DISPLAY_DEVICE_H
+#include "Transform.h"
+
#include <stdlib.h>
+#ifndef USE_HWC2
#include <ui/PixelFormat.h>
+#endif
#include <ui/Region.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
+#ifdef USE_HWC2
+#include <binder/IBinder.h>
+#include <utils/RefBase.h>
+#endif
#include <utils/Mutex.h>
#include <utils/String8.h>
#include <utils/Timers.h>
#include <hardware/hwcomposer_defs.h>
-#include "Transform.h"
+#ifdef USE_HWC2
+#include <memory>
+#endif
struct ANativeWindow;
@@ -39,6 +49,9 @@
struct DisplayInfo;
class DisplaySurface;
+#ifdef USE_HWC2
+class Fence;
+#endif
class IGraphicBufferProducer;
class Layer;
class SurfaceFlinger;
@@ -75,8 +88,10 @@
DisplayDevice(
const sp<SurfaceFlinger>& flinger,
DisplayType type,
- int32_t hwcId, // negative for non-HWC-composited displays
+ int32_t hwcId,
+#ifndef USE_HWC2
int format,
+#endif
bool isSecure,
const wp<IBinder>& displayToken,
const sp<DisplaySurface>& displaySurface,
@@ -99,7 +114,9 @@
int getWidth() const;
int getHeight() const;
+#ifndef USE_HWC2
PixelFormat getFormat() const;
+#endif
uint32_t getFlags() const;
EGLSurface getEGLSurface() const;
@@ -128,13 +145,23 @@
// We pass in mustRecompose so we can keep VirtualDisplaySurface's state
// machine happy without actually queueing a buffer if nothing has changed
status_t beginFrame(bool mustRecompose) const;
+#ifdef USE_HWC2
+ status_t prepareFrame(HWComposer& hwc);
+#else
status_t prepareFrame(const HWComposer& hwc) const;
+#endif
void swapBuffers(HWComposer& hwc) const;
+#ifndef USE_HWC2
status_t compositionComplete() const;
+#endif
// called after h/w composer has completed its set() call
+#ifdef USE_HWC2
+ void onSwapBuffersCompleted() const;
+#else
void onSwapBuffersCompleted(HWComposer& hwc) const;
+#endif
Rect getBounds() const {
return Rect(mDisplayWidth, mDisplayHeight);
@@ -147,6 +174,10 @@
EGLBoolean makeCurrent(EGLDisplay dpy, EGLContext ctx) const;
void setViewportAndProjection() const;
+#ifdef USE_HWC2
+ const sp<Fence>& getClientTargetAcquireFence() const;
+#endif
+
/* ------------------------------------------------------------------------
* Display power mode management.
*/
@@ -187,7 +218,9 @@
EGLSurface mSurface;
int mDisplayWidth;
int mDisplayHeight;
+#ifndef USE_HWC2
PixelFormat mFormat;
+#endif
uint32_t mFlags;
mutable uint32_t mPageFlipCount;
String8 mDisplayName;