New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 729352 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Jun 2017
Cc:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocking:
issue 713891



Sign in to add a comment

color: layout test images/color-profile-svg.html ignores color profile

Project Member Reported by ccameron@chromium.org, Jun 3 2017

Issue description

For the layout test images/color-profile-svg.html, the expected and actual output of the layout test are attached.

The color profile of the image used by the SVG is ignored.


 
color-profile-svg-actual.png
79.4 KB View Download
color-profile-svg-expected.png
74.3 KB View Download
Interestingly, this bug only occurs when the output color space is sRGB (or may be has an sRGB transfer function). When the output color space different (gamma 1.8), the output is correct.

I see similar failures in
  images/color-profile-svg.html
  images/color-profile-svg-fill-text.html
  images/color-profile-group.html
  images/color-profile-background-image-space.html
  virtual/gpu-rasterization/images/color-profile-svg.html

In SkImage::makeColorSpace, we have the early-out if (!this->colorSpace() && target->isSRGB()) ... and *this* doesn't have a color space yet. But it should.

My guess is that something about the load-an-image-through-an-SVG path doesn't require that the size and color space be read as early as they need to be.
Cc: mtklein@chromium.org
The  problem comes up in SkPictureShader::refBitmapShader. When we hit this call, dstColorSpace is nullptr (cause we're in legacy mode), but SkPictureShader::fColorSpace is set to the color space we want to end up in.

We create tileImage by SkImage::MakeFromGenerator(SkPictureImageGenerator::Make(...)).

tileImage's image info will never have a color space (it's a bunch of draw commands, after all), and we're in legacy mode (so we shouldn't be using dstColorSpace, since that's for SkSurfaces, which we don't want here).

We call tileImage->makeColorSpace(fColorSpace).

Only if fColorSpace is non-SRGB will be do color conversion here. The stack for the conversion will be
    SkImage_Lazy::directGeneratePixels(...
    SkImage_Lazy::onMakeColorSpace(...
    SkImage::makeColorSpace(...
    SkPictureShader::refBitmapShader(...
    -----(paths diverge here)------                                                         
    SkPictureShader::onMakeContext(...
    SkShaderBase::makeContext(...
    SkBlitter::Choose(...
    SkAutoBlitterChoose::SkAutoBlitterChoose(...
    SkAutoBlitterChoose::SkAutoBlitterChoose(...
    SkDraw::drawRect(...
    SkDraw::drawRect(...
    SkBitmapDevice::drawRect(...
    SkCanvas::onDrawRect(...
    SkCanvas::drawRect(...
    SkColorSpaceXformCanvas::onDrawRect(...
    SkCanvas::drawRect(...

If fColorSpace is sRGB, then tileImage will do no conversion here, and we'll be reading the image with the stack
    SkCanvas::drawImageRect(...
    SkCanvas::legacy_drawImageRect(...
    void SkRecords::Draw::draw<SkRecords::DrawImageRect>(...
    void SkRecords::Draw::operator(...
    decltype(...
    decltype(...
    SkRecordDraw(...
    SkBigPicture::playback(...
    SkCanvas::drawPicture(...
    SkCanvas::drawPicture(...
 ** SkPictureImageGenerator::onGetPixels(...
    SkImageGenerator::getPixels(...
    SkImageGenerator::getPixels(...
    generate_pixels(...
    SkImage_Lazy::lockAsBitmap(...
    SkImage_Lazy::getROPixels(...
    SkBitmapProvider::asBitmap(...
    SkDefaultBitmapControllerState::SkDefaultBitmapControllerState(...
    SkDefaultBitmapControllerState::SkDefaultBitmapControllerState(...
    SkDefaultBitmapControllerState* SkInPlaceNewCheck<...
    SkDefaultBitmapController::onRequestBitmap(...
    SkBitmapController::requestBitmap(...
    SkBitmapProcInfo::init(...
    SkBitmapProcState::setup(...
    SkBitmapProcLegacyShader::MakeContext(...
    -----------                                                     
    SkImageShader::onMakeContext(...
    SkShaderBase::makeContext(...
    SkPictureShader::PictureShaderContext::PictureShaderContext(...
    SkPictureShader::PictureShaderContext::PictureShaderContext(...
    SkPictureShader::PictureShaderContext* SkArenaAlloc::make<...
    SkPictureShader::onMakeContext(...
    SkShaderBase::makeContext(...
    SkBlitter::Choose(...
    SkAutoBlitterChoose::SkAutoBlitterChoose(...
    SkAutoBlitterChoose::SkAutoBlitterChoose(...
    SkDraw::drawRect(...
    SkDraw::drawRect(...
    SkBitmapDevice::drawRect(...
    SkCanvas::onDrawRect(...
    SkCanvas::drawRect(...
    SkColorSpaceXformCanvas::onDrawRect(...
    SkCanvas::drawRect(...

If we go drill into the call at SkPictureImageGenerator::onGetPixels at the (**), we see that this has a SkCreateColorSpaceXformCanvas path that we don't hit.

I'm not too clear as to in which circumstances we want to be setting a color space on these objects for legacy mode or for non-legacy mode.

So, questions that I'm thinking about are:
1. What should a SkImage::MakeFromGenerator return as its colorSpace()?
     Should it lazily do onMakeColorSpace?
     Should it just say "sRGB" all the time?
     How do we specify that without accidentally hitting non-legacy mode?
2. Should  SkPictureImageGenerator::onGetPixels be hitting the color transform path here?

Blocking: 713891
I've verified that all 4 SW failures are fixed by forcing SkPictureImageGenerator::onGetPixels to know about the target color space.
Cc: -msarett@chromium.org brianosman@chromium.org ccameron@chromium.org
Owner: msarett@chromium.org
IIUC, SkImage::makeColorSpace() takes an early exit because it thinks that converting nullptr->sRGB is a no-op.

Since the SkImage is picture backed, we actually do need to make sure that we render using a SkColorSpaceXformCanvas with the dst set to sRGB.

I'll fix this.
Project Member

Comment 7 by bugdroid1@chromium.org, Jun 5 2017

The following revision refers to this bug:
  https://skia.googlesource.com/skia/+/d3df9ec874b2668111b36ce0993d860b4f88c765

commit d3df9ec874b2668111b36ce0993d860b4f88c765
Author: Matt Sarett <msarett@google.com>
Date: Mon Jun 05 15:13:40 2017

SkImage::makeColorSpace(): Fix nullptr->sRGB bug with picture images

Bug:  729352 
Change-Id: I5ad5e2121ce87dc154528bfd9ec0f3e9253ed792
Reviewed-on: https://skia-review.googlesource.com/18590
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Matt Sarett <msarett@google.com>

[modify] https://crrev.com/d3df9ec874b2668111b36ce0993d860b4f88c765/src/image/SkImage_Gpu.cpp
[modify] https://crrev.com/d3df9ec874b2668111b36ce0993d860b4f88c765/src/image/SkImage.cpp
[modify] https://crrev.com/d3df9ec874b2668111b36ce0993d860b4f88c765/src/image/SkImage_Raster.cpp

Thanks, this fix makes sense. I was a bit iffy on the idea of getting rid of the "un-tagged source" optimization, but the SkImage sub-classes will just return themselves from the makeColorSpace call.
Project Member

Comment 9 by bugdroid1@chromium.org, Jun 7 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/459e0438aa5b70656bdbafe3ab57a7948076834f

commit 459e0438aa5b70656bdbafe3ab57a7948076834f
Author: ccameron <ccameron@chromium.org>
Date: Wed Jun 07 02:36:10 2017

color: Remove test suppressions

The underlying bugs have been fixed

TBR=qyearsley

BUG= 729352 

Review-Url: https://codereview.chromium.org/2923923002
Cr-Commit-Position: refs/heads/master@{#477523}

[modify] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/TestExpectations
[rename] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/images/color-profile-background-image-space-expected.png
[rename] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/images/color-profile-svg-expected.png
[modify] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/linux/virtual/gpu-rasterization/images/color-profile-background-image-space-expected.png
[modify] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/linux/virtual/gpu-rasterization/images/color-profile-group-expected.png
[modify] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/linux/virtual/gpu-rasterization/images/color-profile-layer-filter-expected.png
[modify] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/linux/virtual/gpu-rasterization/images/color-profile-svg-expected.png
[modify] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/linux/virtual/gpu-rasterization/images/color-profile-svg-fill-text-expected.png
[modify] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/mac-mac10.10/images/color-profile-svg-fill-text-expected.png
[add] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/mac-mac10.10/virtual/gpu-rasterization/images/color-profile-group-expected.png
[modify] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/mac-mac10.10/virtual/gpu-rasterization/images/color-profile-svg-fill-text-expected.png
[delete] https://crrev.com/12a15b76226a3f5e24b2fa90a462b28a19634f0a/third_party/WebKit/LayoutTests/platform/mac-mac10.11/virtual/gpu-rasterization/images/color-profile-clip-expected.png
[add] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/mac-mac10.11/virtual/gpu-rasterization/images/color-profile-group-expected.png
[modify] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/mac-mac10.9/images/color-profile-svg-fill-text-expected.png
[modify] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/mac-mac10.9/virtual/gpu-rasterization/images/color-profile-svg-fill-text-expected.png
[delete] https://crrev.com/12a15b76226a3f5e24b2fa90a462b28a19634f0a/third_party/WebKit/LayoutTests/platform/mac-retina/virtual/gpu-rasterization/images/color-profile-clip-expected.png
[add] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/mac-retina/virtual/gpu-rasterization/images/color-profile-group-expected.png
[add] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/mac-retina/virtual/gpu-rasterization/images/color-profile-layer-filter-expected.png
[modify] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/mac/images/color-profile-background-image-cross-fade-expected.png
[delete] https://crrev.com/12a15b76226a3f5e24b2fa90a462b28a19634f0a/third_party/WebKit/LayoutTests/platform/mac/images/color-profile-background-image-space-expected.png
[modify] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/mac/images/color-profile-group-expected.png
[modify] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/mac/images/color-profile-layer-filter-expected.png
[delete] https://crrev.com/12a15b76226a3f5e24b2fa90a462b28a19634f0a/third_party/WebKit/LayoutTests/platform/mac/images/color-profile-svg-expected.png
[modify] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/mac/images/color-profile-svg-fill-text-expected.png
[modify] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/mac/virtual/gpu-rasterization/images/color-profile-background-image-space-expected.png
[modify] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/mac/virtual/gpu-rasterization/images/color-profile-clip-expected.png
[modify] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/mac/virtual/gpu-rasterization/images/color-profile-group-expected.png
[modify] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/mac/virtual/gpu-rasterization/images/color-profile-layer-filter-expected.png
[modify] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/mac/virtual/gpu-rasterization/images/color-profile-svg-expected.png
[modify] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/mac/virtual/gpu-rasterization/images/color-profile-svg-fill-text-expected.png
[modify] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/win/virtual/gpu-rasterization/images/color-profile-background-image-space-expected.png
[modify] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/win/virtual/gpu-rasterization/images/color-profile-layer-filter-expected.png
[modify] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/win/virtual/gpu-rasterization/images/color-profile-svg-expected.png
[modify] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/win/virtual/gpu-rasterization/images/color-profile-svg-fill-text-expected.png
[add] https://crrev.com/459e0438aa5b70656bdbafe3ab57a7948076834f/third_party/WebKit/LayoutTests/platform/win7/virtual/gpu-rasterization/images/color-profile-group-expected.png

Comment 10 by noel@chromium.org, Jun 9 2017

Cc: noel@chromium.org
Actual result color-profile-svg-actual.png in the OP looks odd. 

If I open its test case in Safari, on a screen with whacked color profile (to match was the layout test does), here is the result (attached).

This may or may not work for you, depending on what bugs.chromium.org does with image color profiles.



safari-color-profile-svg-actual.png
100 KB View Download
Status: Fixed (was: Assigned)

Sign in to add a comment