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

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

Issue 23163007: pdfviewer: make pdfviewer compile on mac 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 "SkPdfNativeDoc.h" 1 #include "SkPdfNativeDoc.h"
2 #include "SkPdfNativeTokenizer.h" 2 #include "SkPdfNativeTokenizer.h"
3 #include "SkPdfNativeObject.h" 3 #include "SkPdfNativeObject.h"
4 4
5 #include <stdio.h> 5 #include <stdio.h>
6 #include <string.h> 6 #include <string.h>
7 #include <sys/types.h> 7 #include <sys/types.h>
8 #include <sys/stat.h> 8 #include <sys/stat.h>
9 9
10 #include "SkPdfFileTrailerDictionary_autogen.h" 10 // TODO(edisonn): for some reason on mac these files are found here, but are fou nd from headers
11 #include "SkPdfCatalogDictionary_autogen.h" 11 //#include "SkPdfFileTrailerDictionary_autogen.h"
12 #include "SkPdfPageObjectDictionary_autogen.h" 12 //#include "SkPdfCatalogDictionary_autogen.h"
13 #include "SkPdfPageTreeNodeDictionary_autogen.h" 13 //#include "SkPdfPageObjectDictionary_autogen.h"
14 //#include "SkPdfPageTreeNodeDictionary_autogen.h"
15 #include "SkPdfHeaders_autogen.h"
16
14 #include "SkPdfMapper_autogen.h" 17 #include "SkPdfMapper_autogen.h"
15 18
16 #include "SkStream.h" 19 #include "SkStream.h"
17 20
18 21
19 static long getFileSize(const char* filename) 22 static long getFileSize(const char* filename)
20 { 23 {
21 struct stat stat_buf; 24 struct stat stat_buf;
22 int rc = stat(filename, &stat_buf); 25 int rc = stat(filename, &stat_buf);
23 return rc == 0 ? (long)stat_buf.st_size : -1; 26 return rc == 0 ? (long)stat_buf.st_size : -1;
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 long startOffset = fObjects[id].fOffset; 357 long startOffset = fObjects[id].fOffset;
355 //long endOffset = fObjects[id].fOffsetEnd; 358 //long endOffset = fObjects[id].fOffsetEnd;
356 // TODO(edisonn): use hinted endOffset 359 // TODO(edisonn): use hinted endOffset
357 // TODO(edisonn): current implementation will result in a lot of memory usag e 360 // TODO(edisonn): current implementation will result in a lot of memory usag e
358 // to decrease memory usage, we wither need to be smart and know where objec ts end, and we will 361 // to decrease memory usage, we wither need to be smart and know where objec ts end, and we will
359 // alocate only the chancks needed, or the tokenizer will not make copies, b ut then it needs to 362 // alocate only the chancks needed, or the tokenizer will not make copies, b ut then it needs to
360 // cache the results so it does not go twice on the same buffer 363 // cache the results so it does not go twice on the same buffer
361 const unsigned char* current = fFileContent + startOffset; 364 const unsigned char* current = fFileContent + startOffset;
362 const unsigned char* end = fFileContent + fContentLength; 365 const unsigned char* end = fFileContent + fContentLength;
363 366
364 SkPdfNativeTokenizer tokenizer(current, end - current, fMapper, fAllocator, this); 367 SkPdfNativeTokenizer tokenizer(current, end - current, fAllocator, this);
365 368
366 SkPdfNativeObject idObj; 369 SkPdfNativeObject idObj;
367 SkPdfNativeObject generationObj; 370 SkPdfNativeObject generationObj;
368 SkPdfNativeObject objKeyword; 371 SkPdfNativeObject objKeyword;
369 SkPdfNativeObject* dict = fAllocator->allocObject(); 372 SkPdfNativeObject* dict = fAllocator->allocObject();
370 373
371 current = nextObject(0, current, end, &idObj, NULL, NULL); 374 current = nextObject(0, current, end, &idObj, NULL, NULL);
372 if (current >= end) { 375 if (current >= end) {
373 // TODO(edisonn): report warning/error 376 // TODO(edisonn): report warning/error
374 return NULL; 377 return NULL;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 return NULL; 461 return NULL;
459 } 462 }
460 } 463 }
461 464
462 SkPdfNativeTokenizer* SkPdfNativeDoc::tokenizerOfStream(SkPdfNativeObject* strea m, 465 SkPdfNativeTokenizer* SkPdfNativeDoc::tokenizerOfStream(SkPdfNativeObject* strea m,
463 SkPdfAllocator* alloc ator) { 466 SkPdfAllocator* alloc ator) {
464 if (stream == NULL) { 467 if (stream == NULL) {
465 return NULL; 468 return NULL;
466 } 469 }
467 470
468 return new SkPdfNativeTokenizer(stream, fMapper, allocator, this); 471 return new SkPdfNativeTokenizer(stream, allocator, this);
469 } 472 }
470 473
471 // TODO(edisonn): NYI 474 // TODO(edisonn): NYI
472 SkPdfNativeTokenizer* SkPdfNativeDoc::tokenizerOfBuffer(const unsigned char* buf fer, size_t len, 475 SkPdfNativeTokenizer* SkPdfNativeDoc::tokenizerOfBuffer(const unsigned char* buf fer, size_t len,
473 SkPdfAllocator* alloc ator) { 476 SkPdfAllocator* alloc ator) {
474 // warning does not track two calls in the same buffer! the buffer is update d! 477 // warning does not track two calls in the same buffer! the buffer is update d!
475 // make a clean copy if needed! 478 // make a clean copy if needed!
476 return new SkPdfNativeTokenizer(buffer, len, fMapper, allocator, this); 479 return new SkPdfNativeTokenizer(buffer, len, allocator, this);
477 } 480 }
478 481
479 size_t SkPdfNativeDoc::objects() const { 482 size_t SkPdfNativeDoc::objects() const {
480 return fObjects.count(); 483 return fObjects.count();
481 } 484 }
482 485
483 SkPdfNativeObject* SkPdfNativeDoc::object(int i) { 486 SkPdfNativeObject* SkPdfNativeDoc::object(int i) {
484 SkASSERT(!(i < 0 || i > fObjects.count())); 487 SkASSERT(!(i < 0 || i > fObjects.count()));
485 488
486 if (i < 0 || i > fObjects.count()) { 489 if (i < 0 || i > fObjects.count()) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 return (SkPdfNativeObject*)ref; 570 return (SkPdfNativeObject*)ref;
568 } 571 }
569 572
570 size_t SkPdfNativeDoc::bytesUsed() const { 573 size_t SkPdfNativeDoc::bytesUsed() const {
571 return fAllocator->bytesUsed() + 574 return fAllocator->bytesUsed() +
572 fContentLength + 575 fContentLength +
573 fObjects.count() * sizeof(PublicObjectEntry) + 576 fObjects.count() * sizeof(PublicObjectEntry) +
574 fPages.count() * sizeof(SkPdfPageObjectDictionary*) + 577 fPages.count() * sizeof(SkPdfPageObjectDictionary*) +
575 sizeof(*this); 578 sizeof(*this);
576 } 579 }
OLDNEW
« no previous file with comments | « experimental/PdfViewer/pdf_viewer_main.cpp ('k') | experimental/PdfViewer/pdfparser/native/SkPdfNativeObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698