Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Side by Side Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 6594121: Revert 76553 - Applying factory pattern (through NativeMetafileFactory class)... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « printing/printing_context_cairo.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "ppapi/c/dev/ppb_find_dev.h" 11 #include "ppapi/c/dev/ppb_find_dev.h"
12 #include "ppapi/c/dev/ppb_fullscreen_dev.h" 12 #include "ppapi/c/dev/ppb_fullscreen_dev.h"
13 #include "ppapi/c/dev/ppb_zoom_dev.h" 13 #include "ppapi/c/dev/ppb_zoom_dev.h"
14 #include "ppapi/c/dev/ppp_find_dev.h" 14 #include "ppapi/c/dev/ppp_find_dev.h"
15 #include "ppapi/c/dev/ppp_selection_dev.h" 15 #include "ppapi/c/dev/ppp_selection_dev.h"
16 #include "ppapi/c/dev/ppp_zoom_dev.h" 16 #include "ppapi/c/dev/ppp_zoom_dev.h"
17 #include "ppapi/c/pp_input_event.h" 17 #include "ppapi/c/pp_input_event.h"
18 #include "ppapi/c/pp_instance.h" 18 #include "ppapi/c/pp_instance.h"
19 #include "ppapi/c/pp_rect.h" 19 #include "ppapi/c/pp_rect.h"
20 #include "ppapi/c/pp_resource.h" 20 #include "ppapi/c/pp_resource.h"
21 #include "ppapi/c/pp_var.h" 21 #include "ppapi/c/pp_var.h"
22 #include "ppapi/c/ppb_core.h" 22 #include "ppapi/c/ppb_core.h"
23 #include "ppapi/c/ppb_instance.h" 23 #include "ppapi/c/ppb_instance.h"
24 #include "ppapi/c/ppp_instance.h" 24 #include "ppapi/c/ppp_instance.h"
25 #include "printing/native_metafile.h"
25 #include "printing/units.h" 26 #include "printing/units.h"
26 #include "skia/ext/vector_platform_device.h" 27 #include "skia/ext/vector_platform_device.h"
27 #include "skia/ext/platform_canvas.h" 28 #include "skia/ext/platform_canvas.h"
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" 35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
(...skipping 11 matching lines...) Expand all
46 #include "webkit/plugins/ppapi/plugin_object.h" 47 #include "webkit/plugins/ppapi/plugin_object.h"
47 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" 48 #include "webkit/plugins/ppapi/ppb_buffer_impl.h"
48 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" 49 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
49 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" 50 #include "webkit/plugins/ppapi/ppb_image_data_impl.h"
50 #include "webkit/plugins/ppapi/ppb_surface_3d_impl.h" 51 #include "webkit/plugins/ppapi/ppb_surface_3d_impl.h"
51 #include "webkit/plugins/ppapi/ppb_url_loader_impl.h" 52 #include "webkit/plugins/ppapi/ppb_url_loader_impl.h"
52 #include "webkit/plugins/ppapi/ppp_pdf.h" 53 #include "webkit/plugins/ppapi/ppp_pdf.h"
53 #include "webkit/plugins/ppapi/string.h" 54 #include "webkit/plugins/ppapi/string.h"
54 #include "webkit/plugins/ppapi/var.h" 55 #include "webkit/plugins/ppapi/var.h"
55 56
56 #if defined(OS_POSIX)
57 #include "printing/native_metafile.h"
58 #endif
59
60 #if defined(OS_MACOSX) 57 #if defined(OS_MACOSX)
61 #include "base/mac/mac_util.h" 58 #include "base/mac/mac_util.h"
62 #include "base/mac/scoped_cftyperef.h" 59 #include "base/mac/scoped_cftyperef.h"
63 #include "printing/native_metafile_factory.h"
64 #endif
65
66 #if defined(OS_LINUX)
67 #include "printing/pdf_ps_metafile_cairo.h"
68 #endif 60 #endif
69 61
70 #if defined(OS_WIN) 62 #if defined(OS_WIN)
71 #include "ui/gfx/codec/jpeg_codec.h" 63 #include "ui/gfx/codec/jpeg_codec.h"
72 #include "ui/gfx/gdi_util.h" 64 #include "ui/gfx/gdi_util.h"
73 #endif 65 #endif
74 66
75 using WebKit::WebBindings; 67 using WebKit::WebBindings;
76 using WebKit::WebCanvas; 68 using WebKit::WebCanvas;
77 using WebKit::WebCursorInfo; 69 using WebKit::WebCursorInfo;
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 if (!render_proc) 1028 if (!render_proc)
1037 return false; 1029 return false;
1038 #endif // defined(OS_WIN) 1030 #endif // defined(OS_WIN)
1039 1031
1040 bool ret = false; 1032 bool ret = false;
1041 #if defined(OS_LINUX) 1033 #if defined(OS_LINUX)
1042 // On Linux we need to get the backing PdfPsMetafile and write the bits 1034 // On Linux we need to get the backing PdfPsMetafile and write the bits
1043 // directly. 1035 // directly.
1044 cairo_t* context = canvas->beginPlatformPaint(); 1036 cairo_t* context = canvas->beginPlatformPaint();
1045 printing::NativeMetafile* metafile = 1037 printing::NativeMetafile* metafile =
1046 printing::PdfPsMetafile::FromCairoContext(context); 1038 printing::NativeMetafile::FromCairoContext(context);
1047 DCHECK(metafile); 1039 DCHECK(metafile);
1048 if (metafile) 1040 if (metafile)
1049 ret = metafile->SetRawData(buffer->mapped_buffer(), buffer->size()); 1041 ret = metafile->SetRawData(buffer->mapped_buffer(), buffer->size());
1050 canvas->endPlatformPaint(); 1042 canvas->endPlatformPaint();
1051 #elif defined(OS_MACOSX) 1043 #elif defined(OS_MACOSX)
1052 scoped_ptr<printing::NativeMetafile> metafile( 1044 printing::NativeMetafile metafile;
1053 printing::NativeMetafileFactory::CreateMetafile());
1054 // Create a PDF metafile and render from there into the passed in context. 1045 // Create a PDF metafile and render from there into the passed in context.
1055 if (metafile->Init(buffer->mapped_buffer(), buffer->size())) { 1046 if (metafile.Init(buffer->mapped_buffer(), buffer->size())) {
1056 // Flip the transform. 1047 // Flip the transform.
1057 CGContextSaveGState(canvas); 1048 CGContextSaveGState(canvas);
1058 CGContextTranslateCTM(canvas, 0, 1049 CGContextTranslateCTM(canvas, 0,
1059 current_print_settings_.printable_area.size.height); 1050 current_print_settings_.printable_area.size.height);
1060 CGContextScaleCTM(canvas, 1.0, -1.0); 1051 CGContextScaleCTM(canvas, 1.0, -1.0);
1061 CGRect page_rect; 1052 CGRect page_rect;
1062 page_rect.origin.x = current_print_settings_.printable_area.point.x; 1053 page_rect.origin.x = current_print_settings_.printable_area.point.x;
1063 page_rect.origin.y = current_print_settings_.printable_area.point.y; 1054 page_rect.origin.y = current_print_settings_.printable_area.point.y;
1064 page_rect.size.width = current_print_settings_.printable_area.size.width; 1055 page_rect.size.width = current_print_settings_.printable_area.size.width;
1065 page_rect.size.height = current_print_settings_.printable_area.size.height; 1056 page_rect.size.height = current_print_settings_.printable_area.size.height;
1066 1057
1067 ret = metafile->RenderPage(1, canvas, page_rect, true, false, true, true); 1058 ret = metafile.RenderPage(1, canvas, page_rect, true, false, true, true);
1068 CGContextRestoreGState(canvas); 1059 CGContextRestoreGState(canvas);
1069 } 1060 }
1070 #elif defined(OS_WIN) 1061 #elif defined(OS_WIN)
1071 // On Windows, we now need to render the PDF to the DC that backs the 1062 // On Windows, we now need to render the PDF to the DC that backs the
1072 // supplied canvas. 1063 // supplied canvas.
1073 skia::VectorPlatformDevice& device = 1064 skia::VectorPlatformDevice& device =
1074 static_cast<skia::VectorPlatformDevice&>( 1065 static_cast<skia::VectorPlatformDevice&>(
1075 canvas->getTopPlatformDevice()); 1066 canvas->getTopPlatformDevice());
1076 HDC dc = device.getBitmapDC(); 1067 HDC dc = device.getBitmapDC();
1077 gfx::Size size_in_pixels; 1068 gfx::Size size_in_pixels;
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 return found->second; 1287 return found->second;
1297 } 1288 }
1298 1289
1299 bool PluginInstance::IsFullPagePlugin() const { 1290 bool PluginInstance::IsFullPagePlugin() const {
1300 WebFrame* frame = container()->element().document().frame(); 1291 WebFrame* frame = container()->element().document().frame();
1301 return frame->view()->mainFrame()->document().isPluginDocument(); 1292 return frame->view()->mainFrame()->document().isPluginDocument();
1302 } 1293 }
1303 1294
1304 } // namespace ppapi 1295 } // namespace ppapi
1305 } // namespace webkit 1296 } // namespace webkit
OLDNEW
« no previous file with comments | « printing/printing_context_cairo.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698