Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.h

Issue 18323019: work on the native parser, in progress, uploaded to have a backup (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #ifndef EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKNATIVEPARSEDPDF_H_ 1 #ifndef EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKNATIVEPARSEDPDF_H_
2 #define EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKNATIVEPARSEDPDF_H_ 2 #define EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKNATIVEPARSEDPDF_H_
3 3
4 #include "base/macros.h" 4 #include "SkRect.h"
5 #include "SkTDArray.h"
5 6
6 class SkNativeParsedPDF : public SkParsedPDF { 7 class SkCanvas;
8
9 class SkPdfAllocator;
10 class SkPdfMapper;
11 class SkPdfObject;
12 class SkPdfReal;
13 class SkPdfInteger;
14 class SkPdfString;
15 class SkPdfResourceDictionary;
16 class SkPdfCatalogDictionary;
17 class SkPdfPageObjectDictionary;
18 class SkPdfPageTreeNodeDictionary;
19
20
21
22 class SkPdfNativeTokenizer;
23
24 class SkNativeParsedPDF {
25 private:
26 struct PublicObjectEntry {
27 long fOffset;
28 // long endOffset; // TODO(edisonn): determine the end of the object, t o be used when the doc is corrupted
29 SkPdfObject* fObj;
30 // TODO(edisonn): perf ... probably it does not make sense to cache the ref. test it!
31 SkPdfObject* fResolvedReference;
32 };
33
7 public: 34 public:
8 SkNativeParsedPDF(); 35 // TODO(edisonn): read methods: file, stream, http(s)://url, url with seek?
9 virtual ~SkNativeParsedPDF(); 36 // TODO(edisonn): read first page asap, linearized
37 // TODO(edisonn): read page N asap, read all file
38 // TODO(edisonn): allow corruptions of file (e.g. missing endobj, missing st ream length, ...)
39 // TODO(edisonn): encryption
40 SkNativeParsedPDF(const char* path);
41 ~SkNativeParsedPDF();
42
43 int pages() const;
44 SkPdfResourceDictionary* pageResources(int page);
45 SkRect MediaBox(int page) const;
46 SkPdfNativeTokenizer* tokenizerOfPage(int n) const;
47
48 SkPdfNativeTokenizer* tokenizerOfStream(SkPdfObject* stream) const;
49 SkPdfNativeTokenizer* tokenizerOfBuffer(unsigned char* buffer, size_t len) c onst;
50
51 size_t objects() const;
52 SkPdfObject* object(int i);
53
54 const SkPdfMapper* mapper() const;
55 SkPdfAllocator* allocator() const;
56
57 SkPdfReal* createReal(double value) const;
58 SkPdfInteger* createInteger(int value) const;
59 // the string does not own the char*
60 SkPdfString* createString(unsigned char* sz, size_t len) const;
61
62 void drawPage(int page, SkCanvas* canvas);
63
64 SkPdfObject* resolveReference(SkPdfObject* ref) const;
65 SkPdfObject* resolveReference(const SkPdfObject* ref) const;
66
67 private:
68
69 unsigned char* readCrossReferenceSection(unsigned char* xrefStart, unsigned char* trailerEnd);
70 long readTrailer(unsigned char* trailerStart, unsigned char* trailerEnd, boo l storeCatalog);
71
72 // TODO(edisonn): updates not supported right now, generation ignored
73 void addCrossSectionInfo(int id, int generation, int offset, bool isFreed);
74 static void reset(PublicObjectEntry* obj) {
75 obj->fObj = NULL;
76 obj->fResolvedReference = NULL;
77 obj->fOffset = -1;
78 }
79
80 SkPdfObject* readObject(int id/*, int generation*/) const;
81
82 void fillPages(SkPdfPageTreeNodeDictionary* tree);
83
84 // private fields
85 SkPdfAllocator* fAllocator;
86 SkPdfMapper* fMapper;
87 unsigned char* fFileContent;
88 size_t fContentLength;
89 const SkPdfObject* fRootCatalogRef;
90 SkPdfCatalogDictionary* fRootCatalog;
91
92 mutable SkTDArray<PublicObjectEntry> fObjects;
93 SkTDArray<SkPdfPageObjectDictionary*> fPages;
10 }; 94 };
11 95
12 #endif // EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKNATIVEPARSEDPDF_H_ 96 #endif // EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKNATIVEPARSEDPDF_H_
OLDNEW
« no previous file with comments | « experimental/PdfViewer/pdfparser/SkPdfNYI.h ('k') | experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698