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

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

Issue 324983005: [PPAPI] Add browser tests for compositor API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@compositor_api_impl_new
Patch Set: Disable the test on MACOSX Created 6 years, 6 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
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/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 1859 matching lines...) Expand 10 before | Expand all | Expand 10 after
1870 bool flash_fullscreen) { 1870 bool flash_fullscreen) {
1871 bool is_mouselock_pending = TrackedCallback::IsPending(lock_mouse_callback_); 1871 bool is_mouselock_pending = TrackedCallback::IsPending(lock_mouse_callback_);
1872 1872
1873 if (flash_fullscreen == flash_fullscreen_) { 1873 if (flash_fullscreen == flash_fullscreen_) {
1874 // Manually clear callback when fullscreen fails with mouselock pending. 1874 // Manually clear callback when fullscreen fails with mouselock pending.
1875 if (!flash_fullscreen && is_mouselock_pending) 1875 if (!flash_fullscreen && is_mouselock_pending)
1876 lock_mouse_callback_->Run(PP_ERROR_FAILED); 1876 lock_mouse_callback_->Run(PP_ERROR_FAILED);
1877 return; 1877 return;
1878 } 1878 }
1879 1879
1880 UpdateLayer(); 1880 UpdateLayer(false);
1881 1881
1882 bool old_plugin_focus = PluginHasFocus(); 1882 bool old_plugin_focus = PluginHasFocus();
1883 flash_fullscreen_ = flash_fullscreen; 1883 flash_fullscreen_ = flash_fullscreen;
1884 if (is_mouselock_pending && !IsMouseLocked()) { 1884 if (is_mouselock_pending && !IsMouseLocked()) {
1885 if (!IsProcessingUserGesture() && 1885 if (!IsProcessingUserGesture() &&
1886 !module_->permissions().HasPermission( 1886 !module_->permissions().HasPermission(
1887 ppapi::PERMISSION_BYPASS_USER_GESTURE)) { 1887 ppapi::PERMISSION_BYPASS_USER_GESTURE)) {
1888 lock_mouse_callback_->Run(PP_ERROR_NO_USER_GESTURE); 1888 lock_mouse_callback_->Run(PP_ERROR_NO_USER_GESTURE);
1889 } else { 1889 } else {
1890 // Open a user gesture here so the Webkit user gesture checks will succeed 1890 // 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
2009 skia::EndPlatformPaint(canvas); 2009 skia::EndPlatformPaint(canvas);
2010 } 2010 }
2011 #endif // defined(OS_WIN) 2011 #endif // defined(OS_WIN)
2012 2012
2013 return ret; 2013 return ret;
2014 #else // defined(ENABLE_FULL_PRINTING) 2014 #else // defined(ENABLE_FULL_PRINTING)
2015 return false; 2015 return false;
2016 #endif 2016 #endif
2017 } 2017 }
2018 2018
2019 void PepperPluginInstanceImpl::UpdateLayer() { 2019 void PepperPluginInstanceImpl::UpdateLayer(bool device_changed) {
2020 if (!container_) 2020 if (!container_)
2021 return; 2021 return;
2022 2022
2023 gpu::Mailbox mailbox; 2023 gpu::Mailbox mailbox;
2024 uint32 sync_point = 0; 2024 uint32 sync_point = 0;
2025 if (bound_graphics_3d_.get()) { 2025 if (bound_graphics_3d_.get()) {
2026 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_point); 2026 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_point);
2027 DCHECK_EQ(mailbox.IsZero(), sync_point == 0); 2027 DCHECK_EQ(mailbox.IsZero(), sync_point == 0);
2028 } 2028 }
2029 bool want_3d_layer = !mailbox.IsZero(); 2029 bool want_3d_layer = !mailbox.IsZero();
2030 bool want_2d_layer = !!bound_graphics_2d_platform_; 2030 bool want_2d_layer = !!bound_graphics_2d_platform_;
2031 bool want_texture_layer = want_3d_layer || want_2d_layer; 2031 bool want_texture_layer = want_3d_layer || want_2d_layer;
2032 bool want_compositor_layer = !!bound_compositor_; 2032 bool want_compositor_layer = !!bound_compositor_;
2033 2033
2034 if ((want_texture_layer == !!texture_layer_.get()) && 2034 if (!device_changed &&
2035 (want_texture_layer == !!texture_layer_.get()) &&
2035 (want_3d_layer == layer_is_hardware_) && 2036 (want_3d_layer == layer_is_hardware_) &&
2036 (want_compositor_layer == !!compositor_layer_) && 2037 (want_compositor_layer == !!compositor_layer_) &&
2037 layer_bound_to_fullscreen_ == !!fullscreen_container_) { 2038 layer_bound_to_fullscreen_ == !!fullscreen_container_) {
2038 UpdateLayerTransform(); 2039 UpdateLayerTransform();
2039 return; 2040 return;
2040 } 2041 }
2041 2042
2042 if (texture_layer_ || compositor_layer_) { 2043 if (texture_layer_ || compositor_layer_) {
2043 if (!layer_bound_to_fullscreen_) 2044 if (!layer_bound_to_fullscreen_)
2044 container_->setWebLayer(NULL); 2045 container_->setWebLayer(NULL);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
2265 bound_graphics_2d_platform_->BindToInstance(NULL); 2266 bound_graphics_2d_platform_->BindToInstance(NULL);
2266 bound_graphics_2d_platform_ = NULL; 2267 bound_graphics_2d_platform_ = NULL;
2267 } 2268 }
2268 if (bound_compositor_) { 2269 if (bound_compositor_) {
2269 bound_compositor_->BindToInstance(NULL); 2270 bound_compositor_->BindToInstance(NULL);
2270 bound_compositor_ = NULL; 2271 bound_compositor_ = NULL;
2271 } 2272 }
2272 2273
2273 // Special-case clearing the current device. 2274 // Special-case clearing the current device.
2274 if (!device) { 2275 if (!device) {
2275 UpdateLayer(); 2276 UpdateLayer(true);
2276 InvalidateRect(gfx::Rect()); 2277 InvalidateRect(gfx::Rect());
2277 return PP_TRUE; 2278 return PP_TRUE;
2278 } 2279 }
2279 2280
2280 // Refuse to bind if in transition to fullscreen with PPB_FlashFullscreen or 2281 // Refuse to bind if in transition to fullscreen with PPB_FlashFullscreen or
2281 // to/from fullscreen with PPB_Fullscreen. 2282 // to/from fullscreen with PPB_Fullscreen.
2282 if ((fullscreen_container_ && !flash_fullscreen_) || 2283 if ((fullscreen_container_ && !flash_fullscreen_) ||
2283 desired_fullscreen_state_ != view_data_.is_fullscreen) 2284 desired_fullscreen_state_ != view_data_.is_fullscreen)
2284 return PP_FALSE; 2285 return PP_FALSE;
2285 2286
(...skipping 15 matching lines...) Expand all
2301 2302
2302 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); 2303 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false);
2303 PPB_Graphics3D_Impl* graphics_3d = 2304 PPB_Graphics3D_Impl* graphics_3d =
2304 enter_3d.succeeded() 2305 enter_3d.succeeded()
2305 ? static_cast<PPB_Graphics3D_Impl*>(enter_3d.object()) 2306 ? static_cast<PPB_Graphics3D_Impl*>(enter_3d.object())
2306 : NULL; 2307 : NULL;
2307 2308
2308 if (compositor) { 2309 if (compositor) {
2309 if (compositor->BindToInstance(this)) { 2310 if (compositor->BindToInstance(this)) {
2310 bound_compositor_ = compositor; 2311 bound_compositor_ = compositor;
2311 UpdateLayer(); 2312 UpdateLayer(true);
2312 return PP_TRUE; 2313 return PP_TRUE;
2313 } 2314 }
2314 } else if (graphics_2d) { 2315 } else if (graphics_2d) {
2315 if (graphics_2d->BindToInstance(this)) { 2316 if (graphics_2d->BindToInstance(this)) {
2316 bound_graphics_2d_platform_ = graphics_2d; 2317 bound_graphics_2d_platform_ = graphics_2d;
2317 UpdateLayer(); 2318 UpdateLayer(true);
2318 return PP_TRUE; 2319 return PP_TRUE;
2319 } 2320 }
2320 } else if (graphics_3d) { 2321 } else if (graphics_3d) {
2321 // Make sure graphics can only be bound to the instance it is 2322 // Make sure graphics can only be bound to the instance it is
2322 // associated with. 2323 // associated with.
2323 if (graphics_3d->pp_instance() == pp_instance() && 2324 if (graphics_3d->pp_instance() == pp_instance() &&
2324 graphics_3d->BindToInstance(true)) { 2325 graphics_3d->BindToInstance(true)) {
2325 bound_graphics_3d_ = graphics_3d; 2326 bound_graphics_3d_ = graphics_3d;
2326 UpdateLayer(); 2327 UpdateLayer(true);
2327 return PP_TRUE; 2328 return PP_TRUE;
2328 } 2329 }
2329 } 2330 }
2330 2331
2331 // The instance cannot be bound or the device is not a valid resource type. 2332 // The instance cannot be bound or the device is not a valid resource type.
2332 return PP_FALSE; 2333 return PP_FALSE;
2333 } 2334 }
2334 2335
2335 PP_Bool PepperPluginInstanceImpl::IsFullFrame(PP_Instance instance) { 2336 PP_Bool PepperPluginInstanceImpl::IsFullFrame(PP_Instance instance) {
2336 return PP_FromBool(full_frame()); 2337 return PP_FromBool(full_frame());
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
3087 ->renderer_preferences() 3088 ->renderer_preferences()
3088 .plugin_fullscreen_allowed) 3089 .plugin_fullscreen_allowed)
3089 return false; 3090 return false;
3090 3091
3091 // Unbind current 2D or 3D graphics context. 3092 // Unbind current 2D or 3D graphics context.
3092 VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off"); 3093 VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off");
3093 if (fullscreen) { 3094 if (fullscreen) {
3094 DCHECK(!fullscreen_container_); 3095 DCHECK(!fullscreen_container_);
3095 fullscreen_container_ = 3096 fullscreen_container_ =
3096 render_frame_->CreatePepperFullscreenContainer(this); 3097 render_frame_->CreatePepperFullscreenContainer(this);
3097 UpdateLayer(); 3098 UpdateLayer(false);
3098 } else { 3099 } else {
3099 DCHECK(fullscreen_container_); 3100 DCHECK(fullscreen_container_);
3100 fullscreen_container_->Destroy(); 3101 fullscreen_container_->Destroy();
3101 fullscreen_container_ = NULL; 3102 fullscreen_container_ = NULL;
3102 UpdateFlashFullscreenState(false); 3103 UpdateFlashFullscreenState(false);
3103 if (!delay_report) { 3104 if (!delay_report) {
3104 ReportGeometry(); 3105 ReportGeometry();
3105 } else { 3106 } else {
3106 base::MessageLoop::current()->PostTask( 3107 base::MessageLoop::current()->PostTask(
3107 FROM_HERE, 3108 FROM_HERE,
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
3305 // Running out-of-process. Initiate an IPC call to notify the plugin 3306 // Running out-of-process. Initiate an IPC call to notify the plugin
3306 // process. 3307 // process.
3307 ppapi::proxy::HostDispatcher* dispatcher = 3308 ppapi::proxy::HostDispatcher* dispatcher =
3308 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); 3309 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance());
3309 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( 3310 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad(
3310 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); 3311 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data));
3311 } 3312 }
3312 } 3313 }
3313 3314
3314 } // namespace content 3315 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_plugin_instance_impl.h ('k') | ppapi/examples/compositor/compositor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698