1 | /* |
2 | * Copyright 2011 Google Inc. |
3 | * |
4 | * Use of this source code is governed by a BSD-style license that can be |
5 | * found in the LICENSE file. |
6 | */ |
7 | |
8 | #ifndef SkEmptyShader_DEFINED |
9 | #define SkEmptyShader_DEFINED |
10 | |
11 | #include "src/shaders/SkShaderBase.h" |
12 | |
13 | // TODO: move this to private, as there is a public factory on SkShader |
14 | |
15 | /** |
16 | * \class SkEmptyShader |
17 | * A Shader that always draws nothing. Its createContext always returns nullptr. |
18 | */ |
19 | class SkEmptyShader : public SkShaderBase { |
20 | public: |
21 | SkEmptyShader() {} |
22 | |
23 | protected: |
24 | #ifdef SK_ENABLE_LEGACY_SHADERCONTEXT |
25 | Context* onMakeContext(const ContextRec&, SkArenaAlloc*) const override { |
26 | return nullptr; |
27 | } |
28 | #endif |
29 | |
30 | void flatten(SkWriteBuffer& buffer) const override { |
31 | // Do nothing. |
32 | // We just don't want to fall through to SkShader::flatten(), |
33 | // which will write data we don't care to serialize or decode. |
34 | } |
35 | |
36 | bool onAppendStages(const SkStageRec&) const override { |
37 | return false; |
38 | } |
39 | |
40 | skvm::Color onProgram(skvm::Builder*, skvm::F32, skvm::F32, skvm::Color, const SkMatrix&, |
41 | const SkMatrix*, SkFilterQuality, const SkColorInfo&, skvm::Uniforms*, |
42 | SkArenaAlloc*) const override; |
43 | |
44 | private: |
45 | SK_FLATTENABLE_HOOKS(SkEmptyShader) |
46 | |
47 | typedef SkShaderBase INHERITED; |
48 | }; |
49 | |
50 | #endif |
51 | |