summaryrefslogtreecommitdiff
path: root/core/fxcodec/codec/ccodec_pngmodule.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_pngmodule.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_pngmodule.cpp')
-rw-r--r--core/fxcodec/codec/ccodec_pngmodule.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/core/fxcodec/codec/ccodec_pngmodule.cpp b/core/fxcodec/codec/ccodec_pngmodule.cpp
index d3e24cd9ea..028513b729 100644
--- a/core/fxcodec/codec/ccodec_pngmodule.cpp
+++ b/core/fxcodec/codec/ccodec_pngmodule.cpp
@@ -97,7 +97,6 @@ struct FXPNG_Context {
png_structp png_ptr;
png_infop info_ptr;
void* parent_ptr;
- void* child_ptr;
void* (*m_AllocFunc)(unsigned int);
void (*m_FreeFunc)(void*);
@@ -135,8 +134,8 @@ static void _png_get_header_func(png_structp png_ptr, png_infop info_ptr) {
png_set_palette_to_rgb(png_ptr);
}
pass = png_set_interlace_handling(png_ptr);
- if (!pModule->ReadHeaderCallback(p->child_ptr, width, height, bpc, pass,
- &color_type, &gamma)) {
+ if (!pModule->GetDelegate()->PngReadHeader(width, height, bpc, pass,
+ &color_type, &gamma)) {
png_error(p->png_ptr, "Read Header Callback Error");
}
int intent;
@@ -189,16 +188,22 @@ static void _png_get_row_func(png_structp png_ptr,
CCodec_PngModule* pModule = (CCodec_PngModule*)p->parent_ptr;
uint8_t* src_buf = nullptr;
- if (!pModule->AskScanlineBufCallback(p->child_ptr, row_num, src_buf)) {
+ if (!pModule->GetDelegate()->PngAskScanlineBuf(row_num, src_buf)) {
png_error(png_ptr, "Ask Scanline buffer Callback Error");
}
if (src_buf) {
png_progressive_combine_row(png_ptr, src_buf, new_row);
}
- pModule->FillScanlineBufCompletedCallback(p->child_ptr, pass, row_num);
+ pModule->GetDelegate()->PngFillScanlineBufCompleted(pass, row_num);
}
-FXPNG_Context* CCodec_PngModule::Start(void* pModule) {
+CCodec_PngModule::CCodec_PngModule() {
+ memset(m_szLastError, 0, sizeof(m_szLastError));
+}
+
+CCodec_PngModule::~CCodec_PngModule() {}
+
+FXPNG_Context* CCodec_PngModule::Start() {
FXPNG_Context* p = FX_Alloc(FXPNG_Context, 1);
if (!p)
return nullptr;
@@ -208,7 +213,6 @@ FXPNG_Context* CCodec_PngModule::Start(void* pModule) {
p->png_ptr = nullptr;
p->info_ptr = nullptr;
p->parent_ptr = (void*)this;
- p->child_ptr = pModule;
p->png_ptr =
png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
if (!p->png_ptr) {