Created HardwareBufferRenderer to support rendering into
HardwareBuffer targets.

Relnote: "Created HardwareBufferRenderer API to handle
rendering a single frame into a HardwareBuffer target."

Refactored dlsym logic for dynamically resolving AHardwareBuffer
methods to be shared across multiple locations.

Bug: 255692581
Test: Created HardwareBufferRendererTests
Change-Id: I749b5d763a9ee580abc2d6cc87bd94a46b7abdd9
diff --git a/libs/hwui/renderthread/CanvasContext.h b/libs/hwui/renderthread/CanvasContext.h
index e875c42..3f796d9 100644
--- a/libs/hwui/renderthread/CanvasContext.h
+++ b/libs/hwui/renderthread/CanvasContext.h
@@ -125,12 +125,13 @@
     // Won't take effect until next EGLSurface creation
     void setSwapBehavior(SwapBehavior swapBehavior);
 
+    void setHardwareBuffer(AHardwareBuffer* buffer);
     void setSurface(ANativeWindow* window, bool enableTimeout = true);
     void setSurfaceControl(ASurfaceControl* surfaceControl);
     bool pauseSurface();
     void setStopped(bool stopped);
-    bool isStopped() { return mStopped || !hasSurface(); }
-    bool hasSurface() const { return mNativeSurface.get(); }
+    bool isStopped() { return mStopped || !hasOutputTarget(); }
+    bool hasOutputTarget() const { return mNativeSurface.get() || mHardwareBuffer; }
     void allocateBuffers();
 
     void setLightAlpha(uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha);
@@ -206,6 +207,10 @@
         mASurfaceTransactionCallback = callback;
     }
 
+    void setHardwareBufferRenderParams(const HardwareBufferRenderParams& params) {
+        mBufferParams = params;
+    }
+
     bool mergeTransaction(ASurfaceTransaction* transaction, ASurfaceControl* control);
 
     void setPrepareSurfaceControlForWebviewCallback(const std::function<void()>& callback) {
@@ -258,6 +263,9 @@
     int32_t mLastFrameHeight = 0;
 
     RenderThread& mRenderThread;
+
+    AHardwareBuffer* mHardwareBuffer = nullptr;
+    HardwareBufferRenderParams mBufferParams;
     std::unique_ptr<ReliableSurface> mNativeSurface;
     // The SurfaceControl reference is passed from ViewRootImpl, can be set to
     // NULL to remove the reference