diff options
author | halcanary <halcanary@google.com> | 2015-03-25 08:38:03 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-25 08:38:03 -0700 |
commit | 26b5d15dab81883fac05a2d3685ca6e3a3459678 (patch) | |
tree | 8a55365ba9445dd9c457273e5868c237901e112a /src | |
parent | 7a0118465a2dd1783d7b19b026bedd7e13afadf2 (diff) |
SkPDF: add canon assert before adding code that might break it
Motivation: We can write subsets (by page) of pdf documents (but this
in't yet exposed in the public API), but it is a bad idea to mix pages
from multiple documents (de-duping will break). This assert verifies
that we don't do this by accident in the future.
BUG=skia:3585
Review URL: https://codereview.chromium.org/1037573005
Diffstat (limited to 'src')
-rw-r--r-- | src/pdf/SkPDFDevice.h | 4 | ||||
-rw-r--r-- | src/pdf/SkPDFDocument.cpp | 3 | ||||
-rw-r--r-- | src/pdf/SkPDFDocument.h | 1 |
3 files changed, 7 insertions, 1 deletions
diff --git a/src/pdf/SkPDFDevice.h b/src/pdf/SkPDFDevice.h index a90ea115c1..047841df84 100644 --- a/src/pdf/SkPDFDevice.h +++ b/src/pdf/SkPDFDevice.h @@ -180,6 +180,10 @@ public: return *(fFontGlyphUsage.get()); } +#ifdef SK_DEBUG + SkPDFCanon* getCanon() const { return fCanon; } +#endif // SK_DEBUG + protected: const SkBitmap& onAccessBitmap() SK_OVERRIDE { return fLegacyBitmap; diff --git a/src/pdf/SkPDFDocument.cpp b/src/pdf/SkPDFDocument.cpp index 57eab950ed..6d49e68584 100644 --- a/src/pdf/SkPDFDocument.cpp +++ b/src/pdf/SkPDFDocument.cpp @@ -70,9 +70,12 @@ bool SkPDFDocument::EmitPDF(const SkTDArray<SkPDFDevice*>& pageDevices, if (pageDevices.isEmpty()) { return false; } + SkTDArray<SkPDFPage*> pages; for (int i = 0; i < pageDevices.count(); i++) { SkASSERT(pageDevices[i]); + SkASSERT(i == 0 || + pageDevices[i - 1]->getCanon() == pageDevices[i]->getCanon()); // Reference from new passed to pages. pages.push(SkNEW_ARGS(SkPDFPage, (pageDevices[i]))); } diff --git a/src/pdf/SkPDFDocument.h b/src/pdf/SkPDFDocument.h index f39b59ef47..b63edc12d2 100644 --- a/src/pdf/SkPDFDocument.h +++ b/src/pdf/SkPDFDocument.h @@ -26,7 +26,6 @@ namespace SkPDFDocument { * * @param pageDevices An array of pages, in order. All pages * should be created using the same SkPDFCanon. - * TODO(halcanary): ASSERT this condition. * @param SkWStream The writable output stream to send the PDF to. */ bool EmitPDF(const SkTDArray<SkPDFDevice*>& pageDevices, SkWStream*); |