summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfapi/render/cpdf_dibsource.cpp37
-rw-r--r--core/fpdfapi/render/cpdf_dibsource.h38
2 files changed, 27 insertions, 48 deletions
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 <typename T, typename... Args>
friend RetainPtr<T> 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<const CPDF_Stream> m_pStream;
UnownedPtr<const CPDF_Dictionary> m_pDict;
RetainPtr<CPDF_StreamAcc> 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<CFX_DIBitmap> m_pCachedBitmap;
RetainPtr<CPDF_DIBSource> m_pMask;
RetainPtr<CPDF_StreamAcc> m_pGlobalStream;
std::unique_ptr<CCodec_ScanlineDecoder> m_pDecoder;
std::unique_ptr<CCodec_Jbig2Context> m_pJbig2Context;
UnownedPtr<CPDF_Stream> m_pMaskStream;
- int m_Status;
+ LoadState m_Status = LoadState::kFail;
};
#endif // CORE_FPDFAPI_RENDER_CPDF_DIBSOURCE_H_