diff options
author | Mike Reed <reed@google.com> | 2010-01-21 13:12:26 -0500 |
---|---|---|
committer | Mike Reed <reed@google.com> | 2010-01-21 13:12:26 -0500 |
commit | 79ecb8005fc8987f5adaea60521671c878c2e2d4 (patch) | |
tree | 0ecccf2e6e69e70bb3e9793041fbab5bf5987bc7 /src/images | |
parent | 416023c528d8cad78c9f294000dce57aad59a6f8 (diff) | |
download | external_skia-79ecb8005fc8987f5adaea60521671c878c2e2d4.zip external_skia-79ecb8005fc8987f5adaea60521671c878c2e2d4.tar.gz external_skia-79ecb8005fc8987f5adaea60521671c878c2e2d4.tar.bz2 |
call skip in a loop for network-backed streams
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 9c6eb04..fc4f358 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; |