Chromium Code Reviews| Index: src/codec/SkJpegAutoClean.h |
| diff --git a/src/codec/SkJpegAutoClean.h b/src/codec/SkJpegAutoClean.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..04aebdf48567278e993be892915425c64c60a6e4 |
| --- /dev/null |
| +++ b/src/codec/SkJpegAutoClean.h |
| @@ -0,0 +1,49 @@ |
| +/* |
| + * 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 SkJpegAutoClean_DEFINED |
| +#define SkJpegAutoClean_DEFINED |
| + |
| +#include "SkJpegUtility.h" |
| +#include "SkTemplates.h" |
| + |
| +// stdio is needed for jpeglib |
| +#include <stdio.h> |
| +#include "jpeglib.h" |
| + |
| +/* |
| + * This object automatically cleans up memory after a jpeg decode |
| + */ |
| +class JpegAutoClean : SkNoncopyable { |
| +public: |
| + |
| + /* |
| + * Takes ownership of all thre input pointers. |
|
scroggo
2015/04/14 13:10:32
three*
msarett
2015/04/14 19:30:36
Acknowledged.
|
| + */ |
| + JpegAutoClean(jpeg_decompress_struct* dinfo, |
| + skjpeg_source_mgr* srcMgr, |
| + skjpeg_error_mgr* errMgr); |
| + |
| + /* |
| + * Calls destroy on jpeg_decompress_struct. |
| + * Owned pointers will be delted automatically. |
|
scroggo
2015/04/14 13:10:32
deleted*
msarett
2015/04/14 19:30:36
Acknowledged.
|
| + */ |
| + ~JpegAutoClean(); |
| + |
| + /* |
| + * Get the decompress info struct. |
| + */ |
| + jpeg_decompress_struct* dinfo(); |
| + |
| +private: |
| + |
| + SkAutoTDelete<jpeg_decompress_struct> fDInfo; |
|
scroggo
2015/04/14 13:10:32
Do these all need to be passed in? What if you mak
msarett
2015/04/14 19:30:36
Done.
|
| + SkAutoTDelete<skjpeg_source_mgr> fSrcMgr; |
| + SkAutoTDelete<skjpeg_error_mgr> fErrorMgr; |
| +}; |
| + |
| +#endif |