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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/numerics/safe_conversions.h" | 13 #include "base/numerics/safe_conversions.h" |
14 #include "base/posix/eintr_wrapper.h" | 14 #include "base/posix/eintr_wrapper.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "printing/print_settings.h" | 16 #include "printing/print_settings.h" |
17 #include "skia/ext/refptr.h" | 17 #include "skia/ext/refptr.h" |
| 18 #include "third_party/skia/include/core/SkCanvas.h" |
18 #include "third_party/skia/include/core/SkData.h" | 19 #include "third_party/skia/include/core/SkData.h" |
19 #include "third_party/skia/include/core/SkDocument.h" | 20 #include "third_party/skia/include/core/SkDocument.h" |
20 #include "third_party/skia/include/core/SkPictureRecorder.h" | 21 #include "third_party/skia/include/core/SkPictureRecorder.h" |
21 #include "third_party/skia/include/core/SkRect.h" | 22 #include "third_party/skia/include/core/SkRect.h" |
22 #include "third_party/skia/include/core/SkRefCnt.h" | 23 #include "third_party/skia/include/core/SkRefCnt.h" |
23 #include "third_party/skia/include/core/SkScalar.h" | 24 #include "third_party/skia/include/core/SkScalar.h" |
24 #include "third_party/skia/include/core/SkSize.h" | 25 #include "third_party/skia/include/core/SkSize.h" |
25 #include "third_party/skia/include/core/SkStream.h" | 26 #include "third_party/skia/include/core/SkStream.h" |
26 #include "ui/gfx/geometry/point.h" | 27 #include "ui/gfx/geometry/point.h" |
27 #include "ui/gfx/geometry/rect.h" | 28 #include "ui/gfx/geometry/rect.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // We scale the recording canvas's size so that | 108 // We scale the recording canvas's size so that |
108 // canvas->getTotalMatrix() returns a value that ignores the scale | 109 // canvas->getTotalMatrix() returns a value that ignores the scale |
109 // factor. We store the scale factor and re-apply it to the PDF | 110 // factor. We store the scale factor and re-apply it to the PDF |
110 // Canvas later. http://crbug.com/469656 | 111 // Canvas later. http://crbug.com/469656 |
111 // Recording canvas is owned by the data_->recorder_. No ref() necessary. | 112 // Recording canvas is owned by the data_->recorder_. No ref() necessary. |
112 return !!data_->recorder_.beginRecording(sk_page_size.width() / scale_factor, | 113 return !!data_->recorder_.beginRecording(sk_page_size.width() / scale_factor, |
113 sk_page_size.height() / scale_factor, | 114 sk_page_size.height() / scale_factor, |
114 NULL, 0); | 115 NULL, 0); |
115 } | 116 } |
116 | 117 |
117 skia::PlatformCanvas* PdfMetafileSkia::GetVectorCanvasForNewPage( | 118 SkCanvas* PdfMetafileSkia::GetVectorCanvasForNewPage( |
118 const gfx::Size& page_size, | 119 const gfx::Size& page_size, |
119 const gfx::Rect& content_area, | 120 const gfx::Rect& content_area, |
120 const float& scale_factor) { | 121 const float& scale_factor) { |
121 if (!StartPage(page_size, content_area, scale_factor)) | 122 if (!StartPage(page_size, content_area, scale_factor)) |
122 return nullptr; | 123 return nullptr; |
123 return data_->recorder_.getRecordingCanvas(); | 124 return data_->recorder_.getRecordingCanvas(); |
124 } | 125 } |
125 | 126 |
126 bool PdfMetafileSkia::FinishPage() { | 127 bool PdfMetafileSkia::FinishPage() { |
127 if (!data_->recorder_.getRecordingCanvas()) | 128 if (!data_->recorder_.getRecordingCanvas()) |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 | 310 |
310 metafile->data_->pages_.push_back(page); | 311 metafile->data_->pages_.push_back(page); |
311 | 312 |
312 if (!metafile->FinishDocument()) // Generate PDF. | 313 if (!metafile->FinishDocument()) // Generate PDF. |
313 metafile.reset(); | 314 metafile.reset(); |
314 | 315 |
315 return metafile; | 316 return metafile; |
316 } | 317 } |
317 | 318 |
318 } // namespace printing | 319 } // namespace printing |
OLD | NEW |