• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "SkShader.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 SK_API SkEmptyShader : public SkShader {
20 public:
SkEmptyShader()21     SkEmptyShader() {}
22 
23     SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmptyShader)24     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmptyShader)
25 
26 protected:
27     SkShader::Context* onMakeContext(const ContextRec&, SkArenaAlloc*) const override {
28         return nullptr;
29     }
30 
flatten(SkWriteBuffer & buffer)31     void flatten(SkWriteBuffer& buffer) const override {
32         // Do nothing.
33         // We just don't want to fall through to SkShader::flatten(),
34         // which will write data we don't care to serialize or decode.
35     }
36 
37 private:
38     typedef SkShader INHERITED;
39 };
40 
41 #endif
42