OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/renderer/print_web_view_helper.h" | 5 #include "chrome/renderer/print_web_view_helper.h" |
6 | 6 |
7 #include "base/file_descriptor_posix.h" | 7 #include "base/file_descriptor_posix.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "chrome/common/print_messages.h" | 10 #include "chrome/common/print_messages.h" |
11 #include "content/common/view_messages.h" | 11 #include "content/common/view_messages.h" |
12 #include "printing/native_metafile_factory.h" | 12 #include "printing/native_metafile_factory.h" |
| 13 #include "printing/native_metafile_skia_wrapper.h" |
13 #include "printing/native_metafile.h" | 14 #include "printing/native_metafile.h" |
14 #include "skia/ext/vector_canvas.h" | 15 #include "skia/ext/vector_canvas.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
16 #include "ui/gfx/point.h" | 17 #include "ui/gfx/point.h" |
17 | 18 |
18 #if !defined(OS_CHROMEOS) | 19 #if !defined(OS_CHROMEOS) |
19 #include "base/process_util.h" | 20 #include "base/process_util.h" |
20 #endif // !defined(OS_CHROMEOS) | 21 #endif // !defined(OS_CHROMEOS) |
21 | 22 |
22 using WebKit::WebFrame; | 23 using WebKit::WebFrame; |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 content_height_in_points + margin_top_in_points + | 222 content_height_in_points + margin_top_in_points + |
222 margin_bottom_in_points); | 223 margin_bottom_in_points); |
223 gfx::Point content_origin(margin_left_in_points, margin_top_in_points); | 224 gfx::Point content_origin(margin_left_in_points, margin_top_in_points); |
224 | 225 |
225 skia::PlatformDevice* device = metafile->StartPageForVectorCanvas( | 226 skia::PlatformDevice* device = metafile->StartPageForVectorCanvas( |
226 page_size, content_origin, 1.0f); | 227 page_size, content_origin, 1.0f); |
227 if (!device) | 228 if (!device) |
228 return; | 229 return; |
229 | 230 |
230 canvas->reset(new skia::VectorCanvas(device)); | 231 canvas->reset(new skia::VectorCanvas(device)); |
| 232 printing::NativeMetafileSkiaWrapper::SetMetafileOnCanvas(canvas->get(), |
| 233 metafile); |
231 frame->printPage(params.page_number, canvas->get()); | 234 frame->printPage(params.page_number, canvas->get()); |
232 | 235 |
233 // TODO(myhuang): We should handle transformation for paper margins. | 236 // TODO(myhuang): We should handle transformation for paper margins. |
234 // TODO(myhuang): We should render the header and the footer. | 237 // TODO(myhuang): We should render the header and the footer. |
235 | 238 |
236 // Done printing. Close the device context to retrieve the compiled metafile. | 239 // Done printing. Close the device context to retrieve the compiled metafile. |
237 if (!metafile->FinishPage()) | 240 if (!metafile->FinishPage()) |
238 NOTREACHED() << "metafile failed"; | 241 NOTREACHED() << "metafile failed"; |
239 } | 242 } |
OLD | NEW |