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

Side by Side Diff: content/renderer/pepper/pepper_plugin_instance_impl.cc

Issue 23866006: Make fullscreen pepper flash create a texture layer with software compositor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 "content/renderer/pepper/pepper_plugin_instance_impl.h" 5 #include "content/renderer/pepper/pepper_plugin_instance_impl.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/command_line.h"
9 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/memory/linked_ptr.h" 12 #include "base/memory/linked_ptr.h"
12 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
13 #include "base/stl_util.h" 14 #include "base/stl_util.h"
14 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_offset_string_conversions.h" 16 #include "base/strings/utf_offset_string_conversions.h"
16 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
17 #include "base/time/time.h" 18 #include "base/time/time.h"
18 #include "cc/layers/texture_layer.h" 19 #include "cc/layers/texture_layer.h"
19 #include "content/common/content_constants_internal.h" 20 #include "content/common/content_constants_internal.h"
21 #include "content/public/common/content_switches.h"
20 #include "content/public/common/page_zoom.h" 22 #include "content/public/common/page_zoom.h"
21 #include "content/public/renderer/content_renderer_client.h" 23 #include "content/public/renderer/content_renderer_client.h"
22 #include "content/renderer/pepper/common.h" 24 #include "content/renderer/pepper/common.h"
23 #include "content/renderer/pepper/content_decryptor_delegate.h" 25 #include "content/renderer/pepper/content_decryptor_delegate.h"
24 #include "content/renderer/pepper/event_conversion.h" 26 #include "content/renderer/pepper/event_conversion.h"
25 #include "content/renderer/pepper/fullscreen_container.h" 27 #include "content/renderer/pepper/fullscreen_container.h"
26 #include "content/renderer/pepper/gfx_conversion.h" 28 #include "content/renderer/pepper/gfx_conversion.h"
27 #include "content/renderer/pepper/host_dispatcher_wrapper.h" 29 #include "content/renderer/pepper/host_dispatcher_wrapper.h"
28 #include "content/renderer/pepper/host_globals.h" 30 #include "content/renderer/pepper/host_globals.h"
29 #include "content/renderer/pepper/message_channel.h" 31 #include "content/renderer/pepper/message_channel.h"
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 if (bound_graphics_2d_platform_) 616 if (bound_graphics_2d_platform_)
615 bound_graphics_2d_platform_->Paint(canvas, plugin_rect, paint_rect); 617 bound_graphics_2d_platform_->Paint(canvas, plugin_rect, paint_rect);
616 } 618 }
617 619
618 void PepperPluginInstanceImpl::InvalidateRect(const gfx::Rect& rect) { 620 void PepperPluginInstanceImpl::InvalidateRect(const gfx::Rect& rect) {
619 if (fullscreen_container_) { 621 if (fullscreen_container_) {
620 if (rect.IsEmpty()) 622 if (rect.IsEmpty())
621 fullscreen_container_->Invalidate(); 623 fullscreen_container_->Invalidate();
622 else 624 else
623 fullscreen_container_->InvalidateRect(rect); 625 fullscreen_container_->InvalidateRect(rect);
626 if (software_texture_layer_)
627 software_texture_layer_->SetNeedsDisplay();
624 } else { 628 } else {
625 if (!container_ || 629 if (!container_ ||
626 view_data_.rect.size.width == 0 || view_data_.rect.size.height == 0) 630 view_data_.rect.size.width == 0 || view_data_.rect.size.height == 0)
627 return; // Nothing to do. 631 return; // Nothing to do.
628 if (rect.IsEmpty()) 632 if (rect.IsEmpty())
629 container_->invalidate(); 633 container_->invalidate();
630 else 634 else
631 container_->invalidateRect(rect); 635 container_->invalidateRect(rect);
632 } 636 }
633 } 637 }
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
1658 bool flash_fullscreen) { 1662 bool flash_fullscreen) {
1659 bool is_mouselock_pending = TrackedCallback::IsPending(lock_mouse_callback_); 1663 bool is_mouselock_pending = TrackedCallback::IsPending(lock_mouse_callback_);
1660 1664
1661 if (flash_fullscreen == flash_fullscreen_) { 1665 if (flash_fullscreen == flash_fullscreen_) {
1662 // Manually clear callback when fullscreen fails with mouselock pending. 1666 // Manually clear callback when fullscreen fails with mouselock pending.
1663 if (!flash_fullscreen && is_mouselock_pending) 1667 if (!flash_fullscreen && is_mouselock_pending)
1664 lock_mouse_callback_->Run(PP_ERROR_FAILED); 1668 lock_mouse_callback_->Run(PP_ERROR_FAILED);
1665 return; 1669 return;
1666 } 1670 }
1667 1671
1668 PPB_Graphics3D_Impl* graphics_3d = bound_graphics_3d_.get(); 1672 UpdateLayer();
1669 if (graphics_3d)
1670 UpdateLayer();
1671 1673
1672 bool old_plugin_focus = PluginHasFocus(); 1674 bool old_plugin_focus = PluginHasFocus();
1673 flash_fullscreen_ = flash_fullscreen; 1675 flash_fullscreen_ = flash_fullscreen;
1674 if (is_mouselock_pending && !IsMouseLocked()) { 1676 if (is_mouselock_pending && !IsMouseLocked()) {
1675 if (!IsProcessingUserGesture() && 1677 if (!IsProcessingUserGesture() &&
1676 !module_->permissions().HasPermission( 1678 !module_->permissions().HasPermission(
1677 ppapi::PERMISSION_BYPASS_USER_GESTURE)) { 1679 ppapi::PERMISSION_BYPASS_USER_GESTURE)) {
1678 lock_mouse_callback_->Run(PP_ERROR_NO_USER_GESTURE); 1680 lock_mouse_callback_->Run(PP_ERROR_NO_USER_GESTURE);
1679 } else { 1681 } else {
1680 // Open a user gesture here so the Webkit user gesture checks will succeed 1682 // Open a user gesture here so the Webkit user gesture checks will succeed
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 void PepperPluginInstanceImpl::UpdateLayer() { 1803 void PepperPluginInstanceImpl::UpdateLayer() {
1802 if (!container_) 1804 if (!container_)
1803 return; 1805 return;
1804 1806
1805 gpu::Mailbox mailbox; 1807 gpu::Mailbox mailbox;
1806 if (bound_graphics_3d_.get()) { 1808 if (bound_graphics_3d_.get()) {
1807 PlatformContext3D* context = bound_graphics_3d_->platform_context(); 1809 PlatformContext3D* context = bound_graphics_3d_->platform_context();
1808 context->GetBackingMailbox(&mailbox); 1810 context->GetBackingMailbox(&mailbox);
1809 } 1811 }
1810 bool want_layer = !mailbox.IsZero(); 1812 bool want_layer = !mailbox.IsZero();
1813 bool want_2d_layer =
1814 !!fullscreen_container_ && CommandLine::ForCurrentProcess()->HasSwitch(
piman 2013/09/05 00:19:43 Should we do this in the !fullscreen case too? Wit
1815 switches::kEnableSoftwareCompositing);
1811 1816
1812 if (want_layer == !!texture_layer_.get() && 1817 if (want_layer == !!texture_layer_.get() &&
1818 (want_layer || (want_2d_layer == !!software_texture_layer_.get())) &&
1813 layer_bound_to_fullscreen_ == !!fullscreen_container_) 1819 layer_bound_to_fullscreen_ == !!fullscreen_container_)
1814 return; 1820 return;
1815 1821
1816 if (texture_layer_.get()) { 1822 if (texture_layer_ || software_texture_layer_) {
1817 if (!layer_bound_to_fullscreen_) 1823 if (!layer_bound_to_fullscreen_)
1818 container_->setWebLayer(NULL); 1824 container_->setWebLayer(NULL);
1819 else if (fullscreen_container_) 1825 else if (fullscreen_container_)
1820 fullscreen_container_->SetLayer(NULL); 1826 fullscreen_container_->SetLayer(NULL);
1821 web_layer_.reset(); 1827 web_layer_.reset();
1822 texture_layer_ = NULL; 1828 texture_layer_ = NULL;
1829 software_texture_layer_ = NULL;
1823 } 1830 }
1824 if (want_layer) { 1831 if (want_layer) {
1825 DCHECK(bound_graphics_3d_.get()); 1832 DCHECK(bound_graphics_3d_.get());
1826 texture_layer_ = cc::TextureLayer::CreateForMailbox(NULL); 1833 texture_layer_ = cc::TextureLayer::CreateForMailbox(NULL);
1827 web_layer_.reset(new webkit::WebLayerImpl(texture_layer_)); 1834 web_layer_.reset(new webkit::WebLayerImpl(texture_layer_));
1828 if (fullscreen_container_) { 1835 if (fullscreen_container_) {
1829 fullscreen_container_->SetLayer(web_layer_.get()); 1836 fullscreen_container_->SetLayer(web_layer_.get());
1830 // Ignore transparency in fullscreen, since that's what Flash always 1837 // Ignore transparency in fullscreen, since that's what Flash always
1831 // wants to do, and that lets it not recreate a context if 1838 // wants to do, and that lets it not recreate a context if
1832 // wmode=transparent was specified. 1839 // wmode=transparent was specified.
1833 texture_layer_->SetContentsOpaque(true); 1840 texture_layer_->SetContentsOpaque(true);
1834 } else { 1841 } else {
1835 container_->setWebLayer(web_layer_.get()); 1842 container_->setWebLayer(web_layer_.get());
1836 texture_layer_->SetContentsOpaque(bound_graphics_3d_->IsOpaque()); 1843 texture_layer_->SetContentsOpaque(bound_graphics_3d_->IsOpaque());
1837 } 1844 }
1838 texture_layer_->SetTextureMailbox( 1845 texture_layer_->SetTextureMailbox(
1839 cc::TextureMailbox(mailbox, base::Bind(&IgnoreCallback), 0)); 1846 cc::TextureMailbox(mailbox, base::Bind(&IgnoreCallback), 0));
1847 } else if (want_2d_layer) {
1848 software_texture_layer_ = cc::TextureLayer::CreateForMailbox(this);
1849 software_texture_layer_->SetContentsOpaque(true);
1850 web_layer_.reset(new webkit::WebLayerImpl(software_texture_layer_));
1851 fullscreen_container_->SetLayer(web_layer_.get());
1852 software_texture_layer_->SetIsDrawable(true);
1853 software_texture_layer_->SetFlipped(false);
1840 } 1854 }
1841 layer_bound_to_fullscreen_ = !!fullscreen_container_; 1855 layer_bound_to_fullscreen_ = !!fullscreen_container_;
1842 } 1856 }
1843 1857
1858 unsigned PepperPluginInstanceImpl::PrepareTexture() {
1859 return 0;
1860 }
1861
1862 WebKit::WebGraphicsContext3D* PepperPluginInstanceImpl::Context3d() {
1863 return NULL;
1864 }
1865
1866 bool PepperPluginInstanceImpl::PrepareTextureMailbox(
1867 cc::TextureMailbox* mailbox,
1868 bool use_shared_memory) {
1869 if (!bound_graphics_2d_platform_)
1870 return false;
1871 return bound_graphics_2d_platform_->PrepareTextureMailbox(mailbox);
1872 }
1873
1844 void PepperPluginInstanceImpl::AddPluginObject(PluginObject* plugin_object) { 1874 void PepperPluginInstanceImpl::AddPluginObject(PluginObject* plugin_object) {
1845 DCHECK(live_plugin_objects_.find(plugin_object) == 1875 DCHECK(live_plugin_objects_.find(plugin_object) ==
1846 live_plugin_objects_.end()); 1876 live_plugin_objects_.end());
1847 live_plugin_objects_.insert(plugin_object); 1877 live_plugin_objects_.insert(plugin_object);
1848 } 1878 }
1849 1879
1850 void PepperPluginInstanceImpl::RemovePluginObject(PluginObject* plugin_object) { 1880 void PepperPluginInstanceImpl::RemovePluginObject(PluginObject* plugin_object) {
1851 // Don't actually verify that the object is in the set since during module 1881 // Don't actually verify that the object is in the set since during module
1852 // deletion we'll be in the process of freeing them. 1882 // deletion we'll be in the process of freeing them.
1853 live_plugin_objects_.erase(plugin_object); 1883 live_plugin_objects_.erase(plugin_object);
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after
2906 // Running out-of-process. Initiate an IPC call to notify the plugin 2936 // Running out-of-process. Initiate an IPC call to notify the plugin
2907 // process. 2937 // process.
2908 ppapi::proxy::HostDispatcher* dispatcher = 2938 ppapi::proxy::HostDispatcher* dispatcher =
2909 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); 2939 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance());
2910 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( 2940 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad(
2911 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); 2941 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data));
2912 } 2942 }
2913 } 2943 }
2914 2944
2915 } // namespace content 2945 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698