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

Unified Diff: src/doc/SkDocument_PDF.cpp

Issue 1287443002: SkPDF: add assert for that SkWStream behaves. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/doc/SkDocument_PDF.cpp
diff --git a/src/doc/SkDocument_PDF.cpp b/src/doc/SkDocument_PDF.cpp
index eeb8aa83fd96d5ccce9381a0e32a2dd1bb5eb3d2..c1d5f0f461d039c047abc58b07b2d785e51b0fe1 100644
--- a/src/doc/SkDocument_PDF.cpp
+++ b/src/doc/SkDocument_PDF.cpp
@@ -201,12 +201,16 @@ static bool emit_pdf_document(const SkTDArray<const SkPDFDevice*>& pageDevices,
if (objNumMap.addObject(docCatalog.get())) {
docCatalog->addResources(&objNumMap, substitutes);
}
- size_t baseOffset = SkToOffT(stream->bytesWritten());
+ size_t baseOffset = stream->bytesWritten();
emit_pdf_header(stream);
SkTDArray<int32_t> offsets;
for (int i = 0; i < objNumMap.objects().count(); ++i) {
SkPDFObject* object = objNumMap.objects()[i];
- offsets.push(SkToS32(stream->bytesWritten() - baseOffset));
+ size_t offset = stream->bytesWritten();
+ // This assert checks that size(pdf_header) > 0 and that
+ // the output stream correctly reports bytesWritten().
+ SkASSERT(offset > baseOffset);
+ offsets.push(SkToS32(offset - baseOffset));
SkASSERT(object == substitutes.getSubstitute(object));
SkASSERT(objNumMap.getObjectNumber(object) == i + 1);
stream->writeDecAsText(i + 1);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698