OLD | NEW |
---|---|
1 // Copyright (c) 2010 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 #define PEPPER_APIS_ENABLED 1 | 5 #define PEPPER_APIS_ENABLED 1 |
6 | 6 |
7 #include "chrome/renderer/webplugin_delegate_pepper.h" | 7 #include "chrome/renderer/webplugin_delegate_pepper.h" |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 #include "chrome/renderer/renderer_sandbox_support_linux.h" | 43 #include "chrome/renderer/renderer_sandbox_support_linux.h" |
44 #endif | 44 #endif |
45 #include "chrome/renderer/webplugin_delegate_proxy.h" | 45 #include "chrome/renderer/webplugin_delegate_proxy.h" |
46 #include "ui/gfx/blit.h" | 46 #include "ui/gfx/blit.h" |
47 #if defined(OS_WIN) | 47 #if defined(OS_WIN) |
48 #include "printing/units.h" | 48 #include "printing/units.h" |
49 #include "skia/ext/vector_platform_device.h" | 49 #include "skia/ext/vector_platform_device.h" |
50 #include "ui/gfx/codec/jpeg_codec.h" | 50 #include "ui/gfx/codec/jpeg_codec.h" |
51 #include "ui/gfx/gdi_util.h" | 51 #include "ui/gfx/gdi_util.h" |
52 #endif | 52 #endif |
53 #include "printing/native_metafile_factory.h" | |
53 #include "printing/native_metafile.h" | 54 #include "printing/native_metafile.h" |
55 #if defined(OS_LINUX) | |
56 #include "printing/pdf_ps_metafile_cairo.h" | |
kmadhusu
2011/03/01 19:42:38
As per Chromium coding-style, platform-specific he
dpapad
2011/03/01 22:41:24
Done.
| |
57 #endif | |
54 #include "third_party/npapi/bindings/npapi_extensions.h" | 58 #include "third_party/npapi/bindings/npapi_extensions.h" |
55 #include "third_party/npapi/bindings/npapi_extensions_private.h" | 59 #include "third_party/npapi/bindings/npapi_extensions_private.h" |
56 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 60 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
57 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 61 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
58 #include "webkit/glue/webcursor.h" | 62 #include "webkit/glue/webcursor.h" |
59 #include "webkit/glue/webkit_glue.h" | 63 #include "webkit/glue/webkit_glue.h" |
60 #include "webkit/plugins/npapi/plugin_constants_win.h" | 64 #include "webkit/plugins/npapi/plugin_constants_win.h" |
61 #include "webkit/plugins/npapi/plugin_instance.h" | 65 #include "webkit/plugins/npapi/plugin_instance.h" |
62 #include "webkit/plugins/npapi/plugin_lib.h" | 66 #include "webkit/plugins/npapi/plugin_lib.h" |
63 #include "webkit/plugins/npapi/plugin_list.h" | 67 #include "webkit/plugins/npapi/plugin_list.h" |
(...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1215 &pdf_output, &output_size); | 1219 &pdf_output, &output_size); |
1216 if (err != NPERR_NO_ERROR) | 1220 if (err != NPERR_NO_ERROR) |
1217 return false; | 1221 return false; |
1218 | 1222 |
1219 bool ret = false; | 1223 bool ret = false; |
1220 #if defined(OS_LINUX) | 1224 #if defined(OS_LINUX) |
1221 // On Linux we need to get the backing PdfPsMetafile and write the bits | 1225 // On Linux we need to get the backing PdfPsMetafile and write the bits |
1222 // directly. | 1226 // directly. |
1223 cairo_t* context = canvas->beginPlatformPaint(); | 1227 cairo_t* context = canvas->beginPlatformPaint(); |
1224 printing::NativeMetafile* metafile = | 1228 printing::NativeMetafile* metafile = |
1225 printing::NativeMetafile::FromCairoContext(context); | 1229 printing::PdfPsMetafile::FromCairoContext(context); |
1226 DCHECK(metafile); | 1230 DCHECK(metafile); |
1227 if (metafile) { | 1231 if (metafile) { |
1228 ret = metafile->SetRawData(pdf_output, output_size); | 1232 ret = metafile->SetRawData(pdf_output, output_size); |
1229 if (ret) | 1233 if (ret) |
1230 pdf_output_done_ = true; | 1234 pdf_output_done_ = true; |
1231 } | 1235 } |
1232 canvas->endPlatformPaint(); | 1236 canvas->endPlatformPaint(); |
1233 #elif defined(OS_MACOSX) | 1237 #elif defined(OS_MACOSX) |
1234 printing::NativeMetafile metafile; | 1238 scoped_ptr<printing::NativeMetafile> metafile( |
1239 printing::NativeMetafileFactory::CreateMetafile()); | |
1235 // Create a PDF metafile and render from there into the passed in context. | 1240 // Create a PDF metafile and render from there into the passed in context. |
1236 if (metafile.Init(pdf_output, output_size)) { | 1241 if (metafile->Init(pdf_output, output_size)) { |
1237 // Flip the transform. | 1242 // Flip the transform. |
1238 CGContextSaveGState(canvas); | 1243 CGContextSaveGState(canvas); |
1239 CGContextTranslateCTM(canvas, 0, current_printable_area_.height()); | 1244 CGContextTranslateCTM(canvas, 0, current_printable_area_.height()); |
1240 CGContextScaleCTM(canvas, 1.0, -1.0); | 1245 CGContextScaleCTM(canvas, 1.0, -1.0); |
1241 ret = metafile.RenderPage(1, canvas, current_printable_area_.ToCGRect(), | 1246 ret = metafile->RenderPage(1, canvas, current_printable_area_.ToCGRect(), |
1242 true, false, true, true); | 1247 true, false, true, true); |
1243 CGContextRestoreGState(canvas); | 1248 CGContextRestoreGState(canvas); |
1244 } | 1249 } |
1245 #elif defined(OS_WIN) | 1250 #elif defined(OS_WIN) |
1246 // On Windows, we now need to render the PDF to the DC that backs the | 1251 // On Windows, we now need to render the PDF to the DC that backs the |
1247 // supplied canvas. | 1252 // supplied canvas. |
1248 skia::VectorPlatformDevice& device = | 1253 skia::VectorPlatformDevice& device = |
1249 static_cast<skia::VectorPlatformDevice&>( | 1254 static_cast<skia::VectorPlatformDevice&>( |
1250 canvas->getTopPlatformDevice()); | 1255 canvas->getTopPlatformDevice()); |
1251 HDC dc = device.getBitmapDC(); | 1256 HDC dc = device.getBitmapDC(); |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1760 CGRect bounds; | 1765 CGRect bounds; |
1761 bounds.origin.x = dest_rect.x(); | 1766 bounds.origin.x = dest_rect.x(); |
1762 bounds.origin.y = canvas_height - dest_rect.y() - dest_rect.height(); | 1767 bounds.origin.y = canvas_height - dest_rect.y() - dest_rect.height(); |
1763 bounds.size.width = dest_rect.width(); | 1768 bounds.size.width = dest_rect.width(); |
1764 bounds.size.height = dest_rect.height(); | 1769 bounds.size.height = dest_rect.height(); |
1765 | 1770 |
1766 CGContextDrawImage(canvas, bounds, image); | 1771 CGContextDrawImage(canvas, bounds, image); |
1767 CGContextRestoreGState(canvas); | 1772 CGContextRestoreGState(canvas); |
1768 } | 1773 } |
1769 #endif // defined(OS_MACOSX) | 1774 #endif // defined(OS_MACOSX) |
OLD | NEW |