summaryrefslogtreecommitdiff
path: root/core/fxcodec
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcodec')
-rw-r--r--core/fxcodec/codec/ccodec_progressivedecoder.h12
-rw-r--r--core/fxcodec/codec/ccodec_tiffmodule.h4
-rw-r--r--core/fxcodec/codec/fx_codec_progress.cpp2
-rw-r--r--core/fxcodec/codec/fx_codec_tiff.cpp22
4 files changed, 23 insertions, 17 deletions
diff --git a/core/fxcodec/codec/ccodec_progressivedecoder.h b/core/fxcodec/codec/ccodec_progressivedecoder.h
index de7542e485..614146f79d 100644
--- a/core/fxcodec/codec/ccodec_progressivedecoder.h
+++ b/core/fxcodec/codec/ccodec_progressivedecoder.h
@@ -10,6 +10,7 @@
#include <vector>
#include "core/fxcodec/fx_codec_def.h"
+#include "core/fxcrt/cfx_retain_ptr.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxge/fx_dib.h"
@@ -45,10 +46,11 @@ class CCodec_ProgressiveDecoder {
explicit CCodec_ProgressiveDecoder(CCodec_ModuleMgr* pCodecMgr);
~CCodec_ProgressiveDecoder();
- FXCODEC_STATUS LoadImageInfo(IFX_SeekableReadStream* pFile,
- FXCODEC_IMAGE_TYPE imageType,
- CFX_DIBAttribute* pAttribute,
- bool bSkipImageTypeCheck);
+ FXCODEC_STATUS LoadImageInfo(
+ const CFX_RetainPtr<IFX_SeekableReadStream>& pFile,
+ FXCODEC_IMAGE_TYPE imageType,
+ CFX_DIBAttribute* pAttribute,
+ bool bSkipImageTypeCheck);
FXCODEC_IMAGE_TYPE GetType() const { return m_imagType; }
int32_t GetWidth() const { return m_SrcWidth; }
@@ -125,7 +127,7 @@ class CCodec_ProgressiveDecoder {
std::vector<uint8_t> m_pWeightTables;
};
- IFX_SeekableReadStream* m_pFile;
+ CFX_RetainPtr<IFX_SeekableReadStream> m_pFile;
CCodec_ModuleMgr* m_pCodecMgr;
FXJPEG_Context* m_pJpegContext;
FXPNG_Context* m_pPngContext;
diff --git a/core/fxcodec/codec/ccodec_tiffmodule.h b/core/fxcodec/codec/ccodec_tiffmodule.h
index 37d40821a6..dd2cbd768c 100644
--- a/core/fxcodec/codec/ccodec_tiffmodule.h
+++ b/core/fxcodec/codec/ccodec_tiffmodule.h
@@ -7,6 +7,7 @@
#ifndef CORE_FXCODEC_CODEC_CCODEC_TIFFMODULE_H_
#define CORE_FXCODEC_CODEC_CCODEC_TIFFMODULE_H_
+#include "core/fxcrt/cfx_retain_ptr.h"
#include "core/fxcrt/fx_system.h"
class CCodec_TiffContext;
@@ -18,7 +19,8 @@ class CCodec_TiffModule {
public:
~CCodec_TiffModule() {}
- CCodec_TiffContext* CreateDecoder(IFX_SeekableReadStream* file_ptr);
+ CCodec_TiffContext* CreateDecoder(
+ const CFX_RetainPtr<IFX_SeekableReadStream>& file_ptr);
bool LoadFrameInfo(CCodec_TiffContext* ctx,
int32_t frame,
diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp
index 8d29a7b3f3..386b66a7e6 100644
--- a/core/fxcodec/codec/fx_codec_progress.cpp
+++ b/core/fxcodec/codec/fx_codec_progress.cpp
@@ -1295,7 +1295,7 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType,
}
FXCODEC_STATUS CCodec_ProgressiveDecoder::LoadImageInfo(
- IFX_SeekableReadStream* pFile,
+ const CFX_RetainPtr<IFX_SeekableReadStream>& pFile,
FXCODEC_IMAGE_TYPE imageType,
CFX_DIBAttribute* pAttribute,
bool bSkipImageTypeCheck) {
diff --git a/core/fxcodec/codec/fx_codec_tiff.cpp b/core/fxcodec/codec/fx_codec_tiff.cpp
index 8046f1cc39..be9c7d447f 100644
--- a/core/fxcodec/codec/fx_codec_tiff.cpp
+++ b/core/fxcodec/codec/fx_codec_tiff.cpp
@@ -8,8 +8,10 @@
#include "core/fxcodec/codec/codec_int.h"
#include "core/fxcodec/fx_codec.h"
+#include "core/fxcrt/cfx_retain_ptr.h"
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxge/fx_dib.h"
+#include "third_party/base/ptr_util.h"
extern "C" {
#include "third_party/libtiff/tiffiop.h"
@@ -20,7 +22,7 @@ class CCodec_TiffContext {
CCodec_TiffContext();
~CCodec_TiffContext();
- bool InitDecoder(IFX_SeekableReadStream* file_ptr);
+ bool InitDecoder(const CFX_RetainPtr<IFX_SeekableReadStream>& file_ptr);
bool LoadFrameInfo(int32_t frame,
int32_t* width,
int32_t* height,
@@ -29,7 +31,7 @@ class CCodec_TiffContext {
CFX_DIBAttribute* pAttribute);
bool Decode(CFX_DIBitmap* pDIBitmap);
- IFX_SeekableReadStream* io_in() const { return m_io_in; }
+ CFX_RetainPtr<IFX_SeekableReadStream> io_in() const { return m_io_in; }
uint32_t offset() const { return m_offset; }
void set_offset(uint32_t offset) { m_offset = offset; }
@@ -52,7 +54,7 @@ class CCodec_TiffContext {
uint16_t bps,
uint16_t spp);
- IFX_SeekableReadStream* m_io_in;
+ CFX_RetainPtr<IFX_SeekableReadStream> m_io_in;
uint32_t m_offset;
TIFF* m_tif_ctx;
};
@@ -215,7 +217,8 @@ CCodec_TiffContext::~CCodec_TiffContext() {
TIFFClose(m_tif_ctx);
}
-bool CCodec_TiffContext::InitDecoder(IFX_SeekableReadStream* file_ptr) {
+bool CCodec_TiffContext::InitDecoder(
+ const CFX_RetainPtr<IFX_SeekableReadStream>& file_ptr) {
m_io_in = file_ptr;
m_tif_ctx = tiff_open(this, "r");
return !!m_tif_ctx;
@@ -462,13 +465,12 @@ bool CCodec_TiffContext::Decode(CFX_DIBitmap* pDIBitmap) {
}
CCodec_TiffContext* CCodec_TiffModule::CreateDecoder(
- IFX_SeekableReadStream* file_ptr) {
- CCodec_TiffContext* pDecoder = new CCodec_TiffContext;
- if (!pDecoder->InitDecoder(file_ptr)) {
- delete pDecoder;
+ const CFX_RetainPtr<IFX_SeekableReadStream>& file_ptr) {
+ auto pDecoder = pdfium::MakeUnique<CCodec_TiffContext>();
+ if (!pDecoder->InitDecoder(file_ptr))
return nullptr;
- }
- return pDecoder;
+
+ return pDecoder.release();
}
bool CCodec_TiffModule::LoadFrameInfo(CCodec_TiffContext* ctx,