| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 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 #include "SkCodecPriv.h" | 8 #include "SkCodecPriv.h" |
| 9 #include "SkJpegUtility.h" | 9 #include "SkJpegUtility_codec.h" |
| 10 | 10 |
| 11 /* | 11 /* |
| 12 * Initialize the source manager | 12 * Initialize the source manager |
| 13 */ | 13 */ |
| 14 static void sk_init_source(j_decompress_ptr dinfo) { | 14 static void sk_init_source(j_decompress_ptr dinfo) { |
| 15 skjpeg_source_mgr* src = (skjpeg_source_mgr*) dinfo->src; | 15 skjpeg_source_mgr* src = (skjpeg_source_mgr*) dinfo->src; |
| 16 src->next_input_byte = (const JOCTET*) src->fBuffer; | 16 src->next_input_byte = (const JOCTET*) src->fBuffer; |
| 17 src->bytes_in_buffer = 0; | 17 src->bytes_in_buffer = 0; |
| 18 } | 18 } |
| 19 | 19 |
| 20 /* | 20 /* |
| 21 * Fill the input buffer from the stream | 21 * Fill the input buffer from the stream |
| 22 */ | 22 */ |
| 23 static boolean sk_fill_input_buffer(j_decompress_ptr dinfo) { | 23 static boolean sk_fill_input_buffer(j_decompress_ptr dinfo) { |
| 24 skjpeg_source_mgr* src = (skjpeg_source_mgr*) dinfo->src; | 24 skjpeg_source_mgr* src = (skjpeg_source_mgr*) dinfo->src; |
| 25 size_t bytes = src->fStream->read(src->fBuffer, skjpeg_source_mgr::kBufferSi
ze); | 25 size_t bytes = src->fStream->read(src->fBuffer, skjpeg_source_mgr::kBufferSi
ze); |
| 26 | 26 |
| 27 // libjpeg is still happy with a less than full read, as long as the result
is non-zero | 27 // libjpeg is still happy with a less than full read, as long as the result
is non-zero |
| 28 if (bytes == 0) { | 28 if (bytes == 0) { |
| 29 return false; | 29 return false; |
| 30 } | 30 } |
| 31 | 31 |
| 32 src->next_input_byte = (const JOCTET*) src->fBuffer; | 32 src->next_input_byte = (const JOCTET*) src->fBuffer; |
| 33 src->bytes_in_buffer = bytes; | 33 src->bytes_in_buffer = bytes; |
| 34 return true; | 34 return true; |
| 35 } | 35 } |
| 36 | 36 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 /* | 80 /* |
| 81 * Call longjmp to continue execution on an error | 81 * Call longjmp to continue execution on an error |
| 82 */ | 82 */ |
| 83 void skjpeg_err_exit(j_common_ptr dinfo) { | 83 void skjpeg_err_exit(j_common_ptr dinfo) { |
| 84 // Simply return to Skia client code | 84 // Simply return to Skia client code |
| 85 // JpegDecoderMgr will take care of freeing memory | 85 // JpegDecoderMgr will take care of freeing memory |
| 86 skjpeg_error_mgr* error = (skjpeg_error_mgr*) dinfo->err; | 86 skjpeg_error_mgr* error = (skjpeg_error_mgr*) dinfo->err; |
| 87 (*error->output_message) (dinfo); | 87 (*error->output_message) (dinfo); |
| 88 longjmp(error->fJmpBuf, 1); | 88 longjmp(error->fJmpBuf, 1); |
| 89 } | 89 } |
| OLD | NEW |