Report 0 rowsDecoded for no rows (SkPngCodec interlaced)

incrementalDecode is supposed to report the number of rows decoded. It
failed to if none were decoded (for an interlaced png). Fix the bug and
add a test.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2402063002

Review-Url: https://codereview.chromium.org/2402063002
diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp
index a8f8781..bae8344 100644
--- a/tests/CodecTest.cpp
+++ b/tests/CodecTest.cpp
@@ -1332,3 +1332,32 @@
     result = codec->getAndroidPixels(info, bm.getPixels(), bm.rowBytes(), &opts);
     REPORTER_ASSERT(r, result == SkCodec::kSuccess);
 }
+
+DEF_TEST(Codec_rowsDecoded, r) {
+    auto file = "plane_interlaced.png";
+    std::unique_ptr<SkStream> stream(GetResourceAsStream(file));
+    if (!stream) {
+        return;
+    }
+
+    // This is enough to read the header etc, but no rows.
+    auto data = SkData::MakeFromStream(stream.get(), 99);
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(data));
+    if (!codec) {
+        ERRORF(r, "Failed to create codec\n");
+        return;
+    }
+
+    auto info = codec->getInfo().makeColorType(kN32_SkColorType);
+    SkBitmap bm;
+    bm.allocPixels(info);
+    auto result = codec->startIncrementalDecode(info, bm.getPixels(), bm.rowBytes());
+    REPORTER_ASSERT(r, result == SkCodec::kSuccess);
+
+    // This is an arbitrary value. The important fact is that it is not zero, and rowsDecoded
+    // should get set to zero by incrementalDecode.
+    int rowsDecoded = 77;
+    result = codec->incrementalDecode(&rowsDecoded);
+    REPORTER_ASSERT(r, result == SkCodec::kIncompleteInput);
+    REPORTER_ASSERT(r, rowsDecoded == 0);
+}