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/containers/hash_tables.h" | 7 #include "base/containers/hash_tables.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 if (!StartPage(page_size, content_area, scale_factor)) | 114 if (!StartPage(page_size, content_area, scale_factor)) |
115 return nullptr; | 115 return nullptr; |
116 return data_->recorder_.getRecordingCanvas(); | 116 return data_->recorder_.getRecordingCanvas(); |
117 } | 117 } |
118 | 118 |
119 bool PdfMetafileSkia::FinishPage() { | 119 bool PdfMetafileSkia::FinishPage() { |
120 if (!data_->recorder_.getRecordingCanvas()) | 120 if (!data_->recorder_.getRecordingCanvas()) |
121 return false; | 121 return false; |
122 DCHECK(!(data_->pages_.back().content_)); | 122 DCHECK(!(data_->pages_.back().content_)); |
123 data_->pages_.back().content_ = | 123 data_->pages_.back().content_ = |
124 skia::AdoptRef(data_->recorder_.endRecording()); | 124 skia::AdoptRef(data_->recorder_.endRecordingAsPicture()); |
125 return true; | 125 return true; |
126 } | 126 } |
127 | 127 |
128 bool PdfMetafileSkia::FinishDocument() { | 128 bool PdfMetafileSkia::FinishDocument() { |
129 // If we've already set the data in InitFromData, leave it be. | 129 // If we've already set the data in InitFromData, leave it be. |
130 if (data_->pdf_data_) | 130 if (data_->pdf_data_) |
131 return false; | 131 return false; |
132 | 132 |
133 if (data_->recorder_.getRecordingCanvas()) | 133 if (data_->recorder_.getRecordingCanvas()) |
134 this->FinishPage(); | 134 this->FinishPage(); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 | 278 |
279 metafile->data_->pages_.push_back(page); | 279 metafile->data_->pages_.push_back(page); |
280 | 280 |
281 if (!metafile->FinishDocument()) // Generate PDF. | 281 if (!metafile->FinishDocument()) // Generate PDF. |
282 metafile.reset(); | 282 metafile.reset(); |
283 | 283 |
284 return metafile.Pass(); | 284 return metafile.Pass(); |
285 } | 285 } |
286 | 286 |
287 } // namespace printing | 287 } // namespace printing |
OLD | NEW |