blob: e65ef52c5a6dc39bcdbab9d34f366650b06f6c64 [file] [log] [blame]
msarette16b04a2015-04-15 07:32:19 -07001/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkJpegDecoderMgr_DEFINED
9#define SkJpegDecoderMgr_DEFINED
10
11#include "SkCodec.h"
12#include "SkCodecPriv.h"
mtklein525e90a2015-06-18 09:58:57 -070013#include "SkJpegUtility_codec.h"
msarette16b04a2015-04-15 07:32:19 -070014#include "SkSwizzler.h"
15#include "SkTemplates.h"
16
17// stdio is needed for jpeglib
18#include <stdio.h>
19
20extern "C" {
msarett40141b52015-07-01 14:41:02 -070021 #include "jpeglibmangler.h"
msarette16b04a2015-04-15 07:32:19 -070022 #include "jpeglib.h"
23}
24
25class JpegDecoderMgr : SkNoncopyable {
26public:
27
28 /*
29 * Print a useful error message and return false
30 */
31 bool returnFalse(const char caller[]);
32
33 /*
34 * Print a useful error message and return a decode failure
35 */
36 SkCodec::Result returnFailure(const char caller[], SkCodec::Result result);
37
38 /*
39 * Create the decode manager
40 * Does not take ownership of stream
41 */
42 JpegDecoderMgr(SkStream* stream);
43
44 /*
45 * Initialize decompress struct
46 * Initialize the source manager
47 */
48 void init();
49
50 /*
51 * Recommend a color type based on the encoded format
52 */
53 SkColorType getColorType();
54
55 /*
56 * Free memory used by the decode manager
57 */
58 ~JpegDecoderMgr();
59
60 /*
61 * Get the jump buffer in order to set an error return point
62 */
63 jmp_buf& getJmpBuf();
64
65 /*
66 * Get function for the decompress info struct
67 */
68 jpeg_decompress_struct* dinfo();
69
70private:
71
72 jpeg_decompress_struct fDInfo;
73 skjpeg_source_mgr fSrcMgr;
74 skjpeg_error_mgr fErrorMgr;
75 bool fInit;
76};
77
78#endif