OLD | NEW |
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 "SkRect.h" | 4 #include "SkRect.h" |
5 #include "SkTDArray.h" | 5 #include "SkTDArray.h" |
6 | 6 |
7 class SkCanvas; | 7 class SkCanvas; |
8 | 8 |
9 class SkPdfAllocator; | 9 class SkPdfAllocator; |
10 class SkPdfMapper; | 10 class SkPdfMapper; |
(...skipping 24 matching lines...) Expand all Loading... |
35 // TODO(edisonn): read methods: file, stream, http(s)://url, url with seek? | 35 // TODO(edisonn): read methods: file, stream, http(s)://url, url with seek? |
36 // TODO(edisonn): read first page asap, linearized | 36 // TODO(edisonn): read first page asap, linearized |
37 // TODO(edisonn): read page N asap, read all file | 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, ...) | 38 // TODO(edisonn): allow corruptions of file (e.g. missing endobj, missing st
ream length, ...) |
39 // TODO(edisonn): encryption | 39 // TODO(edisonn): encryption |
40 SkNativeParsedPDF(const char* path); | 40 SkNativeParsedPDF(const char* path); |
41 ~SkNativeParsedPDF(); | 41 ~SkNativeParsedPDF(); |
42 | 42 |
43 int pages() const; | 43 int pages() const; |
44 SkPdfResourceDictionary* pageResources(int page); | 44 SkPdfResourceDictionary* pageResources(int page); |
45 SkRect MediaBox(int page) const; | 45 SkRect MediaBox(int page); |
46 SkPdfNativeTokenizer* tokenizerOfPage(int n) const; | 46 SkPdfNativeTokenizer* tokenizerOfPage(int n); |
47 | 47 |
48 SkPdfNativeTokenizer* tokenizerOfStream(SkPdfObject* stream) const; | 48 SkPdfNativeTokenizer* tokenizerOfStream(SkPdfObject* stream); |
49 SkPdfNativeTokenizer* tokenizerOfBuffer(unsigned char* buffer, size_t len) c
onst; | 49 SkPdfNativeTokenizer* tokenizerOfBuffer(unsigned char* buffer, size_t len); |
50 | 50 |
51 size_t objects() const; | 51 size_t objects() const; |
52 SkPdfObject* object(int i); | 52 SkPdfObject* object(int i); |
53 | 53 |
54 const SkPdfMapper* mapper() const; | 54 const SkPdfMapper* mapper() const; |
55 SkPdfAllocator* allocator() const; | 55 SkPdfAllocator* allocator() const; |
56 | 56 |
57 SkPdfReal* createReal(double value) const; | 57 SkPdfReal* createReal(double value) const; |
58 SkPdfInteger* createInteger(int value) const; | 58 SkPdfInteger* createInteger(int value) const; |
59 // the string does not own the char* | 59 // the string does not own the char* |
60 SkPdfString* createString(unsigned char* sz, size_t len) const; | 60 SkPdfString* createString(unsigned char* sz, size_t len) const; |
61 | 61 |
62 void drawPage(int page, SkCanvas* canvas); | 62 void drawPage(int page, SkCanvas* canvas); |
63 | 63 |
64 SkPdfObject* resolveReference(SkPdfObject* ref) const; | 64 SkPdfObject* resolveReference(const SkPdfObject* ref); |
65 SkPdfObject* resolveReference(const SkPdfObject* ref) const; | |
66 | 65 |
67 private: | 66 private: |
68 | 67 |
69 unsigned char* readCrossReferenceSection(unsigned char* xrefStart, unsigned
char* trailerEnd); | 68 unsigned char* readCrossReferenceSection(unsigned char* xrefStart, unsigned
char* trailerEnd); |
70 long readTrailer(unsigned char* trailerStart, unsigned char* trailerEnd, boo
l storeCatalog); | 69 long readTrailer(unsigned char* trailerStart, unsigned char* trailerEnd, boo
l storeCatalog); |
71 | 70 |
72 // TODO(edisonn): updates not supported right now, generation ignored | 71 // TODO(edisonn): updates not supported right now, generation ignored |
73 void addCrossSectionInfo(int id, int generation, int offset, bool isFreed); | 72 void addCrossSectionInfo(int id, int generation, int offset, bool isFreed); |
74 static void reset(PublicObjectEntry* obj) { | 73 static void reset(PublicObjectEntry* obj) { |
75 obj->fObj = NULL; | 74 obj->fObj = NULL; |
76 obj->fResolvedReference = NULL; | 75 obj->fResolvedReference = NULL; |
77 obj->fOffset = -1; | 76 obj->fOffset = -1; |
78 } | 77 } |
79 | 78 |
80 SkPdfObject* readObject(int id/*, int generation*/) const; | 79 SkPdfObject* readObject(int id/*, int generation*/); |
81 | 80 |
82 void fillPages(SkPdfPageTreeNodeDictionary* tree); | 81 void fillPages(SkPdfPageTreeNodeDictionary* tree); |
83 | 82 |
84 // private fields | 83 // private fields |
85 SkPdfAllocator* fAllocator; | 84 SkPdfAllocator* fAllocator; |
86 SkPdfMapper* fMapper; | 85 SkPdfMapper* fMapper; |
87 unsigned char* fFileContent; | 86 unsigned char* fFileContent; |
88 size_t fContentLength; | 87 size_t fContentLength; |
89 const SkPdfObject* fRootCatalogRef; | 88 const SkPdfObject* fRootCatalogRef; |
90 SkPdfCatalogDictionary* fRootCatalog; | 89 SkPdfCatalogDictionary* fRootCatalog; |
91 | 90 |
92 mutable SkTDArray<PublicObjectEntry> fObjects; | 91 mutable SkTDArray<PublicObjectEntry> fObjects; |
93 SkTDArray<SkPdfPageObjectDictionary*> fPages; | 92 SkTDArray<SkPdfPageObjectDictionary*> fPages; |
94 }; | 93 }; |
95 | 94 |
96 #endif // EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKNATIVEPARSEDPDF_H_ | 95 #endif // EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKNATIVEPARSEDPDF_H_ |
OLD | NEW |