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

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

Issue 2891373002: Use SkPngEncoder and SkWebpEncoder in WebKit platform (Closed)
Patch Set: Response to 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/LoggingCanvas.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/LoggingCanvas.cpp b/third_party/WebKit/Source/platform/graphics/LoggingCanvas.cpp
index fb4eebcc58a5dfe2016627ddd1576acd9b191b24..bcbe81b50e78eac5c6a6a079c771e2044f705a08 100644
--- a/third_party/WebKit/Source/platform/graphics/LoggingCanvas.cpp
+++ b/third_party/WebKit/Source/platform/graphics/LoggingCanvas.cpp
@@ -34,7 +34,7 @@
#include "platform/graphics/ImageBuffer.h"
#include "platform/graphics/skia/ImagePixelLocker.h"
#include "platform/graphics/skia/SkiaUtils.h"
-#include "platform/image-encoders/PNGImageEncoder.h"
+#include "platform/image-encoders/ImageEncoder.h"
#include "platform/wtf/HexNumber.h"
#include "platform/wtf/text/Base64.h"
#include "platform/wtf/text/TextEncoding.h"
@@ -266,14 +266,16 @@ String ColorTypeName(SkColorType color_type) {
std::unique_ptr<JSONObject> ObjectForBitmapData(const SkBitmap& bitmap) {
Vector<unsigned char> output;
- if (sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap)) {
- 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()));
+ SkPixmap src;
+ bool peekResult = bitmap.peekPixels(&src);
+ DCHECK(peekResult);
- PNGImageEncoder::Encode(image_data, &output);
+ SkPngEncoder::Options options;
+ options.fFilterFlags = SkPngEncoder::FilterFlag::kSub;
+ options.fZLibLevel = 3;
+ options.fUnpremulBehavior = SkTransferFunctionBehavior::kIgnore;
+ if (!ImageEncoder::Encode(&output, src, options)) {
+ return nullptr;
}
std::unique_ptr<JSONObject> data_item = JSONObject::Create();

Powered by Google App Engine
This is Rietveld 408576698