/* * Copyright 2019 Google LLC * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkRuntimeEffect_DEFINED #define SkRuntimeEffect_DEFINED #include "include/core/SkBlender.h" // IWYU pragma: keep #include "include/core/SkColorFilter.h" // IWYU pragma: keep #include "include/core/SkData.h" #include "include/core/SkFlattenable.h" #include "include/core/SkMatrix.h" #include "include/core/SkRefCnt.h" #include "include/core/SkShader.h" #include "include/core/SkSpan.h" #include "include/core/SkString.h" #include "include/core/SkTypes.h" #include "include/private/SkSLSampleUsage.h" #include "include/private/base/SkOnce.h" #include "include/private/base/SkTemplates.h" #include "include/private/base/SkTo.h" #include "include/private/base/SkTypeTraits.h" #include "include/sksl/SkSLDebugTrace.h" #include "include/sksl/SkSLVersion.h" #include <cstddef> #include <cstdint> #include <cstring> #include <memory> #include <optional> #include <string> #include <string_view> #include <utility> #include <vector> struct SkIPoint; namespace SkSL { class DebugTracePriv; class FunctionDefinition; struct Program; enum class ProgramKind : int8_t; struct ProgramSettings; } // namespace SkSL namespace SkSL::RP { class Program; } /* * SkRuntimeEffect supports creating custom SkShader and SkColorFilter objects using Skia's SkSL * shading language. * * NOTE: This API is experimental and subject to change. */ class SK_API SkRuntimeEffect : public SkRefCnt { … }; /** Base class for SkRuntimeShaderBuilder, defined below. */ class SkRuntimeEffectBuilder { … }; /** * SkRuntimeShaderBuilder is a utility to simplify creating SkShader objects from SkRuntimeEffects. * * NOTE: Like SkRuntimeEffect, this API is experimental and subject to change! * * Given an SkRuntimeEffect, the SkRuntimeShaderBuilder manages creating an input data block and * provides named access to the 'uniform' variables in that block, as well as named access * to a list of child shader slots. Usage: * * sk_sp<SkRuntimeEffect> effect = ...; * SkRuntimeShaderBuilder builder(effect); * builder.uniform("some_uniform_float") = 3.14f; * builder.uniform("some_uniform_matrix") = SkM44::Rotate(...); * builder.child("some_child_effect") = mySkImage->makeShader(...); * ... * sk_sp<SkShader> shader = builder.makeShader(nullptr, false); * * Note that SkRuntimeShaderBuilder is built entirely on the public API of SkRuntimeEffect, * so can be used as-is or serve as inspiration for other interfaces or binding techniques. */ class SK_API SkRuntimeShaderBuilder : public SkRuntimeEffectBuilder { … }; /** * SkRuntimeColorFilterBuilder makes it easy to setup and assign uniforms to runtime color filters. */ class SK_API SkRuntimeColorFilterBuilder : public SkRuntimeEffectBuilder { … }; /** * SkRuntimeBlendBuilder is a utility to simplify creation and uniform setup of runtime blenders. */ class SK_API SkRuntimeBlendBuilder : public SkRuntimeEffectBuilder { … }; #endif // SkRuntimeEffect_DEFINED