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

Unified Diff: third_party/WebKit/Source/platform/graphics/PictureSnapshot.cpp

Issue 1812273003: Eliminate copies of encoded image data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: m_encodedData -> m_consolidatedData (to better distinguish from m_data) Created 4 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/graphics/PictureSnapshot.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/PictureSnapshot.cpp b/third_party/WebKit/Source/platform/graphics/PictureSnapshot.cpp
index 7d322be9caf0a951dca06ff01ad53ab621f3833f..2264648c8a3f0f4a60ed7faa9139d86058c1775e 100644
--- a/third_party/WebKit/Source/platform/graphics/PictureSnapshot.cpp
+++ b/third_party/WebKit/Source/platform/graphics/PictureSnapshot.cpp
@@ -38,7 +38,9 @@
#include "platform/graphics/skia/ImagePixelLocker.h"
#include "platform/image-decoders/ImageDecoder.h"
#include "platform/image-decoders/ImageFrame.h"
+#include "platform/image-decoders/SegmentReader.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"
@@ -56,11 +58,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<SegmentReader> segmentReader = SegmentReader::createFromSkData(adoptRef(SkData::NewWithoutCopy(data, length)));
+ imageDecoder->setData(segmentReader.release(), true);
ImageFrame* frame = imageDecoder->frameBufferAtIndex(0);
if (!frame)
return true;

Powered by Google App Engine
This is Rietveld 408576698