summaryrefslogtreecommitdiff
path: root/core/fxcodec/codec/ccodec_pngmodule.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-09-25 20:06:50 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-09-25 20:06:50 +0000
commit958142efa4561b5efd52733ad6c3b889cf49b3ae (patch)
treeda605e08bceccbae3e23d87471c197b37ac48e28 /core/fxcodec/codec/ccodec_pngmodule.cpp
parentfed6e124109f089a38e24e37b104d983231bee78 (diff)
downloadpdfium-958142efa4561b5efd52733ad6c3b889cf49b3ae.tar.xz
Introduce CodecModuleIface for progressive decoder modules.
Another step before trying to fix the memory issue. Forces common APIs on the bunch of decoders, though some methods are unused. Requires adding some arguments/return values to get to a common API which are not used in all cases (yet?). Required converting some args to spans. Required proxying a GetJumpMark() call through the public module API to the private context. Bug: pdfium:1082 Change-Id: I0c0b7415141ff2a6f4f44777ca3d05521f08130d Reviewed-on: https://pdfium-review.googlesource.com/41950 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fxcodec/codec/ccodec_pngmodule.cpp')
-rw-r--r--core/fxcodec/codec/ccodec_pngmodule.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/core/fxcodec/codec/ccodec_pngmodule.cpp b/core/fxcodec/codec/ccodec_pngmodule.cpp
index b98e68d961..593c215db4 100644
--- a/core/fxcodec/codec/ccodec_pngmodule.cpp
+++ b/core/fxcodec/codec/ccodec_pngmodule.cpp
@@ -23,9 +23,7 @@
#define PNG_ERROR_SIZE 256
-namespace {
-
-class CPngContext final : public CCodec_PngModule::Context {
+class CPngContext final : public CodecModuleIface::Context {
public:
explicit CPngContext(CCodec_PngModule::Delegate* pDelegate);
~CPngContext() override;
@@ -184,9 +182,7 @@ CPngContext::~CPngContext() {
m_pInfo ? &m_pInfo : nullptr, nullptr);
}
-} // namespace
-
-std::unique_ptr<CCodec_PngModule::Context> CCodec_PngModule::Start(
+std::unique_ptr<CodecModuleIface::Context> CCodec_PngModule::Start(
Delegate* pDelegate) {
auto p = pdfium::MakeUnique<CPngContext>(pDelegate);
p->m_pPng =
@@ -208,9 +204,13 @@ std::unique_ptr<CCodec_PngModule::Context> CCodec_PngModule::Start(
return p;
}
+FX_FILESIZE CCodec_PngModule::GetAvailInput(Context* pContext) const {
+ NOTREACHED();
+ return 0;
+}
+
bool CCodec_PngModule::Input(Context* pContext,
- const uint8_t* src_buf,
- uint32_t src_size,
+ pdfium::span<uint8_t> src_buf,
CFX_DIBAttribute* pAttribute) {
auto* ctx = static_cast<CPngContext*>(pContext);
if (setjmp(png_jmpbuf(ctx->m_pPng))) {
@@ -220,7 +220,6 @@ bool CCodec_PngModule::Input(Context* pContext,
}
return false;
}
- png_process_data(ctx->m_pPng, ctx->m_pInfo, const_cast<uint8_t*>(src_buf),
- src_size);
+ png_process_data(ctx->m_pPng, ctx->m_pInfo, src_buf.data(), src_buf.size());
return true;
}