Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/images/SkJpegUtility.cpp

Issue 22861028: Handle SkStream::rewind properly. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Another comment rewrite. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/images/SkImageRef.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2010 The Android Open Source Project 2 * Copyright 2010 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 8
9 #include "SkJpegUtility.h" 9 #include "SkJpegUtility.h"
10 10
11 ///////////////////////////////////////////////////////////////////// 11 /////////////////////////////////////////////////////////////////////
12 static void sk_init_source(j_decompress_ptr cinfo) { 12 static void sk_init_source(j_decompress_ptr cinfo) {
13 skjpeg_source_mgr* src = (skjpeg_source_mgr*)cinfo->src; 13 skjpeg_source_mgr* src = (skjpeg_source_mgr*)cinfo->src;
14 src->next_input_byte = (const JOCTET*)src->fBuffer; 14 src->next_input_byte = (const JOCTET*)src->fBuffer;
15 src->bytes_in_buffer = 0; 15 src->bytes_in_buffer = 0;
16 #ifdef SK_BUILD_FOR_ANDROID 16 #ifdef SK_BUILD_FOR_ANDROID
17 src->current_offset = 0; 17 src->current_offset = 0;
18 #endif 18 #endif
19 src->fStream->rewind(); 19 if (!src->fStream->rewind()) {
20 SkDebugf("xxxxxxxxxxxxxx failure to rewind\n");
21 cinfo->err->error_exit((j_common_ptr)cinfo);
22 }
20 } 23 }
21 24
22 #ifdef SK_BUILD_FOR_ANDROID 25 #ifdef SK_BUILD_FOR_ANDROID
23 static boolean sk_seek_input_data(j_decompress_ptr cinfo, long byte_offset) { 26 static boolean sk_seek_input_data(j_decompress_ptr cinfo, long byte_offset) {
24 skjpeg_source_mgr* src = (skjpeg_source_mgr*)cinfo->src; 27 skjpeg_source_mgr* src = (skjpeg_source_mgr*)cinfo->src;
25 size_t bo = (size_t) byte_offset; 28 size_t bo = (size_t) byte_offset;
26 29
27 if (bo > src->current_offset) { 30 if (bo > src->current_offset) {
28 (void)src->fStream->skip(bo - src->current_offset); 31 (void)src->fStream->skip(bo - src->current_offset);
29 } else { 32 } else {
30 src->fStream->rewind(); 33 if (!src->fStream->rewind()) {
34 SkDebugf("xxxxxxxxxxxxxx failure to rewind\n");
35 cinfo->err->error_exit((j_common_ptr)cinfo);
36 return false;
37 }
31 (void)src->fStream->skip(bo); 38 (void)src->fStream->skip(bo);
32 } 39 }
33 40
34 src->current_offset = bo; 41 src->current_offset = bo;
35 src->next_input_byte = (const JOCTET*)src->fBuffer; 42 src->next_input_byte = (const JOCTET*)src->fBuffer;
36 src->bytes_in_buffer = 0; 43 src->bytes_in_buffer = 0;
37 return true; 44 return true;
38 } 45 }
39 #endif 46 #endif
40 47
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 void skjpeg_error_exit(j_common_ptr cinfo) { 176 void skjpeg_error_exit(j_common_ptr cinfo) {
170 skjpeg_error_mgr* error = (skjpeg_error_mgr*)cinfo->err; 177 skjpeg_error_mgr* error = (skjpeg_error_mgr*)cinfo->err;
171 178
172 (*error->output_message) (cinfo); 179 (*error->output_message) (cinfo);
173 180
174 /* Let the memory manager delete any temp files before we die */ 181 /* Let the memory manager delete any temp files before we die */
175 jpeg_destroy(cinfo); 182 jpeg_destroy(cinfo);
176 183
177 longjmp(error->fJmpBuf, -1); 184 longjmp(error->fJmpBuf, -1);
178 } 185 }
OLDNEW
« no previous file with comments | « src/images/SkImageRef.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698