| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#pragma once |
| 18 |
|
| 19 |
#include <utils/RefBase.h> |
| 20 |
|
| 21 |
#include <SkBlendMode.h> |
| 22 |
#include <SkColorFilter.h> |
| 23 |
#include <SkColorSpace.h> |
| 24 |
#include <SkCanvas.h> |
| 25 |
#include <SkPaint.h> |
| 26 |
#include <SkImage.h> |
| 27 |
#include <SkMatrix.h> |
| 28 |
#include <system/graphics.h> |
| 29 |
|
| 30 |
namespace android { |
| 31 |
namespace uirenderer { |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
class RenderState; |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
class Layer : public VirtualLightRefBase { |
| 43 |
public: |
| 44 |
Layer(RenderState& renderState, sk_sp<SkColorFilter>, int alpha, SkBlendMode mode); |
| 45 |
|
| 46 |
~Layer(); |
| 47 |
|
| 48 |
uint32_t getWidth() const { return mWidth; } |
| 49 |
|
| 50 |
uint32_t getHeight() const { return mHeight; } |
| 51 |
|
| 52 |
void setSize(uint32_t width, uint32_t height) { mWidth = width; mHeight = height; } |
| 53 |
|
| 54 |
void setBlend(bool blend) { mBlend = blend; } |
| 55 |
|
| 56 |
bool isBlend() const { return mBlend; } |
| 57 |
|
| 58 |
inline void setForceFilter(bool forceFilter) { this->forceFilter = forceFilter; } |
| 59 |
|
| 60 |
inline bool getForceFilter() const { return forceFilter; } |
| 61 |
|
| 62 |
inline void setAlpha(int alpha) { this->alpha = alpha; } |
| 63 |
|
| 64 |
inline void setAlpha(int alpha, SkBlendMode mode) { |
| 65 |
this->alpha = alpha; |
| 66 |
this->mode = mode; |
| 67 |
} |
| 68 |
|
| 69 |
inline int getAlpha() const { return alpha; } |
| 70 |
|
| 71 |
SkBlendMode getMode() const; |
| 72 |
|
| 73 |
inline sk_sp<SkColorFilter> getColorFilter() const { return mColorFilter; } |
| 74 |
|
| 75 |
void setColorFilter(sk_sp<SkColorFilter> filter) { mColorFilter = filter; }; |
| 76 |
|
| 77 |
inline SkMatrix& getTransform() { return transform; } |
| 78 |
|
| 79 |
inline SkRect getCurrentCropRect() { return mCurrentCropRect; } |
| 80 |
|
| 81 |
inline void setCurrentCropRect(const SkRect currentCropRect) { |
| 82 |
mCurrentCropRect = currentCropRect; |
| 83 |
} |
| 84 |
|
| 85 |
inline void setWindowTransform(uint32_t windowTransform) { mWindowTransform = windowTransform; } |
| 86 |
|
| 87 |
inline uint32_t getWindowTransform() { return mWindowTransform; } |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
void postDecStrong(); |
| 94 |
|
| 95 |
inline void setImage(const sk_sp<SkImage>& image) { this->layerImage = image; } |
| 96 |
|
| 97 |
inline sk_sp<SkImage> getImage() const { return this->layerImage; } |
| 98 |
|
| 99 |
inline void setMaxLuminanceNits(float maxLuminanceNits) { |
| 100 |
mMaxLuminanceNits = maxLuminanceNits; |
| 101 |
} |
| 102 |
|
| 103 |
inline float getMaxLuminanceNits() { return mMaxLuminanceNits; } |
| 104 |
|
| 105 |
void setBufferFormat(uint32_t format) { mBufferFormat = format; } |
| 106 |
|
| 107 |
uint32_t getBufferFormat() const { return mBufferFormat; } |
| 108 |
|
| 109 |
void draw(SkCanvas* canvas); |
| 110 |
|
| 111 |
protected: |
| 112 |
|
| 113 |
RenderState& mRenderState; |
| 114 |
|
| 115 |
private: |
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
sk_sp<SkColorFilter> mColorFilter; |
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
bool forceFilter = false; |
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
int alpha; |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
SkBlendMode mode; |
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
SkMatrix transform; |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
SkRect mCurrentCropRect; |
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
uint32_t mWindowTransform; |
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
sk_sp<SkImage> layerImage; |
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
uint32_t mWidth = 0; |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
uint32_t mHeight = 0; |
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
bool mBlend = false; |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
float mMaxLuminanceNits = -1; |
| 175 |
|
| 176 |
uint32_t mBufferFormat = 0; |
| 177 |
|
| 178 |
}; |
| 179 |
|
| 180 |
} |
| 181 |
} |