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

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: Convert to PassRefPtr in ImageDecoder, helper for setData 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 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;

Powered by Google App Engine
This is Rietveld 408576698