diff options
author | Brian Osman <brianosman@google.com> | 2017-04-25 15:01:46 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-04-25 19:28:07 +0000 |
commit | 7ab6a7f40b23610577bd64fbcb6121a2a715469b (patch) | |
tree | a7be62ca577068acd9922bdf0c4de354dfb7e635 | |
parent | cc90174cc46623891aa97ccaf7bdda3184d986a3 (diff) |
Fix writePixels of sRGB data to legacy GPU surface
Adjusted unit test to verify this behavior.
Bug: skia:6547 chromium:713632 chromium:713702
Change-Id: I6240937b2faf6ccb6adfc9477dc85ae961cdbbb7
Reviewed-on: https://skia-review.googlesource.com/14279
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
-rw-r--r-- | src/gpu/GrContext.cpp | 3 | ||||
-rw-r--r-- | tests/SRGBReadWritePixelsTest.cpp | 11 |
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."); |