| 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_codec.h" | 9 #include "SkJpegUtility_codec.h" |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 } else { | 54 } else { |
| 55 src->next_input_byte += numBytes; | 55 src->next_input_byte += numBytes; |
| 56 src->bytes_in_buffer -= numBytes; | 56 src->bytes_in_buffer -= numBytes; |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| 60 /* | 60 /* |
| 61 * We do not need to do anything to terminate our stream | 61 * We do not need to do anything to terminate our stream |
| 62 */ | 62 */ |
| 63 static void sk_term_source(j_decompress_ptr dinfo) | 63 static void sk_term_source(j_decompress_ptr dinfo) |
| 64 {} | 64 { |
| 65 // The current implementation of SkJpegCodec does not call |
| 66 // jpeg_finish_decompress(), so this function is never called. |
| 67 // If we want to modify this function to do something, we also |
| 68 // need to modify SkJpegCodec to call jpeg_finish_decompress(). |
| 69 } |
| 65 | 70 |
| 66 /* | 71 /* |
| 67 * Constructor for the source manager that we provide to libjpeg | 72 * Constructor for the source manager that we provide to libjpeg |
| 68 * We provide skia implementations of all of the stream processing functions req
uired by libjpeg | 73 * We provide skia implementations of all of the stream processing functions req
uired by libjpeg |
| 69 */ | 74 */ |
| 70 skjpeg_source_mgr::skjpeg_source_mgr(SkStream* stream) | 75 skjpeg_source_mgr::skjpeg_source_mgr(SkStream* stream) |
| 71 : fStream(stream) | 76 : fStream(stream) |
| 72 { | 77 { |
| 73 init_source = sk_init_source; | 78 init_source = sk_init_source; |
| 74 fill_input_buffer = sk_fill_input_buffer; | 79 fill_input_buffer = sk_fill_input_buffer; |
| 75 skip_input_data = sk_skip_input_data; | 80 skip_input_data = sk_skip_input_data; |
| 76 resync_to_restart = jpeg_resync_to_restart; | 81 resync_to_restart = jpeg_resync_to_restart; |
| 77 term_source = sk_term_source; | 82 term_source = sk_term_source; |
| 78 } | 83 } |
| 79 | 84 |
| 80 /* | 85 /* |
| 81 * Call longjmp to continue execution on an error | 86 * Call longjmp to continue execution on an error |
| 82 */ | 87 */ |
| 83 void skjpeg_err_exit(j_common_ptr dinfo) { | 88 void skjpeg_err_exit(j_common_ptr dinfo) { |
| 84 // Simply return to Skia client code | 89 // Simply return to Skia client code |
| 85 // JpegDecoderMgr will take care of freeing memory | 90 // JpegDecoderMgr will take care of freeing memory |
| 86 skjpeg_error_mgr* error = (skjpeg_error_mgr*) dinfo->err; | 91 skjpeg_error_mgr* error = (skjpeg_error_mgr*) dinfo->err; |
| 87 (*error->output_message) (dinfo); | 92 (*error->output_message) (dinfo); |
| 88 longjmp(error->fJmpBuf, 1); | 93 longjmp(error->fJmpBuf, 1); |
| 89 } | 94 } |
| OLD | NEW |