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..49c18e02eae3d7c5a7ae082620078b62ea799299 100644 |
| --- a/third_party/WebKit/Source/platform/graphics/PictureSnapshot.cpp |
| +++ b/third_party/WebKit/Source/platform/graphics/PictureSnapshot.cpp |
| @@ -38,7 +38,10 @@ |
| #include "platform/graphics/skia/ImagePixelLocker.h" |
| #include "platform/image-decoders/ImageDecoder.h" |
| #include "platform/image-decoders/ImageFrame.h" |
| +#include "platform/image-decoders/SkDataSegmentReader.h" |
|
scroggo_chromium
2016/03/22 20:18:42
I'm not sure the proper way to name this, since it
Peter Kasting
2016/03/23 02:42:58
I think DataSegmentReader is still readable enough
f(malita)
2016/03/23 16:41:58
I would normally use SkiaDataSegmentReader to clar
scroggo_chromium
2016/03/24 13:59:45
How did you choose between DataSegmentReader and S
Peter Kasting
2016/03/24 22:05:43
It sounds like that would be a bit cleaner, yes; m
scroggo_chromium
2016/03/25 01:05:10
I've left the names alone and switched to using fa
|
| #include "platform/image-encoders/skia/PNGImageEncoder.h" |
| +#include "skia/ext/refptr.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 +58,13 @@ 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); |
| + // No need to copy the data; this decodes immediately. |
| + skia::RefPtr<SkData> skdata = skia::AdoptRef(SkData::NewWithoutCopy(data, length)); |
|
f(malita)
2016/03/23 16:41:58
RefPtr<SkData> skData = adoptRef(...);
scroggo_chromium
2016/03/24 13:59:45
Now that DataSegmentReader takes a PassRefPtr, I j
|
| + SkDataSegmentReader segmentReader(skdata.get()); |
|
Peter Kasting
2016/03/23 02:42:58
I think this needs to be refcounted if it's passed
scroggo_chromium
2016/03/24 13:59:45
I think this is safe since the ImageDecoder will r
|
| + OwnPtr<ImageDecoder> imageDecoder = ImageDecoder::create(segmentReader, ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileIgnored); |
| if (!imageDecoder) |
| return false; |
| - imageDecoder->setData(buffer.get(), true); |
| + imageDecoder->setData(&segmentReader, true); |
| ImageFrame* frame = imageDecoder->frameBufferAtIndex(0); |
| if (!frame) |
| return true; |