diff options
Diffstat (limited to 'libs/hwui/Layer.h')
| -rw-r--r-- | libs/hwui/Layer.h | 105 |
1 files changed, 45 insertions, 60 deletions
diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h index d41c9703e908..ea3bfc9e80cb 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,21 +67,15 @@ public: inline int getAlpha() const { return alpha; } - virtual SkBlendMode getMode() const { return mode; } - - inline SkColorFilter* getColorFilter() const { return mColorFilter.get(); } + SkBlendMode getMode() const; - void setColorFilter(sk_sp<SkColorFilter> filter); + inline sk_sp<SkColorFilter> getColorFilter() const { return mColorFilter; } - void setDataSpace(android_dataspace dataspace); + void setColorFilter(sk_sp<SkColorFilter> filter) { mColorFilter = filter; }; - void setColorSpace(sk_sp<SkColorSpace> colorSpace); + inline SkMatrix& getTexTransform() { return texTransform; } - inline sk_sp<SkColorFilter> getColorSpaceWithFilter() const { return mColorSpaceWithFilter; } - - inline mat4& getTexTransform() { return texTransform; } - - inline mat4& getTransform() { return transform; } + inline SkMatrix& getTransform() { return transform; } /** * Posts a decStrong call to the appropriate thread. @@ -94,70 +83,66 @@ 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; +private: /** - * Blending mode of the layer. + * Color filter used to draw this layer. Optional. */ - SkBlendMode mode; - -private: - void buildColorSpaceWithFilter(); + sk_sp<SkColorFilter> mColorFilter; - Api mApi; + /** + * Indicates raster data backing the layer is scaled, requiring filtration. + */ + bool forceFilter = false; /** - * Color filter used to draw this layer. Optional. + * Opacity of the layer. */ - sk_sp<SkColorFilter> mColorFilter; + int alpha; /** - * Colorspace of the contents of the layer. Optional. + * Blending mode of the layer. */ - android_dataspace mCurrentDataspace = HAL_DATASPACE_UNKNOWN; + SkBlendMode mode; /** - * A color filter that is the combination of the mColorFilter and mColorSpace. Optional. + * Optional texture coordinates transform. */ - sk_sp<SkColorFilter> mColorSpaceWithFilter; + SkMatrix texTransform; /** - * Indicates raster data backing the layer is scaled, requiring filtration. + * Optional transform. */ - bool forceFilter = false; + SkMatrix transform; /** - * Opacity of the layer. + * An image backing the layer. */ - int alpha; + sk_sp<SkImage> layerImage; /** - * Optional texture coordinates transform. + * layer width. */ - mat4 texTransform; + uint32_t mWidth = 0; /** - * Optional transform. + * layer height. */ - mat4 transform; + uint32_t mHeight = 0; - uint32_t mBufferWidth = 0; + /** + * enable blending + */ + bool mBlend = false; - uint32_t mBufferHeight = 0; }; // struct Layer -}; // namespace uirenderer -}; // namespace android +} // namespace uirenderer +} // namespace android |