aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/gpu/GrContext.cpp3
-rw-r--r--tests/SRGBReadWritePixelsTest.cpp11
2 files changed, 12 insertions, 2 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 2a3852ce03..92be35c78c 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -400,7 +400,8 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceContext* dst,
GrPaint paint;
paint.addColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
- paint.setAllowSRGBInputs(true);
+ paint.setAllowSRGBInputs(SkToBool(dst->getColorSpace()) ||
+ GrPixelConfigIsSRGB(renderTargetContext->config()));
SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
renderTargetContext->drawRect(GrNoClip(), std::move(paint), GrAA::kNo, matrix, rect,
nullptr);
diff --git a/tests/SRGBReadWritePixelsTest.cpp b/tests/SRGBReadWritePixelsTest.cpp
index e3087e639e..9038b29770 100644
--- a/tests/SRGBReadWritePixelsTest.cpp
+++ b/tests/SRGBReadWritePixelsTest.cpp
@@ -225,11 +225,20 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SRGBReadWritePixels, reporter, ctxInfo) {
// Write srgba data to a rgba texture and read back as srgba and rgba
if (sContext->writePixels(iiSRGBA, origData, 0, 0, 0)) {
+#if 0
+ // We don't support this conversion (read from untagged source into tagged destination.
+ // If we decide there is a meaningful way to implement this, restore this test.
read_and_check_pixels(reporter, sContext.get(), origData, iiSRGBA,
check_srgb_to_linear_to_srgb_conversion, error,
"write/read srgba to rgba texture");
+#endif
+ // We expect the sRGB -> linear write to do no sRGB conversion (to match the behavior of
+ // drawing tagged sources). skbug.com/6547. So the data we read should still contain
+ // sRGB encoded values.
+ //
+ // srgb_to_linear_to_srgb is a proxy for the expected identity transform.
read_and_check_pixels(reporter, sContext.get(), origData, iiRGBA,
- check_srgb_to_linear_conversion, error,
+ check_srgb_to_linear_to_srgb_conversion, error,
"write srgba/read rgba to rgba texture");
} else {
ERRORF(reporter, "Could not write srgba data to rgba texture.");