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 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 container_->scrollRect(dx, dy, rect); | 720 container_->scrollRect(dx, dy, rect); |
721 } else { | 721 } else { |
722 // Can't do optimized scrolling since there could be other elements on top | 722 // Can't do optimized scrolling since there could be other elements on top |
723 // of us or the view renders via the accelerated compositor which is | 723 // of us or the view renders via the accelerated compositor which is |
724 // incompatible with the move and backfill scrolling model. | 724 // incompatible with the move and backfill scrolling model. |
725 InvalidateRect(rect); | 725 InvalidateRect(rect); |
726 } | 726 } |
727 } | 727 } |
728 } | 728 } |
729 | 729 |
730 void PepperPluginInstanceImpl::CommitBackingTexture() { | 730 static void IgnoreCallback(uint32, bool) {} |
731 if (texture_layer_.get()) | 731 |
732 texture_layer_->SetNeedsDisplay(); | 732 void PepperPluginInstanceImpl::CommitBackingTexture(uint32 sync_point) { |
| 733 if (!texture_layer_.get()) |
| 734 return; |
| 735 gpu::Mailbox mailbox; |
| 736 PlatformContext3D* context = bound_graphics_3d_->platform_context(); |
| 737 context->GetBackingMailbox(&mailbox, &sync_point); |
| 738 DCHECK(!mailbox.IsZero()); |
| 739 DCHECK_NE(sync_point, 0u); |
| 740 texture_layer_->SetTextureMailbox( |
| 741 cc::TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), |
| 742 cc::SingleReleaseCallback::Create(base::Bind(&IgnoreCallback))); |
| 743 texture_layer_->SetNeedsDisplay(); |
733 } | 744 } |
734 | 745 |
735 void PepperPluginInstanceImpl::InstanceCrashed() { | 746 void PepperPluginInstanceImpl::InstanceCrashed() { |
736 // Force free all resources and vars. | 747 // Force free all resources and vars. |
737 HostGlobals::Get()->InstanceCrashed(pp_instance()); | 748 HostGlobals::Get()->InstanceCrashed(pp_instance()); |
738 | 749 |
739 // Free any associated graphics. | 750 // Free any associated graphics. |
740 SetFullscreen(false); | 751 SetFullscreen(false); |
741 FlashSetFullscreen(false, false); | 752 FlashSetFullscreen(false, false); |
742 // Unbind current 2D or 3D graphics context. | 753 // Unbind current 2D or 3D graphics context. |
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1909 skia::EndPlatformPaint(canvas); | 1920 skia::EndPlatformPaint(canvas); |
1910 } | 1921 } |
1911 #endif // defined(OS_WIN) | 1922 #endif // defined(OS_WIN) |
1912 | 1923 |
1913 return ret; | 1924 return ret; |
1914 #else // defined(ENABLE_FULL_PRINTING) | 1925 #else // defined(ENABLE_FULL_PRINTING) |
1915 return false; | 1926 return false; |
1916 #endif | 1927 #endif |
1917 } | 1928 } |
1918 | 1929 |
1919 static void IgnoreCallback(uint32, bool) {} | |
1920 | |
1921 void PepperPluginInstanceImpl::UpdateLayer() { | 1930 void PepperPluginInstanceImpl::UpdateLayer() { |
1922 if (!container_) | 1931 if (!container_) |
1923 return; | 1932 return; |
1924 | 1933 |
1925 gpu::Mailbox mailbox; | 1934 gpu::Mailbox mailbox; |
| 1935 uint32 sync_point = 0; |
1926 if (bound_graphics_3d_.get()) { | 1936 if (bound_graphics_3d_.get()) { |
1927 PlatformContext3D* context = bound_graphics_3d_->platform_context(); | 1937 PlatformContext3D* context = bound_graphics_3d_->platform_context(); |
1928 context->GetBackingMailbox(&mailbox); | 1938 context->GetBackingMailbox(&mailbox, &sync_point); |
| 1939 DCHECK_EQ(!mailbox.IsZero(), sync_point != 0); |
1929 } | 1940 } |
1930 bool want_3d_layer = !mailbox.IsZero(); | 1941 bool want_3d_layer = !mailbox.IsZero(); |
1931 bool want_2d_layer = bound_graphics_2d_platform_ && | 1942 bool want_2d_layer = bound_graphics_2d_platform_ && |
1932 CommandLine::ForCurrentProcess()->HasSwitch( | 1943 CommandLine::ForCurrentProcess()->HasSwitch( |
1933 switches::kEnableSoftwareCompositing); | 1944 switches::kEnableSoftwareCompositing); |
1934 bool want_layer = want_3d_layer || want_2d_layer; | 1945 bool want_layer = want_3d_layer || want_2d_layer; |
1935 | 1946 |
1936 if ((want_layer == !!texture_layer_.get()) && | 1947 if ((want_layer == !!texture_layer_.get()) && |
1937 (want_3d_layer == layer_is_hardware_) && | 1948 (want_3d_layer == layer_is_hardware_) && |
1938 layer_bound_to_fullscreen_ == !!fullscreen_container_) { | 1949 layer_bound_to_fullscreen_ == !!fullscreen_container_) { |
(...skipping 10 matching lines...) Expand all Loading... |
1949 texture_layer_ = NULL; | 1960 texture_layer_ = NULL; |
1950 } | 1961 } |
1951 if (want_layer) { | 1962 if (want_layer) { |
1952 bool opaque = false; | 1963 bool opaque = false; |
1953 scoped_refptr<cc::Layer> plugin_layer; | 1964 scoped_refptr<cc::Layer> plugin_layer; |
1954 if (want_3d_layer) { | 1965 if (want_3d_layer) { |
1955 DCHECK(bound_graphics_3d_.get()); | 1966 DCHECK(bound_graphics_3d_.get()); |
1956 texture_layer_ = cc::TextureLayer::CreateForMailbox(NULL); | 1967 texture_layer_ = cc::TextureLayer::CreateForMailbox(NULL); |
1957 opaque = bound_graphics_3d_->IsOpaque(); | 1968 opaque = bound_graphics_3d_->IsOpaque(); |
1958 texture_layer_->SetTextureMailbox( | 1969 texture_layer_->SetTextureMailbox( |
1959 cc::TextureMailbox(mailbox, GL_TEXTURE_2D, 0), | 1970 cc::TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), |
1960 cc::SingleReleaseCallback::Create(base::Bind(&IgnoreCallback))); | 1971 cc::SingleReleaseCallback::Create(base::Bind(&IgnoreCallback))); |
1961 plugin_layer = texture_layer_; | 1972 plugin_layer = texture_layer_; |
1962 } else { | 1973 } else { |
1963 DCHECK(bound_graphics_2d_platform_); | 1974 DCHECK(bound_graphics_2d_platform_); |
1964 texture_layer_ = cc::TextureLayer::CreateForMailbox(this); | 1975 texture_layer_ = cc::TextureLayer::CreateForMailbox(this); |
1965 bound_graphics_2d_platform_->AttachedToNewLayer(); | 1976 bound_graphics_2d_platform_->AttachedToNewLayer(); |
1966 opaque = bound_graphics_2d_platform_->IsAlwaysOpaque(); | 1977 opaque = bound_graphics_2d_platform_->IsAlwaysOpaque(); |
1967 texture_layer_->SetFlipped(false); | 1978 texture_layer_->SetFlipped(false); |
1968 texture_layer_->SetBounds(bound_graphics_2d_platform_->Size()); | 1979 texture_layer_->SetBounds(bound_graphics_2d_platform_->Size()); |
1969 texture_layer_->SetIsDrawable(true); | 1980 texture_layer_->SetIsDrawable(true); |
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3177 // Running out-of-process. Initiate an IPC call to notify the plugin | 3188 // Running out-of-process. Initiate an IPC call to notify the plugin |
3178 // process. | 3189 // process. |
3179 ppapi::proxy::HostDispatcher* dispatcher = | 3190 ppapi::proxy::HostDispatcher* dispatcher = |
3180 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); | 3191 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); |
3181 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( | 3192 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( |
3182 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); | 3193 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); |
3183 } | 3194 } |
3184 } | 3195 } |
3185 | 3196 |
3186 } // namespace content | 3197 } // namespace content |
OLD | NEW |