| 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 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 at draw time. | 23 at draw time. |
| 24 */ | 24 */ |
| 25 SkColorShader(); | 25 SkColorShader(); |
| 26 | 26 |
| 27 /** Create a ColorShader that ignores the color in the paint, and uses the | 27 /** 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 | 28 specified color. Note: like all shaders, at draw time the paint's alpha |
| 29 will be respected, and is applied to the specified color. | 29 will be respected, and is applied to the specified color. |
| 30 */ | 30 */ |
| 31 SkColorShader(SkColor c); | 31 SkColorShader(SkColor c); |
| 32 | 32 |
| 33 virtual ~SkColorShader(); |
| 34 |
| 35 virtual uint32_t getFlags() SK_OVERRIDE; |
| 36 virtual uint8_t getSpan16Alpha() const SK_OVERRIDE; |
| 33 virtual bool isOpaque() const SK_OVERRIDE; | 37 virtual bool isOpaque() const SK_OVERRIDE; |
| 34 | 38 virtual bool setContext(const SkBitmap& device, const SkPaint& paint, |
| 35 virtual SkShader::Context* createContext(const SkBitmap& device, | 39 const SkMatrix& matrix) SK_OVERRIDE; |
| 36 const SkPaint& paint, | 40 virtual void shadeSpan(int x, int y, SkPMColor span[], int count) SK_OVERRID
E; |
| 37 const SkMatrix& matrix, | 41 virtual void shadeSpan16(int x, int y, uint16_t span[], int count) SK_OVERRI
DE; |
| 38 void* storage) const SK_OVERRIDE; | 42 virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) SK_OVE
RRIDE; |
| 39 | |
| 40 virtual size_t contextSize() const SK_OVERRIDE { | |
| 41 return sizeof(ColorShaderContext); | |
| 42 } | |
| 43 | |
| 44 class ColorShaderContext : public SkShader::Context { | |
| 45 public: | |
| 46 ColorShaderContext(const SkColorShader& shader, const SkBitmap& device, | |
| 47 const SkPaint& paint, const SkMatrix& matrix); | |
| 48 | |
| 49 virtual uint32_t getFlags() const SK_OVERRIDE; | |
| 50 virtual uint8_t getSpan16Alpha() const SK_OVERRIDE; | |
| 51 virtual void shadeSpan(int x, int y, SkPMColor span[], int count) SK_OVE
RRIDE; | |
| 52 virtual void shadeSpan16(int x, int y, uint16_t span[], int count) SK_OV
ERRIDE; | |
| 53 virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) SK
_OVERRIDE; | |
| 54 | |
| 55 private: | |
| 56 SkPMColor fPMColor; | |
| 57 uint32_t fFlags; | |
| 58 uint16_t fColor16; | |
| 59 | |
| 60 typedef SkShader::Context INHERITED; | |
| 61 }; | |
| 62 | 43 |
| 63 // we return false for this, use asAGradient | 44 // we return false for this, use asAGradient |
| 64 virtual BitmapType asABitmap(SkBitmap* outTexture, | 45 virtual BitmapType asABitmap(SkBitmap* outTexture, |
| 65 SkMatrix* outMatrix, | 46 SkMatrix* outMatrix, |
| 66 TileMode xy[2]) const SK_OVERRIDE; | 47 TileMode xy[2]) const SK_OVERRIDE; |
| 67 | 48 |
| 68 virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE; | 49 virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE; |
| 69 | 50 |
| 70 SK_TO_STRING_OVERRIDE() | 51 SK_TO_STRING_OVERRIDE() |
| 71 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader) | 52 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader) |
| 72 | 53 |
| 73 protected: | 54 protected: |
| 74 SkColorShader(SkReadBuffer&); | 55 SkColorShader(SkReadBuffer&); |
| 75 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 56 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
| 76 | 57 |
| 77 private: | 58 private: |
| 59 |
| 78 SkColor fColor; // ignored if fInheritColor is true | 60 SkColor fColor; // ignored if fInheritColor is true |
| 61 SkPMColor fPMColor; // cached after setContext() |
| 62 uint32_t fFlags; // cached after setContext() |
| 63 uint16_t fColor16; // cached after setContext() |
| 79 SkBool8 fInheritColor; | 64 SkBool8 fInheritColor; |
| 80 | 65 |
| 81 typedef SkShader INHERITED; | 66 typedef SkShader INHERITED; |
| 82 }; | 67 }; |
| 83 | 68 |
| 84 #endif | 69 #endif |
| OLD | NEW |