Revert "Created HardwareBufferRenderer to support rendering into..."

Revert submission 20579518-hardware_buffer_renderer

Reason for revert: The submission timing tracks with a major regression in CtsUiRenderingTestCases stability: https://screenshot.googleplex.com/3TxXCSP4xCZq7Zy.png and also some crash bugs, eg: https://b.corp.google.com/issues/264889058

Reverting to re-stabilize the tree

Reverted changes: /q/submissionid:20579518-hardware_buffer_renderer

Change-Id: I29f47da097257bdeaa963fccb9ad0dbe39ead063
diff --git a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
index 202a62c..19cd7bd 100644
--- a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
+++ b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
@@ -55,9 +55,7 @@
 MakeCurrentResult SkiaOpenGLPipeline::makeCurrent() {
     // In case the surface was destroyed (e.g. a previous trimMemory call) we
     // need to recreate it here.
-    if (mHardwareBuffer) {
-        mRenderThread.requireGlContext();
-    } else if (!isSurfaceReady() && mNativeWindow) {
+    if (!isSurfaceReady() && mNativeWindow) {
         setSurface(mNativeWindow.get(), mSwapBehavior);
     }
 
@@ -69,24 +67,17 @@
 }
 
 Frame SkiaOpenGLPipeline::getFrame() {
-    if (mHardwareBuffer) {
-        AHardwareBuffer_Desc description;
-        AHardwareBuffer_describe(mHardwareBuffer, &description);
-        return Frame(description.width, description.height, 0);
-    } else {
-        LOG_ALWAYS_FATAL_IF(mEglSurface == EGL_NO_SURFACE,
-                            "drawRenderNode called on a context with no surface!");
-        return mEglManager.beginFrame(mEglSurface);
-    }
+    LOG_ALWAYS_FATAL_IF(mEglSurface == EGL_NO_SURFACE,
+                        "drawRenderNode called on a context with no surface!");
+    return mEglManager.beginFrame(mEglSurface);
 }
 
 IRenderPipeline::DrawResult SkiaOpenGLPipeline::draw(
         const Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
         const LightGeometry& lightGeometry, LayerUpdateQueue* layerUpdateQueue,
         const Rect& contentDrawBounds, bool opaque, const LightInfo& lightInfo,
-        const std::vector<sp<RenderNode>>& renderNodes, FrameInfoVisualizer* profiler,
-        const HardwareBufferRenderParams& bufferParams) {
-    if (!isCapturingSkp() && !mHardwareBuffer) {
+        const std::vector<sp<RenderNode>>& renderNodes, FrameInfoVisualizer* profiler) {
+    if (!isCapturingSkp()) {
         mEglManager.damageFrame(frame, dirty);
     }
 
@@ -113,25 +104,13 @@
     SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
 
     SkASSERT(mRenderThread.getGrContext() != nullptr);
-    sk_sp<SkSurface> surface;
-    SkMatrix preTransform;
-    if (mHardwareBuffer) {
-        surface = getBufferSkSurface(bufferParams);
-        preTransform = bufferParams.getTransform();
-    } else {
-        surface = SkSurface::MakeFromBackendRenderTarget(mRenderThread.getGrContext(), backendRT,
-                                                         getSurfaceOrigin(), colorType,
-                                                         mSurfaceColorSpace, &props);
-        preTransform = SkMatrix::I();
-    }
+    sk_sp<SkSurface> surface(SkSurface::MakeFromBackendRenderTarget(
+            mRenderThread.getGrContext(), backendRT, this->getSurfaceOrigin(), colorType,
+            mSurfaceColorSpace, &props));
 
-    SkPoint lightCenter = preTransform.mapXY(lightGeometry.center.x, lightGeometry.center.y);
-    LightGeometry localGeometry = lightGeometry;
-    localGeometry.center.x = lightCenter.fX;
-    localGeometry.center.y = lightCenter.fY;
-    LightingInfo::updateLighting(localGeometry, lightInfo);
+    LightingInfo::updateLighting(lightGeometry, lightInfo);
     renderFrame(*layerUpdateQueue, dirty, renderNodes, opaque, contentDrawBounds, surface,
-                preTransform);
+                SkMatrix::I());
 
     // Draw visual debugging features
     if (CC_UNLIKELY(Properties::showDirtyRegions ||
@@ -163,10 +142,6 @@
     // metrics the frame was swapped at this point
     currentFrameInfo->markSwapBuffers();
 
-    if (mHardwareBuffer) {
-        return false;
-    }
-
     *requireSwap = drew || mEglManager.damageRequiresSwap();
 
     if (*requireSwap && (CC_UNLIKELY(!mEglManager.swapBuffers(frame, screenDirty)))) {
@@ -222,26 +197,6 @@
     return false;
 }
 
-[[nodiscard]] android::base::unique_fd SkiaOpenGLPipeline::flush() {
-    int fence = -1;
-    EGLSyncKHR sync = EGL_NO_SYNC_KHR;
-    mEglManager.createReleaseFence(true, &sync, &fence);
-    // If a sync object is returned here then the device does not support native
-    // fences, we block on the returned sync and return -1 as a file descriptor
-    if (sync != EGL_NO_SYNC_KHR) {
-        EGLDisplay display = mEglManager.eglDisplay();
-        EGLint result = eglClientWaitSyncKHR(display, sync, 0, 1000000000);
-        if (result == EGL_FALSE) {
-            ALOGE("EglManager::createReleaseFence: error waiting for previous fence: %#x",
-                  eglGetError());
-        } else if (result == EGL_TIMEOUT_EXPIRED_KHR) {
-            ALOGE("EglManager::createReleaseFence: timeout waiting for previous fence");
-        }
-        eglDestroySyncKHR(display, sync);
-    }
-    return android::base::unique_fd(fence);
-}
-
 bool SkiaOpenGLPipeline::isSurfaceReady() {
     return CC_UNLIKELY(mEglSurface != EGL_NO_SURFACE);
 }