summaryrefslogtreecommitdiffstats
path: root/gfx/skia/skia/src/shaders/SkRTShader.h
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/skia/skia/src/shaders/SkRTShader.h')
-rw-r--r--gfx/skia/skia/src/shaders/SkRTShader.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/gfx/skia/skia/src/shaders/SkRTShader.h b/gfx/skia/skia/src/shaders/SkRTShader.h
new file mode 100644
index 0000000000..57d69c324e
--- /dev/null
+++ b/gfx/skia/skia/src/shaders/SkRTShader.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2019 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkRTShader_DEFINED
+#define SkRTShader_DEFINED
+
+#include "include/core/SkString.h"
+#include "include/private/SkMutex.h"
+#include "src/shaders/SkShaderBase.h"
+#include "src/sksl/SkSLByteCode.h"
+
+#if SK_SUPPORT_GPU
+#include "src/gpu/GrFragmentProcessor.h"
+#endif
+
+class SkData;
+class SkMatrix;
+
+class SkRTShader : public SkShaderBase {
+public:
+ SkRTShader(int index, SkString sksl, sk_sp<SkData> inputs, const SkMatrix* localMatrix,
+ bool isOpaque);
+
+ bool isOpaque() const override { return fIsOpaque; }
+
+#if SK_SUPPORT_GPU
+ std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
+#endif
+
+protected:
+ void flatten(SkWriteBuffer&) const override;
+ bool onAppendStages(const SkStageRec& rec) const override;
+
+private:
+ SK_FLATTENABLE_HOOKS(SkRTShader)
+
+ SkString fSkSL;
+ sk_sp<SkData> fInputs;
+ const uint32_t fUniqueID;
+ const bool fIsOpaque;
+
+ mutable SkMutex fByteCodeMutex;
+ mutable std::unique_ptr<SkSL::ByteCode> fByteCode;
+
+ typedef SkShaderBase INHERITED;
+};
+
+class SkRuntimeShaderFactory {
+public:
+ SkRuntimeShaderFactory(SkString sksl, bool isOpaque);
+
+ sk_sp<SkShader> make(sk_sp<SkData> inputs, const SkMatrix* localMatrix);
+
+private:
+ int fIndex;
+ SkString fSkSL;
+ bool fIsOpaque;
+};
+
+#endif