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

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

Issue 2659063003: Avoid non-opaque->opaque requests to SkCanvas::writePixels() (Closed)
Patch Set: 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 | « no previous file | 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/ImageBuffer.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp b/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp
index da8c2387885358553fa62d6e61f819150e05c167..d141d62a843f46d5dfdad9c689e8684130b279dc 100644
--- a/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp
+++ b/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp
@@ -467,8 +467,20 @@ void ImageBuffer::putByteArray(Multiply multiplied,
const size_t srcBytesPerRow = bytesPerPixel * sourceSize.width();
const void* srcAddr =
source + originY * srcBytesPerRow + originX * bytesPerPixel;
- SkAlphaType alphaType = (multiplied == Premultiplied) ? kPremul_SkAlphaType
- : kUnpremul_SkAlphaType;
+
+ SkAlphaType alphaType;
+ if (Opaque == m_surface->getOpacityMode()) {
+ // If the surface is opaque, tell it that we are writing opaque
+ // pixels. Writing non-opaque pixels to opaque is undefined in
+ // Skia. There is some discussion about whether it should be
+ // defined in skbug.com/6157. For now, we can get the desired
+ // behavior (memcpy) by pretending the write is opaque.
+ alphaType = kOpaque_SkAlphaType;
+ } else {
+ alphaType = (multiplied == Premultiplied) ? kPremul_SkAlphaType
+ : kUnpremul_SkAlphaType;
+ }
+
SkImageInfo info;
if (m_surface->colorSpace()) {
info = SkImageInfo::Make(sourceRect.width(), sourceRect.height(),
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698