SkRTShader.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright 2019 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 SkRTShader_DEFINED
  8. #define SkRTShader_DEFINED
  9. #include "include/core/SkString.h"
  10. #include "include/private/SkMutex.h"
  11. #include "src/shaders/SkShaderBase.h"
  12. #include "src/sksl/SkSLByteCode.h"
  13. #if SK_SUPPORT_GPU
  14. #include "src/gpu/GrFragmentProcessor.h"
  15. #endif
  16. class SkData;
  17. class SkMatrix;
  18. class SkRTShader : public SkShaderBase {
  19. public:
  20. SkRTShader(SkString sksl, sk_sp<SkData> inputs, const SkMatrix* localMatrix, bool isOpaque);
  21. bool isOpaque() const override { return fIsOpaque; }
  22. #if SK_SUPPORT_GPU
  23. std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
  24. #endif
  25. protected:
  26. void flatten(SkWriteBuffer&) const override;
  27. bool onAppendStages(const SkStageRec& rec) const override;
  28. private:
  29. SK_FLATTENABLE_HOOKS(SkRTShader)
  30. SkString fSkSL;
  31. sk_sp<SkData> fInputs;
  32. const uint32_t fUniqueID;
  33. const bool fIsOpaque;
  34. mutable SkMutex fByteCodeMutex;
  35. mutable std::unique_ptr<SkSL::ByteCode> fByteCode;
  36. typedef SkShaderBase INHERITED;
  37. };
  38. #endif