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