summaryrefslogtreecommitdiff
path: root/core/fxcodec/codec/ccodec_gifmodule.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-03-01 12:15:00 -0800
committerChromium commit bot <commit-bot@chromium.org>2017-03-01 20:43:46 +0000
commitb4a261855b34b4c8d938118762ae609a34a3ae99 (patch)
tree7b084e874cbf41eec73a3cec949dc810983cc0cf /core/fxcodec/codec/ccodec_gifmodule.cpp
parentfed39cf4a23341cf9cb5a5b432248b4247022282 (diff)
downloadpdfium-b4a261855b34b4c8d938118762ae609a34a3ae99.tar.xz
Create virtual codec APIs so chrome/fuzzers can link separately
The one step to make an actual concrete class is conditionalized in fpdfview and is unconditional in the fuzzer. Also replace the clumsy C-style callbacks with a delegate interface as long as we are making new interfaces. Change-Id: I733a437483ce5e0c34211cfbbda05105336f55b5 Reviewed-on: https://pdfium-review.googlesource.com/2887 Commit-Queue: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcodec/codec/ccodec_gifmodule.cpp')
-rw-r--r--core/fxcodec/codec/ccodec_gifmodule.cpp31
1 files changed, 20 insertions, 11 deletions
diff --git a/core/fxcodec/codec/ccodec_gifmodule.cpp b/core/fxcodec/codec/ccodec_gifmodule.cpp
index e3b2648c43..a85bc5eddc 100644
--- a/core/fxcodec/codec/ccodec_gifmodule.cpp
+++ b/core/fxcodec/codec/ccodec_gifmodule.cpp
@@ -14,11 +14,11 @@
struct FXGIF_Context {
gif_decompress_struct_p gif_ptr;
void* parent_ptr;
- void* child_ptr;
void* (*m_AllocFunc)(unsigned int);
void (*m_FreeFunc)(void*);
};
+
extern "C" {
static void* gif_alloc_func(unsigned int size) {
return FX_Alloc(char, size);
@@ -27,31 +27,36 @@ static void gif_free_func(void* p) {
FX_Free(p);
}
};
+
static void gif_error_data(gif_decompress_struct_p gif_ptr,
const FX_CHAR* err_msg) {
FXSYS_strncpy((char*)gif_ptr->err_ptr, err_msg, GIF_MAX_ERROR_SIZE - 1);
longjmp(gif_ptr->jmpbuf, 1);
}
+
static uint8_t* gif_ask_buf_for_pal(gif_decompress_struct_p gif_ptr,
int32_t pal_size) {
FXGIF_Context* p = (FXGIF_Context*)gif_ptr->context_ptr;
CCodec_GifModule* pModule = (CCodec_GifModule*)p->parent_ptr;
- return pModule->AskLocalPaletteBufCallback(
- p->child_ptr, gif_get_frame_num(gif_ptr), pal_size);
+ return pModule->GetDelegate()->GifAskLocalPaletteBuf(
+ gif_get_frame_num(gif_ptr), pal_size);
}
+
static void gif_record_current_position(gif_decompress_struct_p gif_ptr,
uint32_t* cur_pos_ptr) {
FXGIF_Context* p = (FXGIF_Context*)gif_ptr->context_ptr;
CCodec_GifModule* pModule = (CCodec_GifModule*)p->parent_ptr;
- pModule->RecordCurrentPositionCallback(p->child_ptr, *cur_pos_ptr);
+ pModule->GetDelegate()->GifRecordCurrentPosition(*cur_pos_ptr);
}
+
static void gif_read_scanline(gif_decompress_struct_p gif_ptr,
int32_t row_num,
uint8_t* row_buf) {
FXGIF_Context* p = (FXGIF_Context*)gif_ptr->context_ptr;
CCodec_GifModule* pModule = (CCodec_GifModule*)p->parent_ptr;
- pModule->ReadScanlineCallback(p->child_ptr, row_num, row_buf);
+ pModule->GetDelegate()->GifReadScanline(row_num, row_buf);
}
+
static bool gif_get_record_position(gif_decompress_struct_p gif_ptr,
uint32_t cur_pos,
int32_t left,
@@ -67,13 +72,18 @@ static bool gif_get_record_position(gif_decompress_struct_p gif_ptr,
bool interlace) {
FXGIF_Context* p = (FXGIF_Context*)gif_ptr->context_ptr;
CCodec_GifModule* pModule = (CCodec_GifModule*)p->parent_ptr;
- return pModule->InputRecordPositionBufCallback(
- p->child_ptr, cur_pos, FX_RECT(left, top, left + width, top + height),
- pal_num, pal_ptr, delay_time, user_input, trans_index, disposal_method,
- interlace);
+ return pModule->GetDelegate()->GifInputRecordPositionBuf(
+ cur_pos, FX_RECT(left, top, left + width, top + height), pal_num, pal_ptr,
+ delay_time, user_input, trans_index, disposal_method, interlace);
+}
+
+CCodec_GifModule::CCodec_GifModule() {
+ memset(m_szLastError, 0, sizeof(m_szLastError));
}
-FXGIF_Context* CCodec_GifModule::Start(void* pModule) {
+CCodec_GifModule::~CCodec_GifModule() {}
+
+FXGIF_Context* CCodec_GifModule::Start() {
FXGIF_Context* p = FX_Alloc(FXGIF_Context, 1);
if (!p)
return nullptr;
@@ -83,7 +93,6 @@ FXGIF_Context* CCodec_GifModule::Start(void* pModule) {
p->m_FreeFunc = gif_free_func;
p->gif_ptr = nullptr;
p->parent_ptr = (void*)this;
- p->child_ptr = pModule;
p->gif_ptr = gif_create_decompress();
if (!p->gif_ptr) {
FX_Free(p);