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

Unified Diff: third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp

Issue 2762643004: Separate zeroing pixel data from setting alpha (Closed)
Patch Set: Rebase Created 3 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp
diff --git a/third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp b/third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp
index af1e07f91fda56196443c9254fd4f3151c1ca6c9..d6eb419669797a89f3ebbc40ffc04508ff0af391 100644
--- a/third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp
@@ -79,7 +79,6 @@ void ImageFrame::clearPixelData() {
void ImageFrame::zeroFillPixelData() {
m_bitmap.eraseARGB(0, 0, 0, 0);
- m_hasAlpha = true;
}
bool ImageFrame::copyBitmapData(const ImageFrame& other) {
@@ -109,10 +108,14 @@ bool ImageFrame::allocatePixelData(int newWidth,
// allocatePixelData() should only be called once.
DCHECK(!width() && !height());
- m_bitmap.setInfo(SkImageInfo::MakeN32(
- newWidth, newHeight,
- m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType,
- std::move(colorSpace)));
+ SkAlphaType alphaType = kOpaque_SkAlphaType;
+ if (m_hasAlpha) {
+ alphaType =
+ m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType;
+ }
+
+ m_bitmap.setInfo(SkImageInfo::MakeN32(newWidth, newHeight, alphaType,
+ std::move(colorSpace)));
return m_bitmap.tryAllocPixels(m_allocator, 0);
}
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698