Chromium Code Reviews| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 444 } | 444 } |
| 445 | 445 |
| 446 void RenderWidgetFullscreenPepper::DidChangeCursor( | 446 void RenderWidgetFullscreenPepper::DidChangeCursor( |
| 447 const WebKit::WebCursorInfo& cursor) { | 447 const WebKit::WebCursorInfo& cursor) { |
| 448 didChangeCursor(cursor); | 448 didChangeCursor(cursor); |
| 449 } | 449 } |
| 450 | 450 |
| 451 webkit::ppapi::PluginDelegate::PlatformContext3D* | 451 webkit::ppapi::PluginDelegate::PlatformContext3D* |
| 452 RenderWidgetFullscreenPepper::CreateContext3D() { | 452 RenderWidgetFullscreenPepper::CreateContext3D() { |
| 453 #ifdef ENABLE_GPU | 453 #ifdef ENABLE_GPU |
| 454 return new PlatformContext3DImpl(this); | 454 return new PlatformContext3DImpl; |
| 455 #else | 455 #else |
| 456 return NULL; | 456 return NULL; |
| 457 #endif | 457 #endif |
| 458 } | 458 } |
| 459 | 459 |
| 460 void RenderWidgetFullscreenPepper::ReparentContext( | |
| 461 webkit::ppapi::PluginDelegate::PlatformContext3D* context) { | |
| 462 static_cast<PlatformContext3DImpl*>(context)->SetParentContext(this); | |
| 463 } | |
| 464 | |
| 465 bool RenderWidgetFullscreenPepper::OnMessageReceived(const IPC::Message& msg) { | 460 bool RenderWidgetFullscreenPepper::OnMessageReceived(const IPC::Message& msg) { |
| 466 bool handled = true; | 461 bool handled = true; |
| 467 IPC_BEGIN_MESSAGE_MAP(RenderWidgetFullscreenPepper, msg) | 462 IPC_BEGIN_MESSAGE_MAP(RenderWidgetFullscreenPepper, msg) |
| 468 IPC_MESSAGE_FORWARD(ViewMsg_LockMouse_ACK, | 463 IPC_MESSAGE_FORWARD(ViewMsg_LockMouse_ACK, |
| 469 mouse_lock_dispatcher_.get(), | 464 mouse_lock_dispatcher_.get(), |
| 470 MouseLockDispatcher::OnLockMouseACK) | 465 MouseLockDispatcher::OnLockMouseACK) |
| 471 IPC_MESSAGE_FORWARD(ViewMsg_MouseLockLost, | 466 IPC_MESSAGE_FORWARD(ViewMsg_MouseLockLost, |
| 472 mouse_lock_dispatcher_.get(), | 467 mouse_lock_dispatcher_.get(), |
| 473 MouseLockDispatcher::OnMouseLockLost) | 468 MouseLockDispatcher::OnMouseLockLost) |
| 474 IPC_MESSAGE_UNHANDLED(handled = false) | 469 IPC_MESSAGE_UNHANDLED(handled = false) |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 558 | 553 |
| 559 void RenderWidgetFullscreenPepper::CreateContext() { | 554 void RenderWidgetFullscreenPepper::CreateContext() { |
| 560 DCHECK(!context_); | 555 DCHECK(!context_); |
| 561 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 556 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 562 if (command_line->HasSwitch(switches::kDisableFlashFullscreen3d)) | 557 if (command_line->HasSwitch(switches::kDisableFlashFullscreen3d)) |
| 563 return; | 558 return; |
| 564 WebKit::WebGraphicsContext3D::Attributes attributes; | 559 WebKit::WebGraphicsContext3D::Attributes attributes; |
| 565 attributes.depth = false; | 560 attributes.depth = false; |
| 566 attributes.stencil = false; | 561 attributes.stencil = false; |
| 567 attributes.antialias = false; | 562 attributes.antialias = false; |
| 568 attributes.shareResources = false; | 563 attributes.shareResources = true; |
| 569 attributes.preferDiscreteGPU = true; | 564 attributes.preferDiscreteGPU = true; |
| 570 context_ = WebGraphicsContext3DCommandBufferImpl::CreateViewContext( | 565 context_ = WebGraphicsContext3DCommandBufferImpl::CreateViewContext( |
| 571 RenderThreadImpl::current(), | 566 RenderThreadImpl::current(), |
| 572 surface_id(), | 567 surface_id(), |
| 573 NULL, | 568 NULL, |
| 574 attributes, | 569 attributes, |
| 575 true /* bind generates resources */, | 570 true /* bind generates resources */, |
| 576 active_url_, | 571 active_url_, |
| 577 CAUSE_FOR_GPU_LAUNCH_RENDERWIDGETFULLSCREENPEPPER_CREATECONTEXT); | 572 CAUSE_FOR_GPU_LAUNCH_RENDERWIDGETFULLSCREENPEPPER_CREATECONTEXT); |
| 578 if (!context_) | 573 if (!context_) |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 677 kTexCoords, | 672 kTexCoords, |
| 678 GL_STATIC_DRAW); | 673 GL_STATIC_DRAW); |
| 679 context_->vertexAttribPointer(0, 2, | 674 context_->vertexAttribPointer(0, 2, |
| 680 GL_FLOAT, GL_FALSE, | 675 GL_FLOAT, GL_FALSE, |
| 681 0, static_cast<WGC3Dintptr>(NULL)); | 676 0, static_cast<WGC3Dintptr>(NULL)); |
| 682 context_->enableVertexAttribArray(0); | 677 context_->enableVertexAttribArray(0); |
| 683 return true; | 678 return true; |
| 684 } | 679 } |
| 685 | 680 |
| 686 bool RenderWidgetFullscreenPepper::CheckCompositing() { | 681 bool RenderWidgetFullscreenPepper::CheckCompositing() { |
| 682 if (webwidget_) { | |
| 683 if (context_ && context_->isContextLost()) { | |
| 684 DestroyContext(context_, program_, buffer_); | |
| 685 context_ = NULL; | |
| 686 } | |
| 687 if (!context_) | |
| 688 CreateContext(); | |
|
piman
2013/03/08 04:43:16
We should only create the context if the plugin ha
danakj
2013/03/08 18:13:34
Done.
| |
| 689 } else if (context_) { | |
|
piman
2013/03/08 04:43:16
I don't really think you need this clause. The web
danakj
2013/03/08 18:13:34
Done.
| |
| 690 DestroyContext(context_, program_, buffer_); | |
| 691 context_ = NULL; | |
| 692 } | |
| 693 | |
| 687 bool compositing = | 694 bool compositing = |
| 688 webwidget_ && webwidget_->isAcceleratedCompositingActive(); | 695 webwidget_ && webwidget_->isAcceleratedCompositingActive(); |
| 689 if (compositing != is_accelerated_compositing_active_) { | 696 if (compositing != is_accelerated_compositing_active_) { |
| 690 if (compositing) | 697 if (compositing) |
| 691 didActivateCompositor(-1); | 698 didActivateCompositor(-1); |
| 692 else | 699 else |
| 693 didDeactivateCompositor(); | 700 didDeactivateCompositor(); |
| 694 } | 701 } |
| 695 return compositing; | 702 return compositing; |
| 696 } | 703 } |
| 697 | 704 |
| 698 void RenderWidgetFullscreenPepper::SwapBuffers() { | 705 void RenderWidgetFullscreenPepper::SwapBuffers() { |
| 699 DCHECK(context_); | 706 DCHECK(context_); |
| 700 context_->prepareTexture(); | 707 context_->prepareTexture(); |
| 701 | 708 |
| 702 // The compositor isn't actually active in this path, but pretend it is for | 709 // The compositor isn't actually active in this path, but pretend it is for |
| 703 // scheduling purposes. | 710 // scheduling purposes. |
| 704 didCommitAndDrawCompositorFrame(); | 711 didCommitAndDrawCompositorFrame(); |
| 705 } | 712 } |
| 706 | 713 |
| 707 WebGraphicsContext3DCommandBufferImpl* | |
| 708 RenderWidgetFullscreenPepper::GetParentContextForPlatformContext3D() { | |
| 709 if (!context_) { | |
| 710 CreateContext(); | |
| 711 } | |
| 712 if (!context_) | |
| 713 return NULL; | |
| 714 return context_; | |
| 715 } | |
| 716 | |
| 717 } // namespace content | 714 } // namespace content |
| OLD | NEW |