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