From b4a261855b34b4c8d938118762ae609a34a3ae99 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 1 Mar 2017 12:15:00 -0800 Subject: 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 Commit-Queue: dsinclair Reviewed-by: dsinclair --- core/fxcodec/codec/ccodec_bmpmodule.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'core/fxcodec/codec/ccodec_bmpmodule.cpp') diff --git a/core/fxcodec/codec/ccodec_bmpmodule.cpp b/core/fxcodec/codec/ccodec_bmpmodule.cpp index c6ebd2d939..9d64199501 100644 --- a/core/fxcodec/codec/ccodec_bmpmodule.cpp +++ b/core/fxcodec/codec/ccodec_bmpmodule.cpp @@ -14,7 +14,6 @@ struct FXBMP_Context { bmp_decompress_struct_p bmp_ptr; void* parent_ptr; - void* child_ptr; void* (*m_AllocFunc)(unsigned int); void (*m_FreeFunc)(void*); @@ -37,16 +36,22 @@ static void bmp_read_scanline(bmp_decompress_struct_p bmp_ptr, uint8_t* row_buf) { FXBMP_Context* p = (FXBMP_Context*)bmp_ptr->context_ptr; CCodec_BmpModule* pModule = (CCodec_BmpModule*)p->parent_ptr; - pModule->ReadScanlineCallback(p->child_ptr, row_num, row_buf); + pModule->GetDelegate()->BmpReadScanline(row_num, row_buf); } static bool bmp_get_data_position(bmp_decompress_struct_p bmp_ptr, uint32_t rcd_pos) { FXBMP_Context* p = (FXBMP_Context*)bmp_ptr->context_ptr; CCodec_BmpModule* pModule = (CCodec_BmpModule*)p->parent_ptr; - return pModule->InputImagePositionBufCallback(p->child_ptr, rcd_pos); + return pModule->GetDelegate()->BmpInputImagePositionBuf(rcd_pos); } -FXBMP_Context* CCodec_BmpModule::Start(void* pModule) { +CCodec_BmpModule::CCodec_BmpModule() { + memset(m_szLastError, 0, sizeof(m_szLastError)); +} + +CCodec_BmpModule::~CCodec_BmpModule() {} + +FXBMP_Context* CCodec_BmpModule::Start() { FXBMP_Context* p = FX_Alloc(FXBMP_Context, 1); if (!p) return nullptr; @@ -59,7 +64,6 @@ FXBMP_Context* CCodec_BmpModule::Start(void* pModule) { p->m_FreeFunc = bmp_free_func; p->bmp_ptr = nullptr; p->parent_ptr = (void*)this; - p->child_ptr = pModule; p->bmp_ptr = bmp_create_decompress(); if (!p->bmp_ptr) { FX_Free(p); -- cgit v1.2.3