add support hwc 1.1

Bug: 7124069

Change-Id: I53d705105c4ad8954d3f50ee4f4c8b7ec936b871
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index 2c06a0b..72f73f7 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -183,6 +183,32 @@
     mPageFlipCount++;
 }
 
+void DisplayDevice::swapBuffers(HWComposer& hwc) const {
+    if (hwc.initCheck() != NO_ERROR) {
+        // no HWC, we call eglSwapBuffers()
+        eglSwapBuffers(mDisplay, mSurface);
+    } else {
+        if (hwc.hasGlesComposition(mType)) {
+            if (hwc.supportsFramebufferTarget() ||
+                    mType >= DisplayDevice::DISPLAY_VIRTUAL) {
+                // as of hwc 1.1 we always call eglSwapBuffers, however,
+                // on older versions of HWC, we need to call it only on
+                // virtual displays
+                eglSwapBuffers(mDisplay, mSurface);
+            }
+        }
+    }
+}
+
+void DisplayDevice::onSwapBuffersCompleted(HWComposer& hwc) const {
+    if (hwc.initCheck() == NO_ERROR) {
+        if (hwc.supportsFramebufferTarget()) {
+            int fd = hwc.getAndResetReleaseFenceFd(mType);
+            mFramebufferSurface->setReleaseFenceFd(fd);
+        }
+    }
+}
+
 uint32_t DisplayDevice::getFlags() const
 {
     return mFlags;