| 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 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1616 | 1616 |
| 1617 PPB_Graphics3D_Impl* PluginInstance::GetBoundGraphics3D() const { | 1617 PPB_Graphics3D_Impl* PluginInstance::GetBoundGraphics3D() const { |
| 1618 if (bound_graphics_.get() == NULL) | 1618 if (bound_graphics_.get() == NULL) |
| 1619 return NULL; | 1619 return NULL; |
| 1620 | 1620 |
| 1621 if (bound_graphics_->AsPPB_Graphics3D_API()) | 1621 if (bound_graphics_->AsPPB_Graphics3D_API()) |
| 1622 return static_cast<PPB_Graphics3D_Impl*>(bound_graphics_.get()); | 1622 return static_cast<PPB_Graphics3D_Impl*>(bound_graphics_.get()); |
| 1623 return NULL; | 1623 return NULL; |
| 1624 } | 1624 } |
| 1625 | 1625 |
| 1626 void PluginInstance::setBackingTextureId(unsigned int id) { | 1626 void PluginInstance::setBackingTextureId(unsigned int id, bool isOpaque) { |
| 1627 // If we have a fullscreen_container_ (under PPB_FlashFullscreen) | 1627 // If we have a fullscreen_container_ (under PPB_FlashFullscreen) |
| 1628 // or desired_fullscreen_state is true (under PPB_Fullscreen), | 1628 // or desired_fullscreen_state is true (under PPB_Fullscreen), |
| 1629 // then the plugin is fullscreen or transitioning to fullscreen | 1629 // then the plugin is fullscreen or transitioning to fullscreen |
| 1630 // and the parent context is not the one for the browser page, | 1630 // and the parent context is not the one for the browser page, |
| 1631 // but for the fullscreen window, and so the parent texture ID | 1631 // but for the fullscreen window, and so the parent texture ID |
| 1632 // doesn't correspond to anything in the page's context. | 1632 // doesn't correspond to anything in the page's context. |
| 1633 // | 1633 // |
| 1634 // TODO(alokp): It would be better at some point to have the equivalent | 1634 // TODO(alokp): It would be better at some point to have the equivalent |
| 1635 // in the FullscreenContainer so that we don't need to poll | 1635 // in the FullscreenContainer so that we don't need to poll |
| 1636 if (fullscreen_container_ || desired_fullscreen_state_) | 1636 if (fullscreen_container_ || desired_fullscreen_state_) |
| 1637 return; | 1637 return; |
| 1638 | 1638 |
| 1639 if (container_) | 1639 if (container_) { |
| 1640 container_->setBackingTextureId(id); | 1640 container_->setBackingTextureId(id); |
| 1641 container_->setOpaque(isOpaque); |
| 1642 } |
| 1641 } | 1643 } |
| 1642 | 1644 |
| 1643 void PluginInstance::AddPluginObject(PluginObject* plugin_object) { | 1645 void PluginInstance::AddPluginObject(PluginObject* plugin_object) { |
| 1644 DCHECK(live_plugin_objects_.find(plugin_object) == | 1646 DCHECK(live_plugin_objects_.find(plugin_object) == |
| 1645 live_plugin_objects_.end()); | 1647 live_plugin_objects_.end()); |
| 1646 live_plugin_objects_.insert(plugin_object); | 1648 live_plugin_objects_.insert(plugin_object); |
| 1647 } | 1649 } |
| 1648 | 1650 |
| 1649 void PluginInstance::RemovePluginObject(PluginObject* plugin_object) { | 1651 void PluginInstance::RemovePluginObject(PluginObject* plugin_object) { |
| 1650 // Don't actually verify that the object is in the set since during module | 1652 // Don't actually verify that the object is in the set since during module |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1706 if (GetBoundGraphics2D()) { | 1708 if (GetBoundGraphics2D()) { |
| 1707 GetBoundGraphics2D()->BindToInstance(NULL); | 1709 GetBoundGraphics2D()->BindToInstance(NULL); |
| 1708 } else if (GetBoundGraphics3D()) { | 1710 } else if (GetBoundGraphics3D()) { |
| 1709 GetBoundGraphics3D()->BindToInstance(false); | 1711 GetBoundGraphics3D()->BindToInstance(false); |
| 1710 } | 1712 } |
| 1711 bound_graphics_ = NULL; | 1713 bound_graphics_ = NULL; |
| 1712 } | 1714 } |
| 1713 | 1715 |
| 1714 // Special-case clearing the current device. | 1716 // Special-case clearing the current device. |
| 1715 if (!device) { | 1717 if (!device) { |
| 1716 setBackingTextureId(0); | 1718 setBackingTextureId(0, false); |
| 1717 InvalidateRect(gfx::Rect()); | 1719 InvalidateRect(gfx::Rect()); |
| 1718 return PP_TRUE; | 1720 return PP_TRUE; |
| 1719 } | 1721 } |
| 1720 | 1722 |
| 1721 // Refuse to bind if in transition to fullscreen with PPB_FlashFullscreen or | 1723 // Refuse to bind if in transition to fullscreen with PPB_FlashFullscreen or |
| 1722 // to/from fullscreen with PPB_Fullscreen. | 1724 // to/from fullscreen with PPB_Fullscreen. |
| 1723 if ((fullscreen_container_ && !flash_fullscreen_) || | 1725 if ((fullscreen_container_ && !flash_fullscreen_) || |
| 1724 desired_fullscreen_state_ != view_data_.is_fullscreen) | 1726 desired_fullscreen_state_ != view_data_.is_fullscreen) |
| 1725 return PP_FALSE; | 1727 return PP_FALSE; |
| 1726 | 1728 |
| 1727 EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false); | 1729 EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false); |
| 1728 PPB_Graphics2D_Impl* graphics_2d = enter_2d.succeeded() ? | 1730 PPB_Graphics2D_Impl* graphics_2d = enter_2d.succeeded() ? |
| 1729 static_cast<PPB_Graphics2D_Impl*>(enter_2d.object()) : NULL; | 1731 static_cast<PPB_Graphics2D_Impl*>(enter_2d.object()) : NULL; |
| 1730 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); | 1732 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); |
| 1731 PPB_Graphics3D_Impl* graphics_3d = enter_3d.succeeded() ? | 1733 PPB_Graphics3D_Impl* graphics_3d = enter_3d.succeeded() ? |
| 1732 static_cast<PPB_Graphics3D_Impl*>(enter_3d.object()) : NULL; | 1734 static_cast<PPB_Graphics3D_Impl*>(enter_3d.object()) : NULL; |
| 1733 | 1735 |
| 1734 if (graphics_2d) { | 1736 if (graphics_2d) { |
| 1735 if (graphics_2d->pp_instance() != pp_instance()) | 1737 if (graphics_2d->pp_instance() != pp_instance()) |
| 1736 return PP_FALSE; // Can't bind other instance's contexts. | 1738 return PP_FALSE; // Can't bind other instance's contexts. |
| 1737 if (!graphics_2d->BindToInstance(this)) | 1739 if (!graphics_2d->BindToInstance(this)) |
| 1738 return PP_FALSE; // Can't bind to more than one instance. | 1740 return PP_FALSE; // Can't bind to more than one instance. |
| 1739 | 1741 |
| 1740 bound_graphics_ = graphics_2d; | 1742 bound_graphics_ = graphics_2d; |
| 1741 setBackingTextureId(0); | 1743 setBackingTextureId(0, graphics_2d->is_always_opaque()); |
| 1742 // BindToInstance will have invalidated the plugin if necessary. | 1744 // BindToInstance will have invalidated the plugin if necessary. |
| 1743 } else if (graphics_3d) { | 1745 } else if (graphics_3d) { |
| 1744 // Make sure graphics can only be bound to the instance it is | 1746 // Make sure graphics can only be bound to the instance it is |
| 1745 // associated with. | 1747 // associated with. |
| 1746 if (graphics_3d->pp_instance() != pp_instance()) | 1748 if (graphics_3d->pp_instance() != pp_instance()) |
| 1747 return PP_FALSE; | 1749 return PP_FALSE; |
| 1748 if (!graphics_3d->BindToInstance(true)) | 1750 if (!graphics_3d->BindToInstance(true)) |
| 1749 return PP_FALSE; | 1751 return PP_FALSE; |
| 1750 | 1752 |
| 1751 bound_graphics_ = graphics_3d; | 1753 bound_graphics_ = graphics_3d; |
| 1752 setBackingTextureId(graphics_3d->GetBackingTextureId()); | 1754 setBackingTextureId(graphics_3d->GetBackingTextureId(), |
| 1755 graphics_3d->IsOpaque()); |
| 1753 } else { | 1756 } else { |
| 1754 // The device is not a valid resource type. | 1757 // The device is not a valid resource type. |
| 1755 return PP_FALSE; | 1758 return PP_FALSE; |
| 1756 } | 1759 } |
| 1757 | 1760 |
| 1758 return PP_TRUE; | 1761 return PP_TRUE; |
| 1759 } | 1762 } |
| 1760 | 1763 |
| 1761 PP_Bool PluginInstance::IsFullFrame(PP_Instance instance) { | 1764 PP_Bool PluginInstance::IsFullFrame(PP_Instance instance) { |
| 1762 return PP_FromBool(full_frame()); | 1765 return PP_FromBool(full_frame()); |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2077 screen_size_for_fullscreen_ = gfx::Size(); | 2080 screen_size_for_fullscreen_ = gfx::Size(); |
| 2078 WebElement element = container_->element(); | 2081 WebElement element = container_->element(); |
| 2079 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2082 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
| 2080 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2083 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
| 2081 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2084 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
| 2082 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2085 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
| 2083 } | 2086 } |
| 2084 | 2087 |
| 2085 } // namespace ppapi | 2088 } // namespace ppapi |
| 2086 } // namespace webkit | 2089 } // namespace webkit |
| OLD | NEW |