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

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

Issue 21125002: pdfviewer: more plumming for soft masks (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
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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 token.reset(); 189 token.reset();
190 current = nextObject(0, current, trailerEnd, &token, NULL, NULL); 190 current = nextObject(0, current, trailerEnd, &token, NULL, NULL);
191 if (!token.isInteger()) { 191 if (!token.isInteger()) {
192 // TODO(edisonn): report/warning 192 // TODO(edisonn): report/warning
193 return current; 193 return current;
194 } 194 }
195 int generation = (int)token.intValue(); 195 int generation = (int)token.intValue();
196 196
197 token.reset(); 197 token.reset();
198 current = nextObject(0, current, trailerEnd, &token, NULL, NULL); 198 current = nextObject(0, current, trailerEnd, &token, NULL, NULL);
199 if (!token.isKeyword() || token.len() != 1 || (*token.c_str() != 'f' && *token.c_str() != 'n')) { 199 if (!token.isKeyword() || token.lenstr() != 1 || (*token.c_str() != 'f' && *token.c_str() != 'n')) {
200 // TODO(edisonn): report/warning 200 // TODO(edisonn): report/warning
201 return current; 201 return current;
202 } 202 }
203 203
204 addCrossSectionInfo(startId + i, generation, offset, *token.c_str() == 'f'); 204 addCrossSectionInfo(startId + i, generation, offset, *token.c_str() == 'f');
205 } 205 }
206 } 206 }
207 // TODO(edisonn): it should never get here? there is no trailer? 207 // TODO(edisonn): it should never get here? there is no trailer?
208 return current; 208 return current;
209 } 209 }
210 210
211 long SkNativeParsedPDF::readTrailer(const unsigned char* trailerStart, const uns igned char* trailerEnd, bool storeCatalog) { 211 long SkNativeParsedPDF::readTrailer(const unsigned char* trailerStart, const uns igned char* trailerEnd, bool storeCatalog) {
212 SkPdfObject trailerKeyword; 212 SkPdfObject trailerKeyword;
213 // TODO(edisonn): use null allocator, and let it just fail if memory 213 // TODO(edisonn): use null allocator, and let it just fail if memory
214 // needs allocated (but no crash)! 214 // needs allocated (but no crash)!
215 const unsigned char* current = 215 const unsigned char* current =
216 nextObject(0, trailerStart, trailerEnd, &trailerKeyword, NULL, NULL) ; 216 nextObject(0, trailerStart, trailerEnd, &trailerKeyword, NULL, NULL) ;
217 217
218 if (!trailerKeyword.isKeyword() || strlen("trailer") != trailerKeyword.len() || 218 if (!trailerKeyword.isKeyword() || strlen("trailer") != trailerKeyword.lenst r() ||
219 strncmp(trailerKeyword.c_str(), "trailer", strlen("trailer")) != 0) { 219 strncmp(trailerKeyword.c_str(), "trailer", strlen("trailer")) != 0) {
220 // TODO(edisonn): report warning, rebuild trailer from objects. 220 // TODO(edisonn): report warning, rebuild trailer from objects.
221 return -1; 221 return -1;
222 } 222 }
223 223
224 SkPdfObject token; 224 SkPdfObject token;
225 current = nextObject(0, current, trailerEnd, &token, fAllocator, NULL); 225 current = nextObject(0, current, trailerEnd, &token, fAllocator, NULL);
226 if (!token.isDictionary()) { 226 if (!token.isDictionary()) {
227 return -1; 227 return -1;
228 } 228 }
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 return (SkPdfObject*)ref; 460 return (SkPdfObject*)ref;
461 } 461 }
462 462
463 size_t SkNativeParsedPDF::bytesUsed() const { 463 size_t SkNativeParsedPDF::bytesUsed() const {
464 return fAllocator->bytesUsed() + 464 return fAllocator->bytesUsed() +
465 fContentLength + 465 fContentLength +
466 fObjects.count() * sizeof(PublicObjectEntry) + 466 fObjects.count() * sizeof(PublicObjectEntry) +
467 fPages.count() * sizeof(SkPdfPageObjectDictionary*) + 467 fPages.count() * sizeof(SkPdfPageObjectDictionary*) +
468 sizeof(*this); 468 sizeof(*this);
469 } 469 }
OLDNEW
« no previous file with comments | « experimental/PdfViewer/SkPdfRenderer.cpp ('k') | experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698