| 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 "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/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 if (!container_ || view_data_.rect.size.width == 0 || | 740 if (!container_ || view_data_.rect.size.width == 0 || |
| 741 view_data_.rect.size.height == 0) | 741 view_data_.rect.size.height == 0) |
| 742 return; // Nothing to do. | 742 return; // Nothing to do. |
| 743 if (rect.IsEmpty()) | 743 if (rect.IsEmpty()) |
| 744 container_->invalidate(); | 744 container_->invalidate(); |
| 745 else | 745 else |
| 746 container_->invalidateRect(rect); | 746 container_->invalidateRect(rect); |
| 747 } | 747 } |
| 748 | 748 |
| 749 cc::Layer* layer = | 749 cc::Layer* layer = |
| 750 texture_layer_ ? texture_layer_.get() : compositor_layer_.get(); | 750 texture_layer_.get() ? texture_layer_.get() : compositor_layer_.get(); |
| 751 if (layer) { | 751 if (layer) { |
| 752 if (rect.IsEmpty()) { | 752 if (rect.IsEmpty()) { |
| 753 layer->SetNeedsDisplay(); | 753 layer->SetNeedsDisplay(); |
| 754 } else { | 754 } else { |
| 755 layer->SetNeedsDisplayRect(rect); | 755 layer->SetNeedsDisplayRect(rect); |
| 756 } | 756 } |
| 757 } | 757 } |
| 758 } | 758 } |
| 759 | 759 |
| 760 void PepperPluginInstanceImpl::ScrollRect(int dx, | 760 void PepperPluginInstanceImpl::ScrollRect(int dx, |
| 761 int dy, | 761 int dy, |
| 762 const gfx::Rect& rect) { | 762 const gfx::Rect& rect) { |
| 763 cc::Layer* layer = | 763 cc::Layer* layer = |
| 764 texture_layer_ ? texture_layer_.get() : compositor_layer_.get(); | 764 texture_layer_.get() ? texture_layer_.get() : compositor_layer_.get(); |
| 765 if (layer) { | 765 if (layer) { |
| 766 InvalidateRect(rect); | 766 InvalidateRect(rect); |
| 767 } else if (fullscreen_container_) { | 767 } else if (fullscreen_container_) { |
| 768 fullscreen_container_->ScrollRect(dx, dy, rect); | 768 fullscreen_container_->ScrollRect(dx, dy, rect); |
| 769 } else { | 769 } else { |
| 770 if (full_frame_ && !IsViewAccelerated()) { | 770 if (full_frame_ && !IsViewAccelerated()) { |
| 771 container_->scrollRect(rect); | 771 container_->scrollRect(rect); |
| 772 } else { | 772 } else { |
| 773 // Can't do optimized scrolling since there could be other elements on top | 773 // Can't do optimized scrolling since there could be other elements on top |
| 774 // of us or the view renders via the accelerated compositor which is | 774 // of us or the view renders via the accelerated compositor which is |
| (...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1522 bool PepperPluginInstanceImpl::LoadPrivateInterface() { | 1522 bool PepperPluginInstanceImpl::LoadPrivateInterface() { |
| 1523 // If this is a NaCl app, we want to talk to the trusted NaCl plugin to | 1523 // If this is a NaCl app, we want to talk to the trusted NaCl plugin to |
| 1524 // call GetInstanceObject. This is necessary to ensure that the properties | 1524 // call GetInstanceObject. This is necessary to ensure that the properties |
| 1525 // the trusted plugin exposes (readyState and lastError) work properly. Note | 1525 // the trusted plugin exposes (readyState and lastError) work properly. Note |
| 1526 // that untrusted NaCl apps are not allowed to provide PPP_InstancePrivate, | 1526 // that untrusted NaCl apps are not allowed to provide PPP_InstancePrivate, |
| 1527 // so it's correct to never look up PPP_InstancePrivate for them. | 1527 // so it's correct to never look up PPP_InstancePrivate for them. |
| 1528 // | 1528 // |
| 1529 // If this is *not* a NaCl plugin, original_module_ will never be set; we talk | 1529 // If this is *not* a NaCl plugin, original_module_ will never be set; we talk |
| 1530 // to the "real" module. | 1530 // to the "real" module. |
| 1531 scoped_refptr<PluginModule> module = | 1531 scoped_refptr<PluginModule> module = |
| 1532 original_module_ ? original_module_ : module_; | 1532 original_module_.get() ? original_module_ : module_; |
| 1533 // Only check for the interface if the plugin has private permission. | 1533 // Only check for the interface if the plugin has private permission. |
| 1534 if (!module->permissions().HasPermission(ppapi::PERMISSION_PRIVATE)) | 1534 if (!module->permissions().HasPermission(ppapi::PERMISSION_PRIVATE)) |
| 1535 return false; | 1535 return false; |
| 1536 if (!plugin_private_interface_) { | 1536 if (!plugin_private_interface_) { |
| 1537 plugin_private_interface_ = static_cast<const PPP_Instance_Private*>( | 1537 plugin_private_interface_ = static_cast<const PPP_Instance_Private*>( |
| 1538 module->GetPluginInterface(PPP_INSTANCE_PRIVATE_INTERFACE)); | 1538 module->GetPluginInterface(PPP_INSTANCE_PRIVATE_INTERFACE)); |
| 1539 } | 1539 } |
| 1540 | 1540 |
| 1541 return !!plugin_private_interface_; | 1541 return !!plugin_private_interface_; |
| 1542 } | 1542 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1561 bool PepperPluginInstanceImpl::LoadZoomInterface() { | 1561 bool PepperPluginInstanceImpl::LoadZoomInterface() { |
| 1562 if (!plugin_zoom_interface_) { | 1562 if (!plugin_zoom_interface_) { |
| 1563 plugin_zoom_interface_ = static_cast<const PPP_Zoom_Dev*>( | 1563 plugin_zoom_interface_ = static_cast<const PPP_Zoom_Dev*>( |
| 1564 module_->GetPluginInterface(PPP_ZOOM_DEV_INTERFACE)); | 1564 module_->GetPluginInterface(PPP_ZOOM_DEV_INTERFACE)); |
| 1565 } | 1565 } |
| 1566 | 1566 |
| 1567 return !!plugin_zoom_interface_; | 1567 return !!plugin_zoom_interface_; |
| 1568 } | 1568 } |
| 1569 | 1569 |
| 1570 void PepperPluginInstanceImpl::UpdateLayerTransform() { | 1570 void PepperPluginInstanceImpl::UpdateLayerTransform() { |
| 1571 if (!bound_graphics_2d_platform_ || !texture_layer_) { | 1571 if (!bound_graphics_2d_platform_ || !texture_layer_.get()) { |
| 1572 // Currently the transform is only applied for Graphics2D. | 1572 // Currently the transform is only applied for Graphics2D. |
| 1573 return; | 1573 return; |
| 1574 } | 1574 } |
| 1575 // Set the UV coordinates of the texture based on the size of the Graphics2D | 1575 // Set the UV coordinates of the texture based on the size of the Graphics2D |
| 1576 // context. By default a texture gets scaled to the size of the layer. But | 1576 // context. By default a texture gets scaled to the size of the layer. But |
| 1577 // if the size of the Graphics2D context doesn't match the size of the plugin | 1577 // if the size of the Graphics2D context doesn't match the size of the plugin |
| 1578 // then it will be incorrectly stretched. This also affects how the plugin | 1578 // then it will be incorrectly stretched. This also affects how the plugin |
| 1579 // is painted when it is being resized. If the Graphics2D contents are | 1579 // is painted when it is being resized. If the Graphics2D contents are |
| 1580 // stretched when a plugin is resized while waiting for a new frame from the | 1580 // stretched when a plugin is resized while waiting for a new frame from the |
| 1581 // plugin to be rendered, then flickering behavior occurs as in | 1581 // plugin to be rendered, then flickering behavior occurs as in |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2036 uint32 sync_point = 0; | 2036 uint32 sync_point = 0; |
| 2037 if (bound_graphics_3d_.get()) { | 2037 if (bound_graphics_3d_.get()) { |
| 2038 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_point); | 2038 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_point); |
| 2039 DCHECK_EQ(mailbox.IsZero(), sync_point == 0); | 2039 DCHECK_EQ(mailbox.IsZero(), sync_point == 0); |
| 2040 } | 2040 } |
| 2041 bool want_3d_layer = !mailbox.IsZero(); | 2041 bool want_3d_layer = !mailbox.IsZero(); |
| 2042 bool want_2d_layer = !!bound_graphics_2d_platform_; | 2042 bool want_2d_layer = !!bound_graphics_2d_platform_; |
| 2043 bool want_texture_layer = want_3d_layer || want_2d_layer; | 2043 bool want_texture_layer = want_3d_layer || want_2d_layer; |
| 2044 bool want_compositor_layer = !!bound_compositor_; | 2044 bool want_compositor_layer = !!bound_compositor_; |
| 2045 | 2045 |
| 2046 if (!device_changed && | 2046 if (!device_changed && (want_texture_layer == !!texture_layer_.get()) && |
| 2047 (want_texture_layer == !!texture_layer_.get()) && | |
| 2048 (want_3d_layer == layer_is_hardware_) && | 2047 (want_3d_layer == layer_is_hardware_) && |
| 2049 (want_compositor_layer == !!compositor_layer_) && | 2048 (want_compositor_layer == !!compositor_layer_.get()) && |
| 2050 layer_bound_to_fullscreen_ == !!fullscreen_container_) { | 2049 layer_bound_to_fullscreen_ == !!fullscreen_container_) { |
| 2051 UpdateLayerTransform(); | 2050 UpdateLayerTransform(); |
| 2052 return; | 2051 return; |
| 2053 } | 2052 } |
| 2054 | 2053 |
| 2055 if (texture_layer_ || compositor_layer_) { | 2054 if (texture_layer_.get() || compositor_layer_.get()) { |
| 2056 if (!layer_bound_to_fullscreen_) | 2055 if (!layer_bound_to_fullscreen_) |
| 2057 container_->setWebLayer(NULL); | 2056 container_->setWebLayer(NULL); |
| 2058 else if (fullscreen_container_) | 2057 else if (fullscreen_container_) |
| 2059 fullscreen_container_->SetLayer(NULL); | 2058 fullscreen_container_->SetLayer(NULL); |
| 2060 web_layer_.reset(); | 2059 web_layer_.reset(); |
| 2061 texture_layer_ = NULL; | 2060 texture_layer_ = NULL; |
| 2062 compositor_layer_ = NULL; | 2061 compositor_layer_ = NULL; |
| 2063 } | 2062 } |
| 2064 | 2063 |
| 2065 if (want_texture_layer) { | 2064 if (want_texture_layer) { |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2626 case ppapi::FLASH_SINGLETON_ID: | 2625 case ppapi::FLASH_SINGLETON_ID: |
| 2627 case ppapi::ISOLATED_FILESYSTEM_SINGLETON_ID: | 2626 case ppapi::ISOLATED_FILESYSTEM_SINGLETON_ID: |
| 2628 case ppapi::NETWORK_PROXY_SINGLETON_ID: | 2627 case ppapi::NETWORK_PROXY_SINGLETON_ID: |
| 2629 case ppapi::PDF_SINGLETON_ID: | 2628 case ppapi::PDF_SINGLETON_ID: |
| 2630 case ppapi::TRUETYPE_FONT_SINGLETON_ID: | 2629 case ppapi::TRUETYPE_FONT_SINGLETON_ID: |
| 2631 NOTIMPLEMENTED(); | 2630 NOTIMPLEMENTED(); |
| 2632 return NULL; | 2631 return NULL; |
| 2633 case ppapi::GAMEPAD_SINGLETON_ID: | 2632 case ppapi::GAMEPAD_SINGLETON_ID: |
| 2634 return gamepad_impl_.get(); | 2633 return gamepad_impl_.get(); |
| 2635 case ppapi::UMA_SINGLETON_ID: { | 2634 case ppapi::UMA_SINGLETON_ID: { |
| 2636 if (!uma_private_impl_) { | 2635 if (!uma_private_impl_.get()) { |
| 2637 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host(); | 2636 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host(); |
| 2638 if (host_impl->in_process_router()) { | 2637 if (host_impl->in_process_router()) { |
| 2639 uma_private_impl_ = new ppapi::proxy::UMAPrivateResource( | 2638 uma_private_impl_ = new ppapi::proxy::UMAPrivateResource( |
| 2640 host_impl->in_process_router()->GetPluginConnection(instance), | 2639 host_impl->in_process_router()->GetPluginConnection(instance), |
| 2641 instance); | 2640 instance); |
| 2642 } | 2641 } |
| 2643 } | 2642 } |
| 2644 return uma_private_impl_.get(); | 2643 return uma_private_impl_.get(); |
| 2645 } | 2644 } |
| 2646 } | 2645 } |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3320 // Running out-of-process. Initiate an IPC call to notify the plugin | 3319 // Running out-of-process. Initiate an IPC call to notify the plugin |
| 3321 // process. | 3320 // process. |
| 3322 ppapi::proxy::HostDispatcher* dispatcher = | 3321 ppapi::proxy::HostDispatcher* dispatcher = |
| 3323 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); | 3322 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); |
| 3324 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( | 3323 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( |
| 3325 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); | 3324 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); |
| 3326 } | 3325 } |
| 3327 } | 3326 } |
| 3328 | 3327 |
| 3329 } // namespace content | 3328 } // namespace content |
| OLD | NEW |