| OLD | NEW |
| 1 | |
| 2 /* | 1 /* |
| 3 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 4 * | 3 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 7 */ | 6 */ |
| 8 | 7 |
| 9 | |
| 10 | |
| 11 #ifndef SkEmptyShader_DEFINED | 8 #ifndef SkEmptyShader_DEFINED |
| 12 #define SkEmptyShader_DEFINED | 9 #define SkEmptyShader_DEFINED |
| 13 | 10 |
| 14 #include "SkShader.h" | 11 #include "SkShader.h" |
| 15 | 12 |
| 13 // TODO: move this to private, as there is a public factory on SkShader |
| 14 |
| 16 /** | 15 /** |
| 17 * \class SkEmptyShader | 16 * \class SkEmptyShader |
| 18 * A Shader that always draws nothing. Its createContext always returns NULL. | 17 * A Shader that always draws nothing. Its createContext always returns NULL. |
| 19 */ | 18 */ |
| 20 class SK_API SkEmptyShader : public SkShader { | 19 class SK_API SkEmptyShader : public SkShader { |
| 21 public: | 20 public: |
| 22 SkEmptyShader() {} | 21 SkEmptyShader() {} |
| 23 | 22 |
| 24 virtual size_t contextSize() const SK_OVERRIDE { | 23 virtual size_t contextSize() const SK_OVERRIDE { |
| 25 // Even though createContext returns NULL we have to return a value of a
t least | 24 // Even though createContext returns NULL we have to return a value of a
t least |
| 26 // sizeof(SkShader::Context) to satisfy SkSmallAllocator. | 25 // sizeof(SkShader::Context) to satisfy SkSmallAllocator. |
| 27 return sizeof(SkShader::Context); | 26 return sizeof(SkShader::Context); |
| 28 } | 27 } |
| 29 | 28 |
| 30 virtual bool validContext(const ContextRec&, SkMatrix* totalInverse = NULL)
const SK_OVERRIDE { | |
| 31 return false; | |
| 32 } | |
| 33 | |
| 34 virtual SkShader::Context* createContext(const ContextRec&, void*) const SK_
OVERRIDE { | |
| 35 // validContext returns false. | |
| 36 return NULL; | |
| 37 } | |
| 38 | |
| 39 SK_TO_STRING_OVERRIDE() | 29 SK_TO_STRING_OVERRIDE() |
| 40 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmptyShader) | 30 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmptyShader) |
| 41 | 31 |
| 42 protected: | 32 protected: |
| 43 SkEmptyShader(SkReadBuffer& buffer) : INHERITED(buffer) {} | 33 SkEmptyShader(SkReadBuffer& buffer) : INHERITED(buffer) {} |
| 44 | 34 |
| 35 virtual SkShader::Context* onCreateContext(const ContextRec&, void*) const S
K_OVERRIDE { |
| 36 return NULL; |
| 37 } |
| 38 |
| 45 private: | 39 private: |
| 46 typedef SkShader INHERITED; | 40 typedef SkShader INHERITED; |
| 47 }; | 41 }; |
| 48 | 42 |
| 49 #endif | 43 #endif |
| OLD | NEW |