OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
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 | 10 |
11 #ifndef SkEmptyShader_DEFINED | 11 #ifndef SkEmptyShader_DEFINED |
12 #define SkEmptyShader_DEFINED | 12 #define SkEmptyShader_DEFINED |
13 | 13 |
14 #include "SkShader.h" | 14 #include "SkShader.h" |
15 | 15 |
16 /** | 16 /** |
17 * \class SkEmptyShader | 17 * \class SkEmptyShader |
18 * A Shader that always draws nothing. Its createContext always returns NULL. | 18 * A Shader that always draws nothing. Its setContext always returns false, |
| 19 * so it never expects that its shadeSpan() methods will get called. |
19 */ | 20 */ |
20 class SK_API SkEmptyShader : public SkShader { | 21 class SK_API SkEmptyShader : public SkShader { |
21 public: | 22 public: |
22 SkEmptyShader() {} | 23 SkEmptyShader() {} |
23 | 24 |
24 virtual size_t contextSize() const SK_OVERRIDE { | 25 virtual uint32_t getFlags() SK_OVERRIDE; |
25 // Even though createContext returns NULL we have to return a value of a
t least | 26 virtual uint8_t getSpan16Alpha() const SK_OVERRIDE; |
26 // sizeof(SkShader::Context) to satisfy SkSmallAllocator. | 27 virtual bool setContext(const SkBitmap&, const SkPaint&, |
27 return sizeof(SkShader::Context); | 28 const SkMatrix&) SK_OVERRIDE; |
28 } | 29 virtual void shadeSpan(int x, int y, SkPMColor span[], int count) SK_OVERRID
E; |
29 | 30 virtual void shadeSpan16(int x, int y, uint16_t span[], int count) SK_OVERRI
DE; |
30 virtual bool validContext(const SkBitmap&, const SkPaint&, | 31 virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) SK_OVE
RRIDE; |
31 const SkMatrix&, SkMatrix* totalInverse = NULL) co
nst SK_OVERRIDE { | |
32 return false; | |
33 } | |
34 | |
35 virtual SkShader::Context* createContext(const SkBitmap&, const SkPaint&, | |
36 const SkMatrix&, void*) const SK_OV
ERRIDE { | |
37 // validContext returns false. | |
38 return NULL; | |
39 } | |
40 | 32 |
41 SK_TO_STRING_OVERRIDE() | 33 SK_TO_STRING_OVERRIDE() |
42 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmptyShader) | 34 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmptyShader) |
43 | 35 |
44 protected: | 36 protected: |
45 SkEmptyShader(SkReadBuffer& buffer) : INHERITED(buffer) {} | 37 SkEmptyShader(SkReadBuffer& buffer) : INHERITED(buffer) {} |
46 | 38 |
47 private: | 39 private: |
48 typedef SkShader INHERITED; | 40 typedef SkShader INHERITED; |
49 }; | 41 }; |
50 | 42 |
51 #endif | 43 #endif |
OLD | NEW |