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

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

Issue 2641393002: Refactor ImageBitmap to stop drawing unpremul SkImage on SkCanvas (Closed)
Patch Set: Addressing comments. Created 3 years, 11 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 | « third_party/WebKit/LayoutTests/fast/canvas/webgl/resources/tex-image-and-sub-image-image-bitmap-utils.js ('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/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 d5f6e8af1790a049ad772ed2c5e34db56f804efc..b71204e87c025f3e20e393a6c404a9ec08b8cb72 100644
--- a/third_party/WebKit/Source/core/frame/ImageBitmap.cpp
+++ b/third_party/WebKit/Source/core/frame/ImageBitmap.cpp
@@ -365,7 +365,6 @@ static void applyColorSpaceConversion(sk_sp<SkImage>& image,
}
return;
}
-
// Skia does not support drawing to unpremul surfaces/canvases.
sk_sp<SkImage> unPremulImage = nullptr;
if (image->alphaType() == kUnpremul_SkAlphaType)
@@ -1102,7 +1101,16 @@ PassRefPtr<Image> ImageBitmap::getSourceImageForCanvas(
SnapshotReason,
const FloatSize&) const {
*status = NormalSourceImageStatus;
- return m_image ? m_image : nullptr;
+ if (!m_image)
+ return nullptr;
+ if (m_image->isPremultiplied())
+ return m_image;
+ // Skia does not support drawing unpremul SkImage on SkCanvas.
+ // Premultiply and return.
+ sk_sp<SkImage> premulSkImage = unPremulSkImageToPremul(
+ m_image->imageForCurrentFrame(ColorBehavior::transformToGlobalTarget())
+ .get());
+ return StaticBitmapImage::create(premulSkImage);
}
void ImageBitmap::adjustDrawRects(FloatRect* srcRect,
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/canvas/webgl/resources/tex-image-and-sub-image-image-bitmap-utils.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698