Chromium Code Reviews| 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 "ppapi/proxy/ppb_instance_proxy.h" | 5 #include "ppapi/proxy/ppb_instance_proxy.h" |
| 6 | 6 |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
| 10 #include "ppapi/c/pp_time.h" | 10 #include "ppapi/c/pp_time.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 | 208 |
| 209 IPC_MESSAGE_UNHANDLED(handled = false) | 209 IPC_MESSAGE_UNHANDLED(handled = false) |
| 210 IPC_END_MESSAGE_MAP() | 210 IPC_END_MESSAGE_MAP() |
| 211 return handled; | 211 return handled; |
| 212 } | 212 } |
| 213 | 213 |
| 214 PP_Bool PPB_Instance_Proxy::BindGraphics(PP_Instance instance, | 214 PP_Bool PPB_Instance_Proxy::BindGraphics(PP_Instance instance, |
| 215 PP_Resource device) { | 215 PP_Resource device) { |
| 216 // If device is 0, pass a null HostResource. This signals the host to unbind | 216 // If device is 0, pass a null HostResource. This signals the host to unbind |
| 217 // all devices. | 217 // all devices. |
| 218 HostResource host_resource; | |
| 219 PP_Resource pp_resource = 0; | 218 PP_Resource pp_resource = 0; |
| 219 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> | |
| 220 GetInstanceData(instance); | |
| 221 scoped_refptr<Resource> old_compositor = data->bound_compositor; | |
| 222 | |
| 220 if (device) { | 223 if (device) { |
| 221 Resource* resource = | 224 do { |
| 222 PpapiGlobals::Get()->GetResourceTracker()->GetResource(device); | 225 // Try enter device as a Graphics3D deivce. |
| 223 if (!resource || resource->pp_instance() != instance) | 226 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); |
| 227 if (enter_3d.succeeded()) { | |
| 228 if (enter_3d.resource()->pp_instance() != instance) | |
| 229 return PP_FALSE; | |
| 230 data->bound_compositor = NULL; | |
| 231 pp_resource = enter_3d.resource()->host_resource().host_resource(); | |
| 232 break; | |
| 233 } | |
| 234 | |
| 235 // Try enter device as a Graphics2D device. | |
| 236 EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false); | |
| 237 if (enter_2d.succeeded()) { | |
| 238 if (enter_2d.resource()->pp_instance() != instance) | |
| 239 return PP_FALSE; | |
| 240 data->bound_compositor = NULL; | |
| 241 pp_resource = enter_2d.resource()->pp_resource(); | |
| 242 break; | |
| 243 } | |
| 244 | |
| 245 // Try enter device as a Compositor device. | |
| 246 EnterResourceNoLock<PPB_Compositor_API> enter_compositor(device, false); | |
| 247 if (enter_compositor.succeeded()) { | |
| 248 if (enter_compositor.resource()->pp_instance() != instance) | |
| 249 return PP_FALSE; | |
| 250 data->bound_compositor = enter_compositor.resource(); | |
| 251 pp_resource = enter_compositor.resource()->pp_resource(); | |
| 252 break; | |
| 253 } | |
| 254 | |
| 224 return PP_FALSE; | 255 return PP_FALSE; |
| 225 host_resource = resource->host_resource(); | 256 } while (false); |
|
piman
2014/06/18 00:55:24
That's a crazy amount of logic to track something
Peng
2014/06/18 02:35:03
Same reason.
And EnterResourceNoLock() will look u
| |
| 226 pp_resource = resource->pp_resource(); | |
| 227 } else { | 257 } else { |
| 228 // Passing 0 means unbinding all devices. | 258 data->bound_compositor = NULL; |
| 229 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics( | |
| 230 API_ID_PPB_INSTANCE, instance, 0)); | |
| 231 return PP_TRUE; | |
| 232 } | 259 } |
| 233 | 260 |
| 234 // We need to pass different resource to Graphics 2D and 3D right now. Once | 261 if (old_compositor) |
| 235 // 3D is migrated to the new design, we should be able to unify this. | 262 old_compositor->AsPPB_Compositor_API()->BindToInstance(0); |
| 236 EnterResourceNoLock<PPB_Compositor_API> enter_compositor(device, false); | 263 |
| 237 EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false); | 264 if (data->bound_compositor) |
| 238 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); | 265 data->bound_compositor->AsPPB_Compositor_API()->BindToInstance(true); |
| 239 if (enter_compositor.succeeded() || enter_2d.succeeded()) { | 266 |
| 240 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics( | 267 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics( |
| 241 API_ID_PPB_INSTANCE, instance, pp_resource)); | 268 API_ID_PPB_INSTANCE, instance, pp_resource)); |
| 242 return PP_TRUE; | 269 |
| 243 } else if (enter_3d.succeeded()) { | 270 return PP_TRUE; |
| 244 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics( | |
| 245 API_ID_PPB_INSTANCE, instance, host_resource.host_resource())); | |
| 246 return PP_TRUE; | |
| 247 } | |
| 248 return PP_FALSE; | |
| 249 } | 271 } |
| 250 | 272 |
| 251 PP_Bool PPB_Instance_Proxy::IsFullFrame(PP_Instance instance) { | 273 PP_Bool PPB_Instance_Proxy::IsFullFrame(PP_Instance instance) { |
| 252 PP_Bool result = PP_FALSE; | 274 PP_Bool result = PP_FALSE; |
| 253 dispatcher()->Send(new PpapiHostMsg_PPBInstance_IsFullFrame( | 275 dispatcher()->Send(new PpapiHostMsg_PPBInstance_IsFullFrame( |
| 254 API_ID_PPB_INSTANCE, instance, &result)); | 276 API_ID_PPB_INSTANCE, instance, &result)); |
| 255 return result; | 277 return result; |
| 256 } | 278 } |
| 257 | 279 |
| 258 const ViewData* PPB_Instance_Proxy::GetViewData(PP_Instance instance) { | 280 const ViewData* PPB_Instance_Proxy::GetViewData(PP_Instance instance) { |
| (...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1430 PP_Instance instance) { | 1452 PP_Instance instance) { |
| 1431 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> | 1453 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> |
| 1432 GetInstanceData(instance); | 1454 GetInstanceData(instance); |
| 1433 if (!data) | 1455 if (!data) |
| 1434 return; // Instance was probably deleted. | 1456 return; // Instance was probably deleted. |
| 1435 data->should_do_request_surrounding_text = false; | 1457 data->should_do_request_surrounding_text = false; |
| 1436 } | 1458 } |
| 1437 | 1459 |
| 1438 } // namespace proxy | 1460 } // namespace proxy |
| 1439 } // namespace ppapi | 1461 } // namespace ppapi |
| OLD | NEW |