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 "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" | 52 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" |
53 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" | 53 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" |
54 #include "webkit/plugins/ppapi/ppb_surface_3d_impl.h" | 54 #include "webkit/plugins/ppapi/ppb_surface_3d_impl.h" |
55 #include "webkit/plugins/ppapi/ppb_url_loader_impl.h" | 55 #include "webkit/plugins/ppapi/ppb_url_loader_impl.h" |
56 #include "webkit/plugins/ppapi/ppb_url_request_info_impl.h" | 56 #include "webkit/plugins/ppapi/ppb_url_request_info_impl.h" |
57 #include "webkit/plugins/ppapi/ppp_pdf.h" | 57 #include "webkit/plugins/ppapi/ppp_pdf.h" |
58 #include "webkit/plugins/ppapi/string.h" | 58 #include "webkit/plugins/ppapi/string.h" |
59 #include "webkit/plugins/ppapi/var.h" | 59 #include "webkit/plugins/ppapi/var.h" |
60 #include "webkit/plugins/sad_plugin.h" | 60 #include "webkit/plugins/sad_plugin.h" |
61 | 61 |
62 #if defined(OS_POSIX) | |
63 #include "printing/native_metafile.h" | |
64 #endif | |
65 | |
66 #if defined(OS_MACOSX) | 62 #if defined(OS_MACOSX) |
67 #include "base/mac/mac_util.h" | 63 #include "base/mac/mac_util.h" |
68 #include "base/mac/scoped_cftyperef.h" | 64 #include "base/mac/scoped_cftyperef.h" |
69 #include "printing/native_metafile_factory.h" | 65 #include "printing/metafile_impl.h" |
70 #endif | 66 #endif |
71 | 67 |
72 #if defined(OS_LINUX) | 68 #if defined(OS_LINUX) |
73 #include "printing/native_metafile_skia_wrapper.h" | 69 #include "printing/metafile.h" |
| 70 #include "printing/metafile_skia_wrapper.h" |
74 #endif | 71 #endif |
75 | 72 |
76 #if defined(OS_WIN) | 73 #if defined(OS_WIN) |
77 #include "skia/ext/vector_platform_device_emf_win.h" | 74 #include "skia/ext/vector_platform_device_emf_win.h" |
78 #include "ui/gfx/codec/jpeg_codec.h" | 75 #include "ui/gfx/codec/jpeg_codec.h" |
79 #include "ui/gfx/gdi_util.h" | 76 #include "ui/gfx/gdi_util.h" |
80 #endif | 77 #endif |
81 | 78 |
82 using WebKit::WebBindings; | 79 using WebKit::WebBindings; |
83 using WebKit::WebCanvas; | 80 using WebKit::WebCanvas; |
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 return false; | 1192 return false; |
1196 RenderPDFPageToDCProc render_proc = | 1193 RenderPDFPageToDCProc render_proc = |
1197 reinterpret_cast<RenderPDFPageToDCProc>( | 1194 reinterpret_cast<RenderPDFPageToDCProc>( |
1198 GetProcAddress(pdf_module, "RenderPDFPageToDC")); | 1195 GetProcAddress(pdf_module, "RenderPDFPageToDC")); |
1199 if (!render_proc) | 1196 if (!render_proc) |
1200 return false; | 1197 return false; |
1201 #endif // defined(OS_WIN) | 1198 #endif // defined(OS_WIN) |
1202 | 1199 |
1203 bool ret = false; | 1200 bool ret = false; |
1204 #if defined(OS_LINUX) | 1201 #if defined(OS_LINUX) |
1205 // On Linux we just set the final bits in the native metafile. | 1202 // On Linux we just set the final bits in the native metafile |
1206 printing::NativeMetafile* metafile = | 1203 // (NativeMetafile and PreviewMetafile must have compatible formats, |
1207 printing::NativeMetafileSkiaWrapper::GetMetafileFromCanvas(canvas); | 1204 // i.e. both PDF for this to work). |
| 1205 printing::Metafile* metafile = |
| 1206 printing::MetafileSkiaWrapper::GetMetafileFromCanvas(canvas); |
1208 DCHECK(metafile != NULL); | 1207 DCHECK(metafile != NULL); |
1209 if (metafile) | 1208 if (metafile) |
1210 ret = metafile->InitFromData(buffer->mapped_buffer(), buffer->size()); | 1209 ret = metafile->InitFromData(buffer->mapped_buffer(), buffer->size()); |
1211 #elif defined(OS_MACOSX) | 1210 #elif defined(OS_MACOSX) |
| 1211 printing::NativeMetafile metafile; |
1212 // Create a PDF metafile and render from there into the passed in context. | 1212 // Create a PDF metafile and render from there into the passed in context. |
1213 scoped_ptr<printing::NativeMetafile> metafile( | 1213 if (metafile.InitFromData(buffer->mapped_buffer(), buffer->size())) { |
1214 printing::NativeMetafileFactory::CreateFromData(buffer->mapped_buffer(), | |
1215 buffer->size())); | |
1216 if (metafile.get() != NULL) { | |
1217 // Flip the transform. | 1214 // Flip the transform. |
1218 CGContextSaveGState(canvas); | 1215 CGContextSaveGState(canvas); |
1219 CGContextTranslateCTM(canvas, 0, | 1216 CGContextTranslateCTM(canvas, 0, |
1220 current_print_settings_.printable_area.size.height); | 1217 current_print_settings_.printable_area.size.height); |
1221 CGContextScaleCTM(canvas, 1.0, -1.0); | 1218 CGContextScaleCTM(canvas, 1.0, -1.0); |
1222 CGRect page_rect; | 1219 CGRect page_rect; |
1223 page_rect.origin.x = current_print_settings_.printable_area.point.x; | 1220 page_rect.origin.x = current_print_settings_.printable_area.point.x; |
1224 page_rect.origin.y = current_print_settings_.printable_area.point.y; | 1221 page_rect.origin.y = current_print_settings_.printable_area.point.y; |
1225 page_rect.size.width = current_print_settings_.printable_area.size.width; | 1222 page_rect.size.width = current_print_settings_.printable_area.size.width; |
1226 page_rect.size.height = current_print_settings_.printable_area.size.height; | 1223 page_rect.size.height = current_print_settings_.printable_area.size.height; |
1227 | 1224 |
1228 ret = metafile->RenderPage(1, canvas, page_rect, true, false, true, true); | 1225 ret = metafile.RenderPage(1, canvas, page_rect, true, false, true, true); |
1229 CGContextRestoreGState(canvas); | 1226 CGContextRestoreGState(canvas); |
1230 } | 1227 } |
1231 #elif defined(OS_WIN) | 1228 #elif defined(OS_WIN) |
1232 // On Windows, we now need to render the PDF to the DC that backs the | 1229 // On Windows, we now need to render the PDF to the DC that backs the |
1233 // supplied canvas. | 1230 // supplied canvas. |
1234 HDC dc = skia::BeginPlatformPaint(canvas); | 1231 HDC dc = skia::BeginPlatformPaint(canvas); |
1235 gfx::Size size_in_pixels; | 1232 gfx::Size size_in_pixels; |
1236 size_in_pixels.set_width( | 1233 size_in_pixels.set_width( |
1237 printing::ConvertUnit(current_print_settings_.printable_area.size.width, | 1234 printing::ConvertUnit(current_print_settings_.printable_area.size.width, |
1238 static_cast<int>(printing::kPointsPerInch), | 1235 static_cast<int>(printing::kPointsPerInch), |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1468 return found->second; | 1465 return found->second; |
1469 } | 1466 } |
1470 | 1467 |
1471 bool PluginInstance::IsFullPagePlugin() const { | 1468 bool PluginInstance::IsFullPagePlugin() const { |
1472 WebFrame* frame = container()->element().document().frame(); | 1469 WebFrame* frame = container()->element().document().frame(); |
1473 return frame->view()->mainFrame()->document().isPluginDocument(); | 1470 return frame->view()->mainFrame()->document().isPluginDocument(); |
1474 } | 1471 } |
1475 | 1472 |
1476 } // namespace ppapi | 1473 } // namespace ppapi |
1477 } // namespace webkit | 1474 } // namespace webkit |
OLD | NEW |