diff options
Diffstat (limited to 'libs/hwui/Layer.h')
-rw-r--r-- | libs/hwui/Layer.h | 81 |
1 files changed, 42 insertions, 39 deletions
diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h index d41c9703e908..e4f96e914c36 100644 --- a/libs/hwui/Layer.h +++ b/libs/hwui/Layer.h @@ -16,15 +16,15 @@ #pragma once -#include <GpuMemoryTracker.h> #include <utils/RefBase.h> +#include <SkBlendMode.h> #include <SkColorFilter.h> #include <SkColorSpace.h> -#include <SkBlendMode.h> #include <SkPaint.h> - -#include "Matrix.h" +#include <SkImage.h> +#include <SkMatrix.h> +#include <system/graphics.h> namespace android { namespace uirenderer { @@ -38,26 +38,21 @@ class RenderState; /** * A layer has dimensions and is backed by a backend specific texture or framebuffer. */ -class Layer : public VirtualLightRefBase, GpuMemoryTracker { +class Layer : public VirtualLightRefBase { public: - enum class Api { - OpenGL = 0, - Vulkan = 1, - }; - - Api getApi() const { return mApi; } + Layer(RenderState& renderState, sk_sp<SkColorFilter>, int alpha, SkBlendMode mode); ~Layer(); - virtual uint32_t getWidth() const = 0; + uint32_t getWidth() const { return mWidth; } - virtual uint32_t getHeight() const = 0; + uint32_t getHeight() const { return mHeight; } - virtual void setSize(uint32_t width, uint32_t height) = 0; + void setSize(uint32_t width, uint32_t height) { mWidth = width; mHeight = height; } - virtual void setBlend(bool blend) = 0; + void setBlend(bool blend) { mBlend = blend; } - virtual bool isBlend() const = 0; + bool isBlend() const { return mBlend; } inline void setForceFilter(bool forceFilter) { this->forceFilter = forceFilter; } @@ -72,7 +67,7 @@ public: inline int getAlpha() const { return alpha; } - virtual SkBlendMode getMode() const { return mode; } + SkBlendMode getMode() const; inline SkColorFilter* getColorFilter() const { return mColorFilter.get(); } @@ -84,9 +79,9 @@ public: inline sk_sp<SkColorFilter> getColorSpaceWithFilter() const { return mColorSpaceWithFilter; } - inline mat4& getTexTransform() { return texTransform; } + inline SkMatrix& getTexTransform() { return texTransform; } - inline mat4& getTransform() { return transform; } + inline SkMatrix& getTransform() { return transform; } /** * Posts a decStrong call to the appropriate thread. @@ -94,31 +89,17 @@ public: */ void postDecStrong(); - inline void setBufferSize(uint32_t width, uint32_t height) { - mBufferWidth = width; - mBufferHeight = height; - } - - inline uint32_t getBufferWidth() const { return mBufferWidth; } + inline void setImage(const sk_sp<SkImage>& image) { this->layerImage = image; } - inline uint32_t getBufferHeight() const { return mBufferHeight; } + inline sk_sp<SkImage> getImage() const { return this->layerImage; } protected: - Layer(RenderState& renderState, Api api, sk_sp<SkColorFilter>, int alpha, - SkBlendMode mode); RenderState& mRenderState; - /** - * Blending mode of the layer. - */ - SkBlendMode mode; - private: void buildColorSpaceWithFilter(); - Api mApi; - /** * Color filter used to draw this layer. Optional. */ @@ -145,18 +126,40 @@ private: int alpha; /** + * Blending mode of the layer. + */ + SkBlendMode mode; + + /** * Optional texture coordinates transform. */ - mat4 texTransform; + SkMatrix texTransform; /** * Optional transform. */ - mat4 transform; + SkMatrix transform; + + /** + * An image backing the layer. + */ + sk_sp<SkImage> layerImage; + + /** + * layer width. + */ + uint32_t mWidth = 0; - uint32_t mBufferWidth = 0; + /** + * layer height. + */ + uint32_t mHeight = 0; + + /** + * enable blending + */ + bool mBlend = false; - uint32_t mBufferHeight = 0; }; // struct Layer }; // namespace uirenderer |