diff options
author | vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-01-30 21:44:40 +0000 |
---|---|---|
committer | vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-01-30 21:44:40 +0000 |
commit | 3c974427a95e9f24eae39167cf972506d70359c9 (patch) | |
tree | 67a8ed432062ad96667456ebd1ff8ca21e099e3d | |
parent | 8d3cd7a170c810e3816bf00220cbef51e7b16795 (diff) |
[PDF] Fix multi-level page count calculation.
BUG=1091
Review URL: https://codereview.appspot.com/7220045
git-svn-id: http://skia.googlecode.com/svn/trunk@7478 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | src/pdf/SkPDFPage.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/pdf/SkPDFPage.cpp b/src/pdf/SkPDFPage.cpp index a18beb156f..f47f8ffd46 100644 --- a/src/pdf/SkPDFPage.cpp +++ b/src/pdf/SkPDFPage.cpp @@ -112,12 +112,19 @@ void SkPDFPage::GeneratePageTree(const SkTDArray<SkPDFPage*>& pages, } } - newNode->insert(kidsName.get(), kids.get()); + // treeCapacity is the number of leaf nodes possible for the + // current set of subtrees being generated. (i.e. 8, 64, 512, ...). + // It is hard to count the number of leaf nodes in the current + // subtree. However, by construction, we know that unless it's the + // last subtree for the current depth, the leaf count will be + // treeCapacity, otherwise it's what ever is left over after + // consuming treeCapacity chunks. int pageCount = treeCapacity; - if (count < kNodeSize) { - pageCount = pages.count() % treeCapacity; + if (i == curNodes.count()) { + pageCount = ((pages.count() - 1) % treeCapacity) + 1; } newNode->insert(countName.get(), new SkPDFInt(pageCount))->unref(); + newNode->insert(kidsName.get(), kids.get()); nextRoundNodes.push(newNode); // Transfer reference. } |