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

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

Issue 21017004: pdfviewer: fix condition for element in array, reset back the default color to white, and verify ty… (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
« no previous file with comments | « experimental/PdfViewer/pdf_viewer_main.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 // TODO(edisonn): fix infinite loop if ref to itself! 497 // TODO(edisonn): fix infinite loop if ref to itself!
498 // TODO(edisonn): perf, fix refs at load, and resolve will simply return fResolv edReference? 498 // TODO(edisonn): perf, fix refs at load, and resolve will simply return fResolv edReference?
499 SkPdfObject* SkNativeParsedPDF::resolveReference(const SkPdfObject* ref) { 499 SkPdfObject* SkNativeParsedPDF::resolveReference(const SkPdfObject* ref) {
500 if (ref && ref->isReference()) { 500 if (ref && ref->isReference()) {
501 int id = ref->referenceId(); 501 int id = ref->referenceId();
502 // TODO(edisonn): generation/updates not supported now 502 // TODO(edisonn): generation/updates not supported now
503 //int gen = ref->referenceGeneration(); 503 //int gen = ref->referenceGeneration();
504 504
505 SkASSERT(!(id < 0 || id > fObjects.count())); 505 SkASSERT(!(id < 0 || id > fObjects.count()));
506 506
507 if (id < 0 || id > fObjects.count()) { 507 // TODO(edisonn): verify id and gen expected
508 if (id < 0 || id >= fObjects.count()) {
509 // TODO(edisonn): report error/warning
508 return NULL; 510 return NULL;
509 } 511 }
510 512
511 // TODO(edisonn): verify id and gen expected
512
513 if (fObjects[id].fResolvedReference != NULL) { 513 if (fObjects[id].fResolvedReference != NULL) {
514 return fObjects[id].fResolvedReference; 514 return fObjects[id].fResolvedReference;
515 } 515 }
516 516
517 if (fObjects[id].fObj == NULL) { 517 if (fObjects[id].fObj == NULL) {
518 fObjects[id].fObj = readObject(id); 518 fObjects[id].fObj = readObject(id);
519 } 519 }
520 520
521 if (fObjects[id].fResolvedReference == NULL) { 521 if (fObjects[id].fResolvedReference == NULL) {
522 if (!fObjects[id].fObj->isReference()) { 522 if (!fObjects[id].fObj->isReference()) {
523 fObjects[id].fResolvedReference = fObjects[id].fObj; 523 fObjects[id].fResolvedReference = fObjects[id].fObj;
524 } else { 524 } else {
525 fObjects[id].fResolvedReference = resolveReference(fObjects[id]. fObj); 525 fObjects[id].fResolvedReference = resolveReference(fObjects[id]. fObj);
526 } 526 }
527 } 527 }
528 528
529 return fObjects[id].fResolvedReference; 529 return fObjects[id].fResolvedReference;
530 } 530 }
531 // TODO(edisonn): fix the mess with const, probably we need to remove it pre tty much everywhere 531 // TODO(edisonn): fix the mess with const, probably we need to remove it pre tty much everywhere
532 return (SkPdfObject*)ref; 532 return (SkPdfObject*)ref;
533 } 533 }
534 534
535 size_t SkNativeParsedPDF::bytesUsed() const { 535 size_t SkNativeParsedPDF::bytesUsed() const {
536 return fAllocator->bytesUsed() + 536 return fAllocator->bytesUsed() +
537 fContentLength + 537 fContentLength +
538 fObjects.count() * sizeof(PublicObjectEntry) + 538 fObjects.count() * sizeof(PublicObjectEntry) +
539 fPages.count() * sizeof(SkPdfPageObjectDictionary*) + 539 fPages.count() * sizeof(SkPdfPageObjectDictionary*) +
540 sizeof(*this); 540 sizeof(*this);
541 } 541 }
OLDNEW
« no previous file with comments | « experimental/PdfViewer/pdf_viewer_main.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698