summaryrefslogtreecommitdiff
path: root/core/fxcodec/codec
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcodec/codec')
-rw-r--r--core/fxcodec/codec/ccodec_gifmodule.cpp24
-rw-r--r--core/fxcodec/codec/ccodec_gifmodule.h29
-rw-r--r--core/fxcodec/codec/ccodec_progressivedecoder.h3
-rw-r--r--core/fxcodec/codec/fx_codec_progress.cpp3
4 files changed, 27 insertions, 32 deletions
diff --git a/core/fxcodec/codec/ccodec_gifmodule.cpp b/core/fxcodec/codec/ccodec_gifmodule.cpp
index 11980ee7a5..757019314d 100644
--- a/core/fxcodec/codec/ccodec_gifmodule.cpp
+++ b/core/fxcodec/codec/ccodec_gifmodule.cpp
@@ -13,23 +13,23 @@
#include "core/fxge/fx_dib.h"
#include "third_party/base/ptr_util.h"
-CCodec_GifModule::CCodec_GifModule() {
- memset(m_szLastError, 0, sizeof(m_szLastError));
-}
+CCodec_GifModule::CCodec_GifModule() {}
CCodec_GifModule::~CCodec_GifModule() {}
-std::unique_ptr<CGifContext> CCodec_GifModule::Start() {
- return pdfium::MakeUnique<CGifContext>(this, m_szLastError);
+std::unique_ptr<CCodec_GifModule::Context> CCodec_GifModule::Start(
+ Delegate* pDelegate) {
+ return pdfium::MakeUnique<CGifContext>(this, pDelegate);
}
-GifDecodeStatus CCodec_GifModule::ReadHeader(CGifContext* context,
+GifDecodeStatus CCodec_GifModule::ReadHeader(Context* pContext,
int* width,
int* height,
int* pal_num,
void** pal_pp,
int* bg_index,
CFX_DIBAttribute* pAttribute) {
+ auto* context = static_cast<CGifContext*>(pContext);
GifDecodeStatus ret = gif_read_header(context);
if (ret != GifDecodeStatus::Success)
return ret;
@@ -43,8 +43,9 @@ GifDecodeStatus CCodec_GifModule::ReadHeader(CGifContext* context,
return GifDecodeStatus::Success;
}
-GifDecodeStatus CCodec_GifModule::LoadFrameInfo(CGifContext* context,
+GifDecodeStatus CCodec_GifModule::LoadFrameInfo(Context* pContext,
int* frame_num) {
+ auto* context = static_cast<CGifContext*>(pContext);
GifDecodeStatus ret = gif_get_frame(context);
if (ret != GifDecodeStatus::Success)
return ret;
@@ -53,9 +54,10 @@ GifDecodeStatus CCodec_GifModule::LoadFrameInfo(CGifContext* context,
return GifDecodeStatus::Success;
}
-GifDecodeStatus CCodec_GifModule::LoadFrame(CGifContext* context,
+GifDecodeStatus CCodec_GifModule::LoadFrame(Context* pContext,
int frame_num,
CFX_DIBAttribute* pAttribute) {
+ auto* context = static_cast<CGifContext*>(pContext);
GifDecodeStatus ret = gif_load_frame(context, frame_num);
if (ret != GifDecodeStatus::Success || !pAttribute)
return ret;
@@ -76,13 +78,15 @@ GifDecodeStatus CCodec_GifModule::LoadFrame(CGifContext* context,
return GifDecodeStatus::Success;
}
-uint32_t CCodec_GifModule::GetAvailInput(CGifContext* context,
+uint32_t CCodec_GifModule::GetAvailInput(Context* pContext,
uint8_t** avail_buf_ptr) {
+ auto* context = static_cast<CGifContext*>(pContext);
return gif_get_avail_input(context, avail_buf_ptr);
}
-void CCodec_GifModule::Input(CGifContext* context,
+void CCodec_GifModule::Input(Context* pContext,
const uint8_t* src_buf,
uint32_t src_size) {
+ auto* context = static_cast<CGifContext*>(pContext);
gif_input_buffer(context, (uint8_t*)src_buf, src_size);
}
diff --git a/core/fxcodec/codec/ccodec_gifmodule.h b/core/fxcodec/codec/ccodec_gifmodule.h
index 2ccd4f407a..fe1c46478d 100644
--- a/core/fxcodec/codec/ccodec_gifmodule.h
+++ b/core/fxcodec/codec/ccodec_gifmodule.h
@@ -10,7 +10,6 @@
#include <memory>
#include "core/fxcodec/lgif/fx_gif.h"
-#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_system.h"
@@ -18,6 +17,11 @@ class CFX_DIBAttribute;
class CCodec_GifModule {
public:
+ class Context {
+ public:
+ virtual ~Context() {}
+ };
+
class Delegate {
public:
virtual void GifRecordCurrentPosition(uint32_t& cur_pos) = 0;
@@ -36,31 +40,20 @@ class CCodec_GifModule {
CCodec_GifModule();
~CCodec_GifModule();
- std::unique_ptr<CGifContext> Start();
- uint32_t GetAvailInput(CGifContext* context,
- uint8_t** avail_buf_ptr = nullptr);
-
- void Input(CGifContext* context, const uint8_t* src_buf, uint32_t src_size);
-
- GifDecodeStatus ReadHeader(CGifContext* context,
+ std::unique_ptr<Context> Start(Delegate* pDelegate);
+ uint32_t GetAvailInput(Context* context, uint8_t** avail_buf_ptr = nullptr);
+ void Input(Context* context, const uint8_t* src_buf, uint32_t src_size);
+ GifDecodeStatus ReadHeader(Context* context,
int* width,
int* height,
int* pal_num,
void** pal_pp,
int* bg_index,
CFX_DIBAttribute* pAttribute);
-
- GifDecodeStatus LoadFrameInfo(CGifContext* context, int* frame_num);
- GifDecodeStatus LoadFrame(CGifContext* context,
+ GifDecodeStatus LoadFrameInfo(Context* context, int* frame_num);
+ GifDecodeStatus LoadFrame(Context* context,
int frame_num,
CFX_DIBAttribute* pAttribute);
-
- Delegate* GetDelegate() const { return m_pDelegate.Get(); }
- void SetDelegate(Delegate* pDelegate) { m_pDelegate = pDelegate; }
-
- protected:
- CFX_UnownedPtr<Delegate> m_pDelegate;
- char m_szLastError[256];
};
#endif // CORE_FXCODEC_CODEC_CCODEC_GIFMODULE_H_
diff --git a/core/fxcodec/codec/ccodec_progressivedecoder.h b/core/fxcodec/codec/ccodec_progressivedecoder.h
index eab76a7e21..19101c1cbb 100644
--- a/core/fxcodec/codec/ccodec_progressivedecoder.h
+++ b/core/fxcodec/codec/ccodec_progressivedecoder.h
@@ -16,7 +16,6 @@
#include "core/fxcodec/codec/ccodec_pngmodule.h"
#include "core/fxcodec/codec/ccodec_tiffmodule.h"
#include "core/fxcodec/fx_codec_def.h"
-#include "core/fxcodec/lgif/cgifcontext.h"
#include "core/fxcrt/cfx_retain_ptr.h"
#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_system.h"
@@ -132,7 +131,7 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate,
// TODO(tsepez): All these contexts probably should be unique_ptrs.
CFX_UnownedPtr<CCodec_JpegModule::Context> m_pJpegContext;
CFX_UnownedPtr<CCodec_PngModule::Context> m_pPngContext;
- std::unique_ptr<CGifContext> m_pGifContext;
+ std::unique_ptr<CCodec_GifModule::Context> m_pGifContext;
CFX_UnownedPtr<CCodec_BmpModule::Context> m_pBmpContext;
CFX_UnownedPtr<CCodec_TiffContext> m_pTiffContext;
FXCODEC_IMAGE_TYPE m_imagType;
diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp
index f65235139d..a11ba4405e 100644
--- a/core/fxcodec/codec/fx_codec_progress.cpp
+++ b/core/fxcodec/codec/fx_codec_progress.cpp
@@ -1160,8 +1160,7 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType,
m_status = FXCODEC_STATUS_ERR_MEMORY;
return false;
}
- pGifModule->SetDelegate(this);
- m_pGifContext = pGifModule->Start();
+ m_pGifContext = pGifModule->Start(this);
bool bResult = m_pFile->ReadBlock(m_pSrcBuf, 0, size);
if (!bResult) {
m_status = FXCODEC_STATUS_ERR_READ;