Chromium Code Reviews| 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..c9c207b434b6543acc31b75f49943b6db2a817e2 100644 |
| --- a/third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp |
| +++ b/third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp |
| @@ -103,11 +103,12 @@ 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::setSizeAndColorSpaceWithoutZeroFilling( |
| + int newWidth, |
| + int newHeight, |
| + sk_sp<SkColorSpace> colorSpace) { |
|
scroggo_chromium
2017/03/13 20:36:40
Why not add a boolean (or an enum) for zeroFill?
cblume
2017/03/13 21:53:12
I am happy to make it 1 function with a parameter
cblume
2017/03/16 11:03:30
I made a separate pull request that I think refact
|
| + // Either setSizeAndColorSpaceWithoutZeroFilling() or setSizeAndcolorSpace() |
| + // should only be called once. It leaks memory otherwise. |
|
scroggo_chromium
2017/03/13 20:36:40
This is a modified version of an existing comment,
cblume
2017/03/13 21:53:12
Okay. If it is safe then I think this comment shou
scroggo_chromium
2017/03/14 16:08:48
The idea of the ExternalMemoryAllocator is that so
|
| DCHECK(!width() && !height()); |
| m_bitmap.setInfo(SkImageInfo::MakeN32( |
| @@ -117,6 +118,17 @@ bool ImageFrame::setSizeAndColorSpace(int newWidth, |
| if (!m_bitmap.tryAllocPixels(m_allocator, 0)) |
| return false; |
|
scroggo_chromium
2017/03/13 20:36:40
I don't like having two separate methods for this,
cblume
2017/03/13 21:53:12
Done.
|
| + return true; |
| +} |
| + |
| +bool ImageFrame::setSizeAndColorSpace(int newWidth, |
| + int newHeight, |
| + sk_sp<SkColorSpace> colorSpace) { |
| + // Either setSizeAndColorSpaceWithoutZeroFilling() or setSizeAndcolorSpace() |
| + // should only be called once. It leaks memory otherwise. |
| + if (!setSizeAndColorSpaceWithoutZeroFilling(newWidth, newHeight, colorSpace)) |
| + return false; |
| + |
| zeroFillPixelData(); |
| return true; |
| } |