aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PDFPrimitivesTest.cpp
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2015-01-13 07:12:57 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-01-13 07:12:57 -0800
commitf361b714390422a5c2a8b1dacb8e67502d0e40bb (patch)
treed93e75f01c0f47ce6ec49bc8065070686b251d20 /tests/PDFPrimitivesTest.cpp
parent7e783786d8bc0abeac0f5a17a8169675a6b7a2b0 (diff)
In SkPDFDocument::emitPDF(), stop pre-calculating file offsets.
* Add Streamer utility class which measures the current pdf offset by calling SkWStream::bytesWritten(). Calls SkPDFCatalog::setFileOffset() and SkPDFObject::emit() at the same time to guarantee that everything works out. * SkPDFCatalog::setFileOffset() no longer calculates the object's size. * SkPDFCatalog::setSubstituteResourcesOffsets() removed. * SkPDFCatalog::emitSubstituteResources() removed and getSubstituteList() made public in its place. * Remove SkPDFPage::getPageSize and SkPDFPage::emitPage. Replace with SkPDFPage::getContentStream(). * SkPDFObject::getOutputSize no longer virtual, only used in unit tests. All SkPDFObject subclasses getOutputSize() overrides removed. * SkPDFObject::getIndirectOutputSize removed. * PDFPrimitivesTest updated for new functions. Review URL: https://codereview.chromium.org/846023003
Diffstat (limited to 'tests/PDFPrimitivesTest.cpp')
-rw-r--r--tests/PDFPrimitivesTest.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/PDFPrimitivesTest.cpp b/tests/PDFPrimitivesTest.cpp
index 9421fc9597..3a4c6f6ab0 100644
--- a/tests/PDFPrimitivesTest.cpp
+++ b/tests/PDFPrimitivesTest.cpp
@@ -228,12 +228,18 @@ static void TestSubstitute(skiatest::Reporter* reporter) {
SkDynamicMemoryWStream buffer;
proxy->emit(&buffer, &catalog, false);
- catalog.emitSubstituteResources(&buffer, false);
+ SkTSet<SkPDFObject*>* substituteResources =
+ catalog.getSubstituteList(false);
+ for (int i = 0; i < substituteResources->count(); ++i) {
+ (*substituteResources)[i]->emit(&buffer, &catalog, true);
+ }
char objectResult[] = "2 0 obj\n<</Value 33\n>>\nendobj\n";
- REPORTER_ASSERT(
- reporter,
- catalog.setFileOffset(proxy.get(), 0) == strlen(objectResult));
+ catalog.setFileOffset(proxy.get(), 0);
+
+ size_t outputSize = catalog.getSubstituteObject(proxy.get())
+ ->getOutputSize(&catalog, true);
+ REPORTER_ASSERT(reporter, outputSize == strlen(objectResult));
char expectedResult[] =
"<</Value 33\n>>1 0 obj\n<</InnerValue 44\n>>\nendobj\n";