Chromium Code Reviews| 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 SkColorShader(SkColor c); |
|
mtklein
2014/04/22 21:49:07
Might take the opportunity to tag this as explicit
bsalomon
2014/04/23 15:22:29
Done.
| |
| 32 | 27 |
| 33 virtual ~SkColorShader(); | 28 virtual ~SkColorShader(); |
| 34 | 29 |
| 35 virtual uint32_t getFlags() SK_OVERRIDE; | 30 virtual uint32_t getFlags() SK_OVERRIDE; |
| 36 virtual uint8_t getSpan16Alpha() const SK_OVERRIDE; | 31 virtual uint8_t getSpan16Alpha() const SK_OVERRIDE; |
| 37 virtual bool isOpaque() const SK_OVERRIDE; | 32 virtual bool isOpaque() const SK_OVERRIDE; |
| 38 virtual bool setContext(const SkBitmap& device, const SkPaint& paint, | 33 virtual bool setContext(const SkBitmap& device, const SkPaint& paint, |
| 39 const SkMatrix& matrix) SK_OVERRIDE; | 34 const SkMatrix& matrix) SK_OVERRIDE; |
| 40 virtual void shadeSpan(int x, int y, SkPMColor span[], int count) SK_OVERRID E; | 35 virtual void shadeSpan(int x, int y, SkPMColor span[], int count) SK_OVERRID E; |
| 41 virtual void shadeSpan16(int x, int y, uint16_t span[], int count) SK_OVERRI DE; | 36 virtual void shadeSpan16(int x, int y, uint16_t span[], int count) SK_OVERRI DE; |
| 42 virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) SK_OVE RRIDE; | 37 virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) SK_OVE RRIDE; |
| 43 | 38 |
| 44 // we return false for this, use asAGradient | 39 // we return false for this, use asAGradient |
| 45 virtual BitmapType asABitmap(SkBitmap* outTexture, | 40 virtual BitmapType asABitmap(SkBitmap* outTexture, |
| 46 SkMatrix* outMatrix, | 41 SkMatrix* outMatrix, |
| 47 TileMode xy[2]) const SK_OVERRIDE; | 42 TileMode xy[2]) const SK_OVERRIDE; |
| 48 | 43 |
| 49 virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE; | 44 virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE; |
| 50 | 45 |
| 51 SK_TO_STRING_OVERRIDE() | 46 SK_TO_STRING_OVERRIDE() |
| 52 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader) | 47 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader) |
| 53 | 48 |
| 54 protected: | 49 protected: |
| 55 SkColorShader(SkReadBuffer&); | 50 SkColorShader(SkReadBuffer&); |
| 56 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 51 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
| 57 | 52 |
| 58 private: | 53 private: |
| 59 | 54 |
| 60 SkColor fColor; // ignored if fInheritColor is true | 55 SkColor fColor; // ignored if fInheritColor is true |
| 61 SkPMColor fPMColor; // cached after setContext() | 56 SkPMColor fPMColor; // cached after setContext() |
| 62 uint32_t fFlags; // cached after setContext() | 57 uint32_t fFlags; // cached after setContext() |
| 63 uint16_t fColor16; // cached after setContext() | 58 uint16_t fColor16; // cached after setContext() |
| 64 SkBool8 fInheritColor; | |
| 65 | 59 |
| 66 typedef SkShader INHERITED; | 60 typedef SkShader INHERITED; |
| 67 }; | 61 }; |
| 68 | 62 |
| 69 #endif | 63 #endif |
| OLD | NEW |