summaryrefslogtreecommitdiff
path: root/core/fxcodec/codec/ccodec_bmpmodule.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_bmpmodule.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_bmpmodule.cpp')
-rw-r--r--core/fxcodec/codec/ccodec_bmpmodule.cpp14
1 files changed, 9 insertions, 5 deletions
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);