diff options
-rw-r--r-- | core/fxcodec/codec/ccodec_pngmodule.cpp | 66 | ||||
-rw-r--r-- | core/fxge/fontdata/chromefontdata/chromefontdata.h | 8 | ||||
-rw-r--r-- | core/fxge/fx_ge_fontmap.cpp | 8 |
3 files changed, 28 insertions, 54 deletions
diff --git a/core/fxcodec/codec/ccodec_pngmodule.cpp b/core/fxcodec/codec/ccodec_pngmodule.cpp index 2c22f6bdba..b98e68d961 100644 --- a/core/fxcodec/codec/ccodec_pngmodule.cpp +++ b/core/fxcodec/codec/ccodec_pngmodule.cpp @@ -23,34 +23,35 @@ #define PNG_ERROR_SIZE 256 +namespace { + class CPngContext final : public CCodec_PngModule::Context { public: - CPngContext(CCodec_PngModule* pModule, CCodec_PngModule::Delegate* pDelegate); + explicit CPngContext(CCodec_PngModule::Delegate* pDelegate); ~CPngContext() override; - png_structp m_pPng; - png_infop m_pInfo; - UnownedPtr<CCodec_PngModule> m_pModule; - UnownedPtr<CCodec_PngModule::Delegate> m_pDelegate; - void* (*m_AllocFunc)(unsigned int); - void (*m_FreeFunc)(void*); + png_structp m_pPng = nullptr; + png_infop m_pInfo = nullptr; + UnownedPtr<CCodec_PngModule::Delegate> const m_pDelegate; char m_szLastError[PNG_ERROR_SIZE]; }; extern "C" { -static void _png_error_data(png_structp png_ptr, png_const_charp error_msg) { - if (png_get_error_ptr(png_ptr)) - strncpy((char*)png_get_error_ptr(png_ptr), error_msg, PNG_ERROR_SIZE - 1); +void _png_error_data(png_structp png_ptr, png_const_charp error_msg) { + if (png_get_error_ptr(png_ptr)) { + strncpy(static_cast<char*>(png_get_error_ptr(png_ptr)), error_msg, + PNG_ERROR_SIZE - 1); + } longjmp(png_jmpbuf(png_ptr), 1); } -static void _png_warning_data(png_structp png_ptr, png_const_charp error_msg) {} +void _png_warning_data(png_structp png_ptr, png_const_charp error_msg) {} -static void _png_load_bmp_attribute(png_structp png_ptr, - png_infop info_ptr, - CFX_DIBAttribute* pAttribute) { +void _png_load_bmp_attribute(png_structp png_ptr, + png_infop info_ptr, + CFX_DIBAttribute* pAttribute) { if (pAttribute) { #if defined(PNG_pHYs_SUPPORTED) pAttribute->m_nXDPI = png_get_x_pixels_per_meter(png_ptr, info_ptr); @@ -82,15 +83,7 @@ static void _png_load_bmp_attribute(png_structp png_ptr, } } -static void* _png_alloc_func(unsigned int size) { - return FX_Alloc(char, size); -} - -static void _png_free_func(void* p) { - FX_Free(p); -} - -static void _png_get_header_func(png_structp png_ptr, png_infop info_ptr) { +void _png_get_header_func(png_structp png_ptr, png_infop info_ptr) { auto* pContext = reinterpret_cast<CPngContext*>(png_get_progressive_ptr(png_ptr)); if (!pContext) @@ -158,12 +151,12 @@ static void _png_get_header_func(png_structp png_ptr, png_infop info_ptr) { png_read_update_info(png_ptr, info_ptr); } -static void _png_get_end_func(png_structp png_ptr, png_infop info_ptr) {} +void _png_get_end_func(png_structp png_ptr, png_infop info_ptr) {} -static void _png_get_row_func(png_structp png_ptr, - png_bytep new_row, - png_uint_32 row_num, - int pass) { +void _png_get_row_func(png_structp png_ptr, + png_bytep new_row, + png_uint_32 row_num, + int pass) { auto* pContext = reinterpret_cast<CPngContext*>(png_get_progressive_ptr(png_ptr)); if (!pContext) @@ -181,14 +174,8 @@ static void _png_get_row_func(png_structp png_ptr, } // extern "C" -CPngContext::CPngContext(CCodec_PngModule* pModule, - CCodec_PngModule::Delegate* pDelegate) - : m_pPng(nullptr), - m_pInfo(nullptr), - m_pModule(pModule), - m_pDelegate(pDelegate), - m_AllocFunc(_png_alloc_func), - m_FreeFunc(_png_free_func) { +CPngContext::CPngContext(CCodec_PngModule::Delegate* pDelegate) + : m_pDelegate(pDelegate) { memset(m_szLastError, 0, sizeof(m_szLastError)); } @@ -197,9 +184,11 @@ CPngContext::~CPngContext() { m_pInfo ? &m_pInfo : nullptr, nullptr); } +} // namespace + std::unique_ptr<CCodec_PngModule::Context> CCodec_PngModule::Start( Delegate* pDelegate) { - auto p = pdfium::MakeUnique<CPngContext>(this, pDelegate); + auto p = pdfium::MakeUnique<CPngContext>(pDelegate); p->m_pPng = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); if (!p->m_pPng) @@ -231,6 +220,7 @@ bool CCodec_PngModule::Input(Context* pContext, } return false; } - png_process_data(ctx->m_pPng, ctx->m_pInfo, (uint8_t*)src_buf, src_size); + png_process_data(ctx->m_pPng, ctx->m_pInfo, const_cast<uint8_t*>(src_buf), + src_size); return true; } diff --git a/core/fxge/fontdata/chromefontdata/chromefontdata.h b/core/fxge/fontdata/chromefontdata/chromefontdata.h index 3cd8d1a8ca..cbd1ad2d6d 100644 --- a/core/fxge/fontdata/chromefontdata/chromefontdata.h +++ b/core/fxge/fontdata/chromefontdata/chromefontdata.h @@ -7,10 +7,6 @@ #ifndef CORE_FXGE_FONTDATA_CHROMEFONTDATA_CHROMEFONTDATA_H_ #define CORE_FXGE_FONTDATA_CHROMEFONTDATA_CHROMEFONTDATA_H_ -#ifdef __cplusplus -extern "C" { -#endif - extern const unsigned char g_FoxitFixedItalicFontData[18746]; extern const unsigned char g_FoxitFixedFontData[17597]; extern const unsigned char g_FoxitSansItalicFontData[16339]; @@ -28,8 +24,4 @@ extern const unsigned char g_FoxitDingbatsFontData[29513]; extern const unsigned char g_FoxitSerifMMFontData[113417]; extern const unsigned char g_FoxitSansMMFontData[66919]; -#ifdef __cplusplus -} // extern "C" -#endif - #endif // CORE_FXGE_FONTDATA_CHROMEFONTDATA_CHROMEFONTDATA_H_ diff --git a/core/fxge/fx_ge_fontmap.cpp b/core/fxge/fx_ge_fontmap.cpp index 58b00f5ec9..a3c9516b2b 100644 --- a/core/fxge/fx_ge_fontmap.cpp +++ b/core/fxge/fx_ge_fontmap.cpp @@ -64,14 +64,6 @@ int SystemFontInfoIface::GetFaceIndex(void* hFont) { return 0; } -extern "C" { -unsigned long _FTStreamRead(FXFT_Stream stream, - unsigned long offset, - unsigned char* buffer, - unsigned long count); -void _FTStreamClose(FXFT_Stream stream); -}; - #if _FX_OS_ == _FX_OS_ANDROID_ std::unique_ptr<SystemFontInfoIface> SystemFontInfoIface::CreateDefault( const char** pUnused) { |