diff options
Diffstat (limited to 'core/fxcodec/lgif')
-rw-r--r-- | core/fxcodec/lgif/cgifcontext.cpp | 21 | ||||
-rw-r--r-- | core/fxcodec/lgif/cgifcontext.h | 18 | ||||
-rw-r--r-- | core/fxcodec/lgif/fx_gif.cpp | 2 |
3 files changed, 21 insertions, 20 deletions
diff --git a/core/fxcodec/lgif/cgifcontext.cpp b/core/fxcodec/lgif/cgifcontext.cpp index 9c03cffa21..e57e978218 100644 --- a/core/fxcodec/lgif/cgifcontext.cpp +++ b/core/fxcodec/lgif/cgifcontext.cpp @@ -13,15 +13,16 @@ #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" -CGifContext::CGifContext(CCodec_GifModule* gif_module, char* error_string) - : global_pal_num(0), +CGifContext::CGifContext(CCodec_GifModule* gif_module, + CCodec_GifModule::Delegate* pDelegate) + : m_pModule(gif_module), + m_pDelegate(pDelegate), + global_pal_num(0), img_row_offset(0), img_row_avail_size(0), avail_in(0), decode_status(GIF_D_STATUS_SIG), skip_size(0), - m_Module(gif_module), - err_ptr(error_string), next_in(nullptr), width(0), height(0), @@ -29,20 +30,22 @@ CGifContext::CGifContext(CCodec_GifModule* gif_module, char* error_string) pixel_aspect(0), global_sort_flag(0), global_color_resolution(0), - img_pass_num(0) {} + img_pass_num(0) { + memset(m_szLastError, 0, sizeof(m_szLastError)); +} CGifContext::~CGifContext() {} void CGifContext::AddError(const char* err_msg) { - strncpy(err_ptr, err_msg, GIF_MAX_ERROR_SIZE - 1); + strncpy(m_szLastError, err_msg, GIF_MAX_ERROR_SIZE - 1); } void CGifContext::RecordCurrentPosition(uint32_t* cur_pos_ptr) { - m_Module->GetDelegate()->GifRecordCurrentPosition(*cur_pos_ptr); + m_pDelegate->GifRecordCurrentPosition(*cur_pos_ptr); } void CGifContext::ReadScanline(int32_t row_num, uint8_t* row_buf) { - m_Module->GetDelegate()->GifReadScanline(row_num, row_buf); + m_pDelegate->GifReadScanline(row_num, row_buf); } bool CGifContext::GetRecordPosition(uint32_t cur_pos, @@ -57,7 +60,7 @@ bool CGifContext::GetRecordPosition(uint32_t cur_pos, int32_t trans_index, int32_t disposal_method, bool interlace) { - return m_Module->GetDelegate()->GifInputRecordPositionBuf( + return m_pDelegate->GifInputRecordPositionBuf( cur_pos, FX_RECT(left, top, left + width, top + height), pal_num, pal_ptr, delay_time, user_input, trans_index, disposal_method, interlace); } diff --git a/core/fxcodec/lgif/cgifcontext.h b/core/fxcodec/lgif/cgifcontext.h index 20d640ef35..fa46b14559 100644 --- a/core/fxcodec/lgif/cgifcontext.h +++ b/core/fxcodec/lgif/cgifcontext.h @@ -10,16 +10,16 @@ #include <memory> #include <vector> +#include "core/fxcodec/codec/ccodec_gifmodule.h" #include "core/fxcodec/lgif/fx_gif.h" #include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_basic.h" -class CCodec_GifModule; - -class CGifContext { +class CGifContext : public CCodec_GifModule::Context { public: - CGifContext(CCodec_GifModule* gif_module, char* error_string); - ~CGifContext(); + CGifContext(CCodec_GifModule* gif_module, + CCodec_GifModule::Delegate* pDelegate); + ~CGifContext() override; void AddError(const char* err_msg); void RecordCurrentPosition(uint32_t* cur_pos_ptr); @@ -37,6 +37,8 @@ class CGifContext { int32_t disposal_method, bool interlace); + CFX_UnownedPtr<CCodec_GifModule> m_pModule; + CFX_UnownedPtr<CCodec_GifModule::Delegate> m_pDelegate; std::vector<GifPalette> m_GlobalPalette; int32_t global_pal_num; uint32_t img_row_offset; @@ -44,23 +46,19 @@ class CGifContext { uint32_t avail_in; int32_t decode_status; uint32_t skip_size; - - CFX_UnownedPtr<CCodec_GifModule> m_Module; - char* err_ptr; CFX_ByteString cmt_data; std::unique_ptr<GifGCE> m_GifGCE; uint8_t* next_in; std::vector<std::unique_ptr<GifImage>> m_Images; std::unique_ptr<CGifLZWDecoder> m_ImgDecoder; - int width; int height; - uint8_t bc_index; uint8_t pixel_aspect; uint8_t global_sort_flag; uint8_t global_color_resolution; uint8_t img_pass_num; + char m_szLastError[GIF_MAX_ERROR_SIZE]; }; #endif // CORE_FXCODEC_LGIF_CGIFCONTEXT_H_ diff --git a/core/fxcodec/lgif/fx_gif.cpp b/core/fxcodec/lgif/fx_gif.cpp index b4fe328f6c..cef4f9a9a5 100644 --- a/core/fxcodec/lgif/fx_gif.cpp +++ b/core/fxcodec/lgif/fx_gif.cpp @@ -565,7 +565,7 @@ GifDecodeStatus gif_load_frame(CGifContext* context, int32_t frame_num) { } if (!context->m_ImgDecoder.get()) context->m_ImgDecoder = - pdfium::MakeUnique<CGifLZWDecoder>(context->err_ptr); + pdfium::MakeUnique<CGifLZWDecoder>(context->m_szLastError); context->m_ImgDecoder->InitTable(gif_image_ptr->image_code_size); context->img_row_offset = 0; context->img_row_avail_size = 0; |