From e9b55327048158958d75ab3577a002084d3aed1b Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 5 Mar 2018 14:39:37 +0000 Subject: Add CPDF_DIBSource::LoadState enum class. Change-Id: I97819912e564e4b52fcdae4ce7f865188fb1a520 Reviewed-on: https://pdfium-review.googlesource.com/27850 Commit-Queue: dsinclair Reviewed-by: dsinclair --- core/fpdfapi/render/cpdf_dibsource.cpp | 37 +++++++-------------------------- core/fpdfapi/render/cpdf_dibsource.h | 38 ++++++++++++++++++---------------- 2 files changed, 27 insertions(+), 48 deletions(-) (limited to 'core') diff --git a/core/fpdfapi/render/cpdf_dibsource.cpp b/core/fpdfapi/render/cpdf_dibsource.cpp index 48715d2ecb..1a35826232 100644 --- a/core/fpdfapi/render/cpdf_dibsource.cpp +++ b/core/fpdfapi/render/cpdf_dibsource.cpp @@ -108,30 +108,7 @@ const int kMaxImageDimension = 0x01FFFF; } // namespace -CPDF_DIBSource::CPDF_DIBSource() - : m_pDocument(nullptr), - m_pStream(nullptr), - m_pDict(nullptr), - m_pColorSpace(nullptr), - m_Family(0), - m_bpc(0), - m_bpc_orig(0), - m_nComponents(0), - m_GroupFamily(0), - m_MatteColor(0), - m_bLoadMask(false), - m_bDefaultDecode(true), - m_bImageMask(false), - m_bDoBpcCheck(true), - m_bColorKey(false), - m_bHasMask(false), - m_bStdCS(false), - m_pCompData(nullptr), - m_pLineBuf(nullptr), - m_pMaskedLine(nullptr), - m_pMask(nullptr), - m_pMaskStream(nullptr), - m_Status(0) {} +CPDF_DIBSource::CPDF_DIBSource() {} CPDF_DIBSource::~CPDF_DIBSource() { FX_Free(m_pMaskedLine); @@ -310,10 +287,10 @@ int CPDF_DIBSource::StartLoadDIBSource(CPDF_Document* pDoc, } int CPDF_DIBSource::ContinueLoadDIBSource(IFX_PauseIndicator* pPause) { - if (m_Status == 2) + if (m_Status == LoadState::kContinue) return ContinueLoadMaskDIB(pPause); - if (m_Status != 1) + if (m_Status == LoadState::kFail) return 0; const ByteString& decoder = m_pStreamAcc->GetImageDecoder(); @@ -352,7 +329,7 @@ int CPDF_DIBSource::ContinueLoadDIBSource(IFX_PauseIndicator* pPause) { int iContinueStatus = 1; if (m_bHasMask) { iContinueStatus = ContinueLoadMaskDIB(pPause); - m_Status = 2; + m_Status = LoadState::kContinue; } if (iContinueStatus == 2) return 2; @@ -493,7 +470,7 @@ int CPDF_DIBSource::CreateDecoder() { m_pCachedBitmap.Reset(); return 0; } - m_Status = 1; + m_Status = LoadState::kSuccess; return 2; } @@ -731,8 +708,8 @@ int CPDF_DIBSource::StartLoadMaskDIB() { int ret = m_pMask->StartLoadDIBSource(m_pDocument.Get(), m_pMaskStream.Get(), false, nullptr, nullptr, true); if (ret == 2) { - if (m_Status == 0) - m_Status = 2; + if (m_Status == LoadState::kFail) + m_Status = LoadState::kContinue; return 2; } if (!ret) { diff --git a/core/fpdfapi/render/cpdf_dibsource.h b/core/fpdfapi/render/cpdf_dibsource.h index bb4fdbad90..dce5a535c4 100644 --- a/core/fpdfapi/render/cpdf_dibsource.h +++ b/core/fpdfapi/render/cpdf_dibsource.h @@ -44,6 +44,8 @@ class CPDF_DIBSource : public CFX_DIBSource { template friend RetainPtr pdfium::MakeRetain(Args&&... args); + enum class LoadState : uint8_t { kFail, kSuccess, kContinue }; + ~CPDF_DIBSource() override; bool Load(CPDF_Document* pDoc, const CPDF_Stream* pStream); @@ -126,30 +128,30 @@ class CPDF_DIBSource : public CFX_DIBSource { UnownedPtr m_pStream; UnownedPtr m_pDict; RetainPtr m_pStreamAcc; - CPDF_ColorSpace* m_pColorSpace; - uint32_t m_Family; - uint32_t m_bpc; - uint32_t m_bpc_orig; - uint32_t m_nComponents; - uint32_t m_GroupFamily; - uint32_t m_MatteColor; - bool m_bLoadMask; - bool m_bDefaultDecode; - bool m_bImageMask; - bool m_bDoBpcCheck; - bool m_bColorKey; - bool m_bHasMask; - bool m_bStdCS; - DIB_COMP_DATA* m_pCompData; - uint8_t* m_pLineBuf; - uint8_t* m_pMaskedLine; + CPDF_ColorSpace* m_pColorSpace = nullptr; + uint32_t m_Family = 0; + uint32_t m_bpc = 0; + uint32_t m_bpc_orig = 0; + uint32_t m_nComponents = 0; + uint32_t m_GroupFamily = 0; + uint32_t m_MatteColor = 0; + bool m_bLoadMask = false; + bool m_bDefaultDecode = true; + bool m_bImageMask = false; + bool m_bDoBpcCheck = true; + bool m_bColorKey = false; + bool m_bHasMask = false; + bool m_bStdCS = false; + DIB_COMP_DATA* m_pCompData = nullptr; + uint8_t* m_pLineBuf = nullptr; + uint8_t* m_pMaskedLine = nullptr; RetainPtr m_pCachedBitmap; RetainPtr m_pMask; RetainPtr m_pGlobalStream; std::unique_ptr m_pDecoder; std::unique_ptr m_pJbig2Context; UnownedPtr m_pMaskStream; - int m_Status; + LoadState m_Status = LoadState::kFail; }; #endif // CORE_FPDFAPI_RENDER_CPDF_DIBSOURCE_H_ -- cgit v1.2.3