Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Unified Diff: src/core/SkColorShader.h

Issue 1934313002: move colorshader into its own .cpp, add color4f variant (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: register for serialization, amend GM view for future picture expansion Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samplecode/GMSampleView.cpp ('k') | src/core/SkColorShader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « samplecode/GMSampleView.cpp ('k') | src/core/SkColorShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698