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; |
piman
2013/03/08 22:37:52
we probably want to return NULL if switches::kDisa
danakj
2013/03/08 22:40:46
I am scared of that, the old code would not have r
piman
2013/03/08 22:44:09
It should be safe. It's only called from PPB_Grap
| |
455 #else | 454 #else |
456 return NULL; | 455 return NULL; |
457 #endif | 456 #endif |
458 } | 457 } |
459 | 458 |
460 void RenderWidgetFullscreenPepper::ReparentContext( | 459 void RenderWidgetFullscreenPepper::ReparentContext( |
461 webkit::ppapi::PluginDelegate::PlatformContext3D* context) { | 460 webkit::ppapi::PluginDelegate::PlatformContext3D* context) { |
462 static_cast<PlatformContext3DImpl*>(context)->SetParentContext(this); | 461 PlatformContext3DImpl* context_impl = |
462 static_cast<PlatformContext3DImpl*>(context); | |
463 | |
464 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
465 if (command_line->HasSwitch(switches::kDisableFlashFullscreen3d)) | |
466 context_impl->DestroyParentContextProviderAndBackingTexture(); | |
467 else | |
468 context_impl->SetParentAndCreateBackingTextureIfNeeded(); | |
463 } | 469 } |
464 | 470 |
465 bool RenderWidgetFullscreenPepper::OnMessageReceived(const IPC::Message& msg) { | 471 bool RenderWidgetFullscreenPepper::OnMessageReceived(const IPC::Message& msg) { |
466 bool handled = true; | 472 bool handled = true; |
467 IPC_BEGIN_MESSAGE_MAP(RenderWidgetFullscreenPepper, msg) | 473 IPC_BEGIN_MESSAGE_MAP(RenderWidgetFullscreenPepper, msg) |
468 IPC_MESSAGE_FORWARD(ViewMsg_LockMouse_ACK, | 474 IPC_MESSAGE_FORWARD(ViewMsg_LockMouse_ACK, |
469 mouse_lock_dispatcher_.get(), | 475 mouse_lock_dispatcher_.get(), |
470 MouseLockDispatcher::OnLockMouseACK) | 476 MouseLockDispatcher::OnLockMouseACK) |
471 IPC_MESSAGE_FORWARD(ViewMsg_MouseLockLost, | 477 IPC_MESSAGE_FORWARD(ViewMsg_MouseLockLost, |
472 mouse_lock_dispatcher_.get(), | 478 mouse_lock_dispatcher_.get(), |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
551 | 557 |
552 DCHECK(context_); | 558 DCHECK(context_); |
553 unsigned int texture = plugin_->GetBackingTextureId(); | 559 unsigned int texture = plugin_->GetBackingTextureId(); |
554 context_->bindTexture(GL_TEXTURE_2D, texture); | 560 context_->bindTexture(GL_TEXTURE_2D, texture); |
555 context_->drawArrays(GL_TRIANGLES, 0, 3); | 561 context_->drawArrays(GL_TRIANGLES, 0, 3); |
556 SwapBuffers(); | 562 SwapBuffers(); |
557 } | 563 } |
558 | 564 |
559 void RenderWidgetFullscreenPepper::CreateContext() { | 565 void RenderWidgetFullscreenPepper::CreateContext() { |
560 DCHECK(!context_); | 566 DCHECK(!context_); |
561 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
562 if (command_line->HasSwitch(switches::kDisableFlashFullscreen3d)) | |
563 return; | |
564 WebKit::WebGraphicsContext3D::Attributes attributes; | 567 WebKit::WebGraphicsContext3D::Attributes attributes; |
565 attributes.depth = false; | 568 attributes.depth = false; |
566 attributes.stencil = false; | 569 attributes.stencil = false; |
567 attributes.antialias = false; | 570 attributes.antialias = false; |
568 attributes.shareResources = false; | 571 attributes.shareResources = true; |
569 attributes.preferDiscreteGPU = true; | 572 attributes.preferDiscreteGPU = true; |
570 context_ = WebGraphicsContext3DCommandBufferImpl::CreateViewContext( | 573 context_ = WebGraphicsContext3DCommandBufferImpl::CreateViewContext( |
571 RenderThreadImpl::current(), | 574 RenderThreadImpl::current(), |
572 surface_id(), | 575 surface_id(), |
573 NULL, | 576 NULL, |
574 attributes, | 577 attributes, |
575 true /* bind generates resources */, | 578 true /* bind generates resources */, |
576 active_url_, | 579 active_url_, |
577 CAUSE_FOR_GPU_LAUNCH_RENDERWIDGETFULLSCREENPEPPER_CREATECONTEXT); | 580 CAUSE_FOR_GPU_LAUNCH_RENDERWIDGETFULLSCREENPEPPER_CREATECONTEXT); |
578 if (!context_) | 581 if (!context_) |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
677 kTexCoords, | 680 kTexCoords, |
678 GL_STATIC_DRAW); | 681 GL_STATIC_DRAW); |
679 context_->vertexAttribPointer(0, 2, | 682 context_->vertexAttribPointer(0, 2, |
680 GL_FLOAT, GL_FALSE, | 683 GL_FLOAT, GL_FALSE, |
681 0, static_cast<WGC3Dintptr>(NULL)); | 684 0, static_cast<WGC3Dintptr>(NULL)); |
682 context_->enableVertexAttribArray(0); | 685 context_->enableVertexAttribArray(0); |
683 return true; | 686 return true; |
684 } | 687 } |
685 | 688 |
686 bool RenderWidgetFullscreenPepper::CheckCompositing() { | 689 bool RenderWidgetFullscreenPepper::CheckCompositing() { |
687 bool compositing = | 690 bool compositing = webwidget_ && webwidget_->isAcceleratedCompositingActive(); |
688 webwidget_ && webwidget_->isAcceleratedCompositingActive(); | 691 if (compositing) { |
692 if (context_ && context_->isContextLost()) { | |
693 DestroyContext(context_, program_, buffer_); | |
694 context_ = NULL; | |
695 } | |
696 if (!context_) | |
697 CreateContext(); | |
698 if (!context_) | |
699 compositing = false; | |
700 } | |
701 | |
689 if (compositing != is_accelerated_compositing_active_) { | 702 if (compositing != is_accelerated_compositing_active_) { |
690 if (compositing) | 703 if (compositing) { |
691 didActivateCompositor(-1); | 704 didActivateCompositor(-1); |
692 else | 705 } else { |
706 if (context_) { | |
707 DestroyContext(context_, program_, buffer_); | |
708 context_ = NULL; | |
709 } | |
693 didDeactivateCompositor(); | 710 didDeactivateCompositor(); |
711 } | |
694 } | 712 } |
695 return compositing; | 713 return compositing; |
696 } | 714 } |
697 | 715 |
698 void RenderWidgetFullscreenPepper::SwapBuffers() { | 716 void RenderWidgetFullscreenPepper::SwapBuffers() { |
699 DCHECK(context_); | 717 DCHECK(context_); |
700 context_->prepareTexture(); | 718 context_->prepareTexture(); |
701 | 719 |
702 // The compositor isn't actually active in this path, but pretend it is for | 720 // The compositor isn't actually active in this path, but pretend it is for |
703 // scheduling purposes. | 721 // scheduling purposes. |
704 didCommitAndDrawCompositorFrame(); | 722 didCommitAndDrawCompositorFrame(); |
705 } | 723 } |
706 | 724 |
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 | 725 } // namespace content |
OLD | NEW |