diff options
author | Greg Daniel <egdaniel@google.com> | 2017-01-09 14:15:41 -0500 |
---|---|---|
committer | Greg Daniel <egdaniel@google.com> | 2017-01-10 15:05:07 -0500 |
commit | 8cd3edfa15cc9cdbffa935d19ab894426b08d174 (patch) | |
tree | 289ec13531b91be5adf6306d8d70434bc756b2c1 /libs/hwui/Layer.h | |
parent | d14cafc27255e0ed44665a0975a57c487b841ab1 (diff) |
Break Layer class into Gl and Vulkan subclasses
Test: manual testing
Change-Id: Ibd2beed39de3ac6da7448e96496253cfe427dfbb
Diffstat (limited to 'libs/hwui/Layer.h')
-rw-r--r-- | libs/hwui/Layer.h | 110 |
1 files changed, 18 insertions, 92 deletions
diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h index 8e71cd11599d..3b639ee49334 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 @@ namespace uirenderer { // 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 @@ public: 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 @@ public: */ 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(); - -private: - Caches& caches; +protected: + Layer(RenderState& renderState, Api api); - RenderState& renderState; + RenderState& mRenderState; - /** - * The texture backing this layer. - */ - Texture texture; +private: + Api mApi; /** * Color filter used to draw this layer. Optional. |