Delete a bunch of code

This removes the duality of DisplayList, removing a small amount of
overhead

Test: buids & hwuiunit passes

Change-Id: I8bb3a20e9ead1caec4b4a8a3e9f2c08f717a7096
diff --git a/libs/hwui/pipeline/skia/GLFunctorDrawable.h b/libs/hwui/pipeline/skia/GLFunctorDrawable.h
index af57d7d..d9e65c9 100644
--- a/libs/hwui/pipeline/skia/GLFunctorDrawable.h
+++ b/libs/hwui/pipeline/skia/GLFunctorDrawable.h
@@ -16,6 +16,8 @@
 
 #pragma once
 
+#include "GlFunctorLifecycleListener.h"
+
 #include <SkCanvas.h>
 #include <SkDrawable.h>
 
@@ -25,8 +27,6 @@
 namespace android {
 namespace uirenderer {
 
-class GlFunctorLifecycleListener;
-
 namespace skiapipeline {
 
 /**
diff --git a/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp b/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp
index 6c04d78..1b816fe 100644
--- a/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp
+++ b/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp
@@ -25,6 +25,19 @@
 namespace uirenderer {
 namespace skiapipeline {
 
+RenderNodeDrawable::RenderNodeDrawable(RenderNode* node, SkCanvas* canvas, bool composeLayer,
+                                       bool inReorderingSection)
+        : mRenderNode(node)
+        , mRecordedTransform(canvas->getTotalMatrix())
+        , mComposeLayer(composeLayer)
+        , mInReorderingSection(inReorderingSection) {}
+
+RenderNodeDrawable::~RenderNodeDrawable() {
+    // Just here to move the destructor into the cpp file where we can access RenderNode.
+
+    // TODO: Detangle the header nightmare.
+}
+
 void RenderNodeDrawable::drawBackwardsProjectedNodes(SkCanvas* canvas,
                                                      const SkiaDisplayList& displayList,
                                                      int nestLevel) {
@@ -115,7 +128,6 @@
         return;
     }
 
-    SkASSERT(renderNode->getDisplayList()->isSkiaDL());
     SkiaDisplayList* displayList = (SkiaDisplayList*)renderNode->getDisplayList();
 
     SkAutoCanvasRestore acr(canvas, true);
diff --git a/libs/hwui/pipeline/skia/RenderNodeDrawable.h b/libs/hwui/pipeline/skia/RenderNodeDrawable.h
index ef21cd8..6594bd22 100644
--- a/libs/hwui/pipeline/skia/RenderNodeDrawable.h
+++ b/libs/hwui/pipeline/skia/RenderNodeDrawable.h
@@ -47,11 +47,9 @@
      *      layer into the canvas.
      */
     explicit RenderNodeDrawable(RenderNode* node, SkCanvas* canvas, bool composeLayer = true,
-                                bool inReorderingSection = false)
-            : mRenderNode(node)
-            , mRecordedTransform(canvas->getTotalMatrix())
-            , mComposeLayer(composeLayer)
-            , mInReorderingSection(inReorderingSection) {}
+                                bool inReorderingSection = false);
+
+    ~RenderNodeDrawable();
 
     /**
      * Draws into the canvas this render node and its children. If the node is marked as a
diff --git a/libs/hwui/pipeline/skia/SkiaDisplayList.h b/libs/hwui/pipeline/skia/SkiaDisplayList.h
index 818ec11..58b9242 100644
--- a/libs/hwui/pipeline/skia/SkiaDisplayList.h
+++ b/libs/hwui/pipeline/skia/SkiaDisplayList.h
@@ -16,10 +16,11 @@
 
 #pragma once
 
-#include "DisplayList.h"
 #include "hwui/AnimatedImageDrawable.h"
 #include "GLFunctorDrawable.h"
 #include "RenderNodeDrawable.h"
+#include "TreeInfo.h"
+#include "utils/LinearAllocator.h"
 
 #include <SkLiteDL.h>
 #include <SkLiteRecorder.h>
@@ -28,8 +29,17 @@
 namespace android {
 namespace uirenderer {
 
+namespace renderthread {
+class CanvasContext;
+}
+
 class Outline;
 
+namespace VectorDrawable {
+class Tree;
+};
+typedef uirenderer::VectorDrawable::Tree VectorDrawableRoot;
+
 namespace skiapipeline {
 
 /**
@@ -38,10 +48,14 @@
  * runtime.  The downside of this inheritance is that we pay for the overhead
  * of the parent class construction/destruction without any real benefit.
  */
-class SkiaDisplayList : public DisplayList {
+class SkiaDisplayList {
 public:
-    SkiaDisplayList() { SkASSERT(projectionReceiveIndex == -1); }
-    virtual ~SkiaDisplayList() {
+    // index of DisplayListOp restore, after which projected descendants should be drawn
+    int projectionReceiveIndex = -1;
+
+    size_t getUsedSize() { return allocator.usedSize(); }
+
+    ~SkiaDisplayList() {
         /* Given that we are using a LinearStdAllocator to store some of the
          * SkDrawable contents we must ensure that any other object that is
          * holding a reference to those drawables is destroyed prior to their
@@ -68,29 +82,27 @@
         return allocator.create<T>(std::forward<Params>(params)...);
     }
 
-    bool isSkiaDL() const override { return true; }
-
     /**
      * Returns true if the DisplayList does not have any recorded content
      */
-    bool isEmpty() const override { return mDisplayList.empty(); }
+    bool isEmpty() const { return mDisplayList.empty(); }
 
     /**
      * Returns true if this list directly contains a GLFunctor drawing command.
      */
-    bool hasFunctor() const override { return !mChildFunctors.empty(); }
+    bool hasFunctor() const { return !mChildFunctors.empty(); }
 
     /**
      * Returns true if this list directly contains a VectorDrawable drawing command.
      */
-    bool hasVectorDrawables() const override { return !mVectorDrawables.empty(); }
+    bool hasVectorDrawables() const { return !mVectorDrawables.empty(); }
 
     /**
      * Attempts to reset and reuse this DisplayList.
      *
      * @return true if the displayList will be reused and therefore should not be deleted
      */
-    bool reuseDisplayList(RenderNode* node, renderthread::CanvasContext* context) override;
+    bool reuseDisplayList(RenderNode* node, renderthread::CanvasContext* context);
 
     /**
      * ONLY to be called by RenderNode::syncDisplayList so that we can notify any
@@ -99,7 +111,7 @@
      * NOTE: This function can be folded into RenderNode when we no longer need
      *       to subclass from DisplayList
      */
-    void syncContents() override;
+    void syncContents();
 
     /**
      * ONLY to be called by RenderNode::prepareTree in order to prepare this
@@ -116,12 +128,12 @@
 
     bool prepareListAndChildren(
             TreeObserver& observer, TreeInfo& info, bool functorsNeedLayer,
-            std::function<void(RenderNode*, TreeObserver&, TreeInfo&, bool)> childFn) override;
+            std::function<void(RenderNode*, TreeObserver&, TreeInfo&, bool)> childFn);
 
     /**
      *  Calls the provided function once for each child of this DisplayList
      */
-    void updateChildren(std::function<void(RenderNode*)> updateFn) override;
+    void updateChildren(std::function<void(RenderNode*)> updateFn);
 
     /**
      *  Returns true if there is a child render node that is a projection receiver.
@@ -134,7 +146,9 @@
 
     void draw(SkCanvas* canvas) { mDisplayList.draw(canvas); }
 
-    void output(std::ostream& output, uint32_t level) override;
+    void output(std::ostream& output, uint32_t level);
+
+    LinearAllocator allocator;
 
     /**
      * We use std::deque here because (1) we need to iterate through these
diff --git a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
index cfcfd2b..15277f1 100644
--- a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
+++ b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
@@ -25,6 +25,7 @@
 #include "renderstate/RenderState.h"
 #include "renderthread/EglManager.h"
 #include "renderthread/Frame.h"
+#include "utils/GLUtils.h"
 #include "utils/TraceUtils.h"
 
 #include <GrBackendSurface.h>
@@ -58,10 +59,10 @@
 }
 
 bool SkiaOpenGLPipeline::draw(const Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
-                              const FrameBuilder::LightGeometry& lightGeometry,
+                              const LightGeometry& lightGeometry,
                               LayerUpdateQueue* layerUpdateQueue, const Rect& contentDrawBounds,
                               bool opaque, bool wideColorGamut,
-                              const BakedOpRenderer::LightInfo& lightInfo,
+                              const LightInfo& lightInfo,
                               const std::vector<sp<RenderNode>>& renderNodes,
                               FrameInfoVisualizer* profiler) {
     mEglManager.damageFrame(frame, dirty);
diff --git a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.h b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.h
index ef5d934..04b68f5 100644
--- a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.h
+++ b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.h
@@ -33,9 +33,9 @@
     renderthread::MakeCurrentResult makeCurrent() override;
     renderthread::Frame getFrame() override;
     bool draw(const renderthread::Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
-              const FrameBuilder::LightGeometry& lightGeometry, LayerUpdateQueue* layerUpdateQueue,
+              const LightGeometry& lightGeometry, LayerUpdateQueue* layerUpdateQueue,
               const Rect& contentDrawBounds, bool opaque, bool wideColorGamut,
-              const BakedOpRenderer::LightInfo& lightInfo,
+              const LightInfo& lightInfo,
               const std::vector<sp<RenderNode> >& renderNodes,
               FrameInfoVisualizer* profiler) override;
     bool swapBuffers(const renderthread::Frame& frame, bool drew, const SkRect& screenDirty,
diff --git a/libs/hwui/pipeline/skia/SkiaPipeline.cpp b/libs/hwui/pipeline/skia/SkiaPipeline.cpp
index d66cba1..988981d 100644
--- a/libs/hwui/pipeline/skia/SkiaPipeline.cpp
+++ b/libs/hwui/pipeline/skia/SkiaPipeline.cpp
@@ -81,9 +81,9 @@
     mVectorDrawables.clear();
 }
 
-void SkiaPipeline::renderLayers(const FrameBuilder::LightGeometry& lightGeometry,
+void SkiaPipeline::renderLayers(const LightGeometry& lightGeometry,
                                 LayerUpdateQueue* layerUpdateQueue, bool opaque,
-                                bool wideColorGamut, const BakedOpRenderer::LightInfo& lightInfo) {
+                                bool wideColorGamut, const LightInfo& lightInfo) {
     updateLighting(lightGeometry, lightInfo);
     ATRACE_NAME("draw layers");
     renderVectorDrawableCache();
@@ -103,7 +103,6 @@
         // as not to lose info on what portion is damaged
         if (CC_LIKELY(layerNode->getLayerSurface() != nullptr)) {
             SkASSERT(layerNode->getLayerSurface());
-            SkASSERT(layerNode->getDisplayList()->isSkiaDL());
             SkiaDisplayList* displayList = (SkiaDisplayList*)layerNode->getDisplayList();
             if (!displayList || displayList->isEmpty()) {
                 SkDEBUGF(("%p drawLayers(%s) : missing drawable", layerNode, layerNode->getName()));
diff --git a/libs/hwui/pipeline/skia/SkiaPipeline.h b/libs/hwui/pipeline/skia/SkiaPipeline.h
index 38ad9c0..8c9c803 100644
--- a/libs/hwui/pipeline/skia/SkiaPipeline.h
+++ b/libs/hwui/pipeline/skia/SkiaPipeline.h
@@ -17,7 +17,7 @@
 #pragma once
 
 #include <SkSurface.h>
-#include "FrameBuilder.h"
+#include "Lighting.h"
 #include "hwui/AnimatedImageDrawable.h"
 #include "renderthread/CanvasContext.h"
 #include "renderthread/IRenderPipeline.h"
@@ -42,9 +42,9 @@
     void unpinImages() override;
     void onPrepareTree() override;
 
-    void renderLayers(const FrameBuilder::LightGeometry& lightGeometry,
+    void renderLayers(const LightGeometry& lightGeometry,
                       LayerUpdateQueue* layerUpdateQueue, bool opaque, bool wideColorGamut,
-                      const BakedOpRenderer::LightInfo& lightInfo) override;
+                      const LightInfo& lightInfo) override;
 
     bool createOrUpdateLayer(RenderNode* node, const DamageAccumulator& damageAccumulator,
                              bool wideColorGamut, ErrorHandler* errorHandler) override;
@@ -97,8 +97,8 @@
         return mLightCenter;
     }
 
-    static void updateLighting(const FrameBuilder::LightGeometry& lightGeometry,
-                               const BakedOpRenderer::LightInfo& lightInfo) {
+    static void updateLighting(const LightGeometry& lightGeometry,
+                               const LightInfo& lightInfo) {
         mLightRadius = lightGeometry.radius;
         mAmbientShadowAlpha = lightInfo.ambientShadowAlpha;
         mSpotShadowAlpha = lightInfo.spotShadowAlpha;
diff --git a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp
index 5825060..b2519fe 100644
--- a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp
+++ b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp
@@ -62,10 +62,10 @@
 }
 
 bool SkiaVulkanPipeline::draw(const Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
-                              const FrameBuilder::LightGeometry& lightGeometry,
+                              const LightGeometry& lightGeometry,
                               LayerUpdateQueue* layerUpdateQueue, const Rect& contentDrawBounds,
                               bool opaque, bool wideColorGamut,
-                              const BakedOpRenderer::LightInfo& lightInfo,
+                              const LightInfo& lightInfo,
                               const std::vector<sp<RenderNode>>& renderNodes,
                               FrameInfoVisualizer* profiler) {
     sk_sp<SkSurface> backBuffer = mVkSurface->getBackBufferSurface();
diff --git a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.h b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.h
index 03b4c79..7806b42 100644
--- a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.h
+++ b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.h
@@ -31,9 +31,9 @@
     renderthread::MakeCurrentResult makeCurrent() override;
     renderthread::Frame getFrame() override;
     bool draw(const renderthread::Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
-              const FrameBuilder::LightGeometry& lightGeometry, LayerUpdateQueue* layerUpdateQueue,
+              const LightGeometry& lightGeometry, LayerUpdateQueue* layerUpdateQueue,
               const Rect& contentDrawBounds, bool opaque, bool wideColorGamut,
-              const BakedOpRenderer::LightInfo& lightInfo,
+              const LightInfo& lightInfo,
               const std::vector<sp<RenderNode> >& renderNodes,
               FrameInfoVisualizer* profiler) override;
     bool swapBuffers(const renderthread::Frame& frame, bool drew, const SkRect& screenDirty,