| 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 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 if (!pdf_module) | 1055 if (!pdf_module) |
| 1056 return false; | 1056 return false; |
| 1057 RenderPDFPageToDCProc render_proc = | 1057 RenderPDFPageToDCProc render_proc = |
| 1058 reinterpret_cast<RenderPDFPageToDCProc>( | 1058 reinterpret_cast<RenderPDFPageToDCProc>( |
| 1059 GetProcAddress(pdf_module, "RenderPDFPageToDC")); | 1059 GetProcAddress(pdf_module, "RenderPDFPageToDC")); |
| 1060 if (!render_proc) | 1060 if (!render_proc) |
| 1061 return false; | 1061 return false; |
| 1062 #endif // defined(OS_WIN) | 1062 #endif // defined(OS_WIN) |
| 1063 | 1063 |
| 1064 bool ret = false; | 1064 bool ret = false; |
| 1065 #if defined(OS_LINUX) | 1065 #if defined(OS_LINUX) || (defined(OS_MACOSX) && defined(USE_SKIA)) |
| 1066 // On Linux we just set the final bits in the native metafile | 1066 // On Linux we just set the final bits in the native metafile |
| 1067 // (NativeMetafile and PreviewMetafile must have compatible formats, | 1067 // (NativeMetafile and PreviewMetafile must have compatible formats, |
| 1068 // i.e. both PDF for this to work). | 1068 // i.e. both PDF for this to work). |
| 1069 printing::Metafile* metafile = | 1069 printing::Metafile* metafile = |
| 1070 printing::MetafileSkiaWrapper::GetMetafileFromCanvas(canvas); | 1070 printing::MetafileSkiaWrapper::GetMetafileFromCanvas(canvas); |
| 1071 DCHECK(metafile != NULL); | 1071 DCHECK(metafile != NULL); |
| 1072 if (metafile) | 1072 if (metafile) |
| 1073 ret = metafile->InitFromData(mapper.data(), mapper.size()); | 1073 ret = metafile->InitFromData(mapper.data(), mapper.size()); |
| 1074 #elif defined(OS_MACOSX) | 1074 #elif defined(OS_MACOSX) |
| 1075 printing::NativeMetafile metafile; | 1075 printing::NativeMetafile metafile; |
| 1076 // Create a PDF metafile and render from there into the passed in context. | 1076 // Create a PDF metafile and render from there into the passed in context. |
| 1077 if (metafile.InitFromData(mapper.data(), mapper.size())) { | 1077 if (metafile.InitFromData(mapper.data(), mapper.size())) { |
| 1078 // Flip the transform. | 1078 // Flip the transform. |
| 1079 #if defined(USE_SKIA) | |
| 1080 gfx::SkiaBitLocker bit_locker(canvas); | |
| 1081 CGContextRef cgContext = bit_locker.cgContext(); | |
| 1082 #else | |
| 1083 CGContextRef cgContext = canvas; | 1079 CGContextRef cgContext = canvas; |
| 1084 #endif | |
| 1085 CGContextSaveGState(cgContext); | 1080 CGContextSaveGState(cgContext); |
| 1086 CGContextTranslateCTM(cgContext, 0, | 1081 CGContextTranslateCTM(cgContext, 0, |
| 1087 current_print_settings_.printable_area.size.height); | 1082 current_print_settings_.printable_area.size.height); |
| 1088 CGContextScaleCTM(cgContext, 1.0, -1.0); | 1083 CGContextScaleCTM(cgContext, 1.0, -1.0); |
| 1089 CGRect page_rect; | 1084 CGRect page_rect; |
| 1090 page_rect.origin.x = current_print_settings_.printable_area.point.x; | 1085 page_rect.origin.x = current_print_settings_.printable_area.point.x; |
| 1091 page_rect.origin.y = current_print_settings_.printable_area.point.y; | 1086 page_rect.origin.y = current_print_settings_.printable_area.point.y; |
| 1092 page_rect.size.width = current_print_settings_.printable_area.size.width; | 1087 page_rect.size.width = current_print_settings_.printable_area.size.width; |
| 1093 page_rect.size.height = current_print_settings_.printable_area.size.height; | 1088 page_rect.size.height = current_print_settings_.printable_area.size.height; |
| 1094 | 1089 |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1504 } | 1499 } |
| 1505 | 1500 |
| 1506 PP_Bool PluginInstance::GetScreenSize(PP_Instance instance, PP_Size* size) { | 1501 PP_Bool PluginInstance::GetScreenSize(PP_Instance instance, PP_Size* size) { |
| 1507 gfx::Size screen_size = delegate()->GetScreenSize(); | 1502 gfx::Size screen_size = delegate()->GetScreenSize(); |
| 1508 *size = PP_MakeSize(screen_size.width(), screen_size.height()); | 1503 *size = PP_MakeSize(screen_size.width(), screen_size.height()); |
| 1509 return PP_TRUE; | 1504 return PP_TRUE; |
| 1510 } | 1505 } |
| 1511 | 1506 |
| 1512 } // namespace ppapi | 1507 } // namespace ppapi |
| 1513 } // namespace webkit | 1508 } // namespace webkit |
| OLD | NEW |