diff options
Diffstat (limited to 'chromium/third_party/skia/include/effects/SkRuntimeEffect.h')
-rw-r--r-- | chromium/third_party/skia/include/effects/SkRuntimeEffect.h | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/chromium/third_party/skia/include/effects/SkRuntimeEffect.h b/chromium/third_party/skia/include/effects/SkRuntimeEffect.h index 2f9b98928e3..24a2fc37256 100644 --- a/chromium/third_party/skia/include/effects/SkRuntimeEffect.h +++ b/chromium/third_party/skia/include/effects/SkRuntimeEffect.h @@ -25,6 +25,8 @@ #ifdef SK_ENABLE_SKSL +#include "include/sksl/SkSLVersion.h" + class GrRecordingContext; class SkFilterColorProgram; class SkImage; @@ -83,13 +85,17 @@ public: // When used with SkMeshSpecification, indicates that the uniform is present in the // fragment shader. Not used with SkRuntimeEffect. kFragment_Flag = 0x8, + + // This flag indicates that the SkSL uniform uses a medium-precision type + // (i.e., `half` instead of `float`). + kHalfPrecision_Flag = 0x10, }; - SkString name; - size_t offset; - Type type; - int count; - uint32_t flags; + std::string_view name; + size_t offset; + Type type; + int count; + uint32_t flags; bool isArray() const { return SkToBool(this->flags & kArray_Flag); } bool isColor() const { return SkToBool(this->flags & kColor_Flag); } @@ -104,9 +110,9 @@ public: }; struct Child { - SkString name; - ChildType type; - int index; + std::string_view name; + ChildType type; + int index; }; class Options { @@ -120,17 +126,16 @@ public: friend class SkRuntimeEffect; friend class SkRuntimeEffectPriv; + // Public SkSL does not allow access to sk_FragCoord. The semantics of that variable are + // confusing, and expose clients to implementation details of saveLayer and image filters. + bool usePrivateRTShaderModule = false; + // TODO(skia:11209) - Replace this with a promised SkCapabilities? // This flag lifts the ES2 restrictions on Runtime Effects that are gated by the // `strictES2Mode` check. Be aware that the software renderer and pipeline-stage effect are // still largely ES3-unaware and can still fail or crash if post-ES2 features are used. // This is only intended for use by tests and certain internally created effects. - bool enforceES2Restrictions = true; - - // Similarly: Public SkSL does not allow access to sk_FragCoord. The semantics of that - // variable are confusing, and expose clients to implementation details of saveLayer and - // image filters. - bool usePrivateRTShaderModule = false; + SkSL::Version maxVersionAllowed = SkSL::Version::k100; }; // If the effect is compiled successfully, `effect` will be non-null. @@ -245,14 +250,19 @@ public: // provide an SkData of this size, containing values for all of those variables. size_t uniformSize() const; - SkSpan<const Uniform> uniforms() const { return SkMakeSpan(fUniforms); } - SkSpan<const Child> children() const { return SkMakeSpan(fChildren); } + SkSpan<const Uniform> uniforms() const { return SkSpan(fUniforms); } + SkSpan<const Child> children() const { return SkSpan(fChildren); } // Returns pointer to the named uniform variable's description, or nullptr if not found - const Uniform* findUniform(const char* name) const; + const Uniform* findUniform(std::string_view name) const; // Returns pointer to the named child's description, or nullptr if not found - const Child* findChild(const char* name) const; + const Child* findChild(std::string_view name) const; + + // Allows the runtime effect type to be identified. + bool allowShader() const { return (fFlags & kAllowShader_Flag); } + bool allowColorFilter() const { return (fFlags & kAllowColorFilter_Flag); } + bool allowBlender() const { return (fFlags & kAllowBlender_Flag); } static void RegisterFlattenables(); ~SkRuntimeEffect() override; @@ -288,14 +298,11 @@ private: uint32_t hash() const { return fHash; } bool usesSampleCoords() const { return (fFlags & kUsesSampleCoords_Flag); } - bool allowShader() const { return (fFlags & kAllowShader_Flag); } - bool allowColorFilter() const { return (fFlags & kAllowColorFilter_Flag); } - bool allowBlender() const { return (fFlags & kAllowBlender_Flag); } bool samplesOutsideMain() const { return (fFlags & kSamplesOutsideMain_Flag); } bool usesColorTransform() const { return (fFlags & kUsesColorTransform_Flag); } bool alwaysOpaque() const { return (fFlags & kAlwaysOpaque_Flag); } - const SkFilterColorProgram* getFilterColorProgram(); + const SkFilterColorProgram* getFilterColorProgram() const; #if SK_SUPPORT_GPU friend class GrSkSLFP; // fBaseProgram, fSampleUsages @@ -405,11 +412,8 @@ public: const SkRuntimeEffect* effect() const { return fEffect.get(); } - BuilderUniform uniform(const char* name) { return { this, fEffect->findUniform(name) }; } - BuilderChild child(const char* name) { - const SkRuntimeEffect::Child* child = fEffect->findChild(name); - return { this, child }; - } + BuilderUniform uniform(std::string_view name) { return { this, fEffect->findUniform(name) }; } + BuilderChild child(std::string_view name) { return { this, fEffect->findChild(name) }; } protected: SkRuntimeEffectBuilder() = delete; |