[graphite] Use runtime effect blocks for runtime color filters, blenders, shaders

With the removal of prelocal matrices (https://skia-review.googlesource.com/c/skia/+/573077), the runtime color filter block no longer has unique handling compared to the more generic runtime shader block. This CL deletes RuntimeColorFilterBlock and its child, RuntimeBlenderBlock, renames RuntimeShaderBlock to RuntimeEffectBlock, and now utilizes this block for all runtime effects.

Change-Id: I3bce86f33b5808d57c146aaa962df99b9b90e3c6
Bug: b/251453923
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/588576
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Nicolette Prevost <nicolettep@google.com>
diff --git a/src/core/SkKeyHelpers.cpp b/src/core/SkKeyHelpers.cpp
index 50d8ead..f603754 100644
--- a/src/core/SkKeyHelpers.cpp
+++ b/src/core/SkKeyHelpers.cpp
@@ -651,10 +651,10 @@
 #endif // SK_GRAPHITE_ENABLED
 }
 
-RuntimeShaderBlock::ShaderData::ShaderData(sk_sp<const SkRuntimeEffect> effect)
+RuntimeEffectBlock::ShaderData::ShaderData(sk_sp<const SkRuntimeEffect> effect)
         : fEffect(std::move(effect)) {}
 
-RuntimeShaderBlock::ShaderData::ShaderData(sk_sp<const SkRuntimeEffect> effect,
+RuntimeEffectBlock::ShaderData::ShaderData(sk_sp<const SkRuntimeEffect> effect,
                                            sk_sp<const SkData> uniforms)
         : fEffect(std::move(effect))
         , fUniforms(std::move(uniforms)) {}
@@ -665,7 +665,7 @@
     return a ? a->equals(b) : (a == b);
 }
 
-bool RuntimeShaderBlock::ShaderData::operator==(const ShaderData& rhs) const {
+bool RuntimeEffectBlock::ShaderData::operator==(const ShaderData& rhs) const {
     return fEffect == rhs.fEffect && skdata_matches(fUniforms.get(), rhs.fUniforms.get());
 }
 
@@ -692,7 +692,7 @@
 }
 #endif
 
-void RuntimeShaderBlock::BeginBlock(const SkKeyContext& keyContext,
+void RuntimeEffectBlock::BeginBlock(const SkKeyContext& keyContext,
                                     SkPaintParamsKeyBuilder* builder,
                                     SkPipelineDataGatherer* gatherer,
                                     const ShaderData& shaderData) {
@@ -718,43 +718,3 @@
     builder->beginBlock(codeSnippetID);
 #endif  // SK_GRAPHITE_ENABLED
 }
-
-RuntimeColorFilterBlock::ColorFilterData::ColorFilterData(sk_sp<const SkRuntimeEffect> effect)
-        : fEffect(std::move(effect)) {}
-
-RuntimeColorFilterBlock::ColorFilterData::ColorFilterData(sk_sp<const SkRuntimeEffect> effect,
-                                                          sk_sp<const SkData> uniforms)
-        : fEffect(std::move(effect))
-        , fUniforms(std::move(uniforms)) {}
-
-bool RuntimeColorFilterBlock::ColorFilterData::operator==(const ColorFilterData& rhs) const {
-    return fEffect == rhs.fEffect &&
-           skdata_matches(fUniforms.get(), rhs.fUniforms.get());
-}
-
-void RuntimeColorFilterBlock::BeginBlock(const SkKeyContext& keyContext,
-                                         SkPaintParamsKeyBuilder* builder,
-                                         SkPipelineDataGatherer* gatherer,
-                                         const ColorFilterData& filterData) {
-#ifdef SK_GRAPHITE_ENABLED
-    SkShaderCodeDictionary* dict = keyContext.dict();
-    int codeSnippetID = dict->findOrCreateRuntimeEffectSnippet(filterData.fEffect.get());
-
-    add_effect_to_recorder(keyContext.recorder(), codeSnippetID, filterData.fEffect);
-
-    if (gatherer) {
-        const SkShaderSnippet* entry = dict->getEntry(codeSnippetID);
-        SkASSERT(entry);
-
-        SkDEBUGCODE(UniformExpectationsValidator uev(gatherer, entry->fUniforms);)
-        gatherer->addFlags(entry->fSnippetRequirementFlags);
-
-        gather_runtime_effect_uniforms(filterData.fEffect->uniforms(),
-                                       entry->fUniforms,
-                                       filterData.fUniforms.get(),
-                                       gatherer);
-    }
-
-    builder->beginBlock(codeSnippetID);
-#endif  // SK_GRAPHITE_ENABLED
-}
diff --git a/src/core/SkKeyHelpers.h b/src/core/SkKeyHelpers.h
index 1a910f4..69cf742 100644
--- a/src/core/SkKeyHelpers.h
+++ b/src/core/SkKeyHelpers.h
@@ -268,7 +268,7 @@
                            SkBlendMode);
 };
 
-struct RuntimeShaderBlock {
+struct RuntimeEffectBlock {
     struct ShaderData {
         // This ctor is used during pre-compilation when we don't have enough information to
         // extract uniform data.
@@ -292,32 +292,4 @@
                            const ShaderData&);
 };
 
-struct RuntimeColorFilterBlock {
-    struct ColorFilterData {
-        // This ctor is used during pre-compilation when we don't have enough information to
-        // extract uniform data.
-        ColorFilterData(sk_sp<const SkRuntimeEffect> effect);
-
-        // This ctor is used when extracting information from PaintParams.
-        ColorFilterData(sk_sp<const SkRuntimeEffect> effect, sk_sp<const SkData> uniforms);
-
-        bool operator==(const ColorFilterData& rhs) const;
-        bool operator!=(const ColorFilterData& rhs) const { return !(*this == rhs); }
-
-        // Runtime shader data.
-        sk_sp<const SkRuntimeEffect> fEffect;
-        sk_sp<const SkData>          fUniforms;
-    };
-
-    static void BeginBlock(const SkKeyContext&,
-                           SkPaintParamsKeyBuilder*,
-                           SkPipelineDataGatherer*,
-                           const ColorFilterData&);
-};
-
-struct RuntimeBlenderBlock : public RuntimeColorFilterBlock {
-    // Runtime Blenders use the same key builder as runtime color filters.
-    using BlenderData = ColorFilterData;
-};
-
 #endif // SkKeyHelpers_DEFINED
diff --git a/src/core/SkRuntimeEffect.cpp b/src/core/SkRuntimeEffect.cpp
index 4a4cd49..a365f97 100644
--- a/src/core/SkRuntimeEffect.cpp
+++ b/src/core/SkRuntimeEffect.cpp
@@ -1059,7 +1059,7 @@
     void addToKey(const SkKeyContext& keyContext,
                   SkPaintParamsKeyBuilder* builder,
                   SkPipelineDataGatherer* gatherer) const override {
-        RuntimeColorFilterBlock::BeginBlock(keyContext, builder, gatherer, {fEffect, fUniforms});
+        RuntimeEffectBlock::BeginBlock(keyContext, builder, gatherer, {fEffect, fUniforms});
 
         add_children_to_key(fChildren, fEffect->children(), keyContext, builder, gatherer);
 
@@ -1235,7 +1235,7 @@
     void addToKey(const SkKeyContext& keyContext,
                   SkPaintParamsKeyBuilder* builder,
                   SkPipelineDataGatherer* gatherer) const override {
-        RuntimeShaderBlock::BeginBlock(keyContext, builder, gatherer, {fEffect, fUniforms});
+        RuntimeEffectBlock::BeginBlock(keyContext, builder, gatherer, {fEffect, fUniforms});
 
         add_children_to_key(fChildren, fEffect->children(), keyContext, builder, gatherer);
 
@@ -1406,7 +1406,7 @@
                   SkPaintParamsKeyBuilder* builder,
                   SkPipelineDataGatherer* gatherer,
                   bool primitiveColorBlender) const override {
-        RuntimeBlenderBlock::BeginBlock(keyContext, builder, gatherer, {fEffect, fUniforms});
+        RuntimeEffectBlock::BeginBlock(keyContext, builder, gatherer, {fEffect, fUniforms});
 
         add_children_to_key(fChildren, fEffect->children(), keyContext, builder, gatherer);