Index: src/core/SkColorShader.h |
diff --git a/src/core/SkColorShader.h b/src/core/SkColorShader.h |
index db71b6ef9fdc4cb6f12c12d7afa56e5b36de3d5d..f7e609498b8a96347b6bf44e6f2e08a11f164bb8 100644 |
--- a/src/core/SkColorShader.h |
+++ b/src/core/SkColorShader.h |
@@ -72,4 +72,60 @@ private: |
typedef SkShader INHERITED; |
}; |
+class SkColor4Shader : public SkShader { |
+public: |
+ SkColor4Shader(const SkColor4f&, sk_sp<SkColorSpace>); |
+ |
+ bool isOpaque() const override { |
+ return SkColorGetA(fCachedByteColor) == 255; |
+ } |
+ |
+ class Color4Context : public SkShader::Context { |
+ public: |
+ Color4Context(const SkColor4Shader& shader, const ContextRec&); |
+ |
+ uint32_t getFlags() const override; |
+ void shadeSpan(int x, int y, SkPMColor span[], int count) override; |
+ void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) override; |
+ void shadeSpan4f(int x, int y, SkPM4f[], int count) override; |
+ |
+ protected: |
+ bool onChooseBlitProcs(const SkImageInfo&, BlitState*) override; |
+ |
+ private: |
+ SkPM4f fPM4f; |
+ SkPMColor fPMColor; |
+ uint32_t fFlags; |
+ |
+ typedef SkShader::Context INHERITED; |
+ }; |
+ |
+ GradientType asAGradient(GradientInfo* info) const override; |
+ |
+#if SK_SUPPORT_GPU |
+ const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM, |
+ const SkMatrix*, SkFilterQuality) const override; |
+#endif |
+ |
+ SK_TO_STRING_OVERRIDE() |
+ SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader) |
+ |
+protected: |
+ SkColor4Shader(SkReadBuffer&); |
+ void flatten(SkWriteBuffer&) const override; |
+ Context* onCreateContext(const ContextRec&, void* storage) const override; |
+ size_t onContextSize(const ContextRec&) const override { return sizeof(Color4Context); } |
+ bool onAsLuminanceColor(SkColor* lum) const override { |
+ *lum = fCachedByteColor; |
+ return true; |
+ } |
+ |
+private: |
+ sk_sp<SkColorSpace> fColorSpace; |
+ const SkColor4f fColor4; |
+ const SkColor fCachedByteColor; |
+ |
+ typedef SkShader INHERITED; |
+}; |
+ |
#endif |