| 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/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 container_->scrollRect(dx, dy, rect); | 566 container_->scrollRect(dx, dy, rect); |
| 567 } else { | 567 } else { |
| 568 // Can't do optimized scrolling since there could be other elements on top | 568 // Can't do optimized scrolling since there could be other elements on top |
| 569 // of us or the view renders via the accelerated compositor which is | 569 // of us or the view renders via the accelerated compositor which is |
| 570 // incompatible with the move and backfill scrolling model. | 570 // incompatible with the move and backfill scrolling model. |
| 571 InvalidateRect(rect); | 571 InvalidateRect(rect); |
| 572 } | 572 } |
| 573 } | 573 } |
| 574 } | 574 } |
| 575 | 575 |
| 576 unsigned PluginInstance::GetBackingTextureId() { | |
| 577 if (bound_graphics_3d_.get()) | |
| 578 return bound_graphics_3d_->GetBackingTextureId(); | |
| 579 | |
| 580 return 0; | |
| 581 } | |
| 582 | |
| 583 void PluginInstance::CommitBackingTexture() { | 576 void PluginInstance::CommitBackingTexture() { |
| 584 if (texture_layer_.get()) | 577 if (texture_layer_.get()) |
| 585 texture_layer_->SetNeedsDisplay(); | 578 texture_layer_->SetNeedsDisplay(); |
| 586 } | 579 } |
| 587 | 580 |
| 588 void PluginInstance::InstanceCrashed() { | 581 void PluginInstance::InstanceCrashed() { |
| 589 // Force free all resources and vars. | 582 // Force free all resources and vars. |
| 590 HostGlobals::Get()->InstanceCrashed(pp_instance()); | 583 HostGlobals::Get()->InstanceCrashed(pp_instance()); |
| 591 | 584 |
| 592 // Free any associated graphics. | 585 // Free any associated graphics. |
| (...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1576 bool is_mouselock_pending = TrackedCallback::IsPending(lock_mouse_callback_); | 1569 bool is_mouselock_pending = TrackedCallback::IsPending(lock_mouse_callback_); |
| 1577 | 1570 |
| 1578 if (flash_fullscreen == flash_fullscreen_) { | 1571 if (flash_fullscreen == flash_fullscreen_) { |
| 1579 // Manually clear callback when fullscreen fails with mouselock pending. | 1572 // Manually clear callback when fullscreen fails with mouselock pending. |
| 1580 if (!flash_fullscreen && is_mouselock_pending) | 1573 if (!flash_fullscreen && is_mouselock_pending) |
| 1581 lock_mouse_callback_->Run(PP_ERROR_FAILED); | 1574 lock_mouse_callback_->Run(PP_ERROR_FAILED); |
| 1582 return; | 1575 return; |
| 1583 } | 1576 } |
| 1584 | 1577 |
| 1585 PPB_Graphics3D_Impl* graphics_3d = bound_graphics_3d_.get(); | 1578 PPB_Graphics3D_Impl* graphics_3d = bound_graphics_3d_.get(); |
| 1586 if (graphics_3d) { | 1579 if (graphics_3d) |
| 1587 if (flash_fullscreen) { | |
| 1588 fullscreen_container_->ReparentContext(graphics_3d->platform_context()); | |
| 1589 } else { | |
| 1590 delegate_->ReparentContext(graphics_3d->platform_context()); | |
| 1591 } | |
| 1592 UpdateLayer(); | 1580 UpdateLayer(); |
| 1593 } | |
| 1594 | 1581 |
| 1595 bool old_plugin_focus = PluginHasFocus(); | 1582 bool old_plugin_focus = PluginHasFocus(); |
| 1596 flash_fullscreen_ = flash_fullscreen; | 1583 flash_fullscreen_ = flash_fullscreen; |
| 1597 if (is_mouselock_pending && !delegate()->IsMouseLocked(this)) { | 1584 if (is_mouselock_pending && !delegate()->IsMouseLocked(this)) { |
| 1598 if (!IsProcessingUserGesture() && | 1585 if (!IsProcessingUserGesture() && |
| 1599 !module_->permissions().HasPermission( | 1586 !module_->permissions().HasPermission( |
| 1600 ::ppapi::PERMISSION_BYPASS_USER_GESTURE)) { | 1587 ::ppapi::PERMISSION_BYPASS_USER_GESTURE)) { |
| 1601 lock_mouse_callback_->Run(PP_ERROR_NO_USER_GESTURE); | 1588 lock_mouse_callback_->Run(PP_ERROR_NO_USER_GESTURE); |
| 1602 } else { | 1589 } else { |
| 1603 // Open a user gesture here so the Webkit user gesture checks will succeed | 1590 // Open a user gesture here so the Webkit user gesture checks will succeed |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1672 if (!frame) | 1659 if (!frame) |
| 1673 return false; | 1660 return false; |
| 1674 WebView* view = frame->view(); | 1661 WebView* view = frame->view(); |
| 1675 if (!view) | 1662 if (!view) |
| 1676 return false; | 1663 return false; |
| 1677 | 1664 |
| 1678 return view->isAcceleratedCompositingActive(); | 1665 return view->isAcceleratedCompositingActive(); |
| 1679 } | 1666 } |
| 1680 | 1667 |
| 1681 PluginDelegate::PlatformContext3D* PluginInstance::CreateContext3D() { | 1668 PluginDelegate::PlatformContext3D* PluginInstance::CreateContext3D() { |
| 1682 if (fullscreen_container_) | 1669 return delegate_->CreateContext3D(); |
| 1683 return fullscreen_container_->CreateContext3D(); | |
| 1684 else | |
| 1685 return delegate_->CreateContext3D(); | |
| 1686 } | 1670 } |
| 1687 | 1671 |
| 1688 bool PluginInstance::PrintPDFOutput(PP_Resource print_output, | 1672 bool PluginInstance::PrintPDFOutput(PP_Resource print_output, |
| 1689 WebKit::WebCanvas* canvas) { | 1673 WebKit::WebCanvas* canvas) { |
| 1690 #if defined(ENABLE_PRINTING) | 1674 #if defined(ENABLE_PRINTING) |
| 1691 ::ppapi::thunk::EnterResourceNoLock<PPB_Buffer_API> enter(print_output, true); | 1675 ::ppapi::thunk::EnterResourceNoLock<PPB_Buffer_API> enter(print_output, true); |
| 1692 if (enter.failed()) | 1676 if (enter.failed()) |
| 1693 return false; | 1677 return false; |
| 1694 | 1678 |
| 1695 BufferAutoMapper mapper(enter.object()); | 1679 BufferAutoMapper mapper(enter.object()); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1774 return ret; | 1758 return ret; |
| 1775 #else // defined(ENABLE_PRINTING) | 1759 #else // defined(ENABLE_PRINTING) |
| 1776 return false; | 1760 return false; |
| 1777 #endif | 1761 #endif |
| 1778 } | 1762 } |
| 1779 | 1763 |
| 1780 PluginDelegate::PlatformGraphics2D* PluginInstance::GetBoundGraphics2D() const { | 1764 PluginDelegate::PlatformGraphics2D* PluginInstance::GetBoundGraphics2D() const { |
| 1781 return bound_graphics_2d_platform_; | 1765 return bound_graphics_2d_platform_; |
| 1782 } | 1766 } |
| 1783 | 1767 |
| 1768 static void IgnoreCallback(unsigned, bool) {} |
| 1769 |
| 1784 void PluginInstance::UpdateLayer() { | 1770 void PluginInstance::UpdateLayer() { |
| 1785 if (!container_) | 1771 if (!container_) |
| 1786 return; | 1772 return; |
| 1787 | 1773 |
| 1788 bool want_layer = GetBackingTextureId(); | 1774 gpu::Mailbox mailbox; |
| 1775 if (bound_graphics_3d_) { |
| 1776 PluginDelegate::PlatformContext3D* context = |
| 1777 bound_graphics_3d_->platform_context(); |
| 1778 context->GetBackingMailbox(&mailbox); |
| 1779 } |
| 1780 bool want_layer = !mailbox.IsZero(); |
| 1789 | 1781 |
| 1790 if (want_layer == !!texture_layer_.get() && | 1782 if (want_layer == !!texture_layer_.get() && |
| 1791 layer_bound_to_fullscreen_ == !!fullscreen_container_) | 1783 layer_bound_to_fullscreen_ == !!fullscreen_container_) |
| 1792 return; | 1784 return; |
| 1793 | 1785 |
| 1794 if (texture_layer_.get()) { | 1786 if (texture_layer_.get()) { |
| 1795 texture_layer_->ClearClient(); | |
| 1796 if (!layer_bound_to_fullscreen_) | 1787 if (!layer_bound_to_fullscreen_) |
| 1797 container_->setWebLayer(NULL); | 1788 container_->setWebLayer(NULL); |
| 1798 else if (fullscreen_container_) | 1789 else if (fullscreen_container_) |
| 1799 fullscreen_container_->SetLayer(NULL); | 1790 fullscreen_container_->SetLayer(NULL); |
| 1800 web_layer_.reset(); | 1791 web_layer_.reset(); |
| 1801 texture_layer_ = NULL; | 1792 texture_layer_ = NULL; |
| 1802 } | 1793 } |
| 1803 if (want_layer) { | 1794 if (want_layer) { |
| 1804 DCHECK(bound_graphics_3d_.get()); | 1795 DCHECK(bound_graphics_3d_.get()); |
| 1805 texture_layer_ = cc::TextureLayer::Create(this); | 1796 texture_layer_ = cc::TextureLayer::CreateForMailbox(NULL); |
| 1806 web_layer_.reset(new webkit::WebLayerImpl(texture_layer_)); | 1797 web_layer_.reset(new webkit::WebLayerImpl(texture_layer_)); |
| 1807 if (fullscreen_container_) { | 1798 if (fullscreen_container_) { |
| 1808 fullscreen_container_->SetLayer(web_layer_.get()); | 1799 fullscreen_container_->SetLayer(web_layer_.get()); |
| 1809 // Ignore transparency in fullscreen, since that's what Flash always | 1800 // Ignore transparency in fullscreen, since that's what Flash always |
| 1810 // wants to do, and that lets it not recreate a context if | 1801 // wants to do, and that lets it not recreate a context if |
| 1811 // wmode=transparent was specified. | 1802 // wmode=transparent was specified. |
| 1812 texture_layer_->SetContentsOpaque(true); | 1803 texture_layer_->SetContentsOpaque(true); |
| 1813 } else { | 1804 } else { |
| 1814 container_->setWebLayer(web_layer_.get()); | 1805 container_->setWebLayer(web_layer_.get()); |
| 1815 texture_layer_->SetContentsOpaque(bound_graphics_3d_->IsOpaque()); | 1806 texture_layer_->SetContentsOpaque(bound_graphics_3d_->IsOpaque()); |
| 1816 } | 1807 } |
| 1808 texture_layer_->SetTextureMailbox( |
| 1809 cc::TextureMailbox(mailbox, base::Bind(&IgnoreCallback), 0)); |
| 1817 } | 1810 } |
| 1818 layer_bound_to_fullscreen_ = !!fullscreen_container_; | 1811 layer_bound_to_fullscreen_ = !!fullscreen_container_; |
| 1819 } | 1812 } |
| 1820 | 1813 |
| 1821 void PluginInstance::AddPluginObject(PluginObject* plugin_object) { | 1814 void PluginInstance::AddPluginObject(PluginObject* plugin_object) { |
| 1822 DCHECK(live_plugin_objects_.find(plugin_object) == | 1815 DCHECK(live_plugin_objects_.find(plugin_object) == |
| 1823 live_plugin_objects_.end()); | 1816 live_plugin_objects_.end()); |
| 1824 live_plugin_objects_.insert(plugin_object); | 1817 live_plugin_objects_.insert(plugin_object); |
| 1825 } | 1818 } |
| 1826 | 1819 |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2171 const PP_DecryptedFrameInfo* frame_info) { | 2164 const PP_DecryptedFrameInfo* frame_info) { |
| 2172 content_decryptor_delegate_->DeliverFrame(decrypted_frame, frame_info); | 2165 content_decryptor_delegate_->DeliverFrame(decrypted_frame, frame_info); |
| 2173 } | 2166 } |
| 2174 | 2167 |
| 2175 void PluginInstance::DeliverSamples(PP_Instance instance, | 2168 void PluginInstance::DeliverSamples(PP_Instance instance, |
| 2176 PP_Resource audio_frames, | 2169 PP_Resource audio_frames, |
| 2177 const PP_DecryptedBlockInfo* block_info) { | 2170 const PP_DecryptedBlockInfo* block_info) { |
| 2178 content_decryptor_delegate_->DeliverSamples(audio_frames, block_info); | 2171 content_decryptor_delegate_->DeliverSamples(audio_frames, block_info); |
| 2179 } | 2172 } |
| 2180 | 2173 |
| 2181 unsigned PluginInstance::PrepareTexture(cc::ResourceUpdateQueue* queue) { | |
| 2182 return GetBackingTextureId(); | |
| 2183 } | |
| 2184 | |
| 2185 WebKit::WebGraphicsContext3D* PluginInstance::Context3d() { | |
| 2186 DCHECK(bound_graphics_3d_.get()); | |
| 2187 DCHECK(bound_graphics_3d_->platform_context()); | |
| 2188 return bound_graphics_3d_->platform_context()->GetParentContext(); | |
| 2189 } | |
| 2190 | |
| 2191 bool PluginInstance::PrepareTextureMailbox(cc::TextureMailbox* mailbox) { | |
| 2192 return false; | |
| 2193 } | |
| 2194 | |
| 2195 void PluginInstance::NumberOfFindResultsChanged(PP_Instance instance, | 2174 void PluginInstance::NumberOfFindResultsChanged(PP_Instance instance, |
| 2196 int32_t total, | 2175 int32_t total, |
| 2197 PP_Bool final_result) { | 2176 PP_Bool final_result) { |
| 2198 DCHECK_NE(find_identifier_, -1); | 2177 DCHECK_NE(find_identifier_, -1); |
| 2199 delegate_->NumberOfFindResultsChanged(find_identifier_, total, | 2178 delegate_->NumberOfFindResultsChanged(find_identifier_, total, |
| 2200 PP_ToBool(final_result)); | 2179 PP_ToBool(final_result)); |
| 2201 } | 2180 } |
| 2202 | 2181 |
| 2203 void PluginInstance::SelectedFindResultChanged(PP_Instance instance, | 2182 void PluginInstance::SelectedFindResultChanged(PP_Instance instance, |
| 2204 int32_t index) { | 2183 int32_t index) { |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2613 screen_size_for_fullscreen_ = gfx::Size(); | 2592 screen_size_for_fullscreen_ = gfx::Size(); |
| 2614 WebElement element = container_->element(); | 2593 WebElement element = container_->element(); |
| 2615 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2594 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
| 2616 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2595 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
| 2617 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2596 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
| 2618 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2597 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
| 2619 } | 2598 } |
| 2620 | 2599 |
| 2621 } // namespace ppapi | 2600 } // namespace ppapi |
| 2622 } // namespace webkit | 2601 } // namespace webkit |
| OLD | NEW |