| 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 "content/renderer/render_widget_fullscreen_pepper.h" | 5 #include "content/renderer/render_widget_fullscreen_pepper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "content/common/gpu/client/gpu_channel_host.h" | 9 #include "content/common/gpu/client/gpu_channel_host.h" |
| 10 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 using WebKit::WebSize; | 29 using WebKit::WebSize; |
| 30 using WebKit::WebString; | 30 using WebKit::WebString; |
| 31 using WebKit::WebTextDirection; | 31 using WebKit::WebTextDirection; |
| 32 using WebKit::WebTextInputType; | 32 using WebKit::WebTextInputType; |
| 33 using WebKit::WebVector; | 33 using WebKit::WebVector; |
| 34 using WebKit::WebWidget; | 34 using WebKit::WebWidget; |
| 35 using WebKit::WGC3Dintptr; | 35 using WebKit::WGC3Dintptr; |
| 36 | 36 |
| 37 namespace { | 37 namespace { |
| 38 | 38 |
| 39 class FullscreenMouseLockDispatcher : public MouseLockDispatcher { |
| 40 public: |
| 41 explicit FullscreenMouseLockDispatcher(RenderWidgetFullscreenPepper* widget); |
| 42 virtual ~FullscreenMouseLockDispatcher(); |
| 43 |
| 44 private: |
| 45 // MouseLockDispatcher implementation. |
| 46 virtual void SendLockMouseRequest(bool unlocked_by_target) OVERRIDE; |
| 47 virtual void SendUnlockMouseRequest() OVERRIDE; |
| 48 |
| 49 RenderWidgetFullscreenPepper* widget_; |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(FullscreenMouseLockDispatcher); |
| 52 }; |
| 53 |
| 54 FullscreenMouseLockDispatcher::FullscreenMouseLockDispatcher( |
| 55 RenderWidgetFullscreenPepper* widget) : widget_(widget) { |
| 56 } |
| 57 |
| 58 FullscreenMouseLockDispatcher::~FullscreenMouseLockDispatcher() { |
| 59 } |
| 60 |
| 61 void FullscreenMouseLockDispatcher::SendLockMouseRequest( |
| 62 bool unlocked_by_target) { |
| 63 widget_->Send(new ViewHostMsg_LockMouse(widget_->routing_id(), false, |
| 64 unlocked_by_target, true)); |
| 65 } |
| 66 |
| 67 void FullscreenMouseLockDispatcher::SendUnlockMouseRequest() { |
| 68 widget_->Send(new ViewHostMsg_UnlockMouse(widget_->routing_id())); |
| 69 } |
| 70 |
| 39 // WebWidget that simply wraps the pepper plugin. | 71 // WebWidget that simply wraps the pepper plugin. |
| 40 class PepperWidget : public WebWidget { | 72 class PepperWidget : public WebWidget { |
| 41 public: | 73 public: |
| 42 explicit PepperWidget(RenderWidgetFullscreenPepper* widget) | 74 explicit PepperWidget(RenderWidgetFullscreenPepper* widget) |
| 43 : widget_(widget) { | 75 : widget_(widget) { |
| 44 } | 76 } |
| 45 | 77 |
| 46 virtual ~PepperWidget() {} | 78 virtual ~PepperWidget() {} |
| 47 | 79 |
| 48 // WebWidget API | 80 // WebWidget API |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 | 265 |
| 234 RenderWidgetFullscreenPepper::RenderWidgetFullscreenPepper( | 266 RenderWidgetFullscreenPepper::RenderWidgetFullscreenPepper( |
| 235 webkit::ppapi::PluginInstance* plugin, | 267 webkit::ppapi::PluginInstance* plugin, |
| 236 const GURL& active_url) | 268 const GURL& active_url) |
| 237 : RenderWidgetFullscreen(), | 269 : RenderWidgetFullscreen(), |
| 238 active_url_(active_url), | 270 active_url_(active_url), |
| 239 plugin_(plugin), | 271 plugin_(plugin), |
| 240 context_(NULL), | 272 context_(NULL), |
| 241 buffer_(0), | 273 buffer_(0), |
| 242 program_(0), | 274 program_(0), |
| 243 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 275 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 276 mouse_lock_dispatcher_(new FullscreenMouseLockDispatcher( |
| 277 ALLOW_THIS_IN_INITIALIZER_LIST(this))) { |
| 244 } | 278 } |
| 245 | 279 |
| 246 RenderWidgetFullscreenPepper::~RenderWidgetFullscreenPepper() { | 280 RenderWidgetFullscreenPepper::~RenderWidgetFullscreenPepper() { |
| 247 if (context_) | 281 if (context_) |
| 248 DestroyContext(context_, program_, buffer_); | 282 DestroyContext(context_, program_, buffer_); |
| 249 } | 283 } |
| 250 | 284 |
| 251 void RenderWidgetFullscreenPepper::OnViewContextSwapBuffersPosted() { | 285 void RenderWidgetFullscreenPepper::OnViewContextSwapBuffersPosted() { |
| 252 OnSwapBuffersPosted(); | 286 OnSwapBuffersPosted(); |
| 253 } | 287 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 | 343 |
| 310 webkit::ppapi::PluginDelegate::PlatformContext3D* | 344 webkit::ppapi::PluginDelegate::PlatformContext3D* |
| 311 RenderWidgetFullscreenPepper::CreateContext3D() { | 345 RenderWidgetFullscreenPepper::CreateContext3D() { |
| 312 #ifdef ENABLE_GPU | 346 #ifdef ENABLE_GPU |
| 313 return new content::PlatformContext3DImpl(this); | 347 return new content::PlatformContext3DImpl(this); |
| 314 #else | 348 #else |
| 315 return NULL; | 349 return NULL; |
| 316 #endif | 350 #endif |
| 317 } | 351 } |
| 318 | 352 |
| 353 MouseLockDispatcher* RenderWidgetFullscreenPepper::GetMouseLockDispatcher() { |
| 354 return mouse_lock_dispatcher_.get(); |
| 355 } |
| 356 |
| 357 bool RenderWidgetFullscreenPepper::OnMessageReceived(const IPC::Message& msg) { |
| 358 bool handled = true; |
| 359 IPC_BEGIN_MESSAGE_MAP(RenderWidgetFullscreenPepper, msg) |
| 360 IPC_MESSAGE_FORWARD(ViewMsg_LockMouse_ACK, |
| 361 mouse_lock_dispatcher_.get(), |
| 362 MouseLockDispatcher::OnLockMouseACK) |
| 363 IPC_MESSAGE_FORWARD(ViewMsg_MouseLockLost, |
| 364 mouse_lock_dispatcher_.get(), |
| 365 MouseLockDispatcher::OnMouseLockLost) |
| 366 IPC_MESSAGE_UNHANDLED(handled = false) |
| 367 IPC_END_MESSAGE_MAP() |
| 368 if (handled) |
| 369 return true; |
| 370 |
| 371 return RenderWidgetFullscreen::OnMessageReceived(msg); |
| 372 } |
| 373 |
| 319 void RenderWidgetFullscreenPepper::WillInitiatePaint() { | 374 void RenderWidgetFullscreenPepper::WillInitiatePaint() { |
| 320 if (plugin_) | 375 if (plugin_) |
| 321 plugin_->ViewWillInitiatePaint(); | 376 plugin_->ViewWillInitiatePaint(); |
| 322 } | 377 } |
| 323 | 378 |
| 324 void RenderWidgetFullscreenPepper::DidInitiatePaint() { | 379 void RenderWidgetFullscreenPepper::DidInitiatePaint() { |
| 325 if (plugin_) | 380 if (plugin_) |
| 326 plugin_->ViewInitiatedPaint(); | 381 plugin_->ViewInitiatedPaint(); |
| 327 } | 382 } |
| 328 | 383 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 | 571 |
| 517 WebGraphicsContext3DCommandBufferImpl* | 572 WebGraphicsContext3DCommandBufferImpl* |
| 518 RenderWidgetFullscreenPepper::GetParentContextForPlatformContext3D() { | 573 RenderWidgetFullscreenPepper::GetParentContextForPlatformContext3D() { |
| 519 if (!context_) { | 574 if (!context_) { |
| 520 CreateContext(); | 575 CreateContext(); |
| 521 } | 576 } |
| 522 if (!context_) | 577 if (!context_) |
| 523 return NULL; | 578 return NULL; |
| 524 return context_; | 579 return context_; |
| 525 } | 580 } |
| OLD | NEW |