diff options
author | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2010-01-21 18:04:44 +0000 |
---|---|---|
committer | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2010-01-21 18:04:44 +0000 |
commit | b8fd84b803b2a2f4d304e0763b83a90f582b449a (patch) | |
tree | d9421585d3ca701f2ea494ec435bda86ce1c09d9 /src/images | |
parent | 6f59815b3dbd19efb8a29d0115deea9c88da8ae1 (diff) |
call skip in a loop to handle the case where the backing stream may be network
based, and will only block to fulfill the request after it has skipped its
current buffer.
git-svn-id: http://skia.googlecode.com/svn/trunk@477 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/images')
-rw-r--r-- | src/images/SkJpegUtility.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/images/SkJpegUtility.cpp b/src/images/SkJpegUtility.cpp index 9c6eb047f6..fc4f358bc3 100644 --- a/src/images/SkJpegUtility.cpp +++ b/src/images/SkJpegUtility.cpp @@ -41,18 +41,18 @@ static boolean sk_fill_input_buffer(j_decompress_ptr cinfo) { } static void sk_skip_input_data(j_decompress_ptr cinfo, long num_bytes) { - SkASSERT(num_bytes > 0); - skjpeg_source_mgr* src = (skjpeg_source_mgr*)cinfo->src; - long bytesToSkip = num_bytes - src->bytes_in_buffer; - - // check if the skip amount exceeds the current buffer - if (bytesToSkip > 0) { - size_t bytes = src->fStream->skip(bytesToSkip); - if (bytes != (size_t)bytesToSkip) { -// SkDebugf("xxxxxxxxxxxxxx failure to skip request %d actual %d\n", bytesToSkip, bytes); - cinfo->err->error_exit((j_common_ptr)cinfo); + if (num_bytes > src->bytes_in_buffer) { + long bytesToSkip = num_bytes - src->bytes_in_buffer; + while (bytesToSkip > 0) { + long bytes = (long)src->fStream->skip(bytesToSkip); + if (bytes <= 0 || bytes > bytesToSkip) { +// SkDebugf("xxxxxxxxxxxxxx failure to skip request %d returned %d\n", bytesToSkip, bytes); + cinfo->err->error_exit((j_common_ptr)cinfo); + return; + } + bytesToSkip -= bytes; } src->next_input_byte = (const JOCTET*)src->fBuffer; src->bytes_in_buffer = 0; |