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

Side by Side Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 10918182: Don't require a recreation of the context when fullscreening (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix style Created 8 years, 3 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
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 "webkit/plugins/ppapi/ppapi_plugin_instance.h" 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
(...skipping 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after
1597 KeepSizeAttributesBeforeFullscreen(); 1597 KeepSizeAttributesBeforeFullscreen();
1598 SetSizeAttributesForFullscreen(); 1598 SetSizeAttributesForFullscreen();
1599 container_->element().requestFullScreen(); 1599 container_->element().requestFullScreen();
1600 } else { 1600 } else {
1601 container_->element().document().cancelFullScreen(); 1601 container_->element().document().cancelFullScreen();
1602 } 1602 }
1603 return true; 1603 return true;
1604 } 1604 }
1605 1605
1606 void PluginInstance::FlashSetFullscreen(bool fullscreen, bool delay_report) { 1606 void PluginInstance::FlashSetFullscreen(bool fullscreen, bool delay_report) {
1607 TRACE_EVENT0("ppapi", "PluginInstance::FlashSetFullscreen");
1607 // Keep a reference on the stack. See NOTE above. 1608 // Keep a reference on the stack. See NOTE above.
1608 scoped_refptr<PluginInstance> ref(this); 1609 scoped_refptr<PluginInstance> ref(this);
1609 1610
1610 // We check whether we are trying to switch to the state we're already going 1611 // We check whether we are trying to switch to the state we're already going
1611 // to (i.e. if we're already switching to fullscreen but the fullscreen 1612 // to (i.e. if we're already switching to fullscreen but the fullscreen
1612 // container isn't ready yet, don't do anything more). 1613 // container isn't ready yet, don't do anything more).
1613 if (fullscreen == FlashIsFullscreenOrPending()) 1614 if (fullscreen == FlashIsFullscreenOrPending())
1614 return; 1615 return;
1615 1616
1616 // Unbind current 2D or 3D graphics context. 1617 // Unbind current 2D or 3D graphics context.
1617 BindGraphics(pp_instance(), 0);
1618 VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off"); 1618 VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off");
1619 if (fullscreen) { 1619 if (fullscreen) {
1620 DCHECK(!fullscreen_container_); 1620 DCHECK(!fullscreen_container_);
1621 setBackingTextureId(0, false);
1621 fullscreen_container_ = delegate_->CreateFullscreenContainer(this); 1622 fullscreen_container_ = delegate_->CreateFullscreenContainer(this);
1622 } else { 1623 } else {
1623 DCHECK(fullscreen_container_); 1624 DCHECK(fullscreen_container_);
1624 fullscreen_container_->Destroy(); 1625 fullscreen_container_->Destroy();
1625 fullscreen_container_ = NULL; 1626 fullscreen_container_ = NULL;
1626 UpdateFlashFullscreenState(false); 1627 UpdateFlashFullscreenState(false);
1627 if (!delay_report) { 1628 if (!delay_report) {
1628 ReportGeometry(); 1629 ReportGeometry();
1629 } else { 1630 } else {
1630 MessageLoop::current()->PostTask( 1631 MessageLoop::current()->PostTask(
1631 FROM_HERE, base::Bind(&PluginInstance::ReportGeometry, this)); 1632 FROM_HERE, base::Bind(&PluginInstance::ReportGeometry, this));
1632 } 1633 }
1633 } 1634 }
1634 } 1635 }
1635 1636
1636 void PluginInstance::UpdateFlashFullscreenState(bool flash_fullscreen) { 1637 void PluginInstance::UpdateFlashFullscreenState(bool flash_fullscreen) {
1637 bool is_mouselock_pending = TrackedCallback::IsPending(lock_mouse_callback_); 1638 bool is_mouselock_pending = TrackedCallback::IsPending(lock_mouse_callback_);
1638 1639
1639 if (flash_fullscreen == flash_fullscreen_) { 1640 if (flash_fullscreen == flash_fullscreen_) {
1640 // Manually clear callback when fullscreen fails with mouselock pending. 1641 // Manually clear callback when fullscreen fails with mouselock pending.
1641 if (!flash_fullscreen && is_mouselock_pending) 1642 if (!flash_fullscreen && is_mouselock_pending)
1642 TrackedCallback::ClearAndRun(&lock_mouse_callback_, PP_ERROR_FAILED); 1643 TrackedCallback::ClearAndRun(&lock_mouse_callback_, PP_ERROR_FAILED);
1643 return; 1644 return;
1644 } 1645 }
1645 1646
1647 PPB_Graphics3D_Impl* graphics_3d = GetBoundGraphics3D();
1648 if (graphics_3d) {
1649 if (flash_fullscreen) {
1650 fullscreen_container_->ReparentContext(graphics_3d->platform_context());
1651 } else {
1652 delegate_->ReparentContext(graphics_3d->platform_context());
1653 setBackingTextureId(graphics_3d->GetBackingTextureId(),
1654 graphics_3d->IsOpaque());
1655 }
1656 }
1657
1646 bool old_plugin_focus = PluginHasFocus(); 1658 bool old_plugin_focus = PluginHasFocus();
1647 flash_fullscreen_ = flash_fullscreen; 1659 flash_fullscreen_ = flash_fullscreen;
1648 if (is_mouselock_pending && !delegate()->IsMouseLocked(this)) { 1660 if (is_mouselock_pending && !delegate()->IsMouseLocked(this)) {
1649 if (!delegate()->LockMouse(this)) 1661 if (!delegate()->LockMouse(this))
1650 TrackedCallback::ClearAndRun(&lock_mouse_callback_, PP_ERROR_FAILED); 1662 TrackedCallback::ClearAndRun(&lock_mouse_callback_, PP_ERROR_FAILED);
1651 } 1663 }
1652 1664
1653 if (PluginHasFocus() != old_plugin_focus) 1665 if (PluginHasFocus() != old_plugin_focus)
1654 SendFocusChangeNotification(); 1666 SendFocusChangeNotification();
1655 } 1667 }
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1996 2008
1997 void PluginInstance::ClosePendingUserGesture(PP_Instance instance, 2009 void PluginInstance::ClosePendingUserGesture(PP_Instance instance,
1998 PP_TimeTicks timestamp) { 2010 PP_TimeTicks timestamp) {
1999 // Do nothing so that the pending user gesture will stay open for 2011 // Do nothing so that the pending user gesture will stay open for
2000 // kUserGestureDurationInSeconds. 2012 // kUserGestureDurationInSeconds.
2001 // TODO(yzshen): remove the code for closing pending user gesture. 2013 // TODO(yzshen): remove the code for closing pending user gesture.
2002 } 2014 }
2003 2015
2004 PP_Bool PluginInstance::BindGraphics(PP_Instance instance, 2016 PP_Bool PluginInstance::BindGraphics(PP_Instance instance,
2005 PP_Resource device) { 2017 PP_Resource device) {
2018 TRACE_EVENT0("ppapi", "PluginInstance::BindGraphics");
2006 // The Graphics3D instance can't be destroyed until we call 2019 // The Graphics3D instance can't be destroyed until we call
2007 // setBackingTextureId. 2020 // setBackingTextureId.
2008 scoped_refptr< ::ppapi::Resource> old_graphics = bound_graphics_; 2021 scoped_refptr< ::ppapi::Resource> old_graphics = bound_graphics_;
2009 if (bound_graphics_.get()) { 2022 if (bound_graphics_.get()) {
2010 if (GetBoundGraphics2D()) { 2023 if (GetBoundGraphics2D()) {
2011 GetBoundGraphics2D()->BindToInstance(NULL); 2024 GetBoundGraphics2D()->BindToInstance(NULL);
2012 } else if (GetBoundGraphics3D()) { 2025 } else if (GetBoundGraphics3D()) {
2013 GetBoundGraphics3D()->BindToInstance(false); 2026 GetBoundGraphics3D()->BindToInstance(false);
2014 } 2027 }
2015 bound_graphics_ = NULL; 2028 bound_graphics_ = NULL;
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
2663 screen_size_for_fullscreen_ = gfx::Size(); 2676 screen_size_for_fullscreen_ = gfx::Size();
2664 WebElement element = container_->element(); 2677 WebElement element = container_->element();
2665 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); 2678 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_);
2666 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); 2679 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_);
2667 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); 2680 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_);
2668 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); 2681 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_);
2669 } 2682 }
2670 2683
2671 } // namespace ppapi 2684 } // namespace ppapi
2672 } // namespace webkit 2685 } // namespace webkit
OLDNEW
« ppapi/cpp/private/flash_fullscreen.cc ('K') | « webkit/plugins/ppapi/plugin_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698