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

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

Issue 79933003: Restructuring of PdfViewer code. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Respond to comments. Created 7 years 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 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkPdfNativeDoc.h" 8 #include "SkPdfNativeDoc.h"
9 9
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 SkPdfPageObjectDictionary* current = fPages[page]; 472 SkPdfPageObjectDictionary* current = fPages[page];
473 while (!current->has_MediaBox() && current->has_Parent()) { 473 while (!current->has_MediaBox() && current->has_Parent()) {
474 current = (SkPdfPageObjectDictionary*)current->Parent(this); 474 current = (SkPdfPageObjectDictionary*)current->Parent(this);
475 } 475 }
476 if (current) { 476 if (current) {
477 return current->MediaBox(this); 477 return current->MediaBox(this);
478 } 478 }
479 return SkRect::MakeEmpty(); 479 return SkRect::MakeEmpty();
480 } 480 }
481 481
482 SkPdfNativeTokenizer* SkPdfNativeDoc::tokenizerOfPage(int page, SkPdfAllocator* allocator) {
483 if (fPages[page]->isContentsAStream(this)) {
484 return tokenizerOfStream(fPages[page]->getContentsAsStream(this), alloca tor);
485 } else {
486 // TODO(edisonn): NYI, we need to concatenate all streams in the array o r
487 // make the tokenizer smart so we don't allocate new memory.
488 return NULL;
489 }
490 }
491
492 SkPdfNativeTokenizer* SkPdfNativeDoc::tokenizerOfStream(SkPdfNativeObject* strea m, 482 SkPdfNativeTokenizer* SkPdfNativeDoc::tokenizerOfStream(SkPdfNativeObject* strea m,
493 SkPdfAllocator* allocato r) { 483 SkPdfAllocator* allocato r) {
494 if (stream == NULL) { 484 if (stream == NULL) {
495 return NULL; 485 return NULL;
496 } 486 }
497 487
498 return new SkPdfNativeTokenizer(stream, allocator, this); 488 return new SkPdfNativeTokenizer(stream, allocator, this);
499 } 489 }
500 490
501 SkPdfNativeTokenizer* SkPdfNativeDoc::tokenizerOfBuffer(const unsigned char* buf fer, size_t len,
502 SkPdfAllocator* allocato r) {
503 return new SkPdfNativeTokenizer(buffer, len, allocator, this);
504 }
505
506 size_t SkPdfNativeDoc::objects() const { 491 size_t SkPdfNativeDoc::objects() const {
507 return fObjects.count(); 492 return fObjects.count();
508 } 493 }
509 494
510 SkPdfNativeObject* SkPdfNativeDoc::object(int i) { 495 SkPdfNativeObject* SkPdfNativeDoc::object(int i) {
511 SkASSERT(!(i < 0 || i > fObjects.count())); 496 SkASSERT(!(i < 0 || i > fObjects.count()));
512 497
513 if (i < 0 || i > fObjects.count()) { 498 if (i < 0 || i > fObjects.count()) {
514 return NULL; 499 return NULL;
515 } 500 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 return (SkPdfNativeObject*)ref; 582 return (SkPdfNativeObject*)ref;
598 } 583 }
599 584
600 size_t SkPdfNativeDoc::bytesUsed() const { 585 size_t SkPdfNativeDoc::bytesUsed() const {
601 return fAllocator->bytesUsed() + 586 return fAllocator->bytesUsed() +
602 fContentLength + 587 fContentLength +
603 fObjects.count() * sizeof(PublicObjectEntry) + 588 fObjects.count() * sizeof(PublicObjectEntry) +
604 fPages.count() * sizeof(SkPdfPageObjectDictionary*) + 589 fPages.count() * sizeof(SkPdfPageObjectDictionary*) +
605 sizeof(*this); 590 sizeof(*this);
606 } 591 }
OLDNEW
« no previous file with comments | « experimental/PdfViewer/pdfparser/native/SkPdfNativeDoc.h ('k') | experimental/PdfViewer/src/SkPdfContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698