Webview overlay support

The basic idea is to create a child surface control from the root surface control passed from ViewRootImpl to the render thread.

Transactions are sent back to the java layer to get merged.

In case of offscreen layers, SurfaceControl must be disabled.

This new feature is disabled for Vulkan at the moment, a new CL will be used to enable the support.

Bug: 173671170
Test: manual, webview apks
Change-Id: I119405d13eca3c59fd3ec78e50dc7739f78411d4
diff --git a/libs/hwui/renderthread/CanvasContext.h b/libs/hwui/renderthread/CanvasContext.h
index 74f426e..af1ebb2 100644
--- a/libs/hwui/renderthread/CanvasContext.h
+++ b/libs/hwui/renderthread/CanvasContext.h
@@ -109,6 +109,8 @@
      */
     GrDirectContext* getGrContext() const { return mRenderThread.getGrContext(); }
 
+    ASurfaceControl* getSurfaceControl() const { return mSurfaceControl; }
+
     // Won't take effect until next EGLSurface creation
     void setSwapBehavior(SwapBehavior swapBehavior);
 
@@ -201,6 +203,15 @@
     static void onSurfaceStatsAvailable(void* context, ASurfaceControl* control,
             ASurfaceControlStats* stats);
 
+    void setASurfaceTransactionCallback(
+            const std::function<void(int64_t, int64_t, int64_t)>& callback) {
+        mASurfaceTransactionCallback = callback;
+    }
+
+    bool mergeTransaction(ASurfaceTransaction* transaction, ASurfaceControl* control);
+
+    static CanvasContext* getActiveContext();
+
 private:
     CanvasContext(RenderThread& thread, bool translucent, RenderNode* rootRenderNode,
                   IContextFactory* contextFactory, std::unique_ptr<IRenderPipeline> renderPipeline);
@@ -296,6 +307,8 @@
 
     // If set to true, we expect that callbacks into onSurfaceStatsAvailable
     bool mExpectSurfaceStats = false;
+
+    std::function<void(int64_t, int64_t, int64_t)> mASurfaceTransactionCallback;
 };
 
 } /* namespace renderthread */