| OLD | NEW |
| 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 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 src->bytes_in_buffer -= num_bytes; | 89 src->bytes_in_buffer -= num_bytes; |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 static void sk_term_source(j_decompress_ptr /*cinfo*/) {} | 93 static void sk_term_source(j_decompress_ptr /*cinfo*/) {} |
| 94 | 94 |
| 95 | 95 |
| 96 /////////////////////////////////////////////////////////////////////////////// | 96 /////////////////////////////////////////////////////////////////////////////// |
| 97 | 97 |
| 98 skjpeg_source_mgr::skjpeg_source_mgr(SkStream* stream, SkImageDecoder* decoder) | 98 skjpeg_source_mgr::skjpeg_source_mgr(SkStream* stream, SkImageDecoder* decoder) |
| 99 : fStream(SkRef(stream)) | 99 : fStream(stream) |
| 100 , fDecoder(decoder) { | 100 , fDecoder(decoder) { |
| 101 | 101 |
| 102 init_source = sk_init_source; | 102 init_source = sk_init_source; |
| 103 fill_input_buffer = sk_fill_input_buffer; | 103 fill_input_buffer = sk_fill_input_buffer; |
| 104 skip_input_data = sk_skip_input_data; | 104 skip_input_data = sk_skip_input_data; |
| 105 resync_to_restart = jpeg_resync_to_restart; | 105 resync_to_restart = jpeg_resync_to_restart; |
| 106 term_source = sk_term_source; | 106 term_source = sk_term_source; |
| 107 #ifdef SK_BUILD_FOR_ANDROID | 107 #ifdef SK_BUILD_FOR_ANDROID |
| 108 seek_input_data = sk_seek_input_data; | 108 seek_input_data = sk_seek_input_data; |
| 109 #endif | 109 #endif |
| 110 // SkDebugf("**************** use memorybase %p %d\n", fMemoryBase, fMemoryBa
seSize); | 110 // SkDebugf("**************** use memorybase %p %d\n", fMemoryBase, fMemoryBa
seSize); |
| 111 } | 111 } |
| 112 | 112 |
| 113 skjpeg_source_mgr::~skjpeg_source_mgr() { | |
| 114 SkSafeUnref(fStream); | |
| 115 } | |
| 116 | |
| 117 /////////////////////////////////////////////////////////////////////////////// | 113 /////////////////////////////////////////////////////////////////////////////// |
| 118 | 114 |
| 119 static void sk_init_destination(j_compress_ptr cinfo) { | 115 static void sk_init_destination(j_compress_ptr cinfo) { |
| 120 skjpeg_destination_mgr* dest = (skjpeg_destination_mgr*)cinfo->dest; | 116 skjpeg_destination_mgr* dest = (skjpeg_destination_mgr*)cinfo->dest; |
| 121 | 117 |
| 122 dest->next_output_byte = dest->fBuffer; | 118 dest->next_output_byte = dest->fBuffer; |
| 123 dest->free_in_buffer = skjpeg_destination_mgr::kBufferSize; | 119 dest->free_in_buffer = skjpeg_destination_mgr::kBufferSize; |
| 124 } | 120 } |
| 125 | 121 |
| 126 static boolean sk_empty_output_buffer(j_compress_ptr cinfo) { | 122 static boolean sk_empty_output_buffer(j_compress_ptr cinfo) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 void skjpeg_error_exit(j_common_ptr cinfo) { | 157 void skjpeg_error_exit(j_common_ptr cinfo) { |
| 162 skjpeg_error_mgr* error = (skjpeg_error_mgr*)cinfo->err; | 158 skjpeg_error_mgr* error = (skjpeg_error_mgr*)cinfo->err; |
| 163 | 159 |
| 164 (*error->output_message) (cinfo); | 160 (*error->output_message) (cinfo); |
| 165 | 161 |
| 166 /* Let the memory manager delete any temp files before we die */ | 162 /* Let the memory manager delete any temp files before we die */ |
| 167 jpeg_destroy(cinfo); | 163 jpeg_destroy(cinfo); |
| 168 | 164 |
| 169 longjmp(error->fJmpBuf, -1); | 165 longjmp(error->fJmpBuf, -1); |
| 170 } | 166 } |
| OLD | NEW |