Remove graphite code from src/effects
Note the default implementation of SkColorFilterBase::addToKey
is handled in the kNoOp switch case.
Change-Id: I963098148a1b9e1b40e5ff53ddc885e23f5e8517
Bug: skia:13983
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/728917
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
diff --git a/src/core/SkRuntimeEffect.cpp b/src/core/SkRuntimeEffect.cpp
index 3f50d80..9b9c7f0 100644
--- a/src/core/SkRuntimeEffect.cpp
+++ b/src/core/SkRuntimeEffect.cpp
@@ -819,7 +819,7 @@
if (type == ChildType::kShader) {
as_SB(child.shader())->addToKey(keyContext, builder, gatherer);
} else if (type == ChildType::kColorFilter) {
- as_CFB(child.colorFilter())->addToKey(keyContext, builder, gatherer);
+ AddToKey(keyContext, builder, gatherer, child.colorFilter());
} else if (type == ChildType::kBlender) {
AddToKey(keyContext, builder, gatherer, child.blender());
} else {
diff --git a/src/effects/colorfilters/SkBlendModeColorFilter.cpp b/src/effects/colorfilters/SkBlendModeColorFilter.cpp
index 9cfbded..198264e 100644
--- a/src/effects/colorfilters/SkBlendModeColorFilter.cpp
+++ b/src/effects/colorfilters/SkBlendModeColorFilter.cpp
@@ -25,12 +25,6 @@
#include "src/core/SkWriteBuffer.h"
#include "src/effects/colorfilters/SkColorFilterBase.h"
-#if defined(SK_GRAPHITE)
-#include "src/gpu/graphite/KeyContext.h"
-#include "src/gpu/graphite/KeyHelpers.h"
-#include "src/gpu/graphite/PaintParamsKey.h"
-#endif
-
template <SkAlphaType kDstAT = kPremul_SkAlphaType>
static SkRGBA4f<kDstAT> map_color(const SkColor4f& c, SkColorSpace* src, SkColorSpace* dst) {
SkRGBA4f<kDstAT> color = {c.fR, c.fG, c.fB, c.fA};
@@ -90,19 +84,6 @@
return true;
}
-#if defined(SK_GRAPHITE)
-void SkBlendModeColorFilter::addToKey(const skgpu::graphite::KeyContext& keyContext,
- skgpu::graphite::PaintParamsKeyBuilder* builder,
- skgpu::graphite::PipelineDataGatherer* gatherer) const {
- using namespace skgpu::graphite;
-
- SkPMColor4f color =
- map_color(fColor, sk_srgb_singleton(), keyContext.dstColorInfo().colorSpace());
- AddColorBlendBlock(keyContext, builder, gatherer, fMode, color);
-}
-
-#endif
-
///////////////////////////////////////////////////////////////////////////////
sk_sp<SkColorFilter> SkColorFilters::Blend(const SkColor4f& color,
diff --git a/src/effects/colorfilters/SkBlendModeColorFilter.h b/src/effects/colorfilters/SkBlendModeColorFilter.h
index 8791d0b..763b3a0 100644
--- a/src/effects/colorfilters/SkBlendModeColorFilter.h
+++ b/src/effects/colorfilters/SkBlendModeColorFilter.h
@@ -16,12 +16,6 @@
enum class SkBlendMode;
struct SkStageRec;
-#if defined(SK_GRAPHITE)
-#include "src/gpu/graphite/KeyContext.h"
-#include "src/gpu/graphite/KeyHelpers.h"
-#include "src/gpu/graphite/PaintParamsKey.h"
-#endif
-
class SkBlendModeColorFilter final : public SkColorFilterBase {
public:
SkBlendModeColorFilter(const SkColor4f& color, SkBlendMode mode);
@@ -30,11 +24,6 @@
bool onIsAlphaUnchanged() const override;
-#if defined(SK_GRAPHITE)
- void addToKey(const skgpu::graphite::KeyContext&,
- skgpu::graphite::PaintParamsKeyBuilder*,
- skgpu::graphite::PipelineDataGatherer*) const override;
-#endif
SkColorFilterBase::Type type() const override { return SkColorFilterBase::Type::kBlendMode; }
SkColor4f color() const { return fColor; }
diff --git a/src/effects/colorfilters/SkColorFilterBase.cpp b/src/effects/colorfilters/SkColorFilterBase.cpp
index 061fbb8..ab31ef6 100644
--- a/src/effects/colorfilters/SkColorFilterBase.cpp
+++ b/src/effects/colorfilters/SkColorFilterBase.cpp
@@ -18,12 +18,6 @@
#include "src/core/SkRasterPipelineOpContexts.h"
#include "src/core/SkRasterPipelineOpList.h"
-#if defined(SK_GRAPHITE)
-#include "src/gpu/graphite/KeyContext.h"
-#include "src/gpu/graphite/KeyHelpers.h"
-#include "src/gpu/graphite/PaintParamsKey.h"
-#endif
-
#include <cstddef>
enum class SkBlendMode;
@@ -56,15 +50,3 @@
SkDEBUGFAIL("onFilterColor4f unimplemented for this filter");
return SkPMColor4f{0,0,0,0};
}
-
-#if defined(SK_GRAPHITE)
-void SkColorFilterBase::addToKey(const skgpu::graphite::KeyContext& keyContext,
- skgpu::graphite::PaintParamsKeyBuilder* builder,
- skgpu::graphite::PipelineDataGatherer* gatherer) const {
- using namespace skgpu::graphite;
-
- // Return the input color as-is.
- PriorOutputBlock::BeginBlock(keyContext, builder, gatherer);
- builder->endBlock();
-}
-#endif
diff --git a/src/effects/colorfilters/SkColorFilterBase.h b/src/effects/colorfilters/SkColorFilterBase.h
index 41d7e6b..e94b7c0 100644
--- a/src/effects/colorfilters/SkColorFilterBase.h
+++ b/src/effects/colorfilters/SkColorFilterBase.h
@@ -22,14 +22,6 @@
struct SkDeserialProcs;
struct SkStageRec;
-#if defined(SK_GRAPHITE)
-namespace skgpu::graphite {
-class KeyContext;
-class PaintParamsKeyBuilder;
-class PipelineDataGatherer;
-}
-#endif
-
#define SK_ALL_COLOR_FILTERS(M) \
M(BlendMode) \
M(ColorSpaceXform) \
@@ -82,20 +74,6 @@
virtual SkPMColor4f onFilterColor4f(const SkPMColor4f& color, SkColorSpace* dstCS) const;
-#if defined(SK_GRAPHITE)
- /**
- Add implementation details, for the specified backend, of this SkColorFilter to the
- provided key.
-
- @param keyContext backend context for key creation
- @param builder builder for creating the key for this SkShader
- @param gatherer if non-null, storage for this colorFilter's data
- */
- virtual void addToKey(const skgpu::graphite::KeyContext& keyContext,
- skgpu::graphite::PaintParamsKeyBuilder* builder,
- skgpu::graphite::PipelineDataGatherer* gatherer) const;
-#endif
-
protected:
SkColorFilterBase() {}
diff --git a/src/effects/colorfilters/SkColorSpaceXformColorFilter.cpp b/src/effects/colorfilters/SkColorSpaceXformColorFilter.cpp
index 82a8820..7a72b94 100644
--- a/src/effects/colorfilters/SkColorSpaceXformColorFilter.cpp
+++ b/src/effects/colorfilters/SkColorSpaceXformColorFilter.cpp
@@ -24,12 +24,6 @@
#include <cstdint>
#include <utility>
-#if defined(SK_GRAPHITE)
-#include "src/gpu/graphite/KeyContext.h"
-#include "src/gpu/graphite/KeyHelpers.h"
-#include "src/gpu/graphite/PaintParamsKey.h"
-#endif
-
SkColorSpaceXformColorFilter::SkColorSpaceXformColorFilter(sk_sp<SkColorSpace> src,
sk_sp<SkColorSpace> dst)
: fSrc(std::move(src))
@@ -40,20 +34,6 @@
fDst.get(),
kUnpremul_SkAlphaType) {}
-#if defined(SK_GRAPHITE)
-void SkColorSpaceXformColorFilter::addToKey(const skgpu::graphite::KeyContext& keyContext,
- skgpu::graphite::PaintParamsKeyBuilder* builder,
- skgpu::graphite::PipelineDataGatherer* gatherer) const {
- using namespace skgpu::graphite;
-
- constexpr SkAlphaType alphaType = kPremul_SkAlphaType;
- ColorSpaceTransformBlock::ColorSpaceTransformData data(
- fSrc.get(), alphaType, fDst.get(), alphaType);
- ColorSpaceTransformBlock::BeginBlock(keyContext, builder, gatherer, &data);
- builder->endBlock();
-}
-#endif
-
bool SkColorSpaceXformColorFilter::appendStages(const SkStageRec& rec, bool shaderIsOpaque) const {
if (!shaderIsOpaque) {
rec.fPipeline->append(SkRasterPipelineOp::unpremul);
diff --git a/src/effects/colorfilters/SkColorSpaceXformColorFilter.h b/src/effects/colorfilters/SkColorSpaceXformColorFilter.h
index 6e77fbe..ee42bf0 100644
--- a/src/effects/colorfilters/SkColorSpaceXformColorFilter.h
+++ b/src/effects/colorfilters/SkColorSpaceXformColorFilter.h
@@ -21,12 +21,6 @@
public:
SkColorSpaceXformColorFilter(sk_sp<SkColorSpace> src, sk_sp<SkColorSpace> dst);
-#if defined(SK_GRAPHITE)
- void addToKey(const skgpu::graphite::KeyContext& keyContext,
- skgpu::graphite::PaintParamsKeyBuilder* builder,
- skgpu::graphite::PipelineDataGatherer* gatherer) const override;
-#endif
-
bool appendStages(const SkStageRec& rec, bool shaderIsOpaque) const override;
SkColorFilterBase::Type type() const override {
diff --git a/src/effects/colorfilters/SkComposeColorFilter.cpp b/src/effects/colorfilters/SkComposeColorFilter.cpp
index 5a13d20..f89904f 100644
--- a/src/effects/colorfilters/SkComposeColorFilter.cpp
+++ b/src/effects/colorfilters/SkComposeColorFilter.cpp
@@ -15,12 +15,6 @@
#include <utility>
struct SkStageRec;
-#if defined(SK_GRAPHITE)
-#include "src/gpu/graphite/KeyContext.h"
-#include "src/gpu/graphite/KeyHelpers.h"
-#include "src/gpu/graphite/PaintParamsKey.h"
-#endif
-
SkComposeColorFilter::SkComposeColorFilter(sk_sp<SkColorFilter> outer, sk_sp<SkColorFilter> inner)
: fOuter(as_CFB_sp(std::move(outer))), fInner(as_CFB_sp(std::move(inner))) {}
@@ -37,21 +31,6 @@
return fInner->appendStages(rec, shaderIsOpaque) && fOuter->appendStages(rec, innerIsOpaque);
}
-#if defined(SK_GRAPHITE)
-void SkComposeColorFilter::addToKey(const skgpu::graphite::KeyContext& keyContext,
- skgpu::graphite::PaintParamsKeyBuilder* builder,
- skgpu::graphite::PipelineDataGatherer* gatherer) const {
- using namespace skgpu::graphite;
-
- ComposeColorFilterBlock::BeginBlock(keyContext, builder, gatherer);
-
- as_CFB(fInner)->addToKey(keyContext, builder, gatherer);
- as_CFB(fOuter)->addToKey(keyContext, builder, gatherer);
-
- builder->endBlock();
-}
-#endif // SK_GRAPHITE
-
void SkComposeColorFilter::flatten(SkWriteBuffer& buffer) const {
buffer.writeFlattenable(fOuter.get());
buffer.writeFlattenable(fInner.get());
diff --git a/src/effects/colorfilters/SkComposeColorFilter.h b/src/effects/colorfilters/SkComposeColorFilter.h
index 5b280cb..2d9500e 100644
--- a/src/effects/colorfilters/SkComposeColorFilter.h
+++ b/src/effects/colorfilters/SkComposeColorFilter.h
@@ -24,12 +24,6 @@
SkColorFilterBase::Type type() const override { return SkColorFilterBase::Type::kCompose; }
-#if defined(SK_GRAPHITE)
- void addToKey(const skgpu::graphite::KeyContext& keyContext,
- skgpu::graphite::PaintParamsKeyBuilder* builder,
- skgpu::graphite::PipelineDataGatherer* gatherer) const override;
-#endif // SK_GRAPHITE
-
sk_sp<SkColorFilterBase> outer() const { return fOuter; }
sk_sp<SkColorFilterBase> inner() const { return fInner; }
diff --git a/src/effects/colorfilters/SkGaussianColorFilter.cpp b/src/effects/colorfilters/SkGaussianColorFilter.cpp
index 6e9172e..e77a6ca 100644
--- a/src/effects/colorfilters/SkGaussianColorFilter.cpp
+++ b/src/effects/colorfilters/SkGaussianColorFilter.cpp
@@ -17,16 +17,6 @@
#include "src/core/SkRasterPipelineOpList.h"
#include "src/effects/colorfilters/SkColorFilterBase.h"
-#if defined(SK_GRAPHITE)
-#include "src/gpu/graphite/KeyContext.h"
-#include "src/gpu/graphite/KeyHelpers.h"
-#include "src/gpu/graphite/PaintParamsKey.h"
-
-namespace skgpu::graphite {
-class PipelineDataGatherer;
-}
-#endif
-
SkGaussianColorFilter::SkGaussianColorFilter() : SkColorFilterBase() {}
bool SkGaussianColorFilter::appendStages(const SkStageRec& rec, bool shaderIsOpaque) const {
@@ -38,19 +28,6 @@
return SkColorFilterPriv::MakeGaussian();
}
-#if defined(SK_GRAPHITE)
-
-void SkGaussianColorFilter::addToKey(const skgpu::graphite::KeyContext& keyContext,
- skgpu::graphite::PaintParamsKeyBuilder* builder,
- skgpu::graphite::PipelineDataGatherer* gatherer) const {
- using namespace skgpu::graphite;
-
- GaussianColorFilterBlock::BeginBlock(keyContext, builder, gatherer);
- builder->endBlock();
-}
-
-#endif
-
sk_sp<SkColorFilter> SkColorFilterPriv::MakeGaussian() {
return sk_sp<SkColorFilter>(new SkGaussianColorFilter);
}
diff --git a/src/effects/colorfilters/SkGaussianColorFilter.h b/src/effects/colorfilters/SkGaussianColorFilter.h
index 3bb6f9e..fd86ddc 100644
--- a/src/effects/colorfilters/SkGaussianColorFilter.h
+++ b/src/effects/colorfilters/SkGaussianColorFilter.h
@@ -15,16 +15,6 @@
class SkWriteBuffer;
struct SkStageRec;
-#if defined(SK_GRAPHITE)
-#include "src/gpu/graphite/KeyContext.h"
-#include "src/gpu/graphite/KeyHelpers.h"
-#include "src/gpu/graphite/PaintParamsKey.h"
-
-namespace skgpu::graphite {
-class PipelineDataGatherer;
-}
-#endif
-
/**
* Remaps the input color's alpha to a Gaussian ramp and then outputs premul white using the
* remapped alpha.
@@ -37,12 +27,6 @@
SkColorFilterBase::Type type() const override { return SkColorFilterBase::Type::kGaussian; }
-#if defined(SK_GRAPHITE)
- void addToKey(const skgpu::graphite::KeyContext&,
- skgpu::graphite::PaintParamsKeyBuilder*,
- skgpu::graphite::PipelineDataGatherer*) const override;
-#endif
-
protected:
void flatten(SkWriteBuffer&) const override {}
diff --git a/src/effects/colorfilters/SkMatrixColorFilter.cpp b/src/effects/colorfilters/SkMatrixColorFilter.cpp
index dc6c9ef..18a2187 100644
--- a/src/effects/colorfilters/SkMatrixColorFilter.cpp
+++ b/src/effects/colorfilters/SkMatrixColorFilter.cpp
@@ -23,11 +23,6 @@
#include <array>
#include <cstring>
-#if defined(SK_GRAPHITE)
-#include "src/gpu/graphite/KeyHelpers.h"
-#include "src/gpu/graphite/PaintParamsKey.h"
-#endif // SK_GRAPHITE
-
static bool is_alpha_unchanged(const float matrix[20]) {
const float* srcA = matrix + 15;
@@ -92,19 +87,6 @@
return true;
}
-#if defined(SK_GRAPHITE)
-void SkMatrixColorFilter::addToKey(const skgpu::graphite::KeyContext& keyContext,
- skgpu::graphite::PaintParamsKeyBuilder* builder,
- skgpu::graphite::PipelineDataGatherer* gatherer) const {
- using namespace skgpu::graphite;
-
- MatrixColorFilterBlock::MatrixColorFilterData matrixCFData(fMatrix, fDomain == Domain::kHSLA);
-
- MatrixColorFilterBlock::BeginBlock(keyContext, builder, gatherer, &matrixCFData);
- builder->endBlock();
-}
-#endif // SK_GRAPHITE
-
///////////////////////////////////////////////////////////////////////////////
static sk_sp<SkColorFilter> MakeMatrix(const float array[20], SkMatrixColorFilter::Domain domain) {
diff --git a/src/effects/colorfilters/SkMatrixColorFilter.h b/src/effects/colorfilters/SkMatrixColorFilter.h
index c350454..eb95b11 100644
--- a/src/effects/colorfilters/SkMatrixColorFilter.h
+++ b/src/effects/colorfilters/SkMatrixColorFilter.h
@@ -17,11 +17,6 @@
class SkWriteBuffer;
struct SkStageRec;
-#if defined(SK_GRAPHITE)
-#include "src/gpu/graphite/KeyHelpers.h"
-#include "src/gpu/graphite/PaintParamsKey.h"
-#endif // SK_GRAPHITE
-
class SkMatrixColorFilter final : public SkColorFilterBase {
public:
enum class Domain : uint8_t { kRGBA, kHSLA };
@@ -34,12 +29,6 @@
SkColorFilterBase::Type type() const override { return SkColorFilterBase::Type::kMatrix; }
-#if defined(SK_GRAPHITE)
- void addToKey(const skgpu::graphite::KeyContext&,
- skgpu::graphite::PaintParamsKeyBuilder*,
- skgpu::graphite::PipelineDataGatherer*) const override;
-#endif
-
Domain domain() const { return fDomain; }
const float* matrix() const { return fMatrix; }
diff --git a/src/effects/colorfilters/SkRuntimeColorFilter.cpp b/src/effects/colorfilters/SkRuntimeColorFilter.cpp
index 443c306..04705f0 100644
--- a/src/effects/colorfilters/SkRuntimeColorFilter.cpp
+++ b/src/effects/colorfilters/SkRuntimeColorFilter.cpp
@@ -37,12 +37,6 @@
#error This only be compiled if SKSL is enabled. See _none.cpp for the non-SKSL version.
#endif
-#if defined(SK_GRAPHITE)
-#include "src/gpu/graphite/KeyContext.h"
-#include "src/gpu/graphite/KeyHelpers.h"
-#include "src/gpu/graphite/PaintParamsKey.h"
-#endif
-
SkRuntimeColorFilter::SkRuntimeColorFilter(sk_sp<SkRuntimeEffect> effect,
sk_sp<const SkData> uniforms,
SkSpan<const SkRuntimeEffect::ChildPtr> children)
@@ -50,25 +44,6 @@
, fUniforms(std::move(uniforms))
, fChildren(children.begin(), children.end()) {}
-#if defined(SK_GRAPHITE)
-void SkRuntimeColorFilter::addToKey(const skgpu::graphite::KeyContext& keyContext,
- skgpu::graphite::PaintParamsKeyBuilder* builder,
- skgpu::graphite::PipelineDataGatherer* gatherer) const {
- using namespace skgpu::graphite;
-
- sk_sp<const SkData> uniforms = SkRuntimeEffectPriv::TransformUniforms(
- fEffect->uniforms(), fUniforms, keyContext.dstColorInfo().colorSpace());
- SkASSERT(uniforms);
-
- RuntimeEffectBlock::BeginBlock(keyContext, builder, gatherer, {fEffect, std::move(uniforms)});
-
- SkRuntimeEffectPriv::AddChildrenToKey(
- fChildren, fEffect->children(), keyContext, builder, gatherer);
-
- builder->endBlock();
-}
-#endif
-
bool SkRuntimeColorFilter::appendStages(const SkStageRec& rec, bool) const {
#ifdef SK_ENABLE_SKSL_IN_RASTER_PIPELINE
if (!SkRuntimeEffectPriv::CanDraw(SkCapabilities::RasterBackend().get(), fEffect.get())) {
diff --git a/src/effects/colorfilters/SkRuntimeColorFilter.h b/src/effects/colorfilters/SkRuntimeColorFilter.h
index 7c22b3c..1115cbe 100644
--- a/src/effects/colorfilters/SkRuntimeColorFilter.h
+++ b/src/effects/colorfilters/SkRuntimeColorFilter.h
@@ -28,12 +28,6 @@
sk_sp<const SkData> uniforms,
SkSpan<const SkRuntimeEffect::ChildPtr> children);
-#if defined(SK_GRAPHITE)
- void addToKey(const skgpu::graphite::KeyContext& keyContext,
- skgpu::graphite::PaintParamsKeyBuilder* builder,
- skgpu::graphite::PipelineDataGatherer* gatherer) const override;
-#endif
-
bool appendStages(const SkStageRec& rec, bool) const override;
bool onIsAlphaUnchanged() const override;
diff --git a/src/effects/colorfilters/SkTableColorFilter.cpp b/src/effects/colorfilters/SkTableColorFilter.cpp
index e6130ea..dac07e4 100644
--- a/src/effects/colorfilters/SkTableColorFilter.cpp
+++ b/src/effects/colorfilters/SkTableColorFilter.cpp
@@ -22,19 +22,6 @@
#include <cstdint>
#include <utility>
-#if defined(SK_GRAPHITE)
-#include "src/gpu/graphite/Image_Graphite.h"
-#include "src/gpu/graphite/KeyContext.h"
-#include "src/gpu/graphite/KeyHelpers.h"
-#include "src/gpu/graphite/Log.h"
-#include "src/gpu/graphite/PaintParamsKey.h"
-#include "src/gpu/graphite/RecorderPriv.h"
-
-namespace skgpu::graphite {
-class PipelineDataGatherer;
-}
-#endif
-
bool SkTableColorFilter::appendStages(const SkStageRec& rec, bool shaderIsOpaque) const {
SkRasterPipeline* p = rec.fPipeline;
if (!shaderIsOpaque) {
@@ -63,32 +50,6 @@
return SkColorFilters::Table(SkColorTable::Deserialize(buffer));
}
-#if defined(SK_GRAPHITE)
-
-void SkTableColorFilter::addToKey(const skgpu::graphite::KeyContext& keyContext,
- skgpu::graphite::PaintParamsKeyBuilder* builder,
- skgpu::graphite::PipelineDataGatherer* gatherer) const {
- using namespace skgpu::graphite;
-
- sk_sp<TextureProxy> proxy = RecorderPriv::CreateCachedProxy(keyContext.recorder(),
- this->bitmap());
- if (!proxy) {
- SKGPU_LOG_W("Couldn't create TableColorFilter's table");
-
- // Return the input color as-is.
- PriorOutputBlock::BeginBlock(keyContext, builder, gatherer);
- builder->endBlock();
- return;
- }
-
- TableColorFilterBlock::TableColorFilterData data(std::move(proxy));
-
- TableColorFilterBlock::BeginBlock(keyContext, builder, gatherer, data);
- builder->endBlock();
-}
-
-#endif
-
///////////////////////////////////////////////////////////////////////////////
sk_sp<SkColorFilter> SkColorFilters::Table(const uint8_t table[256]) {
diff --git a/src/effects/colorfilters/SkTableColorFilter.h b/src/effects/colorfilters/SkTableColorFilter.h
index 752cfb90..44c19aa0 100644
--- a/src/effects/colorfilters/SkTableColorFilter.h
+++ b/src/effects/colorfilters/SkTableColorFilter.h
@@ -19,19 +19,6 @@
class SkWriteBuffer;
struct SkStageRec;
-#if defined(SK_GRAPHITE)
-#include "src/gpu/graphite/Image_Graphite.h"
-#include "src/gpu/graphite/KeyContext.h"
-#include "src/gpu/graphite/KeyHelpers.h"
-#include "src/gpu/graphite/Log.h"
-#include "src/gpu/graphite/PaintParamsKey.h"
-#include "src/gpu/graphite/RecorderPriv.h"
-
-namespace skgpu::graphite {
-class PipelineDataGatherer;
-}
-#endif
-
class SkTableColorFilter final : public SkColorFilterBase {
public:
SkTableColorFilter(sk_sp<SkColorTable> table) : fTable(table) {
@@ -40,12 +27,6 @@
SkColorFilterBase::Type type() const override { return SkColorFilterBase::Type::kTable; }
-#if defined(SK_GRAPHITE)
- void addToKey(const skgpu::graphite::KeyContext&,
- skgpu::graphite::PaintParamsKeyBuilder*,
- skgpu::graphite::PipelineDataGatherer*) const override;
-#endif
-
bool appendStages(const SkStageRec& rec, bool shaderIsOpaque) const override;
void flatten(SkWriteBuffer& buffer) const override;
diff --git a/src/effects/colorfilters/SkWorkingFormatColorFilter.cpp b/src/effects/colorfilters/SkWorkingFormatColorFilter.cpp
index 1f4315e..35337db 100644
--- a/src/effects/colorfilters/SkWorkingFormatColorFilter.cpp
+++ b/src/effects/colorfilters/SkWorkingFormatColorFilter.cpp
@@ -25,12 +25,6 @@
#include <utility>
-#if defined(SK_GRAPHITE)
-#include "src/gpu/graphite/KeyContext.h"
-#include "src/gpu/graphite/KeyHelpers.h"
-#include "src/gpu/graphite/PaintParamsKey.h"
-#endif
-
SkWorkingFormatColorFilter::SkWorkingFormatColorFilter(sk_sp<SkColorFilter> child,
const skcms_TransferFunction* tf,
const skcms_Matrix3x3* gamut,
@@ -66,45 +60,6 @@
return SkColorSpace::MakeRGB(tf, gamut);
}
-#if defined(SK_GRAPHITE)
-void SkWorkingFormatColorFilter::addToKey(const skgpu::graphite::KeyContext& keyContext,
- skgpu::graphite::PaintParamsKeyBuilder* builder,
- skgpu::graphite::PipelineDataGatherer* gatherer) const {
- using namespace skgpu::graphite;
-
- const SkAlphaType dstAT = keyContext.dstColorInfo().alphaType();
- sk_sp<SkColorSpace> dstCS = keyContext.dstColorInfo().refColorSpace();
- if (!dstCS) {
- dstCS = SkColorSpace::MakeSRGB();
- }
-
- SkAlphaType workingAT;
- sk_sp<SkColorSpace> workingCS = this->workingFormat(dstCS, &workingAT);
-
- // Use two nested compose blocks to chain (dst->working), child, and (working->dst) together
- // while appearing as one block to the parent node.
- ComposeColorFilterBlock::BeginBlock(keyContext, builder, gatherer);
- // Inner compose
- ComposeColorFilterBlock::BeginBlock(keyContext, builder, gatherer);
- // Innermost (inner of inner compose)
- ColorSpaceTransformBlock::ColorSpaceTransformData data1(
- dstCS.get(), dstAT, workingCS.get(), workingAT);
- ColorSpaceTransformBlock::BeginBlock(keyContext, builder, gatherer, &data1);
- builder->endBlock();
-
- // Middle (outer of inner compose)
- as_CFB(fChild)->addToKey(keyContext, builder, gatherer);
- builder->endBlock();
-
- // Outermost (outer of outer compose)
- ColorSpaceTransformBlock::ColorSpaceTransformData data2(
- workingCS.get(), workingAT, dstCS.get(), dstAT);
- ColorSpaceTransformBlock::BeginBlock(keyContext, builder, gatherer, &data2);
- builder->endBlock();
- builder->endBlock();
-}
-#endif
-
bool SkWorkingFormatColorFilter::appendStages(const SkStageRec& rec, bool shaderIsOpaque) const {
sk_sp<SkColorSpace> dstCS = sk_ref_sp(rec.fDstCS);
diff --git a/src/effects/colorfilters/SkWorkingFormatColorFilter.h b/src/effects/colorfilters/SkWorkingFormatColorFilter.h
index ca60404..d86e6ca 100644
--- a/src/effects/colorfilters/SkWorkingFormatColorFilter.h
+++ b/src/effects/colorfilters/SkWorkingFormatColorFilter.h
@@ -33,12 +33,6 @@
return SkColorFilterBase::Type::kWorkingFormat;
}
-#if defined(SK_GRAPHITE)
- void addToKey(const skgpu::graphite::KeyContext& keyContext,
- skgpu::graphite::PaintParamsKeyBuilder* builder,
- skgpu::graphite::PipelineDataGatherer* gatherer) const override;
-#endif
-
bool appendStages(const SkStageRec& rec, bool shaderIsOpaque) const override;
SkPMColor4f onFilterColor4f(const SkPMColor4f& origColor,
diff --git a/src/gpu/graphite/KeyHelpers.cpp b/src/gpu/graphite/KeyHelpers.cpp
index 950a84f..212f4c3 100644
--- a/src/gpu/graphite/KeyHelpers.cpp
+++ b/src/gpu/graphite/KeyHelpers.cpp
@@ -7,6 +7,7 @@
#include "src/gpu/graphite/KeyHelpers.h"
+#include "include/core/SkColorFilter.h"
#include "include/core/SkData.h"
#include "include/effects/SkRuntimeEffect.h"
#include "src/core/SkBlendModeBlender.h"
@@ -15,6 +16,15 @@
#include "src/core/SkDebugUtils.h"
#include "src/core/SkRuntimeBlender.h"
#include "src/core/SkRuntimeEffectPriv.h"
+#include "src/effects/colorfilters/SkBlendModeColorFilter.h"
+#include "src/effects/colorfilters/SkColorFilterBase.h"
+#include "src/effects/colorfilters/SkColorSpaceXformColorFilter.h"
+#include "src/effects/colorfilters/SkComposeColorFilter.h"
+#include "src/effects/colorfilters/SkGaussianColorFilter.h"
+#include "src/effects/colorfilters/SkMatrixColorFilter.h"
+#include "src/effects/colorfilters/SkRuntimeColorFilter.h"
+#include "src/effects/colorfilters/SkTableColorFilter.h"
+#include "src/effects/colorfilters/SkWorkingFormatColorFilter.h"
#include "src/gpu/Blend.h"
#include "src/gpu/DitherUtils.h"
#include "src/gpu/graphite/KeyContext.h"
@@ -1015,4 +1025,174 @@
SkUNREACHABLE;
}
+static SkPMColor4f map_color(const SkColor4f& c, SkColorSpace* src, SkColorSpace* dst) {
+ SkPMColor4f color = {c.fR, c.fG, c.fB, c.fA};
+ SkColorSpaceXformSteps(src, kUnpremul_SkAlphaType, dst, kPremul_SkAlphaType).apply(color.vec());
+ return color;
+}
+static void add_to_key(const KeyContext& keyContext,
+ PaintParamsKeyBuilder* builder,
+ PipelineDataGatherer* gatherer,
+ const SkBlendModeColorFilter* filter) {
+ SkASSERT(filter);
+
+ SkPMColor4f color =
+ map_color(filter->color(), sk_srgb_singleton(), keyContext.dstColorInfo().colorSpace());
+ AddColorBlendBlock(keyContext, builder, gatherer, filter->mode(), color);
+}
+
+static void add_to_key(const KeyContext& keyContext,
+ PaintParamsKeyBuilder* builder,
+ PipelineDataGatherer* gatherer,
+ const SkColorSpaceXformColorFilter* filter) {
+ SkASSERT(filter);
+
+ constexpr SkAlphaType alphaType = kPremul_SkAlphaType;
+ ColorSpaceTransformBlock::ColorSpaceTransformData data(
+ filter->src().get(), alphaType, filter->src().get(), alphaType);
+ ColorSpaceTransformBlock::BeginBlock(keyContext, builder, gatherer, &data);
+ builder->endBlock();
+}
+
+static void add_to_key(const KeyContext& keyContext,
+ PaintParamsKeyBuilder* builder,
+ PipelineDataGatherer* gatherer,
+ const SkComposeColorFilter* filter) {
+ SkASSERT(filter);
+
+ ComposeColorFilterBlock::BeginBlock(keyContext, builder, gatherer);
+
+ AddToKey(keyContext, builder, gatherer, filter->inner().get());
+ AddToKey(keyContext, builder, gatherer, filter->outer().get());
+
+ builder->endBlock();
+}
+
+static void add_to_key(const KeyContext& keyContext,
+ PaintParamsKeyBuilder* builder,
+ PipelineDataGatherer* gatherer,
+ const SkGaussianColorFilter*) {
+ GaussianColorFilterBlock::BeginBlock(keyContext, builder, gatherer);
+ builder->endBlock();
+}
+
+static void add_to_key(const KeyContext& keyContext,
+ PaintParamsKeyBuilder* builder,
+ PipelineDataGatherer* gatherer,
+ const SkMatrixColorFilter* filter) {
+ SkASSERT(filter);
+
+ bool inHSLA = filter->domain() == SkMatrixColorFilter::Domain::kHSLA;
+ MatrixColorFilterBlock::MatrixColorFilterData matrixCFData(filter->matrix(), inHSLA);
+
+ MatrixColorFilterBlock::BeginBlock(keyContext, builder, gatherer, &matrixCFData);
+ builder->endBlock();
+}
+
+static void add_to_key(const KeyContext& keyContext,
+ PaintParamsKeyBuilder* builder,
+ PipelineDataGatherer* gatherer,
+ const SkRuntimeColorFilter* filter) {
+ SkASSERT(filter);
+
+ sk_sp<SkRuntimeEffect> effect = filter->effect();
+ sk_sp<const SkData> uniforms = SkRuntimeEffectPriv::TransformUniforms(
+ effect->uniforms(), filter->uniforms(), keyContext.dstColorInfo().colorSpace());
+ SkASSERT(uniforms);
+
+ RuntimeEffectBlock::BeginBlock(keyContext, builder, gatherer, {effect, std::move(uniforms)});
+
+ SkRuntimeEffectPriv::AddChildrenToKey(
+ filter->children(), effect->children(), keyContext, builder, gatherer);
+
+ builder->endBlock();
+}
+
+static void add_to_key(const KeyContext& keyContext,
+ PaintParamsKeyBuilder* builder,
+ PipelineDataGatherer* gatherer,
+ const SkTableColorFilter* filter) {
+ SkASSERT(filter);
+
+ sk_sp<TextureProxy> proxy = RecorderPriv::CreateCachedProxy(keyContext.recorder(),
+ filter->bitmap());
+ if (!proxy) {
+ SKGPU_LOG_W("Couldn't create TableColorFilter's table");
+
+ // Return the input color as-is.
+ PriorOutputBlock::BeginBlock(keyContext, builder, gatherer);
+ builder->endBlock();
+ return;
+ }
+
+ TableColorFilterBlock::TableColorFilterData data(std::move(proxy));
+
+ TableColorFilterBlock::BeginBlock(keyContext, builder, gatherer, data);
+ builder->endBlock();
+}
+
+static void add_to_key(const KeyContext& keyContext,
+ PaintParamsKeyBuilder* builder,
+ PipelineDataGatherer* gatherer,
+ const SkWorkingFormatColorFilter* filter) {
+ SkASSERT(filter);
+
+ const SkAlphaType dstAT = keyContext.dstColorInfo().alphaType();
+ sk_sp<SkColorSpace> dstCS = keyContext.dstColorInfo().refColorSpace();
+ if (!dstCS) {
+ dstCS = SkColorSpace::MakeSRGB();
+ }
+
+ SkAlphaType workingAT;
+ sk_sp<SkColorSpace> workingCS = filter->workingFormat(dstCS, &workingAT);
+
+ // Use two nested compose blocks to chain (dst->working), child, and (working->dst) together
+ // while appearing as one block to the parent node.
+ ComposeColorFilterBlock::BeginBlock(keyContext, builder, gatherer);
+ // Inner compose
+ ComposeColorFilterBlock::BeginBlock(keyContext, builder, gatherer);
+ // Innermost (inner of inner compose)
+ ColorSpaceTransformBlock::ColorSpaceTransformData data1(
+ dstCS.get(), dstAT, workingCS.get(), workingAT);
+ ColorSpaceTransformBlock::BeginBlock(keyContext, builder, gatherer, &data1);
+ builder->endBlock();
+
+ // Middle (outer of inner compose)
+ AddToKey(keyContext, builder, gatherer, filter->child().get());
+ builder->endBlock();
+
+ // Outermost (outer of outer compose)
+ ColorSpaceTransformBlock::ColorSpaceTransformData data2(
+ workingCS.get(), workingAT, dstCS.get(), dstAT);
+ ColorSpaceTransformBlock::BeginBlock(keyContext, builder, gatherer, &data2);
+ builder->endBlock();
+ builder->endBlock();
+}
+
+void AddToKey(const KeyContext& keyContext,
+ PaintParamsKeyBuilder* builder,
+ PipelineDataGatherer* gatherer,
+ const SkColorFilter* filter) {
+ if (!filter) {
+ return;
+ }
+ switch (as_CFB(filter)->type()) {
+ case SkColorFilterBase::Type::kNoop:
+ // Return the input color as-is.
+ PriorOutputBlock::BeginBlock(keyContext, builder, gatherer);
+ builder->endBlock();
+ return;
+#define M(type) \
+ case SkColorFilterBase::Type::k##type: \
+ add_to_key(keyContext, \
+ builder, \
+ gatherer, \
+ static_cast<const Sk##type##ColorFilter*>(filter)); \
+ return;
+ SK_ALL_COLOR_FILTERS(M)
+#undef M
+ }
+ SkUNREACHABLE;
+}
+
} // namespace skgpu::graphite
diff --git a/src/gpu/graphite/KeyHelpers.h b/src/gpu/graphite/KeyHelpers.h
index b7e9a0d..75888c2 100644
--- a/src/gpu/graphite/KeyHelpers.h
+++ b/src/gpu/graphite/KeyHelpers.h
@@ -23,6 +23,7 @@
#include "src/gpu/graphite/TextureProxy.h"
#include "src/shaders/SkShaderBase.h"
+class SkColorFilter;
class SkData;
class SkRuntimeEffect;
@@ -421,6 +422,20 @@
PipelineDataGatherer*,
const SkBlender*);
+/**
+ * Add implementation details, for the specified backend, of this SkColorFilter to the
+ * provided key.
+ *
+ * @param keyContext backend context for key creation
+ * @param builder builder for creating the key for this SkShader
+ * @param gatherer if non-null, storage for this colorFilter's data
+ * @param filter This function is a no-op if filter is null.
+ */
+void AddToKey(const KeyContext& keyContext,
+ PaintParamsKeyBuilder* builder,
+ PipelineDataGatherer* gatherer,
+ const SkColorFilter* filter);
+
} // namespace skgpu::graphite
#endif // skgpu_graphite_KeyHelpers_DEFINED
diff --git a/src/gpu/graphite/PaintParams.cpp b/src/gpu/graphite/PaintParams.cpp
index 876253e..15ee889 100644
--- a/src/gpu/graphite/PaintParams.cpp
+++ b/src/gpu/graphite/PaintParams.cpp
@@ -137,9 +137,7 @@
keyContext, builder, gatherer, SkBlendMode::kDstIn, {0, 0, 0, fColor.fA});
}
- if (fColorFilter) {
- as_CFB(fColorFilter)->addToKey(keyContext, builder, gatherer);
- }
+ AddToKey(keyContext, builder, gatherer, fColorFilter.get());
#ifndef SK_IGNORE_GPU_DITHER
SkColorType ct = keyContext.dstColorInfo().colorType();
diff --git a/src/shaders/SkColorFilterShader.cpp b/src/shaders/SkColorFilterShader.cpp
index 919f44f..c84052f 100644
--- a/src/shaders/SkColorFilterShader.cpp
+++ b/src/shaders/SkColorFilterShader.cpp
@@ -81,7 +81,7 @@
ColorFilterShaderBlock::BeginBlock(keyContext, builder, gatherer);
as_SB(fShader)->addToKey(keyContext, builder, gatherer);
- as_CFB(fFilter)->addToKey(keyContext, builder, gatherer);
+ AddToKey(keyContext, builder, gatherer, fFilter.get());
builder->endBlock();
}