Break Layer class into Gl and Vulkan subclasses

Test: manual testing
Change-Id: Ibd2beed39de3ac6da7448e96496253cfe427dfbb
diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h
index 8e71cd1..3b639ee 100644
--- a/libs/hwui/Layer.h
+++ b/libs/hwui/Layer.h
@@ -16,25 +16,13 @@
 
 #pragma once
 
-#include <cutils/compiler.h>
-#include <sys/types.h>
-#include <utils/StrongPointer.h>
 #include <utils/RefBase.h>
-#include <memory>
-
-#include <GLES2/gl2.h>
 #include <GpuMemoryTracker.h>
 
-#include <ui/Region.h>
-
 #include <SkPaint.h>
 #include <SkBlendMode.h>
 
 #include "Matrix.h"
-#include "Rect.h"
-#include "RenderBuffer.h"
-#include "Texture.h"
-#include "Vertex.h"
 
 namespace android {
 namespace uirenderer {
@@ -43,49 +31,33 @@
 // Layers
 ///////////////////////////////////////////////////////////////////////////////
 
-// Forward declarations
-class Caches;
 class RenderState;
 
 /**
- * A layer has dimensions and is backed by an OpenGL texture or FBO.
+ * A layer has dimensions and is backed by a backend specific texture or framebuffer.
  */
 class Layer : public VirtualLightRefBase, GpuMemoryTracker {
 public:
-    // layer lifecycle, controlled from outside
-    enum class State {
-        Uncached = 0,
-        InCache = 1,
-        FailedToCache = 2,
-        RemovedFromCache = 3,
-        DeletedFromCache = 4,
-        InGarbageList = 5,
+    enum class Api {
+        OpenGL = 0,
+        Vulkan = 1,
     };
-    State state; // public for logging/debugging purposes
 
-    Layer(RenderState& renderState, uint32_t layerWidth, uint32_t layerHeight);
+    Api getApi() const {
+        return mApi;
+    }
+
     ~Layer();
 
-    inline uint32_t getWidth() const {
-        return texture.mWidth;
-    }
+    virtual uint32_t getWidth() const = 0;
 
-    inline uint32_t getHeight() const {
-        return texture.mHeight;
-    }
+    virtual uint32_t getHeight() const = 0;
 
-    void setSize(uint32_t width, uint32_t height) {
-        texture.updateSize(width, height, texture.internalFormat(), texture.format(),
-                texture.target());
-    }
+    virtual void setSize(uint32_t width, uint32_t height) = 0;
 
-    inline void setBlend(bool blend) {
-        texture.blend = blend;
-    }
+    virtual void setBlend(bool blend) = 0;
 
-    inline bool isBlend() const {
-        return texture.blend;
-    }
+    virtual bool isBlend() const = 0;
 
     inline void setForceFilter(bool forceFilter) {
         this->forceFilter = forceFilter;
@@ -112,50 +84,12 @@
         return mode;
     }
 
-    inline GLuint getTextureId() const {
-        return texture.id();
-    }
-
-    inline Texture& getTexture() {
-        return texture;
-    }
-
-    inline GLenum getRenderTarget() const {
-        return texture.target();
-    }
-
-    inline void setRenderTarget(GLenum renderTarget) {
-        texture.mTarget = renderTarget;
-    }
-
-    inline bool isRenderable() const {
-        return texture.target() != GL_NONE;
-    }
-
-    void setWrap(GLenum wrap, bool bindTexture = false, bool force = false) {
-        texture.setWrap(wrap, bindTexture, force);
-    }
-
-    void setFilter(GLenum filter, bool bindTexture = false, bool force = false) {
-        texture.setFilter(filter, bindTexture, force);
-    }
-
     inline SkColorFilter* getColorFilter() const {
         return colorFilter;
     }
 
     void setColorFilter(SkColorFilter* filter);
 
-    void bindTexture() const;
-    void generateTexture();
-
-    /**
-     * When the caller frees the texture itself, the caller
-     * must call this method to tell this layer that it lost
-     * the texture.
-     */
-    void clearTexture();
-
     inline mat4& getTexTransform() {
         return texTransform;
     }
@@ -170,21 +104,13 @@
      */
     void postDecStrong();
 
-    /**
-     * Lost the GL context but the layer is still around, mark it invalid internally
-     * so the dtor knows not to do any GL work
-     */
-    void onGlContextLost();
+protected:
+    Layer(RenderState& renderState, Api api);
+
+    RenderState& mRenderState;
 
 private:
-    Caches& caches;
-
-    RenderState& renderState;
-
-    /**
-     * The texture backing this layer.
-     */
-    Texture texture;
+    Api mApi;
 
     /**
      * Color filter used to draw this layer. Optional.