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 "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 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1592 KeepSizeAttributesBeforeFullscreen(); | 1592 KeepSizeAttributesBeforeFullscreen(); |
| 1593 SetSizeAttributesForFullscreen(); | 1593 SetSizeAttributesForFullscreen(); |
| 1594 container_->element().requestFullScreen(); | 1594 container_->element().requestFullScreen(); |
| 1595 } else { | 1595 } else { |
| 1596 container_->element().document().cancelFullScreen(); | 1596 container_->element().document().cancelFullScreen(); |
| 1597 } | 1597 } |
| 1598 return true; | 1598 return true; |
| 1599 } | 1599 } |
| 1600 | 1600 |
| 1601 void PluginInstance::FlashSetFullscreen(bool fullscreen, bool delay_report) { | 1601 void PluginInstance::FlashSetFullscreen(bool fullscreen, bool delay_report) { |
| 1602 TRACE_EVENT0("ppapi", "PluginInstance::FlashSetFullscreen"); | |
| 1602 // Keep a reference on the stack. See NOTE above. | 1603 // Keep a reference on the stack. See NOTE above. |
| 1603 scoped_refptr<PluginInstance> ref(this); | 1604 scoped_refptr<PluginInstance> ref(this); |
| 1604 | 1605 |
| 1605 // We check whether we are trying to switch to the state we're already going | 1606 // We check whether we are trying to switch to the state we're already going |
| 1606 // to (i.e. if we're already switching to fullscreen but the fullscreen | 1607 // to (i.e. if we're already switching to fullscreen but the fullscreen |
| 1607 // container isn't ready yet, don't do anything more). | 1608 // container isn't ready yet, don't do anything more). |
| 1608 if (fullscreen == FlashIsFullscreenOrPending()) | 1609 if (fullscreen == FlashIsFullscreenOrPending()) |
| 1609 return; | 1610 return; |
| 1610 | 1611 |
| 1611 // Unbind current 2D or 3D graphics context. | 1612 // Unbind current 2D or 3D graphics context. |
| 1612 BindGraphics(pp_instance(), 0); | |
| 1613 VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off"); | 1613 VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off"); |
| 1614 if (fullscreen) { | 1614 if (fullscreen) { |
| 1615 DCHECK(!fullscreen_container_); | 1615 DCHECK(!fullscreen_container_); |
| 1616 setBackingTextureId(0, false); | |
| 1616 fullscreen_container_ = delegate_->CreateFullscreenContainer(this); | 1617 fullscreen_container_ = delegate_->CreateFullscreenContainer(this); |
| 1617 } else { | 1618 } else { |
| 1618 DCHECK(fullscreen_container_); | 1619 DCHECK(fullscreen_container_); |
| 1619 fullscreen_container_->Destroy(); | 1620 fullscreen_container_->Destroy(); |
| 1620 fullscreen_container_ = NULL; | 1621 fullscreen_container_ = NULL; |
| 1621 UpdateFlashFullscreenState(false); | 1622 UpdateFlashFullscreenState(false); |
| 1622 if (!delay_report) { | 1623 if (!delay_report) { |
| 1623 ReportGeometry(); | 1624 ReportGeometry(); |
| 1624 } else { | 1625 } else { |
| 1625 MessageLoop::current()->PostTask( | 1626 MessageLoop::current()->PostTask( |
| 1626 FROM_HERE, base::Bind(&PluginInstance::ReportGeometry, this)); | 1627 FROM_HERE, base::Bind(&PluginInstance::ReportGeometry, this)); |
| 1627 } | 1628 } |
| 1628 } | 1629 } |
| 1629 } | 1630 } |
| 1630 | 1631 |
| 1631 void PluginInstance::UpdateFlashFullscreenState(bool flash_fullscreen) { | 1632 void PluginInstance::UpdateFlashFullscreenState(bool flash_fullscreen) { |
| 1632 bool is_mouselock_pending = TrackedCallback::IsPending(lock_mouse_callback_); | 1633 bool is_mouselock_pending = TrackedCallback::IsPending(lock_mouse_callback_); |
| 1633 | 1634 |
| 1634 if (flash_fullscreen == flash_fullscreen_) { | 1635 if (flash_fullscreen == flash_fullscreen_) { |
| 1635 // Manually clear callback when fullscreen fails with mouselock pending. | 1636 // Manually clear callback when fullscreen fails with mouselock pending. |
| 1636 if (!flash_fullscreen && is_mouselock_pending) | 1637 if (!flash_fullscreen && is_mouselock_pending) |
| 1637 TrackedCallback::ClearAndRun(&lock_mouse_callback_, PP_ERROR_FAILED); | 1638 TrackedCallback::ClearAndRun(&lock_mouse_callback_, PP_ERROR_FAILED); |
| 1638 return; | 1639 return; |
| 1639 } | 1640 } |
| 1641 if (flash_fullscreen && !flash_fullscreen_) { | |
| 1642 PPB_Graphics3D_Impl* graphics_3d = GetBoundGraphics3D(); | |
| 1643 if (graphics_3d) { | |
| 1644 fullscreen_container_->ReparentContext(graphics_3d->platform_context()); | |
| 1645 } | |
| 1646 } | |
| 1647 | |
| 1648 if (!flash_fullscreen && flash_fullscreen_) { | |
| 1649 PPB_Graphics3D_Impl* graphics_3d = GetBoundGraphics3D(); | |
| 1650 if (graphics_3d) { | |
| 1651 delegate_->ReparentContext(graphics_3d->platform_context()); | |
| 1652 setBackingTextureId(graphics_3d->GetBackingTextureId(), | |
| 1653 graphics_3d->IsOpaque()); | |
| 1654 } | |
| 1655 } | |
|
piman
2012/09/13 00:04:33
I think you can write the 2 blocks above in a slig
| |
| 1640 | 1656 |
| 1641 bool old_plugin_focus = PluginHasFocus(); | 1657 bool old_plugin_focus = PluginHasFocus(); |
| 1642 flash_fullscreen_ = flash_fullscreen; | 1658 flash_fullscreen_ = flash_fullscreen; |
| 1643 if (is_mouselock_pending && !delegate()->IsMouseLocked(this)) { | 1659 if (is_mouselock_pending && !delegate()->IsMouseLocked(this)) { |
| 1644 if (!delegate()->LockMouse(this)) | 1660 if (!delegate()->LockMouse(this)) |
| 1645 TrackedCallback::ClearAndRun(&lock_mouse_callback_, PP_ERROR_FAILED); | 1661 TrackedCallback::ClearAndRun(&lock_mouse_callback_, PP_ERROR_FAILED); |
| 1646 } | 1662 } |
| 1647 | 1663 |
| 1648 if (PluginHasFocus() != old_plugin_focus) | 1664 if (PluginHasFocus() != old_plugin_focus) |
| 1649 SendFocusChangeNotification(); | 1665 SendFocusChangeNotification(); |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1991 | 2007 |
| 1992 void PluginInstance::ClosePendingUserGesture(PP_Instance instance, | 2008 void PluginInstance::ClosePendingUserGesture(PP_Instance instance, |
| 1993 PP_TimeTicks timestamp) { | 2009 PP_TimeTicks timestamp) { |
| 1994 // Do nothing so that the pending user gesture will stay open for | 2010 // Do nothing so that the pending user gesture will stay open for |
| 1995 // kUserGestureDurationInSeconds. | 2011 // kUserGestureDurationInSeconds. |
| 1996 // TODO(yzshen): remove the code for closing pending user gesture. | 2012 // TODO(yzshen): remove the code for closing pending user gesture. |
| 1997 } | 2013 } |
| 1998 | 2014 |
| 1999 PP_Bool PluginInstance::BindGraphics(PP_Instance instance, | 2015 PP_Bool PluginInstance::BindGraphics(PP_Instance instance, |
| 2000 PP_Resource device) { | 2016 PP_Resource device) { |
| 2017 TRACE_EVENT0("ppapi", "PluginInstance::BindGraphics"); | |
| 2001 // The Graphics3D instance can't be destroyed until we call | 2018 // The Graphics3D instance can't be destroyed until we call |
| 2002 // setBackingTextureId. | 2019 // setBackingTextureId. |
| 2003 scoped_refptr< ::ppapi::Resource> old_graphics = bound_graphics_; | 2020 scoped_refptr< ::ppapi::Resource> old_graphics = bound_graphics_; |
| 2004 if (bound_graphics_.get()) { | 2021 if (bound_graphics_.get()) { |
| 2005 if (GetBoundGraphics2D()) { | 2022 if (GetBoundGraphics2D()) { |
| 2006 GetBoundGraphics2D()->BindToInstance(NULL); | 2023 GetBoundGraphics2D()->BindToInstance(NULL); |
| 2007 } else if (GetBoundGraphics3D()) { | 2024 } else if (GetBoundGraphics3D()) { |
| 2008 GetBoundGraphics3D()->BindToInstance(false); | 2025 GetBoundGraphics3D()->BindToInstance(false); |
| 2009 } | 2026 } |
| 2010 bound_graphics_ = NULL; | 2027 bound_graphics_ = NULL; |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2665 screen_size_for_fullscreen_ = gfx::Size(); | 2682 screen_size_for_fullscreen_ = gfx::Size(); |
| 2666 WebElement element = container_->element(); | 2683 WebElement element = container_->element(); |
| 2667 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2684 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
| 2668 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2685 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
| 2669 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2686 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
| 2670 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2687 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
| 2671 } | 2688 } |
| 2672 | 2689 |
| 2673 } // namespace ppapi | 2690 } // namespace ppapi |
| 2674 } // namespace webkit | 2691 } // namespace webkit |
| OLD | NEW |