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

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

Issue 19793011: (upload draf code for backup) pdfviewer: improve memory, son't allocate extra buffers, and put the … (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 "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 23 matching lines...) Expand all
34 // TODO(edisonn): read first page asap, linearized 34 // TODO(edisonn): read first page asap, linearized
35 // TODO(edisonn): read page N asap, read all file 35 // TODO(edisonn): read page N asap, read all file
36 // TODO(edisonn): allow corruptions of file (e.g. missing endobj, missing st ream length, ...) 36 // TODO(edisonn): allow corruptions of file (e.g. missing endobj, missing st ream length, ...)
37 // TODO(edisonn): encryption 37 // TODO(edisonn): encryption
38 SkNativeParsedPDF(const char* path); 38 SkNativeParsedPDF(const char* path);
39 ~SkNativeParsedPDF(); 39 ~SkNativeParsedPDF();
40 40
41 int pages() const; 41 int pages() const;
42 SkPdfResourceDictionary* pageResources(int page); 42 SkPdfResourceDictionary* pageResources(int page);
43 SkRect MediaBox(int page); 43 SkRect MediaBox(int page);
44 SkPdfNativeTokenizer* tokenizerOfPage(int n); 44 SkPdfNativeTokenizer* tokenizerOfPage(int n, SkPdfAllocator* allocator);
45 45
46 SkPdfNativeTokenizer* tokenizerOfStream(SkPdfObject* stream); 46 SkPdfNativeTokenizer* tokenizerOfStream(SkPdfObject* stream, SkPdfAllocator* allocator);
47 SkPdfNativeTokenizer* tokenizerOfBuffer(unsigned char* buffer, size_t len); 47 SkPdfNativeTokenizer* tokenizerOfBuffer(const unsigned char* buffer, size_t len,
48 SkPdfAllocator* allocator);
48 49
49 size_t objects() const; 50 size_t objects() const;
50 SkPdfObject* object(int i); 51 SkPdfObject* object(int i);
51 52
52 const SkPdfMapper* mapper() const; 53 const SkPdfMapper* mapper() const;
53 SkPdfAllocator* allocator() const; 54 SkPdfAllocator* allocator() const;
54 55
55 SkPdfReal* createReal(double value) const; 56 SkPdfReal* createReal(double value) const;
56 SkPdfInteger* createInteger(int value) const; 57 SkPdfInteger* createInteger(int value) const;
57 // the string does not own the char* 58 // the string does not own the char*
58 SkPdfString* createString(unsigned char* sz, size_t len) const; 59 SkPdfString* createString(const unsigned char* sz, size_t len) const;
59
60 void drawPage(int page, SkCanvas* canvas);
61 60
62 SkPdfObject* resolveReference(const SkPdfObject* ref); 61 SkPdfObject* resolveReference(const SkPdfObject* ref);
63 62
64 // Reports an approximation of all the memory usage. 63 // Reports an approximation of all the memory usage.
65 size_t bytesUsed() const; 64 size_t bytesUsed() const;
66 65
67 private: 66 private:
68 67
69 unsigned char* readCrossReferenceSection(unsigned char* xrefStart, unsigned char* trailerEnd); 68 const unsigned char* readCrossReferenceSection(const unsigned char* xrefStar t, const unsigned char* trailerEnd);
70 long readTrailer(unsigned char* trailerStart, unsigned char* trailerEnd, boo l storeCatalog); 69 long readTrailer(const unsigned char* trailerStart, const unsigned char* tra ilerEnd, bool 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*/); 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 const 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_
OLDNEW
« no previous file with comments | « experimental/PdfViewer/pdf_viewer_main.cpp ('k') | experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698