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 1828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1839 bool flash_fullscreen) { | 1839 bool flash_fullscreen) { |
1840 bool is_mouselock_pending = TrackedCallback::IsPending(lock_mouse_callback_); | 1840 bool is_mouselock_pending = TrackedCallback::IsPending(lock_mouse_callback_); |
1841 | 1841 |
1842 if (flash_fullscreen == flash_fullscreen_) { | 1842 if (flash_fullscreen == flash_fullscreen_) { |
1843 // Manually clear callback when fullscreen fails with mouselock pending. | 1843 // Manually clear callback when fullscreen fails with mouselock pending. |
1844 if (!flash_fullscreen && is_mouselock_pending) | 1844 if (!flash_fullscreen && is_mouselock_pending) |
1845 lock_mouse_callback_->Run(PP_ERROR_FAILED); | 1845 lock_mouse_callback_->Run(PP_ERROR_FAILED); |
1846 return; | 1846 return; |
1847 } | 1847 } |
1848 | 1848 |
1849 UpdateLayer(); | 1849 UpdateLayer(false); |
1850 | 1850 |
1851 bool old_plugin_focus = PluginHasFocus(); | 1851 bool old_plugin_focus = PluginHasFocus(); |
1852 flash_fullscreen_ = flash_fullscreen; | 1852 flash_fullscreen_ = flash_fullscreen; |
1853 if (is_mouselock_pending && !IsMouseLocked()) { | 1853 if (is_mouselock_pending && !IsMouseLocked()) { |
1854 if (!IsProcessingUserGesture() && | 1854 if (!IsProcessingUserGesture() && |
1855 !module_->permissions().HasPermission( | 1855 !module_->permissions().HasPermission( |
1856 ppapi::PERMISSION_BYPASS_USER_GESTURE)) { | 1856 ppapi::PERMISSION_BYPASS_USER_GESTURE)) { |
1857 lock_mouse_callback_->Run(PP_ERROR_NO_USER_GESTURE); | 1857 lock_mouse_callback_->Run(PP_ERROR_NO_USER_GESTURE); |
1858 } else { | 1858 } else { |
1859 // Open a user gesture here so the Webkit user gesture checks will succeed | 1859 // Open a user gesture here so the Webkit user gesture checks will succeed |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1978 skia::EndPlatformPaint(canvas); | 1978 skia::EndPlatformPaint(canvas); |
1979 } | 1979 } |
1980 #endif // defined(OS_WIN) | 1980 #endif // defined(OS_WIN) |
1981 | 1981 |
1982 return ret; | 1982 return ret; |
1983 #else // defined(ENABLE_FULL_PRINTING) | 1983 #else // defined(ENABLE_FULL_PRINTING) |
1984 return false; | 1984 return false; |
1985 #endif | 1985 #endif |
1986 } | 1986 } |
1987 | 1987 |
1988 void PepperPluginInstanceImpl::UpdateLayer() { | 1988 void PepperPluginInstanceImpl::UpdateLayer(bool device_changed) { |
1989 if (!container_) | 1989 if (!container_) |
1990 return; | 1990 return; |
1991 | 1991 |
1992 gpu::Mailbox mailbox; | 1992 gpu::Mailbox mailbox; |
1993 uint32 sync_point = 0; | 1993 uint32 sync_point = 0; |
1994 if (bound_graphics_3d_.get()) { | 1994 if (bound_graphics_3d_.get()) { |
1995 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_point); | 1995 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_point); |
1996 DCHECK_EQ(mailbox.IsZero(), sync_point == 0); | 1996 DCHECK_EQ(mailbox.IsZero(), sync_point == 0); |
1997 } | 1997 } |
1998 bool want_3d_layer = !mailbox.IsZero(); | 1998 bool want_3d_layer = !mailbox.IsZero(); |
1999 bool want_2d_layer = !!bound_graphics_2d_platform_; | 1999 bool want_2d_layer = !!bound_graphics_2d_platform_; |
2000 bool want_texture_layer = want_3d_layer || want_2d_layer; | 2000 bool want_texture_layer = want_3d_layer || want_2d_layer; |
2001 bool want_compositor_layer = !!bound_compositor_; | 2001 bool want_compositor_layer = !!bound_compositor_; |
2002 | 2002 |
2003 if ((want_texture_layer == !!texture_layer_.get()) && | 2003 if (!device_changed && |
2004 (want_texture_layer == !!texture_layer_.get()) && | |
2004 (want_3d_layer == layer_is_hardware_) && | 2005 (want_3d_layer == layer_is_hardware_) && |
2005 (want_compositor_layer == !!compositor_layer_) && | 2006 (want_compositor_layer == !!compositor_layer_) && |
2006 layer_bound_to_fullscreen_ == !!fullscreen_container_) { | 2007 layer_bound_to_fullscreen_ == !!fullscreen_container_) { |
2007 UpdateLayerTransform(); | 2008 UpdateLayerTransform(); |
2008 return; | 2009 return; |
2009 } | 2010 } |
2010 | 2011 |
2011 if (texture_layer_ || compositor_layer_) { | 2012 if (texture_layer_ || compositor_layer_) { |
2012 if (!layer_bound_to_fullscreen_) | 2013 if (!layer_bound_to_fullscreen_) |
2013 container_->setWebLayer(NULL); | 2014 container_->setWebLayer(NULL); |
(...skipping 22 matching lines...) Expand all Loading... | |
2036 | 2037 |
2037 // Ignore transparency in fullscreen, since that's what Flash always | 2038 // Ignore transparency in fullscreen, since that's what Flash always |
2038 // wants to do, and that lets it not recreate a context if | 2039 // wants to do, and that lets it not recreate a context if |
2039 // wmode=transparent was specified. | 2040 // wmode=transparent was specified. |
2040 opaque = opaque || fullscreen_container_; | 2041 opaque = opaque || fullscreen_container_; |
2041 texture_layer_->SetContentsOpaque(opaque); | 2042 texture_layer_->SetContentsOpaque(opaque); |
2042 web_layer_.reset(new webkit::WebLayerImpl(texture_layer_)); | 2043 web_layer_.reset(new webkit::WebLayerImpl(texture_layer_)); |
2043 } else if (want_compositor_layer) { | 2044 } else if (want_compositor_layer) { |
2044 compositor_layer_ = bound_compositor_->layer(); | 2045 compositor_layer_ = bound_compositor_->layer(); |
2045 web_layer_.reset(new webkit::WebLayerImpl(compositor_layer_)); | 2046 web_layer_.reset(new webkit::WebLayerImpl(compositor_layer_)); |
2047 web_layer_.reset(new webkit::WebLayerImpl(compositor_layer_)); | |
piman
2014/06/18 00:55:24
Why do this twice?
Peng
2014/06/18 02:35:03
Oops! Done
| |
2046 } | 2048 } |
2047 | 2049 |
2048 if (web_layer_) { | 2050 if (web_layer_) { |
2049 if (fullscreen_container_) { | 2051 if (fullscreen_container_) { |
2050 fullscreen_container_->SetLayer(web_layer_.get()); | 2052 fullscreen_container_->SetLayer(web_layer_.get()); |
2051 } else { | 2053 } else { |
2052 container_->setWebLayer(web_layer_.get()); | 2054 container_->setWebLayer(web_layer_.get()); |
2053 } | 2055 } |
2054 } | 2056 } |
2055 | 2057 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2234 bound_graphics_2d_platform_->BindToInstance(NULL); | 2236 bound_graphics_2d_platform_->BindToInstance(NULL); |
2235 bound_graphics_2d_platform_ = NULL; | 2237 bound_graphics_2d_platform_ = NULL; |
2236 } | 2238 } |
2237 if (bound_compositor_) { | 2239 if (bound_compositor_) { |
2238 bound_compositor_->BindToInstance(NULL); | 2240 bound_compositor_->BindToInstance(NULL); |
2239 bound_compositor_ = NULL; | 2241 bound_compositor_ = NULL; |
2240 } | 2242 } |
2241 | 2243 |
2242 // Special-case clearing the current device. | 2244 // Special-case clearing the current device. |
2243 if (!device) { | 2245 if (!device) { |
2244 UpdateLayer(); | 2246 UpdateLayer(true); |
2245 InvalidateRect(gfx::Rect()); | 2247 InvalidateRect(gfx::Rect()); |
2246 return PP_TRUE; | 2248 return PP_TRUE; |
2247 } | 2249 } |
2248 | 2250 |
2249 // Refuse to bind if in transition to fullscreen with PPB_FlashFullscreen or | 2251 // Refuse to bind if in transition to fullscreen with PPB_FlashFullscreen or |
2250 // to/from fullscreen with PPB_Fullscreen. | 2252 // to/from fullscreen with PPB_Fullscreen. |
2251 if ((fullscreen_container_ && !flash_fullscreen_) || | 2253 if ((fullscreen_container_ && !flash_fullscreen_) || |
2252 desired_fullscreen_state_ != view_data_.is_fullscreen) | 2254 desired_fullscreen_state_ != view_data_.is_fullscreen) |
2253 return PP_FALSE; | 2255 return PP_FALSE; |
2254 | 2256 |
(...skipping 15 matching lines...) Expand all Loading... | |
2270 | 2272 |
2271 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); | 2273 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); |
2272 PPB_Graphics3D_Impl* graphics_3d = | 2274 PPB_Graphics3D_Impl* graphics_3d = |
2273 enter_3d.succeeded() | 2275 enter_3d.succeeded() |
2274 ? static_cast<PPB_Graphics3D_Impl*>(enter_3d.object()) | 2276 ? static_cast<PPB_Graphics3D_Impl*>(enter_3d.object()) |
2275 : NULL; | 2277 : NULL; |
2276 | 2278 |
2277 if (compositor) { | 2279 if (compositor) { |
2278 if (compositor->BindToInstance(this)) { | 2280 if (compositor->BindToInstance(this)) { |
2279 bound_compositor_ = compositor; | 2281 bound_compositor_ = compositor; |
2280 UpdateLayer(); | 2282 UpdateLayer(true); |
2281 return PP_TRUE; | 2283 return PP_TRUE; |
2282 } | 2284 } |
2283 } else if (graphics_2d) { | 2285 } else if (graphics_2d) { |
2284 if (graphics_2d->BindToInstance(this)) { | 2286 if (graphics_2d->BindToInstance(this)) { |
2285 bound_graphics_2d_platform_ = graphics_2d; | 2287 bound_graphics_2d_platform_ = graphics_2d; |
2286 UpdateLayer(); | 2288 UpdateLayer(true); |
2287 return PP_TRUE; | 2289 return PP_TRUE; |
2288 } | 2290 } |
2289 } else if (graphics_3d) { | 2291 } else if (graphics_3d) { |
2290 // Make sure graphics can only be bound to the instance it is | 2292 // Make sure graphics can only be bound to the instance it is |
2291 // associated with. | 2293 // associated with. |
2292 if (graphics_3d->pp_instance() == pp_instance() && | 2294 if (graphics_3d->pp_instance() == pp_instance() && |
2293 graphics_3d->BindToInstance(true)) { | 2295 graphics_3d->BindToInstance(true)) { |
2294 bound_graphics_3d_ = graphics_3d; | 2296 bound_graphics_3d_ = graphics_3d; |
2295 UpdateLayer(); | 2297 UpdateLayer(true); |
2296 return PP_TRUE; | 2298 return PP_TRUE; |
2297 } | 2299 } |
2298 } | 2300 } |
2299 | 2301 |
2300 // The instance cannot be bound or the device is not a valid resource type. | 2302 // The instance cannot be bound or the device is not a valid resource type. |
2301 return PP_FALSE; | 2303 return PP_FALSE; |
2302 } | 2304 } |
2303 | 2305 |
2304 PP_Bool PepperPluginInstanceImpl::IsFullFrame(PP_Instance instance) { | 2306 PP_Bool PepperPluginInstanceImpl::IsFullFrame(PP_Instance instance) { |
2305 return PP_FromBool(full_frame()); | 2307 return PP_FromBool(full_frame()); |
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3056 ->renderer_preferences() | 3058 ->renderer_preferences() |
3057 .plugin_fullscreen_allowed) | 3059 .plugin_fullscreen_allowed) |
3058 return false; | 3060 return false; |
3059 | 3061 |
3060 // Unbind current 2D or 3D graphics context. | 3062 // Unbind current 2D or 3D graphics context. |
3061 VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off"); | 3063 VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off"); |
3062 if (fullscreen) { | 3064 if (fullscreen) { |
3063 DCHECK(!fullscreen_container_); | 3065 DCHECK(!fullscreen_container_); |
3064 fullscreen_container_ = | 3066 fullscreen_container_ = |
3065 render_frame_->CreatePepperFullscreenContainer(this); | 3067 render_frame_->CreatePepperFullscreenContainer(this); |
3066 UpdateLayer(); | 3068 UpdateLayer(false); |
3067 } else { | 3069 } else { |
3068 DCHECK(fullscreen_container_); | 3070 DCHECK(fullscreen_container_); |
3069 fullscreen_container_->Destroy(); | 3071 fullscreen_container_->Destroy(); |
3070 fullscreen_container_ = NULL; | 3072 fullscreen_container_ = NULL; |
3071 UpdateFlashFullscreenState(false); | 3073 UpdateFlashFullscreenState(false); |
3072 if (!delay_report) { | 3074 if (!delay_report) { |
3073 ReportGeometry(); | 3075 ReportGeometry(); |
3074 } else { | 3076 } else { |
3075 base::MessageLoop::current()->PostTask( | 3077 base::MessageLoop::current()->PostTask( |
3076 FROM_HERE, | 3078 FROM_HERE, |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3274 // Running out-of-process. Initiate an IPC call to notify the plugin | 3276 // Running out-of-process. Initiate an IPC call to notify the plugin |
3275 // process. | 3277 // process. |
3276 ppapi::proxy::HostDispatcher* dispatcher = | 3278 ppapi::proxy::HostDispatcher* dispatcher = |
3277 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); | 3279 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); |
3278 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( | 3280 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( |
3279 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); | 3281 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); |
3280 } | 3282 } |
3281 } | 3283 } |
3282 | 3284 |
3283 } // namespace content | 3285 } // namespace content |
OLD | NEW |