summaryrefslogtreecommitdiff
path: root/core/src/fxcodec/jbig2/JBig2_Context.h
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-10-08 15:14:24 -0700
committerLei Zhang <thestig@chromium.org>2015-10-08 15:14:24 -0700
commit921cc2403a9e643dfb29d70564fa435a1d79f972 (patch)
tree005543a896eb07b52a416abc2bc681d286fc24db /core/src/fxcodec/jbig2/JBig2_Context.h
parentd1cb813d23df38a8e21df3314658995ded7c4b45 (diff)
downloadpdfium-921cc2403a9e643dfb29d70564fa435a1d79f972.tar.xz
Merge to XFA: 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=dml@google.com TBR=dml@google.com BUG=pdfium:207 Review URL: https://codereview.chromium.org/1380243004 . (cherry picked from commit f1b88e76134808f36f16b9e53a2e9dd89b12c8fd) Review URL: https://codereview.chromium.org/1394373002 .
Diffstat (limited to 'core/src/fxcodec/jbig2/JBig2_Context.h')
-rw-r--r--core/src/fxcodec/jbig2/JBig2_Context.h22
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_