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 683281f3a3f66a592d7656ef167a90e4bdd17438..04c3decee6ac2116768a0585bd597bcd51a8b8a5 100644 |
| --- a/third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp |
| +++ b/third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp |
| @@ -83,10 +83,15 @@ bool ImageFrame::CopyBitmapData(const ImageFrame& other) { |
| DCHECK_NE(this, &other); |
| has_alpha_ = other.has_alpha_; |
| bitmap_.reset(); |
| + bool copied = false; |
|
scroggo_chromium
2017/06/05 19:00:53
nit: My preference would be to drop this local var
cblume
2017/06/06 04:04:35
Done.
|
| SkImageInfo info = other.bitmap_.info(); |
| - return bitmap_.tryAllocPixels(info) && |
| - other.bitmap_.readPixels(info, bitmap_.getPixels(), bitmap_.rowBytes(), |
| - 0, 0); |
| + if (bitmap_.tryAllocPixels(info)) { |
| + status_ = kFrameAllocated; |
|
scroggo_chromium
2017/06/05 19:00:53
So if we fail in readPixels, we'll still have the
cblume
2017/06/06 04:04:35
Right.
At that point we *have* allocated (with try
|
| + copied = other.bitmap_.readPixels(info, bitmap_.getPixels(), |
| + bitmap_.rowBytes(), 0, 0); |
| + } |
| + |
| + return copied; |
| } |
| bool ImageFrame::TakeBitmapDataIfWritable(ImageFrame* other) { |
| @@ -100,6 +105,7 @@ bool ImageFrame::TakeBitmapDataIfWritable(ImageFrame* other) { |
| bitmap_.reset(); |
| bitmap_.swap(other->bitmap_); |
| other->status_ = kFrameEmpty; |
| + status_ = kFrameAllocated; |
| return true; |
| } |
| @@ -113,7 +119,11 @@ bool ImageFrame::AllocatePixelData(int new_width, |
| new_width, new_height, |
| premultiply_alpha_ ? kPremul_SkAlphaType : kUnpremul_SkAlphaType, |
| std::move(color_space))); |
| - return bitmap_.tryAllocPixels(allocator_, 0); |
| + bool allocated = bitmap_.tryAllocPixels(allocator_, 0); |
| + if (allocated) |
| + status_ = kFrameAllocated; |
| + |
| + return allocated; |
| } |
| bool ImageFrame::HasAlpha() const { |