From f6db27e58e65a4c9680fdf00e41047578b6ac9f9 Mon Sep 17 00:00:00 2001 From: msarett Date: Fri, 12 Jun 2015 09:34:04 -0700 Subject: Fixing stripe test I originally thought that there was no harm in reading or skipping zero lines after we have already reached the end of the image. However, once we reach the end of the image, onFinish() is automatically called. Performing a read or a skip after the call to onFinish() is invalid and will cause onFinish() to be called a second time (which is also invalid). Seems like the code requires good behavior and the test is wrong. BUG=skia: Review URL: https://codereview.chromium.org/1179213002 --- dm/DMSrcSink.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index c89ffd1b71..4598a4894b 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -331,15 +331,16 @@ Error CodecSrc::draw(SkCanvas* canvas) const { } // Skip a stripe - const int linesToSkip = SkTMax(0, SkTMin(stripeHeight, - height - (i + 1) * stripeHeight)); - result = decoder->skipScanlines(linesToSkip); - switch (result) { - case SkImageGenerator::kSuccess: - case SkImageGenerator::kIncompleteInput: - break; - default: - return SkStringPrintf("Cannot skip scanlines for %s.", fPath.c_str()); + const int linesToSkip = SkTMin(stripeHeight, height - (i + 1) * stripeHeight); + if (linesToSkip > 0) { + result = decoder->skipScanlines(linesToSkip); + switch (result) { + case SkImageGenerator::kSuccess: + case SkImageGenerator::kIncompleteInput: + break; + default: + return SkStringPrintf("Cannot skip scanlines for %s.", fPath.c_str()); + } } } canvas->drawBitmap(bitmap, 0, 0); -- cgit v1.2.3