OLD | NEW |
1 #include "SkNativeParsedPDF.h" | 1 #include "SkNativeParsedPDF.h" |
2 #include "SkPdfNativeTokenizer.h" | 2 #include "SkPdfNativeTokenizer.h" |
3 #include "SkPdfBasics.h" | 3 #include "SkPdfBasics.h" |
4 #include "SkPdfObject.h" | 4 #include "SkPdfObject.h" |
5 | 5 |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 #include <string.h> | 7 #include <string.h> |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 | 10 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 } | 182 } |
183 // TODO(edisonn): it should never get here? there is no trailer? | 183 // TODO(edisonn): it should never get here? there is no trailer? |
184 return current; | 184 return current; |
185 } | 185 } |
186 | 186 |
187 long SkNativeParsedPDF::readTrailer(const unsigned char* trailerStart, const uns
igned char* trailerEnd, bool storeCatalog) { | 187 long SkNativeParsedPDF::readTrailer(const unsigned char* trailerStart, const uns
igned char* trailerEnd, bool storeCatalog) { |
188 SkPdfObject trailerKeyword; | 188 SkPdfObject trailerKeyword; |
189 // TODO(edisonn): use null allocator, and let it just fail if memory | 189 // TODO(edisonn): use null allocator, and let it just fail if memory |
190 // needs allocated (but no crash)! | 190 // needs allocated (but no crash)! |
191 const unsigned char* current = | 191 const unsigned char* current = |
192 nextObject(0, trailerStart, trailerEnd, &trailerKeyword, fAllocator,
NULL); | 192 nextObject(0, trailerStart, trailerEnd, &trailerKeyword, NULL, NULL)
; |
193 | 193 |
194 if (strlen("trailer") != trailerKeyword.len() && | 194 if (!trailerKeyword.isKeyword() || strlen("trailer") != trailerKeyword.len()
|| |
195 strncmp(trailerKeyword.c_str(), "trailer", strlen("trailer")) != 0) { | 195 strncmp(trailerKeyword.c_str(), "trailer", strlen("trailer")) != 0) { |
196 // TODO(edisonn): report warning, rebuild trailer from objects. | 196 // TODO(edisonn): report warning, rebuild trailer from objects. |
197 return -1; | 197 return -1; |
198 } | 198 } |
199 | 199 |
200 SkPdfObject token; | 200 SkPdfObject token; |
201 current = nextObject(0, current, trailerEnd, &token, fAllocator, NULL); | 201 current = nextObject(0, current, trailerEnd, &token, fAllocator, NULL); |
202 if (!token.isDictionary()) { | 202 if (!token.isDictionary()) { |
203 return -1; | 203 return -1; |
204 } | 204 } |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 return (SkPdfObject*)ref; | 436 return (SkPdfObject*)ref; |
437 } | 437 } |
438 | 438 |
439 size_t SkNativeParsedPDF::bytesUsed() const { | 439 size_t SkNativeParsedPDF::bytesUsed() const { |
440 return fAllocator->bytesUsed() + | 440 return fAllocator->bytesUsed() + |
441 fContentLength + | 441 fContentLength + |
442 fObjects.count() * sizeof(PublicObjectEntry) + | 442 fObjects.count() * sizeof(PublicObjectEntry) + |
443 fPages.count() * sizeof(SkPdfPageObjectDictionary*) + | 443 fPages.count() * sizeof(SkPdfPageObjectDictionary*) + |
444 sizeof(*this); | 444 sizeof(*this); |
445 } | 445 } |
OLD | NEW |