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

Unified Diff: third_party/WebKit/Source/platform/image-encoders/ImageEncoder.h

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/image-encoders/ImageEncoder.h
diff --git a/third_party/WebKit/Source/platform/image-encoders/ImageEncoder.h b/third_party/WebKit/Source/platform/image-encoders/ImageEncoder.h
index b33e72deead2f37e50780ab36ea4c45541e87cc7..819fd6bc5bbd21dbe5c16f614483e14b2834abe0 100644
--- a/third_party/WebKit/Source/platform/image-encoders/ImageEncoder.h
+++ b/third_party/WebKit/Source/platform/image-encoders/ImageEncoder.h
@@ -10,6 +10,7 @@
#include "third_party/skia/include/core/SkStream.h"
#include "third_party/skia/include/encode/SkJpegEncoder.h"
#include "third_party/skia/include/encode/SkPngEncoder.h"
+#include "third_party/skia/include/encode/SkWebpEncoder.h"
namespace blink {
@@ -42,6 +43,10 @@ class PLATFORM_EXPORT ImageEncoder {
const SkPixmap& src,
const SkPngEncoder::Options&);
+ static bool Encode(Vector<unsigned char>* dst,
+ const SkPixmap& src,
+ const SkWebpEncoder::Options&);
+
static std::unique_ptr<ImageEncoder> Create(Vector<unsigned char>* dst,
const SkPixmap& src,
const SkJpegEncoder::Options&);
@@ -56,10 +61,25 @@ class PLATFORM_EXPORT ImageEncoder {
* If quality is in [0, 1], this will simply convert to a [0, 100]
* integer scale (which is what is used by libjpeg-turbo).
*
- * Otherwise, this will return the default value.
+ * Otherwise, this will return the default value (92).
*/
static int ComputeJpegQuality(double quality);
+ /**
+ * Sets Skia encoding options based on the requested quality.
+ *
+ * If quality is 1, this will signal a lossless encode.
+ *
+ * Otherwise, this will use webp lossy encoding.
+ * If quality is in [0, 1), this will simply convert to a [0, 100)
+ * float scale (which is what is used by libwebp). If the quality
+ * is out of range, this will perform a lossy encode with the default
+ * value (80).
+ */
+ static SkWebpEncoder::Options ComputeWebpOptions(
+ double quality,
+ SkTransferFunctionBehavior unpremulBehavior);
+
private:
ImageEncoder(Vector<unsigned char>* dst) : dst_(dst) {}

Powered by Google App Engine
This is Rietveld 408576698