Add support for row-by-row png encodes
Also adds a SkEncoder base class.
Bug: 713862
Change-Id: Ia3f009cd9f376514f6c19396245fab3a43ae6536
Reviewed-on: https://skia-review.googlesource.com/15152
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Matt Sarett <msarett@google.com>
diff --git a/gm/encode-platform.cpp b/gm/encode-platform.cpp
index b6e0c1c..fa940b6 100644
--- a/gm/encode-platform.cpp
+++ b/gm/encode-platform.cpp
@@ -13,6 +13,7 @@
#include "SkImage.h"
#include "SkImageEncoderPriv.h"
#include "SkJpegEncoder.h"
+#include "SkPngEncoder.h"
#include "SkUnPreMultiply.h"
namespace skiagm {
@@ -69,9 +70,12 @@
return SkEncodeImageWithWIC(&buf, src, type, 100) ? buf.detachAsData() : nullptr;
#else
switch (type) {
- case SkEncodedImageFormat::kPNG:
- return SkEncodeImageAsPNG(&buf, src, SkEncodeOptions()) ? buf.detachAsData()
- : nullptr;
+ case SkEncodedImageFormat::kPNG: {
+ SkPngEncoder::Options options;
+ options.fUnpremulBehavior = SkTransferFunctionBehavior::kIgnore;
+ bool success = SkPngEncoder::Encode(&buf, src, options);
+ return success ? buf.detachAsData() : nullptr;
+ }
case SkEncodedImageFormat::kJPEG: {
bool success = SkJpegEncoder::Encode(&buf, src, SkJpegEncoder::Options());
return success ? buf.detachAsData() : nullptr;