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-srgb.cpp b/gm/encode-srgb.cpp
index bbaeaa7..bf9ef82 100644
--- a/gm/encode-srgb.cpp
+++ b/gm/encode-srgb.cpp
@@ -15,6 +15,7 @@
 #include "SkImage.h"
 #include "SkImageEncoderPriv.h"
 #include "SkJpegEncoder.h"
+#include "SkPngEncoder.h"
 #include "SkPM4f.h"
 #include "SkSRGB.h"
 
@@ -117,14 +118,16 @@
     }
     SkDynamicMemoryWStream buf;
 
+    SkPngEncoder::Options pngOptions;
     SkEncodeOptions options;
     if (bitmap.colorSpace()) {
+        pngOptions.fUnpremulBehavior = SkTransferFunctionBehavior::kRespect;
         options.fUnpremulBehavior = SkTransferFunctionBehavior::kRespect;
     }
 
     switch (format) {
         case SkEncodedImageFormat::kPNG:
-            SkAssertResult(SkEncodeImageAsPNG(&buf, src, options));
+            SkAssertResult(SkPngEncoder::Encode(&buf, src, pngOptions));
             break;
         case SkEncodedImageFormat::kWEBP:
             SkAssertResult(SkEncodeImageAsWEBP(&buf, src, options));