diff options
author | msarett <msarett@google.com> | 2015-06-12 09:34:04 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-12 09:34:04 -0700 |
commit | f6db27e58e65a4c9680fdf00e41047578b6ac9f9 (patch) | |
tree | 1c23fd16449c08d015dbf9fbb27d53f163c9d07a | |
parent | 1dd0542ca37cf1b4a2ab0ea41f8009ded097fd47 (diff) |
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
-rw-r--r-- | dm/DMSrcSink.cpp | 19 |
1 files 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); |