summaryrefslogtreecommitdiff
path: root/core/fxcodec/jbig2/JBig2_Context.h
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2018-05-09 23:25:53 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-09 23:25:53 +0000
commitad18d2fba9dd5833a2e34bfe90c8e3c9a485e805 (patch)
tree2c5b678637ad9324e6fcd8414fbc883ac07ad0c1 /core/fxcodec/jbig2/JBig2_Context.h
parent3774c7a452886b9c8beeb5fa1b54a34611551180 (diff)
downloadpdfium-ad18d2fba9dd5833a2e34bfe90c8e3c9a485e805.tar.xz
Use enum class instead of int in CJBig2_Contextchromium/3426
This CL changes CJBig2_Context return methods as follows: * Internal methods return JBig2_Result instead of int. * Public methods return a bool (for success/failure) instead of int. In a followup, several of the enum class values may be merged together since they are not all needed. Change-Id: Ifdab83b8037262370cd7c4a80e94aa94d59aa589 Reviewed-on: https://pdfium-review.googlesource.com/32310 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Diffstat (limited to 'core/fxcodec/jbig2/JBig2_Context.h')
-rw-r--r--core/fxcodec/jbig2/JBig2_Context.h67
1 files changed, 35 insertions, 32 deletions
diff --git a/core/fxcodec/jbig2/JBig2_Context.h b/core/fxcodec/jbig2/JBig2_Context.h
index e1ee679de7..148866a914 100644
--- a/core/fxcodec/jbig2/JBig2_Context.h
+++ b/core/fxcodec/jbig2/JBig2_Context.h
@@ -28,15 +28,18 @@ using CJBig2_CacheKey = std::pair<uint32_t, uint32_t>;
using CJBig2_CachePair =
std::pair<CJBig2_CacheKey, std::unique_ptr<CJBig2_SymbolDict>>;
-#define JBIG2_SUCCESS 0
-#define JBIG2_FAILED -1
-#define JBIG2_ERROR_TOO_SHORT -2
-#define JBIG2_ERROR_FATAL -3
-#define JBIG2_END_OF_PAGE 2
-#define JBIG2_END_OF_FILE 3
-#define JBIG2_ERROR_LIMIT -6
#define JBIG2_MIN_SEGMENT_SIZE 11
+enum class JBig2_Result {
+ Success,
+ Failure,
+ ErrorTooShort,
+ ErrorFatal,
+ ErrorLimit,
+ EndOfPage,
+ EndOfFile
+};
+
class CJBig2_Context {
public:
CJBig2_Context(const RetainPtr<CPDF_StreamAcc>& pGlobalStream,
@@ -47,40 +50,40 @@ class CJBig2_Context {
static bool HuffmanAssignCode(JBig2HuffmanCode* SBSYMCODES, uint32_t NTEMP);
- int32_t GetFirstPage(uint8_t* pBuf,
- int32_t width,
- int32_t height,
- int32_t stride,
- PauseIndicatorIface* pPause);
+ bool GetFirstPage(uint8_t* pBuf,
+ int32_t width,
+ int32_t height,
+ int32_t stride,
+ PauseIndicatorIface* pPause);
- int32_t Continue(PauseIndicatorIface* pPause);
+ bool Continue(PauseIndicatorIface* pPause);
FXCODEC_STATUS GetProcessingStatus() const { return m_ProcessingStatus; }
private:
- int32_t DecodeSequential(PauseIndicatorIface* pPause);
- int32_t DecodeRandomFirstPage(PauseIndicatorIface* pPause);
- int32_t DecodeRandom(PauseIndicatorIface* pPause);
+ JBig2_Result DecodeSequential(PauseIndicatorIface* pPause);
+ JBig2_Result DecodeRandomFirstPage(PauseIndicatorIface* pPause);
+ JBig2_Result DecodeRandom(PauseIndicatorIface* pPause);
CJBig2_Segment* FindSegmentByNumber(uint32_t dwNumber);
CJBig2_Segment* FindReferredTableSegmentByIndex(CJBig2_Segment* pSegment,
int32_t nIndex);
- int32_t ParseSegmentHeader(CJBig2_Segment* pSegment);
- int32_t ParseSegmentData(CJBig2_Segment* pSegment,
- PauseIndicatorIface* pPause);
- int32_t ProcessingParseSegmentData(CJBig2_Segment* pSegment,
- PauseIndicatorIface* pPause);
- int32_t ParseSymbolDict(CJBig2_Segment* pSegment);
- int32_t ParseTextRegion(CJBig2_Segment* pSegment);
- int32_t ParsePatternDict(CJBig2_Segment* pSegment,
- PauseIndicatorIface* pPause);
- int32_t ParseHalftoneRegion(CJBig2_Segment* pSegment,
- PauseIndicatorIface* pPause);
- int32_t ParseGenericRegion(CJBig2_Segment* pSegment,
- PauseIndicatorIface* pPause);
- int32_t ParseGenericRefinementRegion(CJBig2_Segment* pSegment);
- int32_t ParseTable(CJBig2_Segment* pSegment);
- int32_t ParseRegionInfo(JBig2RegionInfo* pRI);
+ JBig2_Result ParseSegmentHeader(CJBig2_Segment* pSegment);
+ JBig2_Result ParseSegmentData(CJBig2_Segment* pSegment,
+ PauseIndicatorIface* pPause);
+ JBig2_Result ProcessingParseSegmentData(CJBig2_Segment* pSegment,
+ PauseIndicatorIface* pPause);
+ JBig2_Result ParseSymbolDict(CJBig2_Segment* pSegment);
+ JBig2_Result ParseTextRegion(CJBig2_Segment* pSegment);
+ JBig2_Result ParsePatternDict(CJBig2_Segment* pSegment,
+ PauseIndicatorIface* pPause);
+ JBig2_Result ParseHalftoneRegion(CJBig2_Segment* pSegment,
+ PauseIndicatorIface* pPause);
+ JBig2_Result ParseGenericRegion(CJBig2_Segment* pSegment,
+ PauseIndicatorIface* pPause);
+ JBig2_Result ParseGenericRefinementRegion(CJBig2_Segment* pSegment);
+ JBig2_Result ParseTable(CJBig2_Segment* pSegment);
+ JBig2_Result ParseRegionInfo(JBig2RegionInfo* pRI);
std::vector<JBig2HuffmanCode> DecodeSymbolIDHuffmanTable(uint32_t SBNUMSYMS);