OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkColorSpace_Base.h" | 8 #include "SkColorSpace_Base.h" |
9 #include "SkPDFCanvas.h" | 9 #include "SkPDFCanvas.h" |
10 #include "SkPDFDevice.h" | 10 #include "SkPDFDevice.h" |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 fCanvas.reset(nullptr); | 271 fCanvas.reset(nullptr); |
272 SkASSERT(fPageDevice); | 272 SkASSERT(fPageDevice); |
273 auto page = sk_make_sp<SkPDFDict>("Page"); | 273 auto page = sk_make_sp<SkPDFDict>("Page"); |
274 page->insertObject("Resources", fPageDevice->makeResourceDict()); | 274 page->insertObject("Resources", fPageDevice->makeResourceDict()); |
275 page->insertObject("MediaBox", fPageDevice->copyMediaBox()); | 275 page->insertObject("MediaBox", fPageDevice->copyMediaBox()); |
276 auto annotations = sk_make_sp<SkPDFArray>(); | 276 auto annotations = sk_make_sp<SkPDFArray>(); |
277 fPageDevice->appendAnnotations(annotations.get()); | 277 fPageDevice->appendAnnotations(annotations.get()); |
278 if (annotations->size() > 0) { | 278 if (annotations->size() > 0) { |
279 page->insertObject("Annots", std::move(annotations)); | 279 page->insertObject("Annots", std::move(annotations)); |
280 } | 280 } |
281 auto contentData = fPageDevice->content(); | 281 auto contentObject = sk_make_sp<SkPDFStream>(fPageDevice->content()); |
282 auto contentObject = sk_make_sp<SkPDFStream>(contentData.get()); | |
283 this->serialize(contentObject); | 282 this->serialize(contentObject); |
284 page->insertObjRef("Contents", std::move(contentObject)); | 283 page->insertObjRef("Contents", std::move(contentObject)); |
285 fPageDevice->appendDestinations(fDests.get(), page.get()); | 284 fPageDevice->appendDestinations(fDests.get(), page.get()); |
286 fPages.emplace_back(std::move(page)); | 285 fPages.emplace_back(std::move(page)); |
287 fPageDevice.reset(nullptr); | 286 fPageDevice.reset(nullptr); |
288 } | 287 } |
289 | 288 |
290 void SkPDFDocument::onAbort() { | 289 void SkPDFDocument::onAbort() { |
291 fCanvas.reset(nullptr); | 290 fCanvas.reset(nullptr); |
292 fPages.reset(); | 291 fPages.reset(); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 } | 417 } |
419 | 418 |
420 sk_sp<SkDocument> SkDocument::MakePDF(SkWStream* stream, | 419 sk_sp<SkDocument> SkDocument::MakePDF(SkWStream* stream, |
421 SkScalar dpi, | 420 SkScalar dpi, |
422 const SkDocument::PDFMetadata& metadata, | 421 const SkDocument::PDFMetadata& metadata, |
423 sk_sp<SkPixelSerializer> jpegEncoder, | 422 sk_sp<SkPixelSerializer> jpegEncoder, |
424 bool pdfa) { | 423 bool pdfa) { |
425 return SkPDFMakeDocument(stream, nullptr, dpi, metadata, | 424 return SkPDFMakeDocument(stream, nullptr, dpi, metadata, |
426 std::move(jpegEncoder), pdfa); | 425 std::move(jpegEncoder), pdfa); |
427 } | 426 } |
OLD | NEW |