From 76020fc9751e55661d1c01b6cd92dfcb1fd56e6a Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 18 May 2017 15:51:20 -0700 Subject: Move CCodec_ModuleMgr ownership to CPDF_ModuleMgr. More straight forward than CFX_GEModule owning in and CPDF_ModuleMgr holding a pointer to it. Remove assumptions that the codec modules may return nullptr, and do IWYU. Change-Id: Iba7fc3c7ec223fd6d29a1ab74ed13d35689bc5d5 Reviewed-on: https://pdfium-review.googlesource.com/5654 Commit-Queue: dsinclair Reviewed-by: dsinclair --- xfa/fxfa/DEPS | 5 ---- xfa/fxfa/app/DEPS | 3 --- xfa/fxfa/cxfa_ffwidget.cpp | 53 +++++++++++++++++--------------------- xfa/fxfa/parser/cxfa_localemgr.cpp | 20 +++++--------- 4 files changed, 31 insertions(+), 50 deletions(-) delete mode 100644 xfa/fxfa/app/DEPS (limited to 'xfa/fxfa') diff --git a/xfa/fxfa/DEPS b/xfa/fxfa/DEPS index 97e9f52afa..886ee8e2b7 100644 --- a/xfa/fxfa/DEPS +++ b/xfa/fxfa/DEPS @@ -1,8 +1,3 @@ include_rules = [ - '+core/fdrm/crypto', - '+core/fpdfapi/font', - '+core/fpdfapi/page', - '+core/fpdfdoc', - '+core/fxcodec', '+fxjs', ] diff --git a/xfa/fxfa/app/DEPS b/xfa/fxfa/app/DEPS deleted file mode 100644 index f722184c91..0000000000 --- a/xfa/fxfa/app/DEPS +++ /dev/null @@ -1,3 +0,0 @@ -include_rules = [ - '+core/fdrm/crypto', -] diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp index 7bbb8c8265..2ea30b59e5 100644 --- a/xfa/fxfa/cxfa_ffwidget.cpp +++ b/xfa/fxfa/cxfa_ffwidget.cpp @@ -10,12 +10,12 @@ #include #include +#include "core/fpdfapi/cpdf_modulemgr.h" #include "core/fpdfapi/page/cpdf_pageobjectholder.h" #include "core/fxcodec/codec/ccodec_progressivedecoder.h" #include "core/fxcodec/fx_codec.h" #include "core/fxcrt/cfx_maybe_owned.h" #include "core/fxcrt/cfx_memorystream.h" -#include "core/fxge/cfx_gemodule.h" #include "core/fxge/cfx_pathdata.h" #include "core/fxge/cfx_renderdevice.h" #include "core/fxge/dib/cfx_imagerenderer.h" @@ -1120,18 +1120,11 @@ CFX_RetainPtr XFA_LoadImageFromBuffer( FXCODEC_IMAGE_TYPE type, int32_t& iImageXDpi, int32_t& iImageYDpi) { - CFX_GEModule* pGeModule = CFX_GEModule::Get(); - if (!pGeModule) - return nullptr; - - CCodec_ModuleMgr* pCodecMgr = pGeModule->GetCodecModule(); - if (!pCodecMgr) - return nullptr; - - CFX_DIBAttribute dibAttr; - CFX_RetainPtr pBitmap; + CCodec_ModuleMgr* pCodecMgr = CPDF_ModuleMgr::Get()->GetCodecModule(); std::unique_ptr pProgressiveDecoder = pCodecMgr->CreateProgressiveDecoder(); + + CFX_DIBAttribute dibAttr; pProgressiveDecoder->LoadImageInfo(pImageFileRead, type, &dibAttr, false); switch (dibAttr.m_wDPIUnit) { case FXCODEC_RESUNIT_CENTIMETER: @@ -1147,24 +1140,26 @@ CFX_RetainPtr XFA_LoadImageFromBuffer( } iImageXDpi = dibAttr.m_nXDPI > 1 ? dibAttr.m_nXDPI : (96); iImageYDpi = dibAttr.m_nYDPI > 1 ? dibAttr.m_nYDPI : (96); - if (pProgressiveDecoder->GetWidth() > 0 && - pProgressiveDecoder->GetHeight() > 0) { - type = pProgressiveDecoder->GetType(); - int32_t iComponents = pProgressiveDecoder->GetNumComponents(); - int32_t iBpc = pProgressiveDecoder->GetBPC(); - FXDIB_Format dibFormat = XFA_GetDIBFormat(type, iComponents, iBpc); - pBitmap = pdfium::MakeRetain(); - pBitmap->Create(pProgressiveDecoder->GetWidth(), - pProgressiveDecoder->GetHeight(), dibFormat); - pBitmap->Clear(0xffffffff); - int32_t nFrames; - if ((pProgressiveDecoder->GetFrames(nFrames) == - FXCODEC_STATUS_DECODE_READY) && - (nFrames > 0)) { - pProgressiveDecoder->StartDecode(pBitmap, 0, 0, pBitmap->GetWidth(), - pBitmap->GetHeight()); - pProgressiveDecoder->ContinueDecode(); - } + if (pProgressiveDecoder->GetWidth() <= 0 || + pProgressiveDecoder->GetHeight() <= 0) { + return nullptr; + } + + type = pProgressiveDecoder->GetType(); + int32_t iComponents = pProgressiveDecoder->GetNumComponents(); + int32_t iBpc = pProgressiveDecoder->GetBPC(); + FXDIB_Format dibFormat = XFA_GetDIBFormat(type, iComponents, iBpc); + CFX_RetainPtr pBitmap = pdfium::MakeRetain(); + pBitmap->Create(pProgressiveDecoder->GetWidth(), + pProgressiveDecoder->GetHeight(), dibFormat); + pBitmap->Clear(0xffffffff); + int32_t nFrames; + if ((pProgressiveDecoder->GetFrames(nFrames) == + FXCODEC_STATUS_DECODE_READY) && + (nFrames > 0)) { + pProgressiveDecoder->StartDecode(pBitmap, 0, 0, pBitmap->GetWidth(), + pBitmap->GetHeight()); + pProgressiveDecoder->ContinueDecode(); } return pBitmap; } diff --git a/xfa/fxfa/parser/cxfa_localemgr.cpp b/xfa/fxfa/parser/cxfa_localemgr.cpp index 0a691a6ceb..fbb12e2b48 100644 --- a/xfa/fxfa/parser/cxfa_localemgr.cpp +++ b/xfa/fxfa/parser/cxfa_localemgr.cpp @@ -11,9 +11,9 @@ #include #include +#include "core/fpdfapi/cpdf_modulemgr.h" #include "core/fxcodec/fx_codec.h" #include "core/fxcrt/xml/cxml_element.h" -#include "core/fxge/cfx_gemodule.h" #include "third_party/base/ptr_util.h" #include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_nodelocale.h" @@ -1056,23 +1056,17 @@ static std::unique_ptr XFA_GetLocaleFromBuffer(const uint8_t* pBuf, int nBufLen) { if (!pBuf || nBufLen <= 0) return nullptr; - CFX_GEModule* pGeModule = CFX_GEModule::Get(); - if (!pGeModule) - return nullptr; - - CCodec_ModuleMgr* pCodecMgr = pGeModule->GetCodecModule(); - if (!pCodecMgr) - return nullptr; - std::unique_ptr pLocale; uint8_t* pOut = nullptr; uint32_t dwSize; + CCodec_ModuleMgr* pCodecMgr = CPDF_ModuleMgr::Get()->GetCodecModule(); pCodecMgr->GetFlateModule()->FlateOrLZWDecode(false, pBuf, nBufLen, true, 0, 0, 0, 0, 0, pOut, dwSize); - if (pOut) { - pLocale = CXML_Element::Parse(pOut, dwSize); - FX_Free(pOut); - } + if (!pOut) + return nullptr; + + std::unique_ptr pLocale = CXML_Element::Parse(pOut, dwSize); + FX_Free(pOut); return pLocale ? pdfium::MakeUnique(std::move(pLocale)) : nullptr; } -- cgit v1.2.3