1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/images/SkJpegUtility.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,66 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2010 The Android Open Source Project 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 + 1.12 + 1.13 +#ifndef SkJpegUtility_DEFINED 1.14 +#define SkJpegUtility_DEFINED 1.15 + 1.16 +#include "SkImageDecoder.h" 1.17 +#include "SkStream.h" 1.18 + 1.19 +extern "C" { 1.20 + #include "jpeglib.h" 1.21 + #include "jerror.h" 1.22 +} 1.23 + 1.24 +#include <setjmp.h> 1.25 + 1.26 +/* Our error-handling struct. 1.27 + * 1.28 +*/ 1.29 +struct skjpeg_error_mgr : jpeg_error_mgr { 1.30 + jmp_buf fJmpBuf; 1.31 +}; 1.32 + 1.33 + 1.34 +void skjpeg_error_exit(j_common_ptr cinfo); 1.35 + 1.36 +/////////////////////////////////////////////////////////////////////////// 1.37 +/* Our source struct for directing jpeg to our stream object. 1.38 +*/ 1.39 +struct skjpeg_source_mgr : jpeg_source_mgr { 1.40 + skjpeg_source_mgr(SkStream* stream, SkImageDecoder* decoder); 1.41 + ~skjpeg_source_mgr(); 1.42 + 1.43 + // fStream is ref'ed and unref'ed 1.44 + SkStream* fStream; 1.45 + // Unowned pointer to the decoder, used to check if the decoding process 1.46 + // has been cancelled. 1.47 + SkImageDecoder* fDecoder; 1.48 + enum { 1.49 + kBufferSize = 1024 1.50 + }; 1.51 + char fBuffer[kBufferSize]; 1.52 +}; 1.53 + 1.54 +///////////////////////////////////////////////////////////////////////////// 1.55 +/* Our destination struct for directing decompressed pixels to our stream 1.56 + * object. 1.57 + */ 1.58 +struct skjpeg_destination_mgr : jpeg_destination_mgr { 1.59 + skjpeg_destination_mgr(SkWStream* stream); 1.60 + 1.61 + SkWStream* fStream; 1.62 + 1.63 + enum { 1.64 + kBufferSize = 1024 1.65 + }; 1.66 + uint8_t fBuffer[kBufferSize]; 1.67 +}; 1.68 + 1.69 +#endif