/* * Copyright 2015 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkJpegDecoderMgr_MTK_DEFINED #define SkJpegDecoderMgr_MTK_DEFINED #include "include/codec/SkCodec.h" #include "include/private/SkEncodedInfo.h" #include "include/private/base/SkNoncopyable.h" #include "src/codec/SkJpegPriv.h" #include "src/codec/SkJpegSourceMgr.h" #include "include/mtk/SkJpegUtility_MTK.h" extern "C" { #include "jpeglib_alpha.h" #include "jmorecfg.h" } #include class SkStream; class JpegDecoderMgr_MTK : SkNoncopyable { public: /* * Print a useful error message and return false */ bool returnFalse_MTK(const char caller[]); /* * Print a useful error message and return a decode failure */ SkCodec::Result returnFailure_MTK(const char caller[], SkCodec::Result result); /* * Create the decode manager * Does not take ownership of stream */ JpegDecoderMgr_MTK(SkStream* stream); /* * Initialize decompress struct * Initialize the source manager */ void init_MTK(); /* * Returns true if it successfully sets outColor to the encoded color, * and false otherwise. */ bool getEncodedColor_MTK(SkEncodedInfo::Color* outColor); /* * Free memory used by the decode manager */ ~JpegDecoderMgr_MTK(); /* * Get the skjpeg_error_mgr_MTK in order to set an error return jmp_buf */ skjpeg_error_mgr_MTK* errorMgr_MTK() { return &fErrorMgr; } /* * Get function for the decompress info struct */ jpeg_decompress_struct_ALPHA* dinfo_MTK() { return &fDInfo; } // Get the source manager. SkJpegSourceMgr* getSourceMgr_MTK(); /* * Get Oal Structure */ jpeg_oal_mgr_ALPHA* oal_MTK() { return &fOal; } private: // Wrapper that calls into the full SkJpegSourceMgr interface. struct SourceMgr : jpeg_source_mgr_ALPHA { static void InitSource(j_decompress_ptr_ALPHA dinfo); static void SkipInputData(j_decompress_ptr_ALPHA dinfo, long num_bytes_long); static boolean_ALPHA FillInputBuffer(j_decompress_ptr_ALPHA dinfo); static void TermSource(j_decompress_ptr_ALPHA dinfo); static boolean_ALPHA SeekInputData(j_decompress_ptr_ALPHA dinfo, long byte_offset); SourceMgr(std::unique_ptr mgr); std::unique_ptr fSourceMgr; }; jpeg_decompress_struct_ALPHA fDInfo; jpeg_oal_mgr_ALPHA fOal; SourceMgr fSrcMgr; skjpeg_error_mgr_MTK fErrorMgr; jpeg_progress_mgr_ALPHA fProgressMgr; bool fInit; }; #endif