Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Unified Diff: src/codec/SkJpegAutoClean.cpp

Issue 1076923002: SkJpegCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@gif-real
Patch Set: SkJpegCodec Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/codec/SkJpegAutoClean.cpp
diff --git a/src/codec/SkJpegAutoClean.cpp b/src/codec/SkJpegAutoClean.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f2c5fe3a0894468bee53c2cb737c343eec79d28e
--- /dev/null
+++ b/src/codec/SkJpegAutoClean.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkJpegAutoClean.h"
+#include "SkJpegUtility.h"
+
+JpegAutoClean::JpegAutoClean(jpeg_decompress_struct* jpegInfo, bool init)
+ : fJpegInfo(jpegInfo)
+ , fInit(init)
+{}
+
+JpegAutoClean::~JpegAutoClean() {
+ free();
scroggo 2015/04/10 17:19:05 nit: this->free()
msarett 2015/04/13 20:54:04 Done.
+}
+
+void JpegAutoClean::setInit(bool init) {
+ fInit = init;
+}
+
+jpeg_decompress_struct* JpegAutoClean::get() {
scroggo 2015/04/10 17:19:05 Down below I think I suggest that you do not call
msarett 2015/04/13 20:54:04 I added three operators and removed about one mill
+ return fJpegInfo.get();
+}
+
+jpeg_decompress_struct* JpegAutoClean::detach() {
+ fInit = false;
+ return fJpegInfo.detach();
+}
+
+void JpegAutoClean::reset(jpeg_decompress_struct* jpegInfo) {
+ free();
+ fJpegInfo.reset(jpegInfo);
+}
+
+void JpegAutoClean::free() {
+ if (NULL != fJpegInfo.get() && fInit) {
+ SkDELETE_ARRAY(((skjpeg_source_mgr*) fJpegInfo.get()->src)->fBuffer);
+ SkDELETE(fJpegInfo.get()->src);
+ SkDELETE(fJpegInfo.get()->err);
+ jpeg_destroy_decompress(fJpegInfo.get());
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698