Chromium Code Reviews| Index: third_party/WebKit/Source/platform/graphics/DecodingImageGenerator.cpp |
| diff --git a/third_party/WebKit/Source/platform/graphics/DecodingImageGenerator.cpp b/third_party/WebKit/Source/platform/graphics/DecodingImageGenerator.cpp |
| index a50faac2c0d81841ba6ea89ba3ebb135e5525756..b482e220e84dc60ce3b84d5ca97ee704913879cf 100644 |
| --- a/third_party/WebKit/Source/platform/graphics/DecodingImageGenerator.cpp |
| +++ b/third_party/WebKit/Source/platform/graphics/DecodingImageGenerator.cpp |
| @@ -65,11 +65,16 @@ SkData* DecodingImageGenerator::onRefEncodedData() { |
| static void doColorSpaceXform(const SkImageInfo& dst_info, |
|
msarett1
2017/05/16 18:02:46
Now that readPixels() has been ramped up, we shoul
|
| void* pixels, |
| size_t row_bytes, |
| - SkColorSpace* src_color_space) { |
| + SkColorSpace* src_color_space, |
| + SkTransferFunctionBehavior behavior) { |
| TRACE_EVENT0("blink", "DecodingImageGenerator::getPixels - apply xform"); |
| std::unique_ptr<SkColorSpaceXform> xform = |
| SkColorSpaceXform::New(src_color_space, dst_info.colorSpace()); |
| + const bool post_xform_premul = |
| + (dst_info.alphaType() == kPremul_SkAlphaType) && |
| + (behavior == SkTransferFunctionBehavior::kIgnore); |
| + |
| uint32_t* row = reinterpret_cast<uint32_t*>(pixels); |
| for (int y = 0; y < dst_info.height(); y++) { |
| SkColorSpaceXform::ColorFormat format = |
| @@ -77,14 +82,16 @@ static void doColorSpaceXform(const SkImageInfo& dst_info, |
| if (kN32_SkColorType == kBGRA_8888_SkColorType) { |
| format = SkColorSpaceXform::kBGRA_8888_ColorFormat; |
| } |
| - SkAlphaType alpha_type = |
| - dst_info.isOpaque() ? kOpaque_SkAlphaType : kUnpremul_SkAlphaType; |
| + SkAlphaType alpha_type = dst_info.alphaType(); |
| + if (post_xform_premul) { |
| + alpha_type = kUnpremul_SkAlphaType; |
|
f(malita)
2017/05/16 18:16:45
uber-nit: i think ternary op would fit better than
msarett1
2017/05/16 18:59:16
Done.
|
| + } |
| bool xformed = |
| xform->apply(format, row, format, row, dst_info.width(), alpha_type); |
| DCHECK(xformed); |
| // To be compatible with dst space blending, premultiply in the dst space. |
| - if (kPremul_SkAlphaType == dst_info.alphaType()) { |
| + if (post_xform_premul) { |
| for (int x = 0; x < dst_info.width(); x++) { |
| row[x] = |
| SkPreMultiplyARGB(SkGetPackedA32(row[x]), SkGetPackedR32(row[x]), |
| @@ -100,8 +107,7 @@ static void doColorSpaceXform(const SkImageInfo& dst_info, |
| bool DecodingImageGenerator::onGetPixels(const SkImageInfo& dst_info, |
| void* pixels, |
| size_t row_bytes, |
| - SkPMColor*, |
| - int*) { |
| + const Options& options) { |
| TRACE_EVENT1("blink", "DecodingImageGenerator::getPixels", "frame index", |
| static_cast<int>(frame_index_)); |
| @@ -142,7 +148,8 @@ bool DecodingImageGenerator::onGetPixels(const SkImageInfo& dst_info, |
| PlatformInstrumentation::DidDecodeLazyPixelRef(); |
| if (decoded && needs_color_xform) { |
| - doColorSpaceXform(dst_info, pixels, row_bytes, decode_color_space); |
| + doColorSpaceXform(dst_info, pixels, row_bytes, decode_color_space, |
| + options.fBehavior); |
| } |
| return decoded; |