diff options
author | David Lattimore <dml@google.com> | 2015-10-09 08:18:20 +1100 |
---|---|---|
committer | David Lattimore <dml@google.com> | 2015-10-09 08:18:20 +1100 |
commit | f1b88e76134808f36f16b9e53a2e9dd89b12c8fd (patch) | |
tree | 215fae3dd4fe42787ea4cc2fa2a4d1e4cd587d76 /core/src/fxcodec/jbig2/JBig2_Context.h | |
parent | 8793b4a071fad51a770b93838e0752505b020e43 (diff) | |
download | pdfium-f1b88e76134808f36f16b9e53a2e9dd89b12c8fd.tar.xz |
Various changes to JBig2 cache:
- Makes the cache be per-document
- Keys the cache on ObjNum and stream offset instead of keying on a pointer to the data (which can result in false cache hits).
- Makes it so the cache is only used for the globals stream.
- Reenable the cache.
R=thestig@chromium.org
BUG=pdfium:207
Review URL: https://codereview.chromium.org/1380243004 .
Diffstat (limited to 'core/src/fxcodec/jbig2/JBig2_Context.h')
-rw-r--r-- | core/src/fxcodec/jbig2/JBig2_Context.h | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/core/src/fxcodec/jbig2/JBig2_Context.h b/core/src/fxcodec/jbig2/JBig2_Context.h index 4fcef810f6..61379fe2ff 100644 --- a/core/src/fxcodec/jbig2/JBig2_Context.h +++ b/core/src/fxcodec/jbig2/JBig2_Context.h @@ -11,6 +11,7 @@ #include <utility> #include "../../../../third_party/base/nonstd_unique_ptr.h" +#include "../../../include/fpdfapi/fpdf_objects.h" #include "../../../include/fxcodec/fx_codec_def.h" #include "JBig2_List.h" #include "JBig2_Page.h" @@ -20,7 +21,10 @@ class CJBig2_ArithDecoder; class CJBig2_GRDProc; class IFX_Pause; -using CJBig2_CachePair = std::pair<const uint8_t*, CJBig2_SymbolDict*>; +// Cache is keyed by the ObjNum of a stream and an index within the stream. +using CJBig2_CacheKey = std::pair<FX_DWORD, FX_DWORD>; +// NB: CJBig2_SymbolDict* is owned. +using CJBig2_CachePair = std::pair<CJBig2_CacheKey, CJBig2_SymbolDict*>; #define JBIG2_SUCCESS 0 #define JBIG2_FAILED -1 @@ -36,10 +40,8 @@ using CJBig2_CachePair = std::pair<const uint8_t*, CJBig2_SymbolDict*>; class CJBig2_Context { public: static CJBig2_Context* CreateContext( - const uint8_t* pGlobalData, - FX_DWORD dwGlobalLength, - const uint8_t* pData, - FX_DWORD dwLength, + CPDF_StreamAcc* pGlobalStream, + CPDF_StreamAcc* pSrcStream, std::list<CJBig2_CachePair>* pSymbolDictCache, IFX_Pause* pPause = NULL); @@ -55,12 +57,11 @@ class CJBig2_Context { FXCODEC_STATUS GetProcessingStatus() { return m_ProcessingStatus; } private: - CJBig2_Context(const uint8_t* pGlobalData, - FX_DWORD dwGlobalLength, - const uint8_t* pData, - FX_DWORD dwLength, + CJBig2_Context(CPDF_StreamAcc* pGlobalStream, + CPDF_StreamAcc* pSrcStream, std::list<CJBig2_CachePair>* pSymbolDictCache, - IFX_Pause* pPause); + IFX_Pause* pPause, + bool bIsGlobal); ~CJBig2_Context(); @@ -126,6 +127,7 @@ class CJBig2_Context { FX_DWORD m_dwOffset; JBig2RegionInfo m_ri; std::list<CJBig2_CachePair>* const m_pSymbolDictCache; + bool m_bIsGlobal; }; #endif // CORE_SRC_FXCODEC_JBIG2_JBIG2_CONTEXT_H_ |