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

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

Issue 2749703002: Refactor ImageFrame::setSizeAndColorSpace() (Closed)
Patch Set: Call setHasAlpha(true); from within zeroFillPixelData() 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
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 40952951b85fb16987b40f5a4ab85f7c284ea00a..9fde4bd8f3fdc0a717ecaff793dd0d5a466bb91f 100644
--- a/third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp
@@ -78,8 +78,8 @@ void ImageFrame::clearPixelData() {
}
void ImageFrame::zeroFillPixelData() {
+ setHasAlpha(true);
Noel Gordon 2017/03/16 12:01:50 Harmless, but also redundant. It sets the m_bitma
cblume 2017/03/17 05:35:14 Wait....you're right. I could have sworn it made p
Peter Kasting 2017/03/17 06:35:50 Because the BMP decoder needs it, no? It allocate
cblume 2017/03/17 18:05:45 It is now being explicitly set in BMPImageReader.c
Noel Gordon 2017/03/20 13:24:52 Not sure they're separate concepts. Somewhat odd
m_bitmap.eraseARGB(0, 0, 0, 0);
- m_hasAlpha = true;
}
bool ImageFrame::copyBitmapData(const ImageFrame& other) {
@@ -103,22 +103,14 @@ bool ImageFrame::takeBitmapDataIfWritable(ImageFrame* other) {
return true;
}
-bool ImageFrame::setSizeAndColorSpace(int newWidth,
- int newHeight,
- sk_sp<SkColorSpace> colorSpace) {
- // setSizeAndColorSpace() should only be called once, it leaks memory
- // otherwise.
- DCHECK(!width() && !height());
-
+bool ImageFrame::allocatePixelData(int newWidth,
+ int newHeight,
+ sk_sp<SkColorSpace> colorSpace) {
m_bitmap.setInfo(SkImageInfo::MakeN32(
newWidth, newHeight,
m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType,
std::move(colorSpace)));
- if (!m_bitmap.tryAllocPixels(m_allocator, 0))
- return false;
-
- zeroFillPixelData();
- return true;
+ return m_bitmap.tryAllocPixels(m_allocator, 0);
}
bool ImageFrame::hasAlpha() const {

Powered by Google App Engine
This is Rietveld 408576698