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

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

Issue 12437007: Pepper cleanup: USE_SKIA is always true. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 25 matching lines...) Expand all
36 #include "ppapi/shared_impl/ppb_input_event_shared.h" 36 #include "ppapi/shared_impl/ppb_input_event_shared.h"
37 #include "ppapi/shared_impl/ppb_url_util_shared.h" 37 #include "ppapi/shared_impl/ppb_url_util_shared.h"
38 #include "ppapi/shared_impl/ppb_view_shared.h" 38 #include "ppapi/shared_impl/ppb_view_shared.h"
39 #include "ppapi/shared_impl/ppp_instance_combined.h" 39 #include "ppapi/shared_impl/ppp_instance_combined.h"
40 #include "ppapi/shared_impl/resource.h" 40 #include "ppapi/shared_impl/resource.h"
41 #include "ppapi/shared_impl/scoped_pp_resource.h" 41 #include "ppapi/shared_impl/scoped_pp_resource.h"
42 #include "ppapi/shared_impl/time_conversion.h" 42 #include "ppapi/shared_impl/time_conversion.h"
43 #include "ppapi/shared_impl/var.h" 43 #include "ppapi/shared_impl/var.h"
44 #include "ppapi/thunk/enter.h" 44 #include "ppapi/thunk/enter.h"
45 #include "ppapi/thunk/ppb_buffer_api.h" 45 #include "ppapi/thunk/ppb_buffer_api.h"
46 #include "printing/metafile.h"
47 #include "printing/metafile_skia_wrapper.h"
46 #include "printing/units.h" 48 #include "printing/units.h"
49 #include "skia/ext/platform_device.h"
47 #include "third_party/WebKit/Source/Platform/chromium/public/WebGamepads.h" 50 #include "third_party/WebKit/Source/Platform/chromium/public/WebGamepads.h"
48 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" 51 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
49 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" 52 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h"
50 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h" 53 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h"
51 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" 54 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
52 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli ne.h" 55 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli ne.h"
53 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" 56 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
54 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 57 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
55 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" 58 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
56 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 59 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
(...skipping 24 matching lines...) Expand all
81 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" 84 #include "webkit/plugins/ppapi/ppb_buffer_impl.h"
82 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" 85 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h"
83 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" 86 #include "webkit/plugins/ppapi/ppb_image_data_impl.h"
84 #include "webkit/plugins/ppapi/ppb_url_loader_impl.h" 87 #include "webkit/plugins/ppapi/ppb_url_loader_impl.h"
85 #include "webkit/plugins/ppapi/ppp_pdf.h" 88 #include "webkit/plugins/ppapi/ppp_pdf.h"
86 #include "webkit/plugins/ppapi/url_request_info_util.h" 89 #include "webkit/plugins/ppapi/url_request_info_util.h"
87 #include "webkit/plugins/sad_plugin.h" 90 #include "webkit/plugins/sad_plugin.h"
88 91
89 #if defined(OS_MACOSX) 92 #if defined(OS_MACOSX)
90 #include "printing/metafile_impl.h" 93 #include "printing/metafile_impl.h"
91 #if !defined(USE_SKIA)
92 #include "base/mac/mac_util.h"
93 #include "base/mac/scoped_cftyperef.h"
94 #endif // !defined(USE_SKIA)
95 #endif // defined(OS_MACOSX) 94 #endif // defined(OS_MACOSX)
96 95
97 #if defined(USE_SKIA)
98 #include "printing/metafile.h"
99 #include "printing/metafile_skia_wrapper.h"
100 #include "skia/ext/platform_device.h"
101 #endif
102
103 #if defined(OS_WIN) 96 #if defined(OS_WIN)
104 #include "base/metrics/histogram.h" 97 #include "base/metrics/histogram.h"
105 #include "base/win/windows_version.h" 98 #include "base/win/windows_version.h"
106 #include "skia/ext/platform_canvas.h" 99 #include "skia/ext/platform_canvas.h"
107 #include "ui/gfx/codec/jpeg_codec.h" 100 #include "ui/gfx/codec/jpeg_codec.h"
108 #include "ui/gfx/gdi_util.h" 101 #include "ui/gfx/gdi_util.h"
109 #endif 102 #endif
110 103
111 using base::StringPrintf; 104 using base::StringPrintf;
112 using ppapi::InputEventData; 105 using ppapi::InputEventData;
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 print_settings.orientation = PP_PRINTORIENTATION_NORMAL; 1306 print_settings.orientation = PP_PRINTORIENTATION_NORMAL;
1314 print_settings.grayscale = PP_FALSE; 1307 print_settings.grayscale = PP_FALSE;
1315 print_settings.print_scaling_option = static_cast<PP_PrintScalingOption_Dev>( 1308 print_settings.print_scaling_option = static_cast<PP_PrintScalingOption_Dev>(
1316 print_params.printScalingOption); 1309 print_params.printScalingOption);
1317 print_settings.format = format; 1310 print_settings.format = format;
1318 num_pages = plugin_print_interface_->Begin(pp_instance(), 1311 num_pages = plugin_print_interface_->Begin(pp_instance(),
1319 &print_settings); 1312 &print_settings);
1320 if (!num_pages) 1313 if (!num_pages)
1321 return 0; 1314 return 0;
1322 current_print_settings_ = print_settings; 1315 current_print_settings_ = print_settings;
1323 #if defined(USE_SKIA)
1324 canvas_ = NULL; 1316 canvas_ = NULL;
1325 ranges_.clear(); 1317 ranges_.clear();
1326 #endif // USE_SKIA
1327 return num_pages; 1318 return num_pages;
1328 } 1319 }
1329 1320
1330 bool PluginInstance::PrintPage(int page_number, WebKit::WebCanvas* canvas) { 1321 bool PluginInstance::PrintPage(int page_number, WebKit::WebCanvas* canvas) {
1331 #if defined(ENABLE_PRINTING) 1322 #if defined(ENABLE_PRINTING)
1332 DCHECK(plugin_print_interface_); 1323 DCHECK(plugin_print_interface_);
1333 PP_PrintPageNumberRange_Dev page_range; 1324 PP_PrintPageNumberRange_Dev page_range;
1334 page_range.first_page_number = page_range.last_page_number = page_number; 1325 page_range.first_page_number = page_range.last_page_number = page_number;
1335 #if defined(USE_SKIA)
1336 // The canvas only has a metafile on it for print preview. 1326 // The canvas only has a metafile on it for print preview.
1337 bool save_for_later = 1327 bool save_for_later =
1338 (printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas) != NULL); 1328 (printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas) != NULL);
1339 #if defined(OS_MACOSX) || defined(OS_WIN) 1329 #if defined(OS_MACOSX) || defined(OS_WIN)
1340 save_for_later = save_for_later && skia::IsPreviewMetafile(*canvas); 1330 save_for_later = save_for_later && skia::IsPreviewMetafile(*canvas);
1341 #endif 1331 #endif
1342 if (save_for_later) { 1332 if (save_for_later) {
1343 ranges_.push_back(page_range); 1333 ranges_.push_back(page_range);
1344 canvas_ = canvas; 1334 canvas_ = canvas;
1345 return true; 1335 return true;
1346 } else 1336 } else {
1347 #endif // USE_SKIA
1348 {
1349 return PrintPageHelper(&page_range, 1, canvas); 1337 return PrintPageHelper(&page_range, 1, canvas);
1350 } 1338 }
1351 #else // defined(ENABLED_PRINTING) 1339 #else // defined(ENABLED_PRINTING)
1352 return false; 1340 return false;
1353 #endif 1341 #endif
1354 } 1342 }
1355 1343
1356 bool PluginInstance::PrintPageHelper(PP_PrintPageNumberRange_Dev* page_ranges, 1344 bool PluginInstance::PrintPageHelper(PP_PrintPageNumberRange_Dev* page_ranges,
1357 int num_ranges, 1345 int num_ranges,
1358 WebKit::WebCanvas* canvas) { 1346 WebKit::WebCanvas* canvas) {
(...skipping 14 matching lines...) Expand all
1373 1361
1374 // Now we need to release the print output resource. 1362 // Now we need to release the print output resource.
1375 PluginModule::GetCore()->ReleaseResource(print_output); 1363 PluginModule::GetCore()->ReleaseResource(print_output);
1376 1364
1377 return ret; 1365 return ret;
1378 } 1366 }
1379 1367
1380 void PluginInstance::PrintEnd() { 1368 void PluginInstance::PrintEnd() {
1381 // Keep a reference on the stack. See NOTE above. 1369 // Keep a reference on the stack. See NOTE above.
1382 scoped_refptr<PluginInstance> ref(this); 1370 scoped_refptr<PluginInstance> ref(this);
1383 #if defined(USE_SKIA)
1384 if (!ranges_.empty()) 1371 if (!ranges_.empty())
1385 PrintPageHelper(&(ranges_.front()), ranges_.size(), canvas_.get()); 1372 PrintPageHelper(&(ranges_.front()), ranges_.size(), canvas_.get());
1386 canvas_ = NULL; 1373 canvas_ = NULL;
1387 ranges_.clear(); 1374 ranges_.clear();
1388 #endif // USE_SKIA
1389 1375
1390 DCHECK(plugin_print_interface_); 1376 DCHECK(plugin_print_interface_);
1391 if (plugin_print_interface_) 1377 if (plugin_print_interface_)
1392 plugin_print_interface_->End(pp_instance()); 1378 plugin_print_interface_->End(pp_instance());
1393 1379
1394 memset(&current_print_settings_, 0, sizeof(current_print_settings_)); 1380 memset(&current_print_settings_, 0, sizeof(current_print_settings_));
1395 #if defined(OS_MACOSX) 1381 #if defined(OS_MACOSX)
1396 last_printed_page_ = NULL; 1382 last_printed_page_ = NULL;
1397 #endif // defined(OS_MACOSX) 1383 #endif // defined(OS_MACOSX)
1398 } 1384 }
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1630 if (!pdf_module) 1616 if (!pdf_module)
1631 return false; 1617 return false;
1632 RenderPDFPageToDCProc render_proc = 1618 RenderPDFPageToDCProc render_proc =
1633 reinterpret_cast<RenderPDFPageToDCProc>( 1619 reinterpret_cast<RenderPDFPageToDCProc>(
1634 GetProcAddress(pdf_module, "RenderPDFPageToDC")); 1620 GetProcAddress(pdf_module, "RenderPDFPageToDC"));
1635 if (!render_proc) 1621 if (!render_proc)
1636 return false; 1622 return false;
1637 #endif // defined(OS_WIN) 1623 #endif // defined(OS_WIN)
1638 1624
1639 bool ret = false; 1625 bool ret = false;
1640 #if defined(OS_LINUX) || (defined(OS_MACOSX) && defined(USE_SKIA)) 1626 #if defined(OS_LINUX) || defined(OS_MACOSX)
1641 // On Linux we just set the final bits in the native metafile 1627 // On Linux we just set the final bits in the native metafile
1642 // (NativeMetafile and PreviewMetafile must have compatible formats, 1628 // (NativeMetafile and PreviewMetafile must have compatible formats,
1643 // i.e. both PDF for this to work). 1629 // i.e. both PDF for this to work).
1644 printing::Metafile* metafile = 1630 printing::Metafile* metafile =
1645 printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas); 1631 printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas);
1646 DCHECK(metafile != NULL); 1632 DCHECK(metafile != NULL);
1647 if (metafile) 1633 if (metafile)
1648 ret = metafile->InitFromData(mapper.data(), mapper.size()); 1634 ret = metafile->InitFromData(mapper.data(), mapper.size());
1649 #elif defined(OS_MACOSX)
1650 printing::NativeMetafile metafile;
1651 // Create a PDF metafile and render from there into the passed in context.
1652 if (metafile.InitFromData(mapper.data(), mapper.size())) {
1653 // Flip the transform.
1654 CGContextRef cgContext = canvas;
1655 gfx::ScopedCGContextSaveGState save_gstate(cgContext)
1656 CGContextTranslateCTM(cgContext, 0,
1657 current_print_settings_.printable_area.size.height);
1658 CGContextScaleCTM(cgContext, 1.0, -1.0);
1659 CGRect page_rect;
1660 page_rect.origin.x = current_print_settings_.printable_area.point.x;
1661 page_rect.origin.y = current_print_settings_.printable_area.point.y;
1662 page_rect.size.width = current_print_settings_.printable_area.size.width;
1663 page_rect.size.height = current_print_settings_.printable_area.size.height;
1664
1665 ret = metafile.RenderPage(1, cgContext, page_rect, true, false, true, true);
1666 }
1667 #elif defined(OS_WIN) 1635 #elif defined(OS_WIN)
1668 printing::Metafile* metafile = 1636 printing::Metafile* metafile =
1669 printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas); 1637 printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas);
1670 if (metafile) { 1638 if (metafile) {
1671 // We only have a metafile when doing print preview, so we just want to 1639 // We only have a metafile when doing print preview, so we just want to
1672 // pass the PDF off to preview. 1640 // pass the PDF off to preview.
1673 ret = metafile->InitFromData(mapper.data(), mapper.size()); 1641 ret = metafile->InitFromData(mapper.data(), mapper.size());
1674 } else { 1642 } else {
1675 // On Windows, we now need to render the PDF to the DC that backs the 1643 // On Windows, we now need to render the PDF to the DC that backs the
1676 // supplied canvas. 1644 // supplied canvas.
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
2514 screen_size_for_fullscreen_ = gfx::Size(); 2482 screen_size_for_fullscreen_ = gfx::Size();
2515 WebElement element = container_->element(); 2483 WebElement element = container_->element();
2516 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); 2484 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_);
2517 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); 2485 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_);
2518 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); 2486 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_);
2519 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); 2487 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_);
2520 } 2488 }
2521 2489
2522 } // namespace ppapi 2490 } // namespace ppapi
2523 } // namespace webkit 2491 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppapi_plugin_instance.h ('k') | webkit/plugins/ppapi/ppb_graphics_2d_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698