diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-06-01 10:18:53 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-06-01 19:12:48 +0000 |
commit | 5f34d479d06ebab9079c2d0704dee872cc45dd86 (patch) | |
tree | abcde4e8d564fbfbc2e1c89e96ba2d30e74be1e8 /core/fxcodec/codec/ccodec_gifmodule.cpp | |
parent | 1fed5a255f03232f74db882bb0d39df340479da4 (diff) | |
download | pdfium-5f34d479d06ebab9079c2d0704dee872cc45dd86.tar.xz |
Move CCodec_GifModule state to CGifContext
Introduce a base CCodec_GifModule::Context class with a virtual
destructor so holders of unique_ptr's to these can delete them
without actually having any knowledge of the implementation
details of the context.
Bug: 728669
Change-Id: Ia50f94300924a1053c326984eac3b03f25f1b83c
Reviewed-on: https://pdfium-review.googlesource.com/6190
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fxcodec/codec/ccodec_gifmodule.cpp')
-rw-r--r-- | core/fxcodec/codec/ccodec_gifmodule.cpp | 24 |
1 files changed, 14 insertions, 10 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); } |