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

Unified Diff: third_party/WebKit/Source/core/frame/ImageBitmap.cpp

Issue 1843953003: Add ColorspaceConversion to createImageBitmap(HTMLImageElement) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
Index: third_party/WebKit/Source/core/frame/ImageBitmap.cpp
diff --git a/third_party/WebKit/Source/core/frame/ImageBitmap.cpp b/third_party/WebKit/Source/core/frame/ImageBitmap.cpp
index 694ed0c58b08b296d90b7ee82202a9e2a2c93849..3076004f3d6da5f8045f308796feb29ae45256ea 100644
--- a/third_party/WebKit/Source/core/frame/ImageBitmap.cpp
+++ b/third_party/WebKit/Source/core/frame/ImageBitmap.cpp
@@ -102,7 +102,7 @@ PassRefPtr<SkImage> ImageBitmap::getSkImageFromDecoder(PassOwnPtr<ImageDecoder>
return adoptRef(SkImage::NewFromBitmap(bitmap));
}
-static PassRefPtr<StaticBitmapImage> cropImage(Image* image, const IntRect& cropRect, bool flipY, bool premultiplyAlpha, AlphaDisposition alphaOp = DontPremultiplyAlpha)
+static PassRefPtr<StaticBitmapImage> cropImage(Image* image, const IntRect& cropRect, bool flipY, bool premultiplyAlpha, AlphaDisposition alphaOp = DontPremultiplyAlpha, ImageDecoder::GammaAndColorProfileOption colorspaceOp = ImageDecoder::GammaAndColorProfileApplied)
{
ASSERT(image);
@@ -119,11 +119,10 @@ static PassRefPtr<StaticBitmapImage> cropImage(Image* image, const IntRect& crop
RefPtr<SkImage> skiaImage = image->imageForCurrentFrame();
// Attempt to get raw unpremultiplied image data, executed only when skiaImage is premultiplied.
- if (((!premultiplyAlpha && !skiaImage->isOpaque()) || !skiaImage) && image->data() && alphaOp == DontPremultiplyAlpha) {
- // TODO(xidachen): GammaAndColorProfileApplied needs to be changed when working on color-space conversion
- OwnPtr<ImageDecoder> decoder(ImageDecoder::create(
- *(image->data()), ImageDecoder::AlphaNotPremultiplied,
- ImageDecoder::GammaAndColorProfileApplied));
+ if ((((!premultiplyAlpha && !skiaImage->isOpaque()) || !skiaImage) && image->data() && alphaOp == DontPremultiplyAlpha) || colorspaceOp == ImageDecoder::GammaAndColorProfileIgnored) {
+ OwnPtr<ImageDecoder> decoder(ImageDecoder::create(*(image->data()),
+ premultiplyAlpha ? ImageDecoder::AlphaPremultiplied : ImageDecoder::AlphaNotPremultiplied,
Justin Novosad 2016/03/30 16:03:20 Not new to this CL, but could you clarify the diff
xidachen 2016/03/30 17:36:03 The parameter "premultiplyAlpha" indicates whether
xidachen 2016/03/30 17:45:30 Maybe change the "alphaOp" to "imageFormat" to ind
+ colorspaceOp));
if (!decoder)
return nullptr;
decoder->setData(image->data(), true);
@@ -169,7 +168,10 @@ ImageBitmap::ImageBitmap(HTMLImageElement* image, const IntRect& cropRect, Docum
bool premultiplyAlpha;
parseOptions(options, flipY, premultiplyAlpha);
- m_image = cropImage(image->cachedImage()->getImage(), cropRect, flipY, premultiplyAlpha);
+ if (options.colorspaceConversion() == "none")
+ m_image = cropImage(image->cachedImage()->getImage(), cropRect, flipY, premultiplyAlpha, DontPremultiplyAlpha, ImageDecoder::GammaAndColorProfileIgnored);
+ else
+ m_image = cropImage(image->cachedImage()->getImage(), cropRect, flipY, premultiplyAlpha, DontPremultiplyAlpha, ImageDecoder::GammaAndColorProfileApplied);
if (!m_image)
return;
m_image->setOriginClean(!image->wouldTaintOrigin(document->getSecurityOrigin()));

Powered by Google App Engine
This is Rietveld 408576698