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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 } | 325 } |
| 326 | 326 |
| 327 virtual bool caretOrSelectionRange(size_t* location, size_t* length) { | 327 virtual bool caretOrSelectionRange(size_t* location, size_t* length) { |
| 328 return false; | 328 return false; |
| 329 } | 329 } |
| 330 | 330 |
| 331 virtual void setTextDirection(WebTextDirection) { | 331 virtual void setTextDirection(WebTextDirection) { |
| 332 } | 332 } |
| 333 | 333 |
| 334 virtual bool isAcceleratedCompositingActive() const { | 334 virtual bool isAcceleratedCompositingActive() const { |
| 335 return widget_->context() && widget_->plugin() && | 335 return widget_->plugin() && widget_->plugin()->GetBackingTextureId(); |
| 336 (widget_->plugin()->GetBackingTextureId() != 0); | |
| 337 } | 336 } |
| 338 | 337 |
| 339 private: | 338 private: |
| 340 RenderWidgetFullscreenPepper* widget_; | 339 RenderWidgetFullscreenPepper* widget_; |
| 341 WebSize size_; | 340 WebSize size_; |
| 342 | 341 |
| 343 DISALLOW_COPY_AND_ASSIGN(PepperWidget); | 342 DISALLOW_COPY_AND_ASSIGN(PepperWidget); |
| 344 }; | 343 }; |
| 345 | 344 |
| 346 void DestroyContext(WebGraphicsContext3DCommandBufferImpl* context, | 345 void DestroyContext(WebGraphicsContext3DCommandBufferImpl* context, |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 444 } | 443 } |
| 445 | 444 |
| 446 void RenderWidgetFullscreenPepper::DidChangeCursor( | 445 void RenderWidgetFullscreenPepper::DidChangeCursor( |
| 447 const WebKit::WebCursorInfo& cursor) { | 446 const WebKit::WebCursorInfo& cursor) { |
| 448 didChangeCursor(cursor); | 447 didChangeCursor(cursor); |
| 449 } | 448 } |
| 450 | 449 |
| 451 webkit::ppapi::PluginDelegate::PlatformContext3D* | 450 webkit::ppapi::PluginDelegate::PlatformContext3D* |
| 452 RenderWidgetFullscreenPepper::CreateContext3D() { | 451 RenderWidgetFullscreenPepper::CreateContext3D() { |
| 453 #ifdef ENABLE_GPU | 452 #ifdef ENABLE_GPU |
| 454 return new PlatformContext3DImpl(this); | 453 return new PlatformContext3DImpl; |
| 455 #else | 454 #else |
| 456 return NULL; | 455 return NULL; |
| 457 #endif | 456 #endif |
| 458 } | 457 } |
| 459 | 458 |
| 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) { | 459 bool RenderWidgetFullscreenPepper::OnMessageReceived(const IPC::Message& msg) { |
| 466 bool handled = true; | 460 bool handled = true; |
| 467 IPC_BEGIN_MESSAGE_MAP(RenderWidgetFullscreenPepper, msg) | 461 IPC_BEGIN_MESSAGE_MAP(RenderWidgetFullscreenPepper, msg) |
| 468 IPC_MESSAGE_FORWARD(ViewMsg_LockMouse_ACK, | 462 IPC_MESSAGE_FORWARD(ViewMsg_LockMouse_ACK, |
| 469 mouse_lock_dispatcher_.get(), | 463 mouse_lock_dispatcher_.get(), |
| 470 MouseLockDispatcher::OnLockMouseACK) | 464 MouseLockDispatcher::OnLockMouseACK) |
| 471 IPC_MESSAGE_FORWARD(ViewMsg_MouseLockLost, | 465 IPC_MESSAGE_FORWARD(ViewMsg_MouseLockLost, |
| 472 mouse_lock_dispatcher_.get(), | 466 mouse_lock_dispatcher_.get(), |
| 473 MouseLockDispatcher::OnMouseLockLost) | 467 MouseLockDispatcher::OnMouseLockLost) |
| 474 IPC_MESSAGE_UNHANDLED(handled = false) | 468 IPC_MESSAGE_UNHANDLED(handled = false) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 553 unsigned int texture = plugin_->GetBackingTextureId(); | 547 unsigned int texture = plugin_->GetBackingTextureId(); |
| 554 context_->bindTexture(GL_TEXTURE_2D, texture); | 548 context_->bindTexture(GL_TEXTURE_2D, texture); |
| 555 context_->drawArrays(GL_TRIANGLES, 0, 3); | 549 context_->drawArrays(GL_TRIANGLES, 0, 3); |
| 556 SwapBuffers(); | 550 SwapBuffers(); |
| 557 } | 551 } |
| 558 | 552 |
| 559 void RenderWidgetFullscreenPepper::CreateContext() { | 553 void RenderWidgetFullscreenPepper::CreateContext() { |
| 560 DCHECK(!context_); | 554 DCHECK(!context_); |
| 561 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 555 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 562 if (command_line->HasSwitch(switches::kDisableFlashFullscreen3d)) | 556 if (command_line->HasSwitch(switches::kDisableFlashFullscreen3d)) |
| 563 return; | 557 return; |
|
piman
2013/03/08 18:27:08
I just thought of something else: what about this
danakj
2013/03/08 18:58:13
Right! You're right, SetParentContext() would earl
| |
| 564 WebKit::WebGraphicsContext3D::Attributes attributes; | 558 WebKit::WebGraphicsContext3D::Attributes attributes; |
| 565 attributes.depth = false; | 559 attributes.depth = false; |
| 566 attributes.stencil = false; | 560 attributes.stencil = false; |
| 567 attributes.antialias = false; | 561 attributes.antialias = false; |
| 568 attributes.shareResources = false; | 562 attributes.shareResources = true; |
| 569 attributes.preferDiscreteGPU = true; | 563 attributes.preferDiscreteGPU = true; |
| 570 context_ = WebGraphicsContext3DCommandBufferImpl::CreateViewContext( | 564 context_ = WebGraphicsContext3DCommandBufferImpl::CreateViewContext( |
| 571 RenderThreadImpl::current(), | 565 RenderThreadImpl::current(), |
| 572 surface_id(), | 566 surface_id(), |
| 573 NULL, | 567 NULL, |
| 574 attributes, | 568 attributes, |
| 575 true /* bind generates resources */, | 569 true /* bind generates resources */, |
| 576 active_url_, | 570 active_url_, |
| 577 CAUSE_FOR_GPU_LAUNCH_RENDERWIDGETFULLSCREENPEPPER_CREATECONTEXT); | 571 CAUSE_FOR_GPU_LAUNCH_RENDERWIDGETFULLSCREENPEPPER_CREATECONTEXT); |
| 578 if (!context_) | 572 if (!context_) |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 679 context_->vertexAttribPointer(0, 2, | 673 context_->vertexAttribPointer(0, 2, |
| 680 GL_FLOAT, GL_FALSE, | 674 GL_FLOAT, GL_FALSE, |
| 681 0, static_cast<WGC3Dintptr>(NULL)); | 675 0, static_cast<WGC3Dintptr>(NULL)); |
| 682 context_->enableVertexAttribArray(0); | 676 context_->enableVertexAttribArray(0); |
| 683 return true; | 677 return true; |
| 684 } | 678 } |
| 685 | 679 |
| 686 bool RenderWidgetFullscreenPepper::CheckCompositing() { | 680 bool RenderWidgetFullscreenPepper::CheckCompositing() { |
| 687 bool compositing = | 681 bool compositing = |
| 688 webwidget_ && webwidget_->isAcceleratedCompositingActive(); | 682 webwidget_ && webwidget_->isAcceleratedCompositingActive(); |
| 683 | |
| 684 if (compositing) { | |
| 685 if (context_ && context_->isContextLost()) { | |
| 686 DestroyContext(context_, program_, buffer_); | |
| 687 context_ = NULL; | |
| 688 } | |
| 689 if (!context_) | |
| 690 CreateContext(); | |
|
piman
2013/03/08 18:27:08
If CreateContext fails, we should reset compositin
danakj
2013/03/08 18:40:28
Done.
| |
| 691 } | |
| 692 | |
| 689 if (compositing != is_accelerated_compositing_active_) { | 693 if (compositing != is_accelerated_compositing_active_) { |
| 690 if (compositing) | 694 if (compositing) |
| 691 didActivateCompositor(-1); | 695 didActivateCompositor(-1); |
| 692 else | 696 else { |
| 697 if (context_) { | |
| 698 DestroyContext(context_, program_, buffer_); | |
| 699 context_ = NULL; | |
| 700 } | |
| 693 didDeactivateCompositor(); | 701 didDeactivateCompositor(); |
| 702 } | |
| 694 } | 703 } |
| 695 return compositing; | 704 return compositing; |
| 696 } | 705 } |
| 697 | 706 |
| 698 void RenderWidgetFullscreenPepper::SwapBuffers() { | 707 void RenderWidgetFullscreenPepper::SwapBuffers() { |
| 699 DCHECK(context_); | 708 DCHECK(context_); |
| 700 context_->prepareTexture(); | 709 context_->prepareTexture(); |
| 701 | 710 |
| 702 // The compositor isn't actually active in this path, but pretend it is for | 711 // The compositor isn't actually active in this path, but pretend it is for |
| 703 // scheduling purposes. | 712 // scheduling purposes. |
| 704 didCommitAndDrawCompositorFrame(); | 713 didCommitAndDrawCompositorFrame(); |
| 705 } | 714 } |
| 706 | 715 |
| 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 | 716 } // namespace content |
| OLD | NEW |