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

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

Issue 2749703002: Refactor ImageFrame::setSizeAndColorSpace() (Closed)
Patch Set: Moving to another CR the separation of zeroing pixel data from setting alpha 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..af1e07f91fda56196443c9254fd4f3151c1ca6c9 100644
--- a/third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp
@@ -103,22 +103,17 @@ 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.
+bool ImageFrame::allocatePixelData(int newWidth,
+ int newHeight,
+ sk_sp<SkColorSpace> colorSpace) {
+ // 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)));
- 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