diff options
author | Brian Osman <brianosman@google.com> | 2017-01-17 16:10:07 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-01-17 21:53:57 +0000 |
commit | 0d4ff6c601f2ce404a97068718caad5a2bb3d594 (patch) | |
tree | be37c1e4b454893b7df99aa19585455b728560fc /gm/gamut.cpp | |
parent | 98420d0c9b5934d6b08ea994844476ddedd23de0 (diff) |
Fix code that relied on readPixels not doing color space conversion
SampleApp doesn't have (can't easily get) an image, so I couldn't use
the new helper function there. It's probably still worth having?
BUG=skia:
Change-Id: I60c208ff958076015a9539359921b9aff68f25c8
Reviewed-on: https://skia-review.googlesource.com/7129
Reviewed-by: Matt Sarett <msarett@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'gm/gamut.cpp')
-rw-r--r-- | gm/gamut.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/gm/gamut.cpp b/gm/gamut.cpp index 21312ce6fa..d513bc65c9 100644 --- a/gm/gamut.cpp +++ b/gm/gamut.cpp @@ -9,6 +9,7 @@ #include "SkColorSpace_Base.h" #include "SkGradientShader.h" +#include "SkImagePriv.h" #include "SkPM4fPriv.h" #include "SkSurface.h" @@ -147,13 +148,12 @@ static void draw_gamut_grid(SkCanvas* canvas, SkTArray<std::unique_ptr<CellRende SkASSERT(srgbCS); SkASSERT(wideCS); - // Make our two working surfaces (one sRGB, one Adobe) + // Make our two working surfaces (one sRGB, one Wide) SkImageInfo srgbGamutInfo = SkImageInfo::Make(gRectSize, gRectSize, origInfo.colorType(), kPremul_SkAlphaType, srgbCS); SkImageInfo wideGamutInfo = SkImageInfo::Make(gRectSize, gRectSize, origInfo.colorType(), kPremul_SkAlphaType, wideCS); - // readPixels doesn't do color conversion (yet), so we can use it to see the raw (wide) data - SkImageInfo dstInfo = srgbGamutInfo.makeColorSpace(nullptr); + sk_sp<SkSurface> srgbGamutSurface = canvas->makeSurface(srgbGamutInfo); sk_sp<SkSurface> wideGamutSurface = canvas->makeSurface(wideGamutInfo); if (!srgbGamutSurface || !wideGamutSurface) { @@ -179,16 +179,18 @@ static void draw_gamut_grid(SkCanvas* canvas, SkTArray<std::unique_ptr<CellRende canvas->drawText(renderer->label(), strlen(renderer->label()), x, y + textHeight, textPaint); - SkBitmap srgbBitmap; - srgbBitmap.setInfo(dstInfo); - srgbGamutCanvas->readPixels(&srgbBitmap, 0, 0); - canvas->drawBitmap(srgbBitmap, x, y + textHeight + 5); + // Re-interpret the off-screen images, so we can see the raw data (eg, Wide gamut squares + // will look desaturated, relative to sRGB). + auto srgbImage = srgbGamutSurface->makeImageSnapshot(); + srgbImage = SkImageMakeRasterCopyAndAssignColorSpace(srgbImage.get(), + origInfo.colorSpace()); + canvas->drawImage(srgbImage, x, y + textHeight + 5); x += (gScalarSize + 1); - SkBitmap wideBitmap; - wideBitmap.setInfo(dstInfo); - wideGamutCanvas->readPixels(&wideBitmap, 0, 0); - canvas->drawBitmap(wideBitmap, x, y + textHeight + 5); + auto wideImage = wideGamutSurface->makeImageSnapshot(); + wideImage = SkImageMakeRasterCopyAndAssignColorSpace(wideImage.get(), + origInfo.colorSpace()); + canvas->drawImage(wideImage, x, y + textHeight + 5); x += (gScalarSize + 10); if (x + (2 * gScalarSize + 1) > gTestWidth) { |