blob: 0775dc07f080e96354ace1c932868a0d42328c0b [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" {
msarette16b04a2015-04-15 07:32:19 -070021 #include "jpeglib.h"
22}
23
24class JpegDecoderMgr : SkNoncopyable {
25public:
26
27 /*
28 * Print a useful error message and return false
29 */
30 bool returnFalse(const char caller[]);
31
32 /*
33 * Print a useful error message and return a decode failure
34 */
35 SkCodec::Result returnFailure(const char caller[], SkCodec::Result result);
36
37 /*
38 * Create the decode manager
39 * Does not take ownership of stream
40 */
41 JpegDecoderMgr(SkStream* stream);
42
43 /*
44 * Initialize decompress struct
45 * Initialize the source manager
46 */
47 void init();
48
49 /*
50 * Recommend a color type based on the encoded format
51 */
52 SkColorType getColorType();
53
54 /*
55 * Free memory used by the decode manager
56 */
57 ~JpegDecoderMgr();
58
59 /*
60 * Get the jump buffer in order to set an error return point
61 */
62 jmp_buf& getJmpBuf();
63
64 /*
65 * Get function for the decompress info struct
66 */
67 jpeg_decompress_struct* dinfo();
68
69private:
70
71 jpeg_decompress_struct fDInfo;
72 skjpeg_source_mgr fSrcMgr;
73 skjpeg_error_mgr fErrorMgr;
74 bool fInit;
75};
76
77#endif