| 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/npapi/webplugin_delegate_impl.h" | 5 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 #import <QuartzCore/QuartzCore.h> | 8 #import <QuartzCore/QuartzCore.h> |
| 9 #include <unistd.h> | 9 #include <unistd.h> |
| 10 | 10 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 222 |
| 223 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; | 223 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
| 224 // On dual GPU systems, force the use of the discrete GPU for | 224 // On dual GPU systems, force the use of the discrete GPU for |
| 225 // the CARenderer underlying our Core Animation backend for | 225 // the CARenderer underlying our Core Animation backend for |
| 226 // all plugins except Flash. For some reason Unity3D's output | 226 // all plugins except Flash. For some reason Unity3D's output |
| 227 // doesn't show up if the integrated GPU is used. Safari keeps | 227 // doesn't show up if the integrated GPU is used. Safari keeps |
| 228 // even Flash 11 with Stage3D on the integrated GPU, so mirror | 228 // even Flash 11 with Stage3D on the integrated GPU, so mirror |
| 229 // that behavior here. | 229 // that behavior here. |
| 230 const WebPluginInfo& plugin_info = | 230 const WebPluginInfo& plugin_info = |
| 231 instance_->plugin_lib()->plugin_info(); | 231 instance_->plugin_lib()->plugin_info(); |
| 232 if (plugin_info.name.find(ASCIIToUTF16("Flash")) != string16::npos) | 232 if (plugin_info.name.find(ASCIIToUTF16("Flash")) != |
| 233 base::string16::npos) |
| 233 gpu_preference = gfx::PreferIntegratedGpu; | 234 gpu_preference = gfx::PreferIntegratedGpu; |
| 234 surface_ = plugin_->GetAcceleratedSurface(gpu_preference); | 235 surface_ = plugin_->GetAcceleratedSurface(gpu_preference); |
| 235 | 236 |
| 236 // If surface initialization fails for some reason, just continue | 237 // If surface initialization fails for some reason, just continue |
| 237 // without any drawing; returning false would be a more confusing user | 238 // without any drawing; returning false would be a more confusing user |
| 238 // experience (since it triggers a missing plugin placeholder). | 239 // experience (since it triggers a missing plugin placeholder). |
| 239 if (surface_ && surface_->context()) { | 240 if (surface_ && surface_->context()) { |
| 240 renderer_ = [[CARenderer rendererWithCGLContext:surface_->context() | 241 renderer_ = [[CARenderer rendererWithCGLContext:surface_->context() |
| 241 options:NULL] retain]; | 242 options:NULL] retain]; |
| 242 [renderer_ setLayer:layer_]; | 243 [renderer_ setLayer:layer_]; |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 if (!clip_rect_.IsEmpty()) | 609 if (!clip_rect_.IsEmpty()) |
| 609 instance()->webplugin()->InvalidateRect(gfx::Rect()); | 610 instance()->webplugin()->InvalidateRect(gfx::Rect()); |
| 610 } | 611 } |
| 611 | 612 |
| 612 void WebPluginDelegateImpl::WindowFrameChanged(const gfx::Rect& window_frame, | 613 void WebPluginDelegateImpl::WindowFrameChanged(const gfx::Rect& window_frame, |
| 613 const gfx::Rect& view_frame) { | 614 const gfx::Rect& view_frame) { |
| 614 instance()->set_window_frame(window_frame); | 615 instance()->set_window_frame(window_frame); |
| 615 SetContentAreaOrigin(gfx::Point(view_frame.x(), view_frame.y())); | 616 SetContentAreaOrigin(gfx::Point(view_frame.x(), view_frame.y())); |
| 616 } | 617 } |
| 617 | 618 |
| 618 void WebPluginDelegateImpl::ImeCompositionCompleted(const string16& text) { | 619 void WebPluginDelegateImpl::ImeCompositionCompleted( |
| 620 const base::string16& text) { |
| 619 ime_enabled_ = false; | 621 ime_enabled_ = false; |
| 620 | 622 |
| 621 // If |text| is empty this was just called to tell us composition was | 623 // If |text| is empty this was just called to tell us composition was |
| 622 // cancelled externally (e.g., the user pressed esc). | 624 // cancelled externally (e.g., the user pressed esc). |
| 623 if (!text.empty()) { | 625 if (!text.empty()) { |
| 624 NPCocoaEvent text_event; | 626 NPCocoaEvent text_event; |
| 625 memset(&text_event, 0, sizeof(NPCocoaEvent)); | 627 memset(&text_event, 0, sizeof(NPCocoaEvent)); |
| 626 text_event.type = NPCocoaEventTextInput; | 628 text_event.type = NPCocoaEventTextInput; |
| 627 text_event.data.text.text = | 629 text_event.data.text.text = |
| 628 reinterpret_cast<NPNSString*>(base::SysUTF16ToNSString(text)); | 630 reinterpret_cast<NPNSString*>(base::SysUTF16ToNSString(text)); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 [CATransaction commit]; | 721 [CATransaction commit]; |
| 720 | 722 |
| 721 [renderer_ setBounds:[layer_ bounds]]; | 723 [renderer_ setBounds:[layer_ bounds]]; |
| 722 surface_->SetSize(window_rect_.size()); | 724 surface_->SetSize(window_rect_.size()); |
| 723 // Kick off the drawing timer, if necessary. | 725 // Kick off the drawing timer, if necessary. |
| 724 PluginVisibilityChanged(); | 726 PluginVisibilityChanged(); |
| 725 } | 727 } |
| 726 | 728 |
| 727 } // namespace npapi | 729 } // namespace npapi |
| 728 } // namespace webkit | 730 } // namespace webkit |
| OLD | NEW |