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

Unified Diff: include/core/SkColorShader.h

Issue 207683004: Extract most of the mutable state of SkShader into a separate Context object. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 8 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 | « no previous file | include/core/SkComposeShader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkColorShader.h
diff --git a/include/core/SkColorShader.h b/include/core/SkColorShader.h
index 975156c0eb3a9e10120a02a92070030a72d3912e..56e5add4a31a446667ed5c121f92432de9f80657 100644
--- a/include/core/SkColorShader.h
+++ b/include/core/SkColorShader.h
@@ -30,16 +30,35 @@ public:
*/
SkColorShader(SkColor c);
- virtual ~SkColorShader();
-
- virtual uint32_t getFlags() SK_OVERRIDE;
- virtual uint8_t getSpan16Alpha() const SK_OVERRIDE;
virtual bool isOpaque() const SK_OVERRIDE;
- virtual bool setContext(const SkBitmap& device, const SkPaint& paint,
- const SkMatrix& matrix) SK_OVERRIDE;
- virtual void shadeSpan(int x, int y, SkPMColor span[], int count) SK_OVERRIDE;
- virtual void shadeSpan16(int x, int y, uint16_t span[], int count) SK_OVERRIDE;
- virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) SK_OVERRIDE;
+
+ virtual SkShader::Context* createContext(const SkBitmap& device,
+ const SkPaint& paint,
+ const SkMatrix& matrix,
+ void* storage) const SK_OVERRIDE;
+
+ virtual size_t contextSize() const SK_OVERRIDE {
+ return sizeof(ColorShaderContext);
+ }
+
+ class ColorShaderContext : public SkShader::Context {
+ public:
+ ColorShaderContext(const SkColorShader& shader, const SkBitmap& device,
+ const SkPaint& paint, const SkMatrix& matrix);
+
+ virtual uint32_t getFlags() const SK_OVERRIDE;
+ virtual uint8_t getSpan16Alpha() const SK_OVERRIDE;
+ virtual void shadeSpan(int x, int y, SkPMColor span[], int count) SK_OVERRIDE;
+ virtual void shadeSpan16(int x, int y, uint16_t span[], int count) SK_OVERRIDE;
+ virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) SK_OVERRIDE;
+
+ private:
+ SkPMColor fPMColor;
+ uint32_t fFlags;
+ uint16_t fColor16;
+
+ typedef SkShader::Context INHERITED;
+ };
// we return false for this, use asAGradient
virtual BitmapType asABitmap(SkBitmap* outTexture,
@@ -56,11 +75,7 @@ protected:
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private:
-
SkColor fColor; // ignored if fInheritColor is true
- SkPMColor fPMColor; // cached after setContext()
- uint32_t fFlags; // cached after setContext()
- uint16_t fColor16; // cached after setContext()
SkBool8 fInheritColor;
typedef SkShader INHERITED;
« no previous file with comments | « no previous file | include/core/SkComposeShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698