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

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

Issue 23020003: pdfviewer: debug code for drawText (show magenta background for text, to show text even when we fai… (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 4 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
(Empty)
1 #ifndef EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKNATIVEPARSEDPDF_H_
2 #define EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKNATIVEPARSEDPDF_H_
3
4 #include "SkRect.h"
5 #include "SkTDArray.h"
6
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 class SkPdfNativeTokenizer;
21
22 class SkStream;
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
34 public:
35 // TODO(edisonn): read methods: file, stream, http(s)://url, url with seek?
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
41 SkNativeParsedPDF(const char* path);
42 SkNativeParsedPDF(SkStream* stream);
43
44 ~SkNativeParsedPDF();
45
46 int pages() const;
47 SkPdfResourceDictionary* pageResources(int page);
48 SkRect MediaBox(int page);
49 SkPdfNativeTokenizer* tokenizerOfPage(int n, SkPdfAllocator* allocator);
50
51 SkPdfNativeTokenizer* tokenizerOfStream(SkPdfObject* stream, SkPdfAllocator* allocator);
52 SkPdfNativeTokenizer* tokenizerOfBuffer(const unsigned char* buffer, size_t len,
53 SkPdfAllocator* allocator);
54
55 size_t objects() const;
56 SkPdfObject* object(int i);
57 SkPdfPageObjectDictionary* page(int page);
58
59 const SkPdfMapper* mapper() const;
60 SkPdfAllocator* allocator() const;
61
62 SkPdfReal* createReal(double value) const;
63 SkPdfInteger* createInteger(int value) const;
64 // the string does not own the char*
65 SkPdfString* createString(const unsigned char* sz, size_t len) const;
66
67 SkPdfObject* resolveReference(SkPdfObject* ref);
68
69 // Reports an approximation of all the memory usage.
70 size_t bytesUsed() const;
71
72 private:
73
74 // Takes ownership of bytes.
75 void init(const void* bytes, size_t length);
76 void loadWithoutXRef();
77
78 const unsigned char* readCrossReferenceSection(const unsigned char* xrefStar t, const unsigned char* trailerEnd);
79 const unsigned char* readTrailer(const unsigned char* trailerStart, const un signed char* trailerEnd, bool storeCatalog, long* prev, bool skipKeyword);
80
81 // TODO(edisonn): updates not supported right now, generation ignored
82 void addCrossSectionInfo(int id, int generation, int offset, bool isFreed);
83 static void reset(PublicObjectEntry* obj) {
84 obj->fObj = NULL;
85 obj->fResolvedReference = NULL;
86 obj->fOffset = -1;
87 }
88
89 SkPdfObject* readObject(int id/*, int generation*/);
90
91 void fillPages(SkPdfPageTreeNodeDictionary* tree);
92
93 // private fields
94 SkPdfAllocator* fAllocator;
95 SkPdfMapper* fMapper;
96 const unsigned char* fFileContent;
97 size_t fContentLength;
98 SkPdfObject* fRootCatalogRef;
99 SkPdfCatalogDictionary* fRootCatalog;
100
101 mutable SkTDArray<PublicObjectEntry> fObjects;
102 SkTDArray<SkPdfPageObjectDictionary*> fPages;
103 };
104
105 #endif // EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKNATIVEPARSEDPDF_H_
OLDNEW
« no previous file with comments | « experimental/PdfViewer/generate_code.py ('k') | experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698