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" | |
14 #include "SkStream.h" | 13 #include "SkStream.h" |
15 | 14 |
16 extern "C" { | 15 extern "C" { |
17 #include "jpeglib.h" | 16 #include "jpeglib.h" |
18 #include "jerror.h" | 17 #include "jerror.h" |
19 } | 18 } |
20 | 19 |
21 #include <setjmp.h> | 20 #include <setjmp.h> |
22 | 21 |
23 /* Our error-handling struct. | 22 /* Our error-handling struct. |
24 * | 23 * |
25 */ | 24 */ |
26 struct skjpeg_error_mgr : jpeg_error_mgr { | 25 struct skjpeg_error_mgr : jpeg_error_mgr { |
27 jmp_buf fJmpBuf; | 26 jmp_buf fJmpBuf; |
28 }; | 27 }; |
29 | 28 |
30 | 29 |
31 void skjpeg_error_exit(j_common_ptr cinfo); | 30 void skjpeg_error_exit(j_common_ptr cinfo); |
32 | 31 |
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 | |
50 ///////////////////////////////////////////////////////////////////////////// | 32 ///////////////////////////////////////////////////////////////////////////// |
51 /* Our destination struct for directing decompressed pixels to our stream | 33 /* Our destination struct for directing decompressed pixels to our stream |
52 * object. | 34 * object. |
53 */ | 35 */ |
54 struct skjpeg_destination_mgr : jpeg_destination_mgr { | 36 struct skjpeg_destination_mgr : jpeg_destination_mgr { |
55 skjpeg_destination_mgr(SkWStream* stream); | 37 skjpeg_destination_mgr(SkWStream* stream); |
56 | 38 |
57 SkWStream* fStream; | 39 SkWStream* fStream; |
58 | 40 |
59 enum { | 41 enum { |
60 kBufferSize = 1024 | 42 kBufferSize = 1024 |
61 }; | 43 }; |
62 uint8_t fBuffer[kBufferSize]; | 44 uint8_t fBuffer[kBufferSize]; |
63 }; | 45 }; |
64 | 46 |
65 #endif | 47 #endif |
OLD | NEW |