Reland "Switch sRGB color filter to use GrColorSpaceXformEffect"
This reverts commit 81c8f4b8027e193ca168b81d2285e28f9259b2cc.
Other CLs have fixed the precision issue on Bifrost GPUs.
Change-Id: I155a33f7e11e56a8912ae1467d9e2acafab52d6f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/279042
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/core/SkColorFilter.cpp b/src/core/SkColorFilter.cpp
index 45c5b43..d94d4d4 100644
--- a/src/core/SkColorFilter.cpp
+++ b/src/core/SkColorFilter.cpp
@@ -20,6 +20,7 @@
#include "src/core/SkWriteBuffer.h"
#if SK_SUPPORT_GPU
+#include "src/gpu/GrColorSpaceXform.h"
#include "src/gpu/GrFragmentProcessor.h"
#include "src/gpu/effects/generated/GrMixerEffect.h"
#endif
@@ -222,6 +223,7 @@
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(GrRecordingContext*,
const GrColorInfo&) const override {
// wish our caller would let us know if our input was opaque...
+#if defined(SK_USE_LEGACY_SRGB_COLOR_FILTER)
GrSRGBEffect::Alpha alpha = GrSRGBEffect::Alpha::kPremul;
switch (fDir) {
case Direction::kLinearToSRGB:
@@ -229,6 +231,17 @@
case Direction::kSRGBToLinear:
return GrSRGBEffect::Make(GrSRGBEffect::Mode::kSRGBToLinear, alpha);
}
+#else
+ SkAlphaType at = kPremul_SkAlphaType;
+ switch (fDir) {
+ case Direction::kLinearToSRGB:
+ return GrColorSpaceXformEffect::Make(sk_srgb_linear_singleton(), at,
+ sk_srgb_singleton(), at);
+ case Direction::kSRGBToLinear:
+ return GrColorSpaceXformEffect::Make(sk_srgb_singleton(), at,
+ sk_srgb_linear_singleton(), at);
+ }
+#endif
return nullptr;
}
#endif
diff --git a/src/gpu/GrProcessorUnitTest.cpp b/src/gpu/GrProcessorUnitTest.cpp
index ed98ada..4fc7470 100644
--- a/src/gpu/GrProcessorUnitTest.cpp
+++ b/src/gpu/GrProcessorUnitTest.cpp
@@ -81,7 +81,12 @@
* we verify the count is as expected. If a new factory is added, then these numbers must be
* manually adjusted.
*/
+#if defined(SK_USE_LEGACY_SRGB_COLOR_FILTER)
static const int kFPFactoryCount = 36;
+#else
+static const int kFPFactoryCount = 35;
+#endif
+
static const int kGPFactoryCount = 14;
static const int kXPFactoryCount = 4;
diff --git a/src/gpu/effects/GrSRGBEffect.cpp b/src/gpu/effects/GrSRGBEffect.cpp
index b7e27a6..4c17782 100644
--- a/src/gpu/effects/GrSRGBEffect.cpp
+++ b/src/gpu/effects/GrSRGBEffect.cpp
@@ -12,6 +12,8 @@
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
+#if defined(SK_USE_LEGACY_SRGB_COLOR_FILTER)
+
class GrGLSRGBEffect : public GrGLSLFragmentProcessor {
public:
void emitCode(EmitArgs& args) override {
@@ -134,3 +136,4 @@
return new GrGLSRGBEffect;
}
+#endif
diff --git a/src/gpu/effects/GrSRGBEffect.h b/src/gpu/effects/GrSRGBEffect.h
index 2135a50..abaedd1 100644
--- a/src/gpu/effects/GrSRGBEffect.h
+++ b/src/gpu/effects/GrSRGBEffect.h
@@ -10,6 +10,8 @@
#include "src/gpu/GrFragmentProcessor.h"
+#if defined(SK_USE_LEGACY_SRGB_COLOR_FILTER)
+
class GrSRGBEffect : public GrFragmentProcessor {
public:
enum class Mode {
@@ -54,3 +56,5 @@
};
#endif
+
+#endif