Chromium Code Reviews| Index: third_party/WebKit/Source/platform/graphics/PictureSnapshot.cpp |
| diff --git a/third_party/WebKit/Source/platform/graphics/PictureSnapshot.cpp b/third_party/WebKit/Source/platform/graphics/PictureSnapshot.cpp |
| index 2746fbf217dcf0933e2abbe00ccbf2fbd48a1e52..3c8e3365bec5af33142fa266cf255c95cb9d8484 100644 |
| --- a/third_party/WebKit/Source/platform/graphics/PictureSnapshot.cpp |
| +++ b/third_party/WebKit/Source/platform/graphics/PictureSnapshot.cpp |
| @@ -36,9 +36,11 @@ |
| #include "platform/graphics/ProfilingCanvas.h" |
| #include "platform/graphics/ReplayingCanvas.h" |
| #include "platform/graphics/skia/ImagePixelLocker.h" |
| +#include "platform/image-decoders/DataSegmentReader.h" |
| #include "platform/image-decoders/ImageDecoder.h" |
| #include "platform/image-decoders/ImageFrame.h" |
| #include "platform/image-encoders/skia/PNGImageEncoder.h" |
| +#include "third_party/skia/include/core/SkData.h" |
| #include "third_party/skia/include/core/SkImage.h" |
| #include "third_party/skia/include/core/SkPictureRecorder.h" |
| #include "third_party/skia/include/core/SkStream.h" |
| @@ -55,11 +57,14 @@ PictureSnapshot::PictureSnapshot(PassRefPtr<const SkPicture> picture) |
| static bool decodeBitmap(const void* data, size_t length, SkBitmap* result) |
| { |
| - RefPtr<SharedBuffer> buffer = SharedBuffer::create(static_cast<const char*>(data), length); |
| - OwnPtr<ImageDecoder> imageDecoder = ImageDecoder::create(*buffer, ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileIgnored); |
| + OwnPtr<ImageDecoder> imageDecoder = ImageDecoder::create(static_cast<const char*>(data), length, |
| + ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileIgnored); |
| if (!imageDecoder) |
| return false; |
| - imageDecoder->setData(buffer.get(), true); |
| + |
| + // No need to copy the data; this decodes immediately. |
| + RefPtr<DataSegmentReader> segmentReader = new DataSegmentReader(adoptRef(SkData::NewWithoutCopy(data, length))); |
|
scroggo_chromium
2016/03/24 13:59:46
Oops, I think the DataSegmentReader needs to be ad
|
| + imageDecoder->setData(segmentReader.release(), true); |
| ImageFrame* frame = imageDecoder->frameBufferAtIndex(0); |
| if (!frame) |
| return true; |