michael@0: michael@0: /* michael@0: * Copyright 2010 The Android Open Source Project michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: michael@0: #ifndef SkJpegUtility_DEFINED michael@0: #define SkJpegUtility_DEFINED michael@0: michael@0: #include "SkImageDecoder.h" michael@0: #include "SkStream.h" michael@0: michael@0: extern "C" { michael@0: #include "jpeglib.h" michael@0: #include "jerror.h" michael@0: } michael@0: michael@0: #include michael@0: michael@0: /* Our error-handling struct. michael@0: * michael@0: */ michael@0: struct skjpeg_error_mgr : jpeg_error_mgr { michael@0: jmp_buf fJmpBuf; michael@0: }; michael@0: michael@0: michael@0: void skjpeg_error_exit(j_common_ptr cinfo); michael@0: michael@0: /////////////////////////////////////////////////////////////////////////// michael@0: /* Our source struct for directing jpeg to our stream object. michael@0: */ michael@0: struct skjpeg_source_mgr : jpeg_source_mgr { michael@0: skjpeg_source_mgr(SkStream* stream, SkImageDecoder* decoder); michael@0: ~skjpeg_source_mgr(); michael@0: michael@0: // fStream is ref'ed and unref'ed michael@0: SkStream* fStream; michael@0: // Unowned pointer to the decoder, used to check if the decoding process michael@0: // has been cancelled. michael@0: SkImageDecoder* fDecoder; michael@0: enum { michael@0: kBufferSize = 1024 michael@0: }; michael@0: char fBuffer[kBufferSize]; michael@0: }; michael@0: michael@0: ///////////////////////////////////////////////////////////////////////////// michael@0: /* Our destination struct for directing decompressed pixels to our stream michael@0: * object. michael@0: */ michael@0: struct skjpeg_destination_mgr : jpeg_destination_mgr { michael@0: skjpeg_destination_mgr(SkWStream* stream); michael@0: michael@0: SkWStream* fStream; michael@0: michael@0: enum { michael@0: kBufferSize = 1024 michael@0: }; michael@0: uint8_t fBuffer[kBufferSize]; michael@0: }; michael@0: michael@0: #endif