| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2007 The Android Open Source Project | 3 * Copyright 2007 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #ifndef SkColorShader_DEFINED | 10 #ifndef SkColorShader_DEFINED |
| 11 #define SkColorShader_DEFINED | 11 #define SkColorShader_DEFINED |
| 12 | 12 |
| 13 #include "SkShader.h" | 13 #include "SkShader.h" |
| 14 | 14 |
| 15 /** \class SkColorShader | 15 /** \class SkColorShader |
| 16 A Shader that represents a single color. In general, this effect can be | 16 A Shader that represents a single color. In general, this effect can be |
| 17 accomplished by just using the color field on the paint, but if an | 17 accomplished by just using the color field on the paint, but if an |
| 18 actual shader object is needed, this provides that feature. | 18 actual shader object is needed, this provides that feature. |
| 19 */ | 19 */ |
| 20 class SK_API SkColorShader : public SkShader { | 20 class SK_API SkColorShader : public SkShader { |
| 21 public: | 21 public: |
| 22 /** Create a ColorShader that will inherit its color from the Paint | |
| 23 at draw time. | |
| 24 */ | |
| 25 SkColorShader(); | |
| 26 | |
| 27 /** Create a ColorShader that ignores the color in the paint, and uses the | 22 /** Create a ColorShader that ignores the color in the paint, and uses the |
| 28 specified color. Note: like all shaders, at draw time the paint's alpha | 23 specified color. Note: like all shaders, at draw time the paint's alpha |
| 29 will be respected, and is applied to the specified color. | 24 will be respected, and is applied to the specified color. |
| 30 */ | 25 */ |
| 31 SkColorShader(SkColor c); | 26 explicit SkColorShader(SkColor c); |
| 32 | 27 |
| 33 virtual bool isOpaque() const SK_OVERRIDE; | 28 virtual bool isOpaque() const SK_OVERRIDE; |
| 34 | 29 |
| 35 virtual SkShader::Context* createContext(const SkBitmap& device, | 30 virtual SkShader::Context* createContext(const SkBitmap& device, |
| 36 const SkPaint& paint, | 31 const SkPaint& paint, |
| 37 const SkMatrix& matrix, | 32 const SkMatrix& matrix, |
| 38 void* storage) const SK_OVERRIDE; | 33 void* storage) const SK_OVERRIDE; |
| 39 | 34 |
| 40 virtual size_t contextSize() const SK_OVERRIDE { | 35 virtual size_t contextSize() const SK_OVERRIDE { |
| 41 return sizeof(ColorShaderContext); | 36 return sizeof(ColorShaderContext); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 58 uint16_t fColor16; | 53 uint16_t fColor16; |
| 59 | 54 |
| 60 typedef SkShader::Context INHERITED; | 55 typedef SkShader::Context INHERITED; |
| 61 }; | 56 }; |
| 62 | 57 |
| 63 // we return false for this, use asAGradient | 58 // we return false for this, use asAGradient |
| 64 virtual BitmapType asABitmap(SkBitmap* outTexture, | 59 virtual BitmapType asABitmap(SkBitmap* outTexture, |
| 65 SkMatrix* outMatrix, | 60 SkMatrix* outMatrix, |
| 66 TileMode xy[2]) const SK_OVERRIDE; | 61 TileMode xy[2]) const SK_OVERRIDE; |
| 67 | 62 |
| 68 virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE; | 63 virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE; |
| 69 | 64 |
| 70 SK_TO_STRING_OVERRIDE() | 65 SK_TO_STRING_OVERRIDE() |
| 71 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader) | 66 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader) |
| 72 | 67 |
| 73 protected: | 68 protected: |
| 74 SkColorShader(SkReadBuffer&); | 69 SkColorShader(SkReadBuffer&); |
| 75 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 70 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
| 76 | 71 |
| 77 private: | 72 private: |
| 78 SkColor fColor; // ignored if fInheritColor is true | 73 SkColor fColor; // ignored if fInheritColor is true |
| 79 SkBool8 fInheritColor; | |
| 80 | 74 |
| 81 typedef SkShader INHERITED; | 75 typedef SkShader INHERITED; |
| 82 }; | 76 }; |
| 83 | 77 |
| 84 #endif | 78 #endif |
| OLD | NEW |