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