Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Side by Side Diff: content/renderer/render_widget_fullscreen_pepper.cc

Issue 12673002: pepper: Use the RenderThread's shared context as the parent context. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: null context3d in swiftshader Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/render_widget_fullscreen_pepper.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 Release(); 442 Release();
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 CommandLine* command_line = CommandLine::ForCurrentProcess();
454 return new PlatformContext3DImpl(this); 453 if (command_line->HasSwitch(switches::kDisableFlashFullscreen3d))
455 #else 454 return NULL;
456 return NULL; 455 return new PlatformContext3DImpl;
457 #endif
458 } 456 }
459 457
460 void RenderWidgetFullscreenPepper::ReparentContext( 458 void RenderWidgetFullscreenPepper::ReparentContext(
461 webkit::ppapi::PluginDelegate::PlatformContext3D* context) { 459 webkit::ppapi::PluginDelegate::PlatformContext3D* context) {
462 static_cast<PlatformContext3DImpl*>(context)->SetParentContext(this); 460 PlatformContext3DImpl* context_impl =
461 static_cast<PlatformContext3DImpl*>(context);
462
463 CommandLine* command_line = CommandLine::ForCurrentProcess();
464 if (command_line->HasSwitch(switches::kDisableFlashFullscreen3d))
465 context_impl->DestroyParentContextProviderAndBackingTexture();
466 else
467 context_impl->SetParentAndCreateBackingTextureIfNeeded();
463 } 468 }
464 469
465 bool RenderWidgetFullscreenPepper::OnMessageReceived(const IPC::Message& msg) { 470 bool RenderWidgetFullscreenPepper::OnMessageReceived(const IPC::Message& msg) {
466 bool handled = true; 471 bool handled = true;
467 IPC_BEGIN_MESSAGE_MAP(RenderWidgetFullscreenPepper, msg) 472 IPC_BEGIN_MESSAGE_MAP(RenderWidgetFullscreenPepper, msg)
468 IPC_MESSAGE_FORWARD(ViewMsg_LockMouse_ACK, 473 IPC_MESSAGE_FORWARD(ViewMsg_LockMouse_ACK,
469 mouse_lock_dispatcher_.get(), 474 mouse_lock_dispatcher_.get(),
470 MouseLockDispatcher::OnLockMouseACK) 475 MouseLockDispatcher::OnLockMouseACK)
471 IPC_MESSAGE_FORWARD(ViewMsg_MouseLockLost, 476 IPC_MESSAGE_FORWARD(ViewMsg_MouseLockLost,
472 mouse_lock_dispatcher_.get(), 477 mouse_lock_dispatcher_.get(),
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 556
552 DCHECK(context_); 557 DCHECK(context_);
553 unsigned int texture = plugin_->GetBackingTextureId(); 558 unsigned int texture = plugin_->GetBackingTextureId();
554 context_->bindTexture(GL_TEXTURE_2D, texture); 559 context_->bindTexture(GL_TEXTURE_2D, texture);
555 context_->drawArrays(GL_TRIANGLES, 0, 3); 560 context_->drawArrays(GL_TRIANGLES, 0, 3);
556 SwapBuffers(); 561 SwapBuffers();
557 } 562 }
558 563
559 void RenderWidgetFullscreenPepper::CreateContext() { 564 void RenderWidgetFullscreenPepper::CreateContext() {
560 DCHECK(!context_); 565 DCHECK(!context_);
561 CommandLine* command_line = CommandLine::ForCurrentProcess();
562 if (command_line->HasSwitch(switches::kDisableFlashFullscreen3d))
563 return;
564 WebKit::WebGraphicsContext3D::Attributes attributes; 566 WebKit::WebGraphicsContext3D::Attributes attributes;
565 attributes.depth = false; 567 attributes.depth = false;
566 attributes.stencil = false; 568 attributes.stencil = false;
567 attributes.antialias = false; 569 attributes.antialias = false;
568 attributes.shareResources = false; 570 attributes.shareResources = true;
569 attributes.preferDiscreteGPU = true; 571 attributes.preferDiscreteGPU = true;
570 context_ = WebGraphicsContext3DCommandBufferImpl::CreateViewContext( 572 context_ = WebGraphicsContext3DCommandBufferImpl::CreateViewContext(
571 RenderThreadImpl::current(), 573 RenderThreadImpl::current(),
572 surface_id(), 574 surface_id(),
573 NULL, 575 NULL,
574 attributes, 576 attributes,
575 true /* bind generates resources */, 577 true /* bind generates resources */,
576 active_url_, 578 active_url_,
577 CAUSE_FOR_GPU_LAUNCH_RENDERWIDGETFULLSCREENPEPPER_CREATECONTEXT); 579 CAUSE_FOR_GPU_LAUNCH_RENDERWIDGETFULLSCREENPEPPER_CREATECONTEXT);
578 if (!context_) 580 if (!context_)
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 kTexCoords, 679 kTexCoords,
678 GL_STATIC_DRAW); 680 GL_STATIC_DRAW);
679 context_->vertexAttribPointer(0, 2, 681 context_->vertexAttribPointer(0, 2,
680 GL_FLOAT, GL_FALSE, 682 GL_FLOAT, GL_FALSE,
681 0, static_cast<WGC3Dintptr>(NULL)); 683 0, static_cast<WGC3Dintptr>(NULL));
682 context_->enableVertexAttribArray(0); 684 context_->enableVertexAttribArray(0);
683 return true; 685 return true;
684 } 686 }
685 687
686 bool RenderWidgetFullscreenPepper::CheckCompositing() { 688 bool RenderWidgetFullscreenPepper::CheckCompositing() {
687 bool compositing = 689 bool compositing = webwidget_ && webwidget_->isAcceleratedCompositingActive();
688 webwidget_ && webwidget_->isAcceleratedCompositingActive(); 690 if (compositing) {
691 if (context_ && context_->isContextLost()) {
692 DestroyContext(context_, program_, buffer_);
693 context_ = NULL;
694 }
695 if (!context_)
696 CreateContext();
697 if (!context_)
698 compositing = false;
699 }
700
689 if (compositing != is_accelerated_compositing_active_) { 701 if (compositing != is_accelerated_compositing_active_) {
690 if (compositing) 702 if (compositing) {
691 didActivateCompositor(-1); 703 didActivateCompositor(-1);
692 else 704 } else {
705 if (context_) {
706 DestroyContext(context_, program_, buffer_);
707 context_ = NULL;
708 }
693 didDeactivateCompositor(); 709 didDeactivateCompositor();
710 }
694 } 711 }
695 return compositing; 712 return compositing;
696 } 713 }
697 714
698 void RenderWidgetFullscreenPepper::SwapBuffers() { 715 void RenderWidgetFullscreenPepper::SwapBuffers() {
699 DCHECK(context_); 716 DCHECK(context_);
700 context_->prepareTexture(); 717 context_->prepareTexture();
701 718
702 // The compositor isn't actually active in this path, but pretend it is for 719 // The compositor isn't actually active in this path, but pretend it is for
703 // scheduling purposes. 720 // scheduling purposes.
704 didCommitAndDrawCompositorFrame(); 721 didCommitAndDrawCompositorFrame();
705 } 722 }
706 723
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 724 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget_fullscreen_pepper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698