OLD | NEW |
---|---|
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/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
22 #include "ppapi/c/pp_rect.h" | 22 #include "ppapi/c/pp_rect.h" |
23 #include "ppapi/c/ppb_audio_config.h" | 23 #include "ppapi/c/ppb_audio_config.h" |
24 #include "ppapi/c/ppb_core.h" | 24 #include "ppapi/c/ppb_core.h" |
25 #include "ppapi/c/ppb_gamepad.h" | 25 #include "ppapi/c/ppb_gamepad.h" |
26 #include "ppapi/c/ppp_input_event.h" | 26 #include "ppapi/c/ppp_input_event.h" |
27 #include "ppapi/c/ppp_instance.h" | 27 #include "ppapi/c/ppp_instance.h" |
28 #include "ppapi/c/ppp_messaging.h" | 28 #include "ppapi/c/ppp_messaging.h" |
29 #include "ppapi/c/ppp_mouse_lock.h" | 29 #include "ppapi/c/ppp_mouse_lock.h" |
30 #include "ppapi/c/private/pp_content_decryptor.h" | 30 #include "ppapi/c/private/pp_content_decryptor.h" |
31 #include "ppapi/c/private/ppp_instance_private.h" | 31 #include "ppapi/c/private/ppp_instance_private.h" |
32 #include "ppapi/shared_impl/ppapi_preferences.h" | |
32 #include "ppapi/shared_impl/ppb_input_event_shared.h" | 33 #include "ppapi/shared_impl/ppb_input_event_shared.h" |
33 #include "ppapi/shared_impl/ppb_url_util_shared.h" | 34 #include "ppapi/shared_impl/ppb_url_util_shared.h" |
34 #include "ppapi/shared_impl/ppb_view_shared.h" | 35 #include "ppapi/shared_impl/ppb_view_shared.h" |
35 #include "ppapi/shared_impl/ppp_instance_combined.h" | 36 #include "ppapi/shared_impl/ppp_instance_combined.h" |
36 #include "ppapi/shared_impl/resource.h" | 37 #include "ppapi/shared_impl/resource.h" |
37 #include "ppapi/shared_impl/scoped_pp_resource.h" | 38 #include "ppapi/shared_impl/scoped_pp_resource.h" |
38 #include "ppapi/shared_impl/time_conversion.h" | 39 #include "ppapi/shared_impl/time_conversion.h" |
39 #include "ppapi/shared_impl/var.h" | 40 #include "ppapi/shared_impl/var.h" |
40 #include "ppapi/thunk/enter.h" | 41 #include "ppapi/thunk/enter.h" |
41 #include "ppapi/thunk/ppb_buffer_api.h" | 42 #include "ppapi/thunk/ppb_buffer_api.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 #endif // defined(OS_MACOSX) | 90 #endif // defined(OS_MACOSX) |
90 | 91 |
91 #if defined(USE_SKIA) | 92 #if defined(USE_SKIA) |
92 #include "printing/metafile.h" | 93 #include "printing/metafile.h" |
93 #include "printing/metafile_skia_wrapper.h" | 94 #include "printing/metafile_skia_wrapper.h" |
94 #include "skia/ext/platform_device.h" | 95 #include "skia/ext/platform_device.h" |
95 #endif | 96 #endif |
96 | 97 |
97 #if defined(OS_WIN) | 98 #if defined(OS_WIN) |
98 #include "base/metrics/histogram.h" | 99 #include "base/metrics/histogram.h" |
100 #include "base/win/windows_version.h" | |
99 #include "skia/ext/platform_canvas.h" | 101 #include "skia/ext/platform_canvas.h" |
100 #include "ui/gfx/codec/jpeg_codec.h" | 102 #include "ui/gfx/codec/jpeg_codec.h" |
101 #include "ui/gfx/gdi_util.h" | 103 #include "ui/gfx/gdi_util.h" |
102 #endif | 104 #endif |
103 | 105 |
104 using base::StringPrintf; | 106 using base::StringPrintf; |
105 using ppapi::InputEventData; | 107 using ppapi::InputEventData; |
106 using ppapi::PpapiGlobals; | 108 using ppapi::PpapiGlobals; |
107 using ppapi::PPB_InputEvent_Shared; | 109 using ppapi::PPB_InputEvent_Shared; |
108 using ppapi::PPB_View_Shared; | 110 using ppapi::PPB_View_Shared; |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 // Free any associated graphics. | 528 // Free any associated graphics. |
527 SetFullscreen(false); | 529 SetFullscreen(false); |
528 FlashSetFullscreen(false, false); | 530 FlashSetFullscreen(false, false); |
529 // Unbind current 2D or 3D graphics context. | 531 // Unbind current 2D or 3D graphics context. |
530 BindGraphics(pp_instance(), 0); | 532 BindGraphics(pp_instance(), 0); |
531 InvalidateRect(gfx::Rect()); | 533 InvalidateRect(gfx::Rect()); |
532 | 534 |
533 delegate()->PluginCrashed(this); | 535 delegate()->PluginCrashed(this); |
534 } | 536 } |
535 | 537 |
538 static void SetGPUHistogram(const ::ppapi::Preferences& prefs, | |
539 const std::vector<std::string>& arg_names, | |
540 const std::vector<std::string>& arg_values) { | |
541 // Calculate a histogram to let us determine how likely people are to try to | |
542 // run Stage3D content on machines that have it blacklisted. This only tests | |
543 // on XP at the moment. | |
544 #if defined(OS_WIN) | |
545 if (base::win::GetVersion() <= base::win::VERSION_XP) { | |
546 bool needs_gpu = false; | |
547 | |
548 for (size_t i = 0; i < arg_names.size(); i++) { | |
549 if (arg_names[i] == "wmode") { | |
550 // In theory content other than Flash could have a "wmode" argument, | |
551 // but that's pretty unlikely. | |
552 if (arg_values[i] == "direct" || arg_values[i] == "gpu") | |
553 needs_gpu = true; | |
554 break; | |
555 } | |
556 } | |
557 // The value of this histogram is 1 or 3 if 3D is not blacklisted on this | |
558 // card, and 2 or 3 if the content needs the GPU. | |
vangelis
2012/08/28 17:30:23
Maybe it would be more clear to enumerate the pote
| |
559 UMA_HISTOGRAM_ENUMERATION("Flash.UsesGPU", | |
560 needs_gpu * 2 + prefs.is_webgl_supported, 4); | |
561 } | |
562 #endif | |
563 } | |
564 | |
536 bool PluginInstance::Initialize(WebPluginContainer* container, | 565 bool PluginInstance::Initialize(WebPluginContainer* container, |
537 const std::vector<std::string>& arg_names, | 566 const std::vector<std::string>& arg_names, |
538 const std::vector<std::string>& arg_values, | 567 const std::vector<std::string>& arg_values, |
539 const GURL& plugin_url, | 568 const GURL& plugin_url, |
540 bool full_frame) { | 569 bool full_frame) { |
541 container_ = container; | 570 container_ = container; |
542 plugin_url_ = plugin_url; | 571 plugin_url_ = plugin_url; |
543 full_frame_ = full_frame; | 572 full_frame_ = full_frame; |
544 | 573 |
545 container_->setIsAcceptingTouchEvents(IsAcceptingTouchEvents()); | 574 container_->setIsAcceptingTouchEvents(IsAcceptingTouchEvents()); |
546 | 575 |
576 SetGPUHistogram(delegate_->GetPreferences(), arg_names, arg_values); | |
577 | |
547 argn_ = arg_names; | 578 argn_ = arg_names; |
548 argv_ = arg_values; | 579 argv_ = arg_values; |
549 scoped_array<const char*> argn_array(StringVectorToArgArray(argn_)); | 580 scoped_array<const char*> argn_array(StringVectorToArgArray(argn_)); |
550 scoped_array<const char*> argv_array(StringVectorToArgArray(argv_)); | 581 scoped_array<const char*> argv_array(StringVectorToArgArray(argv_)); |
551 return PP_ToBool(instance_interface_->DidCreate(pp_instance(), | 582 return PP_ToBool(instance_interface_->DidCreate(pp_instance(), |
552 argn_.size(), | 583 argn_.size(), |
553 argn_array.get(), | 584 argn_array.get(), |
554 argv_array.get())); | 585 argv_array.get())); |
555 } | 586 } |
556 | 587 |
(...skipping 1876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2433 screen_size_for_fullscreen_ = gfx::Size(); | 2464 screen_size_for_fullscreen_ = gfx::Size(); |
2434 WebElement element = container_->element(); | 2465 WebElement element = container_->element(); |
2435 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2466 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
2436 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2467 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
2437 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2468 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
2438 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2469 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
2439 } | 2470 } |
2440 | 2471 |
2441 } // namespace ppapi | 2472 } // namespace ppapi |
2442 } // namespace webkit | 2473 } // namespace webkit |
OLD | NEW |