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

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

Issue 6544028: Create a Factory for NativeMetafile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes for Mac Created 9 years, 10 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
OLDNEW
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 #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/native_metafile.h"
26 #include "printing/native_metafile_factory.h"
27 #if defined(OS_LINUX)
vandebo (ex-Chrome) 2011/02/24 22:42:50 per platform includes generally go at the end.
dpapad 2011/02/26 01:42:29 Done.
28 #include "printing/pdf_ps_metafile_cairo.h"
29 #endif
26 #include "printing/units.h" 30 #include "printing/units.h"
27 #include "skia/ext/vector_platform_device.h" 31 #include "skia/ext/vector_platform_device.h"
28 #include "skia/ext/platform_canvas.h" 32 #include "skia/ext/platform_canvas.h"
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" 39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 if (!render_proc) 1025 if (!render_proc)
1022 return false; 1026 return false;
1023 #endif // defined(OS_WIN) 1027 #endif // defined(OS_WIN)
1024 1028
1025 bool ret = false; 1029 bool ret = false;
1026 #if defined(OS_LINUX) 1030 #if defined(OS_LINUX)
1027 // On Linux we need to get the backing PdfPsMetafile and write the bits 1031 // On Linux we need to get the backing PdfPsMetafile and write the bits
1028 // directly. 1032 // directly.
1029 cairo_t* context = canvas->beginPlatformPaint(); 1033 cairo_t* context = canvas->beginPlatformPaint();
1030 printing::NativeMetafile* metafile = 1034 printing::NativeMetafile* metafile =
1031 printing::NativeMetafile::FromCairoContext(context); 1035 printing::PdfPsMetafile::FromCairoContext(context);
1032 DCHECK(metafile); 1036 DCHECK(metafile);
1033 if (metafile) 1037 if (metafile)
1034 ret = metafile->SetRawData(buffer->mapped_buffer(), buffer->size()); 1038 ret = metafile->SetRawData(buffer->mapped_buffer(), buffer->size());
1035 canvas->endPlatformPaint(); 1039 canvas->endPlatformPaint();
1036 #elif defined(OS_MACOSX) 1040 #elif defined(OS_MACOSX)
1037 printing::NativeMetafile metafile; 1041 scoped_ptr<printing::NativeMetafile> metafile(
1042 printing::NativeMetafileFactory::CreateMetafile());
1038 // Create a PDF metafile and render from there into the passed in context. 1043 // Create a PDF metafile and render from there into the passed in context.
1039 if (metafile.Init(buffer->mapped_buffer(), buffer->size())) { 1044 if (metafile->Init(buffer->mapped_buffer(), buffer->size())) {
1040 // Flip the transform. 1045 // Flip the transform.
1041 CGContextSaveGState(canvas); 1046 CGContextSaveGState(canvas);
1042 CGContextTranslateCTM(canvas, 0, 1047 CGContextTranslateCTM(canvas, 0,
1043 current_print_settings_.printable_area.size.height); 1048 current_print_settings_.printable_area.size.height);
1044 CGContextScaleCTM(canvas, 1.0, -1.0); 1049 CGContextScaleCTM(canvas, 1.0, -1.0);
1045 CGRect page_rect; 1050 CGRect page_rect;
1046 page_rect.origin.x = current_print_settings_.printable_area.point.x; 1051 page_rect.origin.x = current_print_settings_.printable_area.point.x;
1047 page_rect.origin.y = current_print_settings_.printable_area.point.y; 1052 page_rect.origin.y = current_print_settings_.printable_area.point.y;
1048 page_rect.size.width = current_print_settings_.printable_area.size.width; 1053 page_rect.size.width = current_print_settings_.printable_area.size.width;
1049 page_rect.size.height = current_print_settings_.printable_area.size.height; 1054 page_rect.size.height = current_print_settings_.printable_area.size.height;
1050 1055
1051 ret = metafile.RenderPage(1, canvas, page_rect, true, false, true, true); 1056 ret = metafile->RenderPage(1, canvas, page_rect, true, false, true, true);
1052 CGContextRestoreGState(canvas); 1057 CGContextRestoreGState(canvas);
1053 } 1058 }
1054 #elif defined(OS_WIN) 1059 #elif defined(OS_WIN)
1055 // On Windows, we now need to render the PDF to the DC that backs the 1060 // On Windows, we now need to render the PDF to the DC that backs the
1056 // supplied canvas. 1061 // supplied canvas.
1057 skia::VectorPlatformDevice& device = 1062 skia::VectorPlatformDevice& device =
1058 static_cast<skia::VectorPlatformDevice&>( 1063 static_cast<skia::VectorPlatformDevice&>(
1059 canvas->getTopPlatformDevice()); 1064 canvas->getTopPlatformDevice());
1060 HDC dc = device.getBitmapDC(); 1065 HDC dc = device.getBitmapDC();
1061 gfx::Size size_in_pixels; 1066 gfx::Size size_in_pixels;
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 return found->second; 1285 return found->second;
1281 } 1286 }
1282 1287
1283 bool PluginInstance::IsFullPagePlugin() const { 1288 bool PluginInstance::IsFullPagePlugin() const {
1284 WebFrame* frame = container()->element().document().frame(); 1289 WebFrame* frame = container()->element().document().frame();
1285 return frame->view()->mainFrame()->document().isPluginDocument(); 1290 return frame->view()->mainFrame()->document().isPluginDocument();
1286 } 1291 }
1287 1292
1288 } // namespace ppapi 1293 } // namespace ppapi
1289 } // namespace webkit 1294 } // namespace webkit
OLDNEW
« printing/printing_context_cairo.cc ('K') | « printing/printing_context_cairo.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698