| 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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 // TODO(edisonn): verify that it is a page tree indeed | 396 // TODO(edisonn): verify that it is a page tree indeed |
| 397 fillPages((SkPdfPageTreeNodeDictionary*)obj); | 397 fillPages((SkPdfPageTreeNodeDictionary*)obj); |
| 398 } | 398 } |
| 399 } | 399 } |
| 400 } | 400 } |
| 401 | 401 |
| 402 int SkNativeParsedPDF::pages() const { | 402 int SkNativeParsedPDF::pages() const { |
| 403 return fPages.count(); | 403 return fPages.count(); |
| 404 } | 404 } |
| 405 | 405 |
| 406 SkPdfPageObjectDictionary* SkNativeParsedPDF::page(int page) { |
| 407 SkASSERT(page >= 0 && page < fPages.count()); |
| 408 return fPages[page]; |
| 409 } |
| 410 |
| 411 |
| 406 SkPdfResourceDictionary* SkNativeParsedPDF::pageResources(int page) { | 412 SkPdfResourceDictionary* SkNativeParsedPDF::pageResources(int page) { |
| 413 SkASSERT(page >= 0 && page < fPages.count()); |
| 407 return fPages[page]->Resources(this); | 414 return fPages[page]->Resources(this); |
| 408 } | 415 } |
| 409 | 416 |
| 410 // TODO(edisonn): Partial implemented. Move the logics directly in the code gene
rator for inheritable and default value? | 417 // TODO(edisonn): Partial implemented. Move the logics directly in the code gene
rator for inheritable and default value? |
| 411 SkRect SkNativeParsedPDF::MediaBox(int page) { | 418 SkRect SkNativeParsedPDF::MediaBox(int page) { |
| 412 SkPdfPageObjectDictionary* current = fPages[page]; | 419 SkPdfPageObjectDictionary* current = fPages[page]; |
| 413 while (!current->has_MediaBox() && current->has_Parent()) { | 420 while (!current->has_MediaBox() && current->has_Parent()) { |
| 414 current = (SkPdfPageObjectDictionary*)current->Parent(this); | 421 current = (SkPdfPageObjectDictionary*)current->Parent(this); |
| 415 } | 422 } |
| 416 if (current) { | 423 if (current) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 } | 502 } |
| 496 | 503 |
| 497 // TODO(edisonn): fix infinite loop if ref to itself! | 504 // TODO(edisonn): fix infinite loop if ref to itself! |
| 498 // TODO(edisonn): perf, fix refs at load, and resolve will simply return fResolv
edReference? | 505 // TODO(edisonn): perf, fix refs at load, and resolve will simply return fResolv
edReference? |
| 499 SkPdfObject* SkNativeParsedPDF::resolveReference(const SkPdfObject* ref) { | 506 SkPdfObject* SkNativeParsedPDF::resolveReference(const SkPdfObject* ref) { |
| 500 if (ref && ref->isReference()) { | 507 if (ref && ref->isReference()) { |
| 501 int id = ref->referenceId(); | 508 int id = ref->referenceId(); |
| 502 // TODO(edisonn): generation/updates not supported now | 509 // TODO(edisonn): generation/updates not supported now |
| 503 //int gen = ref->referenceGeneration(); | 510 //int gen = ref->referenceGeneration(); |
| 504 | 511 |
| 505 SkASSERT(!(id < 0 || id > fObjects.count())); | |
| 506 | |
| 507 // TODO(edisonn): verify id and gen expected | 512 // TODO(edisonn): verify id and gen expected |
| 508 if (id < 0 || id >= fObjects.count()) { | 513 if (id < 0 || id >= fObjects.count()) { |
| 509 // TODO(edisonn): report error/warning | 514 // TODO(edisonn): report error/warning |
| 510 return NULL; | 515 return NULL; |
| 511 } | 516 } |
| 512 | 517 |
| 513 if (fObjects[id].fResolvedReference != NULL) { | 518 if (fObjects[id].fResolvedReference != NULL) { |
| 514 return fObjects[id].fResolvedReference; | 519 return fObjects[id].fResolvedReference; |
| 515 } | 520 } |
| 516 | 521 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 532 return (SkPdfObject*)ref; | 537 return (SkPdfObject*)ref; |
| 533 } | 538 } |
| 534 | 539 |
| 535 size_t SkNativeParsedPDF::bytesUsed() const { | 540 size_t SkNativeParsedPDF::bytesUsed() const { |
| 536 return fAllocator->bytesUsed() + | 541 return fAllocator->bytesUsed() + |
| 537 fContentLength + | 542 fContentLength + |
| 538 fObjects.count() * sizeof(PublicObjectEntry) + | 543 fObjects.count() * sizeof(PublicObjectEntry) + |
| 539 fPages.count() * sizeof(SkPdfPageObjectDictionary*) + | 544 fPages.count() * sizeof(SkPdfPageObjectDictionary*) + |
| 540 sizeof(*this); | 545 sizeof(*this); |
| 541 } | 546 } |
| OLD | NEW |