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

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

Issue 2891373002: Use SkPngEncoder and SkWebpEncoder in WebKit platform (Closed)
Patch Set: Adjust comments Created 3 years, 7 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 a915e391eab6ed432aa8c0bfe65fd0a4a7fee394..07abbb02b1f8e18cd386a093edae4ba227de0e4e 100644
--- a/third_party/WebKit/Source/platform/graphics/PictureSnapshot.cpp
+++ b/third_party/WebKit/Source/platform/graphics/PictureSnapshot.cpp
@@ -40,7 +40,7 @@
#include "platform/image-decoders/ImageDecoder.h"
#include "platform/image-decoders/ImageFrame.h"
#include "platform/image-decoders/SegmentReader.h"
-#include "platform/image-encoders/PNGImageEncoder.h"
+#include "platform/image-encoders/ImageEncoder.h"
#include "platform/wtf/CurrentTime.h"
#include "platform/wtf/HexNumber.h"
#include "platform/wtf/PtrUtil.h"
@@ -145,18 +145,19 @@ std::unique_ptr<Vector<char>> PictureSnapshot::Replay(unsigned from_step,
std::unique_ptr<Vector<char>> base64_data = WTF::MakeUnique<Vector<char>>();
Vector<char> encoded_image;
- sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
- if (!image)
- return nullptr;
-
- ImagePixelLocker pixel_locker(image, kUnpremul_SkAlphaType,
- kRGBA_8888_SkColorType);
- ImageDataBuffer image_data(
- IntSize(image->width(), image->height()),
- static_cast<const unsigned char*>(pixel_locker.Pixels()));
- if (!PNGImageEncoder::Encode(
- image_data, reinterpret_cast<Vector<unsigned char>*>(&encoded_image)))
+ SkPixmap src;
+ bool peekResult = bitmap.peekPixels(&src);
+ DCHECK(peekResult);
+
+ SkPngEncoder::Options options;
scroggo_chromium 2017/05/22 13:35:04 Both LoggingCanvas.cpp and this one use the same v
msarett1 2017/05/22 15:33:56 Arguably kIgnore should be the default - but I'm t
+ options.fFilterFlags = SkPngEncoder::FilterFlag::kSub;
+ options.fZLibLevel = 3;
+ options.fUnpremulBehavior = SkTransferFunctionBehavior::kIgnore;
+ if (!ImageEncoder::Encode(
+ reinterpret_cast<Vector<unsigned char>*>(&encoded_image), src,
+ options)) {
return nullptr;
+ }
Base64Encode(encoded_image, *base64_data);
return base64_data;

Powered by Google App Engine
This is Rietveld 408576698