| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "printing/pdf_metafile_skia.h" | 5 #include "printing/pdf_metafile_skia.h" |
| 6 | 6 |
| 7 #include "base/files/file.h" | 7 #include "base/files/file.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "printing/print_settings.h" | 9 #include "printing/print_settings.h" |
| 10 #include "third_party/skia/include/core/SkDocument.h" | 10 #include "third_party/skia/include/core/SkDocument.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 case MSKP_SKIA_DOCUMENT_TYPE: | 188 case MSKP_SKIA_DOCUMENT_TYPE: |
| 189 doc = SkMakeMultiPictureDocument(&stream); | 189 doc = SkMakeMultiPictureDocument(&stream); |
| 190 break; | 190 break; |
| 191 } | 191 } |
| 192 | 192 |
| 193 for (const Page& page : data_->pages_) { | 193 for (const Page& page : data_->pages_) { |
| 194 SkCanvas* canvas = doc->beginPage(page.size_.width(), page.size_.height()); | 194 SkCanvas* canvas = doc->beginPage(page.size_.width(), page.size_.height()); |
| 195 canvas->drawPicture(page.content_); | 195 canvas->drawPicture(page.content_); |
| 196 doc->endPage(); | 196 doc->endPage(); |
| 197 } | 197 } |
| 198 if (!doc->close()) | 198 doc->close(); |
| 199 return false; | |
| 200 | 199 |
| 201 data_->pdf_data_.reset(stream.detachAsStream()); | 200 data_->pdf_data_.reset(stream.detachAsStream()); |
| 202 return true; | 201 return true; |
| 203 } | 202 } |
| 204 | 203 |
| 205 uint32_t PdfMetafileSkia::GetDataSize() const { | 204 uint32_t PdfMetafileSkia::GetDataSize() const { |
| 206 if (!data_->pdf_data_) | 205 if (!data_->pdf_data_) |
| 207 return 0; | 206 return 0; |
| 208 return base::checked_cast<uint32_t>(data_->pdf_data_->getLength()); | 207 return base::checked_cast<uint32_t>(data_->pdf_data_->getLength()); |
| 209 } | 208 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 | 314 |
| 316 metafile->data_->pages_.push_back(data_->pages_.back()); | 315 metafile->data_->pages_.push_back(data_->pages_.back()); |
| 317 | 316 |
| 318 if (!metafile->FinishDocument()) // Generate PDF. | 317 if (!metafile->FinishDocument()) // Generate PDF. |
| 319 metafile.reset(); | 318 metafile.reset(); |
| 320 | 319 |
| 321 return metafile; | 320 return metafile; |
| 322 } | 321 } |
| 323 | 322 |
| 324 } // namespace printing | 323 } // namespace printing |
| OLD | NEW |