| 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..2327de1ccefab0f9c98ff73bbfd07cfb7ef3ffd5 100644
|
| --- a/third_party/WebKit/Source/core/frame/ImageBitmap.cpp
|
| +++ b/third_party/WebKit/Source/core/frame/ImageBitmap.cpp
|
| @@ -102,7 +102,10 @@ 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)
|
| +// The parameter imageFormat indicates whether the first parameter "image" is unpremultiplied or not.
|
| +// For example, if the image is already in unpremultiplied format and we want the created ImageBitmap
|
| +// in the same format, then we don't need to use the ImageDecoder to decode the image.
|
| +static PassRefPtr<StaticBitmapImage> cropImage(Image* image, const IntRect& cropRect, bool flipY, bool premultiplyAlpha, AlphaDisposition imageFormat = DontPremultiplyAlpha, ImageDecoder::GammaAndColorProfileOption colorspaceOp = ImageDecoder::GammaAndColorProfileApplied)
|
| {
|
| ASSERT(image);
|
|
|
| @@ -119,11 +122,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() && imageFormat == DontPremultiplyAlpha) || colorspaceOp == ImageDecoder::GammaAndColorProfileIgnored) {
|
| + OwnPtr<ImageDecoder> decoder(ImageDecoder::create(*(image->data()),
|
| + premultiplyAlpha ? ImageDecoder::AlphaPremultiplied : ImageDecoder::AlphaNotPremultiplied,
|
| + colorspaceOp));
|
| if (!decoder)
|
| return nullptr;
|
| decoder->setData(image->data(), true);
|
| @@ -169,7 +171,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()));
|
|
|