| 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/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 #include "printing/native_metafile.h" | 62 #include "printing/native_metafile.h" |
| 63 #endif | 63 #endif |
| 64 | 64 |
| 65 #if defined(OS_MACOSX) | 65 #if defined(OS_MACOSX) |
| 66 #include "base/mac/mac_util.h" | 66 #include "base/mac/mac_util.h" |
| 67 #include "base/mac/scoped_cftyperef.h" | 67 #include "base/mac/scoped_cftyperef.h" |
| 68 #include "printing/native_metafile_factory.h" | 68 #include "printing/native_metafile_factory.h" |
| 69 #endif | 69 #endif |
| 70 | 70 |
| 71 #if defined(OS_LINUX) | 71 #if defined(OS_LINUX) |
| 72 #include "printing/pdf_ps_metafile_cairo.h" | 72 #include "printing/native_metafile_skia_wrapper.h" |
| 73 #endif | 73 #endif |
| 74 | 74 |
| 75 #if defined(OS_WIN) | 75 #if defined(OS_WIN) |
| 76 #include "ui/gfx/codec/jpeg_codec.h" | 76 #include "ui/gfx/codec/jpeg_codec.h" |
| 77 #include "ui/gfx/gdi_util.h" | 77 #include "ui/gfx/gdi_util.h" |
| 78 #endif | 78 #endif |
| 79 | 79 |
| 80 using WebKit::WebBindings; | 80 using WebKit::WebBindings; |
| 81 using WebKit::WebCanvas; | 81 using WebKit::WebCanvas; |
| 82 using WebKit::WebCursorInfo; | 82 using WebKit::WebCursorInfo; |
| (...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1173 return false; | 1173 return false; |
| 1174 RenderPDFPageToDCProc render_proc = | 1174 RenderPDFPageToDCProc render_proc = |
| 1175 reinterpret_cast<RenderPDFPageToDCProc>( | 1175 reinterpret_cast<RenderPDFPageToDCProc>( |
| 1176 GetProcAddress(pdf_module, "RenderPDFPageToDC")); | 1176 GetProcAddress(pdf_module, "RenderPDFPageToDC")); |
| 1177 if (!render_proc) | 1177 if (!render_proc) |
| 1178 return false; | 1178 return false; |
| 1179 #endif // defined(OS_WIN) | 1179 #endif // defined(OS_WIN) |
| 1180 | 1180 |
| 1181 bool ret = false; | 1181 bool ret = false; |
| 1182 #if defined(OS_LINUX) | 1182 #if defined(OS_LINUX) |
| 1183 // On Linux we need to get the backing PdfPsMetafile and write the bits | 1183 // On Linux we just set the final bits in the native metafile. |
| 1184 // directly. | |
| 1185 cairo_t* context = canvas->beginPlatformPaint(); | |
| 1186 printing::NativeMetafile* metafile = | 1184 printing::NativeMetafile* metafile = |
| 1187 printing::PdfPsMetafile::FromCairoContext(context); | 1185 printing::NativeMetafileSkiaWrapper::GetMetafileFromCanvas(canvas); |
| 1188 DCHECK(metafile); | 1186 DCHECK(metafile != NULL); |
| 1189 if (metafile) | 1187 if (metafile) |
| 1190 ret = metafile->InitFromData(buffer->mapped_buffer(), buffer->size()); | 1188 ret = metafile->InitFromData(buffer->mapped_buffer(), buffer->size()); |
| 1191 canvas->endPlatformPaint(); | |
| 1192 #elif defined(OS_MACOSX) | 1189 #elif defined(OS_MACOSX) |
| 1193 scoped_ptr<printing::NativeMetafile> metafile( | 1190 scoped_ptr<printing::NativeMetafile> metafile( |
| 1194 printing::NativeMetafileFactory::Create()); | 1191 printing::NativeMetafileFactory::Create()); |
| 1195 // Create a PDF metafile and render from there into the passed in context. | 1192 // Create a PDF metafile and render from there into the passed in context. |
| 1196 if (metafile->InitFromData(buffer->mapped_buffer(), buffer->size())) { | 1193 if (metafile->InitFromData(buffer->mapped_buffer(), buffer->size())) { |
| 1197 // Flip the transform. | 1194 // Flip the transform. |
| 1198 CGContextSaveGState(canvas); | 1195 CGContextSaveGState(canvas); |
| 1199 CGContextTranslateCTM(canvas, 0, | 1196 CGContextTranslateCTM(canvas, 0, |
| 1200 current_print_settings_.printable_area.size.height); | 1197 current_print_settings_.printable_area.size.height); |
| 1201 CGContextScaleCTM(canvas, 1.0, -1.0); | 1198 CGContextScaleCTM(canvas, 1.0, -1.0); |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1452 return found->second; | 1449 return found->second; |
| 1453 } | 1450 } |
| 1454 | 1451 |
| 1455 bool PluginInstance::IsFullPagePlugin() const { | 1452 bool PluginInstance::IsFullPagePlugin() const { |
| 1456 WebFrame* frame = container()->element().document().frame(); | 1453 WebFrame* frame = container()->element().document().frame(); |
| 1457 return frame->view()->mainFrame()->document().isPluginDocument(); | 1454 return frame->view()->mainFrame()->document().isPluginDocument(); |
| 1458 } | 1455 } |
| 1459 | 1456 |
| 1460 } // namespace ppapi | 1457 } // namespace ppapi |
| 1461 } // namespace webkit | 1458 } // namespace webkit |
| OLD | NEW |