summaryrefslogtreecommitdiff
path: root/core/fpdfapi/render
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-03-30 16:12:02 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-03-30 20:26:02 +0000
commit0bb1333a9eff1190ddd68f34c71d6a779c69dfef (patch)
tree5a46946c4852f147309e2b1389e6f42d6553abf7 /core/fpdfapi/render
parent908c848202ef137e98d96f82a4eadfae551403b7 (diff)
downloadpdfium-0bb1333a9eff1190ddd68f34c71d6a779c69dfef.tar.xz
Add some calls to MakeUnique
This CL replaces some new's with pdfium::MakeUnique. Change-Id: I50faf3ed55e7730b094c14a7989a9dd51cf33cbb Reviewed-on: https://pdfium-review.googlesource.com/3430 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi/render')
-rw-r--r--core/fpdfapi/render/cpdf_dibsource.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/core/fpdfapi/render/cpdf_dibsource.cpp b/core/fpdfapi/render/cpdf_dibsource.cpp
index f3703dd23a..cb8e9c9eee 100644
--- a/core/fpdfapi/render/cpdf_dibsource.cpp
+++ b/core/fpdfapi/render/cpdf_dibsource.cpp
@@ -21,6 +21,7 @@
#include "core/fpdfapi/parser/fpdf_parser_decode.h"
#include "core/fpdfapi/render/cpdf_pagerendercache.h"
#include "core/fpdfapi/render/cpdf_renderstatus.h"
+#include "core/fxcodec/codec/cjpx_decoder.h"
#include "core/fxcodec/fx_codec.h"
#include "core/fxcrt/fx_safe_types.h"
#include "third_party/base/ptr_util.h"
@@ -79,16 +80,17 @@ class JpxBitMapContext {
explicit JpxBitMapContext(CCodec_JpxModule* jpx_module)
: jpx_module_(jpx_module), decoder_(nullptr) {}
- ~JpxBitMapContext() { jpx_module_->DestroyDecoder(decoder_); }
+ ~JpxBitMapContext() {}
- // Takes ownership of |decoder|.
- void set_decoder(CJPX_Decoder* decoder) { decoder_ = decoder; }
+ void set_decoder(std::unique_ptr<CJPX_Decoder> decoder) {
+ decoder_ = std::move(decoder);
+ }
- CJPX_Decoder* decoder() { return decoder_; }
+ CJPX_Decoder* decoder() { return decoder_.get(); }
private:
CCodec_JpxModule* const jpx_module_; // Weak pointer.
- CJPX_Decoder* decoder_; // Decoder, owned.
+ std::unique_ptr<CJPX_Decoder> decoder_;
// Disallow evil constructors
JpxBitMapContext(const JpxBitMapContext&);
@@ -613,7 +615,7 @@ void CPDF_DIBSource::LoadJpxBitmap() {
if (!pJpxModule)
return;
- std::unique_ptr<JpxBitMapContext> context(new JpxBitMapContext(pJpxModule));
+ auto context = pdfium::MakeUnique<JpxBitMapContext>(pJpxModule);
context->set_decoder(pJpxModule->CreateDecoder(
m_pStreamAcc->GetData(), m_pStreamAcc->GetSize(), m_pColorSpace));
if (!context->decoder())