| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2010 The Android Open Source Project | 3 * Copyright 2010 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #ifndef SkJpegUtility_DEFINED | 10 #ifndef SkJpegUtility_DEFINED |
| 11 #define SkJpegUtility_DEFINED | 11 #define SkJpegUtility_DEFINED |
| 12 | 12 |
| 13 #include "SkImageDecoder.h" |
| 13 #include "SkStream.h" | 14 #include "SkStream.h" |
| 14 | 15 |
| 15 extern "C" { | 16 extern "C" { |
| 16 #include "jpeglib.h" | 17 #include "jpeglib.h" |
| 17 #include "jerror.h" | 18 #include "jerror.h" |
| 18 } | 19 } |
| 19 | 20 |
| 20 #include <setjmp.h> | 21 #include <setjmp.h> |
| 21 | 22 |
| 22 /* Our error-handling struct. | 23 /* Our error-handling struct. |
| 23 * | 24 * |
| 24 */ | 25 */ |
| 25 struct skjpeg_error_mgr : jpeg_error_mgr { | 26 struct skjpeg_error_mgr : jpeg_error_mgr { |
| 26 jmp_buf fJmpBuf; | 27 jmp_buf fJmpBuf; |
| 27 }; | 28 }; |
| 28 | 29 |
| 29 | 30 |
| 30 void skjpeg_error_exit(j_common_ptr cinfo); | 31 void skjpeg_error_exit(j_common_ptr cinfo); |
| 31 | 32 |
| 33 /////////////////////////////////////////////////////////////////////////// |
| 34 /* Our source struct for directing jpeg to our stream object. |
| 35 */ |
| 36 struct skjpeg_source_mgr : jpeg_source_mgr { |
| 37 skjpeg_source_mgr(SkStream* stream, SkImageDecoder* decoder); |
| 38 |
| 39 // Unowned. |
| 40 SkStream* fStream; |
| 41 // Unowned pointer to the decoder, used to check if the decoding process |
| 42 // has been cancelled. |
| 43 SkImageDecoder* fDecoder; |
| 44 enum { |
| 45 kBufferSize = 1024 |
| 46 }; |
| 47 char fBuffer[kBufferSize]; |
| 48 }; |
| 49 |
| 32 ///////////////////////////////////////////////////////////////////////////// | 50 ///////////////////////////////////////////////////////////////////////////// |
| 33 /* Our destination struct for directing decompressed pixels to our stream | 51 /* Our destination struct for directing decompressed pixels to our stream |
| 34 * object. | 52 * object. |
| 35 */ | 53 */ |
| 36 struct skjpeg_destination_mgr : jpeg_destination_mgr { | 54 struct skjpeg_destination_mgr : jpeg_destination_mgr { |
| 37 skjpeg_destination_mgr(SkWStream* stream); | 55 skjpeg_destination_mgr(SkWStream* stream); |
| 38 | 56 |
| 39 SkWStream* fStream; | 57 SkWStream* fStream; |
| 40 | 58 |
| 41 enum { | 59 enum { |
| 42 kBufferSize = 1024 | 60 kBufferSize = 1024 |
| 43 }; | 61 }; |
| 44 uint8_t fBuffer[kBufferSize]; | 62 uint8_t fBuffer[kBufferSize]; |
| 45 }; | 63 }; |
| 46 | 64 |
| 47 #endif | 65 #endif |
| OLD | NEW |