SkEmptyShader.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. #ifndef SkEmptyShader_DEFINED
  8. #define SkEmptyShader_DEFINED
  9. #include "src/shaders/SkShaderBase.h"
  10. // TODO: move this to private, as there is a public factory on SkShader
  11. /**
  12. * \class SkEmptyShader
  13. * A Shader that always draws nothing. Its createContext always returns nullptr.
  14. */
  15. class SkEmptyShader : public SkShaderBase {
  16. public:
  17. SkEmptyShader() {}
  18. protected:
  19. #ifdef SK_ENABLE_LEGACY_SHADERCONTEXT
  20. Context* onMakeContext(const ContextRec&, SkArenaAlloc*) const override {
  21. return nullptr;
  22. }
  23. #endif
  24. void flatten(SkWriteBuffer& buffer) const override {
  25. // Do nothing.
  26. // We just don't want to fall through to SkShader::flatten(),
  27. // which will write data we don't care to serialize or decode.
  28. }
  29. bool onAppendStages(const SkStageRec&) const override {
  30. return false;
  31. }
  32. private:
  33. SK_FLATTENABLE_HOOKS(SkEmptyShader)
  34. typedef SkShaderBase INHERITED;
  35. };
  36. #endif