Initial HW layer support in new reorderer/renderer

Shares vast majority of clipped savelayer code, with only minor
differences in lifecycle.

Doesn't yet handle fill region, resize, or window transform.

Change-Id: Iabdd71811590d2b937eb11e1b01ce556ade54a5a
diff --git a/libs/hwui/unit_tests/TestUtils.h b/libs/hwui/unit_tests/TestUtils.h
index 5b09fda..770f413 100644
--- a/libs/hwui/unit_tests/TestUtils.h
+++ b/libs/hwui/unit_tests/TestUtils.h
@@ -89,15 +89,24 @@
         return std::unique_ptr<DisplayList>(canvas.finishRecording());
     }
 
-    template<class CanvasType>
-    static sp<RenderNode> createNode(int left, int top, int right, int bottom,
-            std::function<void(CanvasType& canvas)> canvasCallback) {
+    static sp<RenderNode> createNode(int left, int top, int right, int bottom, bool onLayer = false) {
         sp<RenderNode> node = new RenderNode();
         node->mutateStagingProperties().setLeftTopRightBottom(left, top, right, bottom);
         node->setPropertyFieldsDirty(RenderNode::X | RenderNode::Y);
+        if (onLayer) {
+            node->mutateStagingProperties().mutateLayerProperties().setType(LayerType::RenderLayer);
+            node->setPropertyFieldsDirty(RenderNode::GENERIC);
+        }
+        return node;
+    }
 
-        CanvasType canvas(
-                node->stagingProperties().getWidth(), node->stagingProperties().getHeight());
+    template<class CanvasType>
+    static sp<RenderNode> createNode(int left, int top, int right, int bottom,
+            std::function<void(CanvasType& canvas)> canvasCallback, bool onLayer = false) {
+        sp<RenderNode> node = createNode(left, top, right, bottom, onLayer);
+
+        auto&& props = node->stagingProperties(); // staging, since not sync'd yet
+        CanvasType canvas(props.getWidth(), props.getHeight());
         canvasCallback(canvas);
         node->setStagingDisplayList(canvas.finishRecording());
         return node;
@@ -108,7 +117,7 @@
         node->syncDisplayList();
     }
 
-    typedef std::function<void(RenderState& state, Caches& caches)> RtCallback;
+    typedef std::function<void(renderthread::RenderThread& thread)> RtCallback;
 
     class TestTask : public renderthread::RenderTask {
     public:
@@ -120,7 +129,7 @@
             RenderState& renderState = renderthread::RenderThread::getInstance().renderState();
 
             renderState.onGLContextCreated();
-            rtCallback(renderState, Caches::getInstance());
+            rtCallback(renderthread::RenderThread::getInstance());
             renderState.onGLContextDestroyed();
         };
         RtCallback rtCallback;