Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(656)

Unified Diff: third_party/WebKit/Source/platform/graphics/DecodingImageGenerator.cpp

Issue 2801413002: color: Enable color conversion in image decoder caches (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/tiles/software_image_decode_cache.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 78dea66626650db17f55dd143817340770044d42..412b7f7f331f0695e3187fb4e7d2642ca2956701 100644
--- a/third_party/WebKit/Source/platform/graphics/DecodingImageGenerator.cpp
+++ b/third_party/WebKit/Source/platform/graphics/DecodingImageGenerator.cpp
@@ -96,8 +96,46 @@ bool DecodingImageGenerator::onGetPixels(const SkImageInfo& info,
m_data.get(), m_allDataReceived, m_frameIndex, getInfo(), pixels,
rowBytes);
PlatformInstrumentation::didDecodeLazyPixelRef();
+ if (!decoded)
+ return false;
- return decoded;
+ // Apply color space transformation if requested. Do not fail the decode if
msarett1 2017/04/10 15:27:21 Why not? When is it ok to fail?
ccameron 2017/04/10 20:04:06 This is to match existing behavior -- see for inst
msarett1 2017/04/10 21:02:53 Acknowledged.
+ // the color transform fails.
+ if (info.colorSpace() &&
+ !SkColorSpace::Equals(info.colorSpace(), getInfo().colorSpace())) {
+ SkColorSpaceXform::ColorFormat xformColorFormat =
+ SkColorSpaceXform::kRGBA_8888_ColorFormat;
+ switch (info.colorType()) {
+ case kRGBA_8888_SkColorType:
+ xformColorFormat = SkColorSpaceXform::kRGBA_8888_ColorFormat;
+ break;
+ case kBGRA_8888_SkColorType:
+ xformColorFormat = SkColorSpaceXform::kBGRA_8888_ColorFormat;
+ break;
+ case kRGBA_F16_SkColorType:
msarett1 2017/04/10 15:27:21 This case feels a little strange here. Supporting
ccameron 2017/04/10 20:04:06 (rebased on your patch instead)
+ xformColorFormat = SkColorSpaceXform::kRGBA_F16_ColorFormat;
+ break;
+ case kRGB_565_SkColorType:
msarett1 2017/04/10 15:27:21 Let's not support 565 in Chrome. This ColorFormat
ccameron 2017/04/10 20:04:06 (rebased on your patch instead)
+ xformColorFormat = SkColorSpaceXform::kBGR_565_ColorFormat;
+ break;
+ default:
+ // Not supported.
+ return true;
+ }
+ std::unique_ptr<SkColorSpaceXform> xform =
+ SkColorSpaceXform::New(getInfo().colorSpace(), info.colorSpace());
+ if (!xform)
+ return true;
+ uint8_t* row = reinterpret_cast<uint8_t*>(pixels);
+ for (int y = 0; y < info.height(); y++) {
+ bool applyResult = xform->apply(xformColorFormat, row, xformColorFormat,
+ row, info.width(), info.alphaType());
msarett1 2017/04/10 15:27:21 This won't handle alpha correctly. kOpaque will b
ccameron 2017/04/10 20:04:06 (rebased on your patch instead)
+ DCHECK(applyResult);
+ row += rowBytes;
+ }
+ }
+
+ return true;
}
bool DecodingImageGenerator::onQueryYUV8(SkYUVSizeInfo* sizeInfo,
« no previous file with comments | « cc/tiles/software_image_decode_cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698