diff options
-rw-r--r-- | BUILD.gn | 1 | ||||
-rw-r--r-- | core/include/fxcodec/fx_codec.h | 3 | ||||
-rw-r--r-- | core/include/fxcodec/fx_codec_provider.h | 77 | ||||
-rw-r--r-- | core/src/fxcodec/codec/codec_int.h | 6 | ||||
-rw-r--r-- | core/src/fxcodec/codec/fx_codec_jpeg.cpp | 68 | ||||
-rw-r--r-- | pdfium.gyp | 1 |
6 files changed, 4 insertions, 152 deletions
@@ -382,7 +382,6 @@ static_library("fxcodec") { "core/include/fxcodec/fx_codec.h", "core/include/fxcodec/fx_codec_def.h", "core/include/fxcodec/fx_codec_flate.h", - "core/include/fxcodec/fx_codec_provider.h", "core/src/fxcodec/codec/codec_int.h", "core/src/fxcodec/codec/fx_codec.cpp", "core/src/fxcodec/codec/fx_codec_bmp.cpp", diff --git a/core/include/fxcodec/fx_codec.h b/core/include/fxcodec/fx_codec.h index 82af1aa560..fe3d84d53e 100644 --- a/core/include/fxcodec/fx_codec.h +++ b/core/include/fxcodec/fx_codec.h @@ -13,7 +13,6 @@ #include "../../../third_party/base/nonstd_unique_ptr.h" #include "../fxcrt/fx_basic.h" #include "fx_codec_def.h" -#include "fx_codec_provider.h" #include "../fxcrt/fx_coordinates.h" // For FX_RECT. @@ -195,8 +194,6 @@ class ICodec_JpegModule { public: virtual ~ICodec_JpegModule() {} - virtual void SetPovider(IFX_JpegProvider* pJP) = 0; - virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, FX_DWORD src_size, int width, diff --git a/core/include/fxcodec/fx_codec_provider.h b/core/include/fxcodec/fx_codec_provider.h deleted file mode 100644 index bd4db44c89..0000000000 --- a/core/include/fxcodec/fx_codec_provider.h +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef CORE_INCLUDE_FXCODEC_FX_CODEC_PROVIDER_H_ -#define CORE_INCLUDE_FXCODEC_FX_CODEC_PROVIDER_H_ - -#include "../fxcrt/fx_system.h" - -class CFX_DIBAttribute; - -class IFX_JpegProvider { - public: - virtual void Release() = 0; - - virtual void* CreateDecoder(const uint8_t* src_buf, - FX_DWORD src_size, - int width, - int height, - int nComps, - FX_BOOL ColorTransform) = 0; - - virtual void DestroyDecoder(void* pDecoder) = 0; - - virtual void DownScale(void* pDecoder, int dest_width, int dest_height) = 0; - - virtual FX_BOOL Rewind(void* pDecoder) = 0; - - virtual uint8_t* GetNextLine(void* pDecoder) = 0; - - virtual FX_DWORD GetSrcOffset(void* pDecoder) = 0; - - virtual FX_BOOL LoadInfo(const uint8_t* src_buf, - FX_DWORD src_size, - int& width, - int& height, - int& num_components, - int& bits_per_components, - FX_BOOL& color_transform, - uint8_t** icc_buf_ptr = NULL, - FX_DWORD* icc_length = NULL) = 0; - - virtual FX_BOOL Encode(const class CFX_DIBSource* pSource, - uint8_t*& dest_buf, - FX_STRSIZE& dest_size, - int quality = 75, - const uint8_t* icc_buf = NULL, - FX_DWORD icc_length = 0) = 0; - - virtual void* Start() = 0; - - virtual void Finish(void* pContext) = 0; - - virtual void Input(void* pContext, - const uint8_t* src_buf, - FX_DWORD src_size) = 0; - - virtual int ReadHeader(void* pContext, - int* width, - int* height, - int* nComps, - CFX_DIBAttribute* pAttribute = NULL) = 0; - - virtual int StartScanline(void* pContext, int down_scale) = 0; - - virtual FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf) = 0; - - virtual FX_DWORD GetAvailInput(void* pContext, - uint8_t** avail_buf_ptr = NULL) = 0; - - protected: - ~IFX_JpegProvider() {} -}; - -#endif // CORE_INCLUDE_FXCODEC_FX_CODEC_PROVIDER_H_ diff --git a/core/src/fxcodec/codec/codec_int.h b/core/src/fxcodec/codec/codec_int.h index fbf44c0564..93384caac9 100644 --- a/core/src/fxcodec/codec/codec_int.h +++ b/core/src/fxcodec/codec/codec_int.h @@ -158,8 +158,7 @@ class CCodec_FlateModule : public ICodec_FlateModule { class CCodec_JpegModule : public ICodec_JpegModule { public: - CCodec_JpegModule() : m_pExtProvider(NULL) {} - void SetPovider(IFX_JpegProvider* pJP) override { m_pExtProvider = pJP; } + CCodec_JpegModule() {} ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, FX_DWORD src_size, int width, @@ -194,9 +193,6 @@ class CCodec_JpegModule : public ICodec_JpegModule { int StartScanline(void* pContext, int down_scale) override; FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf) override; FX_DWORD GetAvailInput(void* pContext, uint8_t** avail_buf_ptr) override; - - protected: - IFX_JpegProvider* m_pExtProvider; }; #define PNG_ERROR_SIZE 256 class CCodec_PngModule : public ICodec_PngModule { diff --git a/core/src/fxcodec/codec/fx_codec_jpeg.cpp b/core/src/fxcodec/codec/fx_codec_jpeg.cpp index 2ef7d35b2b..b3cd2c72e3 100644 --- a/core/src/fxcodec/codec/fx_codec_jpeg.cpp +++ b/core/src/fxcodec/codec/fx_codec_jpeg.cpp @@ -307,8 +307,7 @@ class CCodec_JpegDecoder : public CCodec_ScanlineDecoder { int width, int height, int nComps, - FX_BOOL ColorTransform, - IFX_JpegProvider* pJP); + FX_BOOL ColorTransform); void Destroy() { delete this; } // CCodec_ScanlineDecoder @@ -332,8 +331,6 @@ class CCodec_JpegDecoder : public CCodec_ScanlineDecoder { FX_BOOL m_bJpegTransform; protected: - IFX_JpegProvider* m_pExtProvider; - void* m_pExtContext; FX_DWORD m_nDefaultScaleDenom; }; @@ -342,18 +339,12 @@ CCodec_JpegDecoder::CCodec_JpegDecoder() { m_DownScale = 1; m_bStarted = FALSE; m_bInited = FALSE; - m_pExtProvider = NULL; - m_pExtContext = NULL; FXSYS_memset(&cinfo, 0, sizeof(cinfo)); FXSYS_memset(&jerr, 0, sizeof(jerr)); FXSYS_memset(&src, 0, sizeof(src)); m_nDefaultScaleDenom = 1; } CCodec_JpegDecoder::~CCodec_JpegDecoder() { - if (m_pExtProvider) { - m_pExtProvider->DestroyDecoder(m_pExtContext); - return; - } FX_Free(m_pScanlineBuf); if (m_bInited) { jpeg_destroy_decompress(&cinfo); @@ -399,14 +390,7 @@ FX_BOOL CCodec_JpegDecoder::Create(const uint8_t* src_buf, int width, int height, int nComps, - FX_BOOL ColorTransform, - IFX_JpegProvider* pJP) { - if (pJP) { - m_pExtProvider = pJP; - m_pExtContext = m_pExtProvider->CreateDecoder( - src_buf, src_size, width, height, nComps, ColorTransform); - return m_pExtContext != NULL; - } + FX_BOOL ColorTransform) { _JpegScanSOI(src_buf, src_size); m_SrcBuf = src_buf; m_SrcSize = src_size; @@ -466,10 +450,6 @@ int32_t FX_GetDownsampleRatio(int32_t originWidth, } } void CCodec_JpegDecoder::v_DownScale(int dest_width, int dest_height) { - if (m_pExtProvider) { - m_pExtProvider->DownScale(m_pExtContext, dest_width, dest_height); - return; - } int old_scale = m_DownScale; m_DownScale = FX_GetDownsampleRatio(m_OrigWidth, m_OrigHeight, dest_width, dest_height); @@ -481,9 +461,6 @@ void CCodec_JpegDecoder::v_DownScale(int dest_width, int dest_height) { } } FX_BOOL CCodec_JpegDecoder::v_Rewind() { - if (m_pExtProvider) { - return m_pExtProvider->Rewind(m_pExtContext); - } if (m_bStarted) { jpeg_destroy_decompress(&cinfo); if (!InitDecode()) { @@ -508,9 +485,6 @@ FX_BOOL CCodec_JpegDecoder::v_Rewind() { return TRUE; } uint8_t* CCodec_JpegDecoder::v_GetNextLine() { - if (m_pExtProvider) { - return m_pExtProvider->GetNextLine(m_pExtContext); - } int nlines = jpeg_read_scanlines(&cinfo, &m_pScanlineBuf, 1); if (nlines < 1) { return NULL; @@ -518,9 +492,6 @@ uint8_t* CCodec_JpegDecoder::v_GetNextLine() { return m_pScanlineBuf; } FX_DWORD CCodec_JpegDecoder::GetSrcOffset() { - if (m_pExtProvider) { - return m_pExtProvider->GetSrcOffset(m_pExtContext); - } return (FX_DWORD)(m_SrcSize - src.bytes_in_buffer); } ICodec_ScanlineDecoder* CCodec_JpegModule::CreateDecoder( @@ -535,7 +506,7 @@ ICodec_ScanlineDecoder* CCodec_JpegModule::CreateDecoder( } CCodec_JpegDecoder* pDecoder = new CCodec_JpegDecoder; if (!pDecoder->Create(src_buf, src_size, width, height, nComps, - ColorTransform, m_pExtProvider)) { + ColorTransform)) { delete pDecoder; return NULL; } @@ -550,11 +521,6 @@ FX_BOOL CCodec_JpegModule::LoadInfo(const uint8_t* src_buf, FX_BOOL& color_transform, uint8_t** icc_buf_ptr, FX_DWORD* icc_length) { - if (m_pExtProvider) { - return m_pExtProvider->LoadInfo(src_buf, src_size, width, height, - num_components, bits_per_components, - color_transform, icc_buf_ptr, icc_length); - } return _JpegLoadInfo(src_buf, src_size, width, height, num_components, bits_per_components, color_transform, icc_buf_ptr, icc_length); @@ -565,10 +531,6 @@ FX_BOOL CCodec_JpegModule::Encode(const CFX_DIBSource* pSource, int quality, const uint8_t* icc_buf, FX_DWORD icc_length) { - if (m_pExtProvider) { - return m_pExtProvider->Encode(pSource, dest_buf, dest_size, quality, - icc_buf, icc_length); - } if (pSource->GetBPP() < 8 || pSource->GetPalette() != NULL) { ASSERT(pSource->GetBPP() >= 8 && pSource->GetPalette() == NULL); return FALSE; @@ -609,9 +571,6 @@ static void jpeg_free_func(void* p) { FX_Free(p); } void* CCodec_JpegModule::Start() { - if (m_pExtProvider) { - return m_pExtProvider->Start(); - } FXJPEG_Context* p = FX_Alloc(FXJPEG_Context, 1); p->m_AllocFunc = jpeg_alloc_func; p->m_FreeFunc = jpeg_free_func; @@ -636,10 +595,6 @@ void* CCodec_JpegModule::Start() { return p; } void CCodec_JpegModule::Finish(void* pContext) { - if (m_pExtProvider) { - m_pExtProvider->Finish(pContext); - return; - } FXJPEG_Context* p = (FXJPEG_Context*)pContext; jpeg_destroy_decompress(&p->m_Info); p->m_FreeFunc(p); @@ -647,10 +602,6 @@ void CCodec_JpegModule::Finish(void* pContext) { void CCodec_JpegModule::Input(void* pContext, const unsigned char* src_buf, FX_DWORD src_size) { - if (m_pExtProvider) { - m_pExtProvider->Input(pContext, src_buf, src_size); - return; - } FXJPEG_Context* p = (FXJPEG_Context*)pContext; if (p->m_SkipSize) { if (p->m_SkipSize > src_size) { @@ -670,10 +621,6 @@ int CCodec_JpegModule::ReadHeader(void* pContext, int* height, int* nComps, CFX_DIBAttribute* pAttribute) { - if (m_pExtProvider) { - return m_pExtProvider->ReadHeader(pContext, width, height, nComps, - pAttribute); - } FXJPEG_Context* p = (FXJPEG_Context*)pContext; if (setjmp(p->m_JumpMark) == -1) { return 1; @@ -692,9 +639,6 @@ int CCodec_JpegModule::ReadHeader(void* pContext, return 0; } int CCodec_JpegModule::StartScanline(void* pContext, int down_scale) { - if (m_pExtProvider) { - return m_pExtProvider->StartScanline(pContext, down_scale); - } FXJPEG_Context* p = (FXJPEG_Context*)pContext; if (setjmp(p->m_JumpMark) == -1) { return 0; @@ -704,9 +648,6 @@ int CCodec_JpegModule::StartScanline(void* pContext, int down_scale) { } FX_BOOL CCodec_JpegModule::ReadScanline(void* pContext, unsigned char* dest_buf) { - if (m_pExtProvider) { - return m_pExtProvider->ReadScanline(pContext, dest_buf); - } FXJPEG_Context* p = (FXJPEG_Context*)pContext; if (setjmp(p->m_JumpMark) == -1) { return FALSE; @@ -716,9 +657,6 @@ FX_BOOL CCodec_JpegModule::ReadScanline(void* pContext, } FX_DWORD CCodec_JpegModule::GetAvailInput(void* pContext, uint8_t** avail_buf_ptr) { - if (m_pExtProvider) { - return m_pExtProvider->GetAvailInput(pContext, avail_buf_ptr); - } if (avail_buf_ptr != NULL) { *avail_buf_ptr = NULL; if (((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) { diff --git a/pdfium.gyp b/pdfium.gyp index 10f0cffda5..48ed36de42 100644 --- a/pdfium.gyp +++ b/pdfium.gyp @@ -332,7 +332,6 @@ 'core/include/fxcodec/fx_codec.h', 'core/include/fxcodec/fx_codec_def.h', 'core/include/fxcodec/fx_codec_flate.h', - 'core/include/fxcodec/fx_codec_provider.h', 'core/src/fxcodec/codec/codec_int.h', 'core/src/fxcodec/codec/fx_codec.cpp', 'core/src/fxcodec/codec/fx_codec_bmp.cpp', |