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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 | 209 |
| 210 IPC_MESSAGE_UNHANDLED(handled = false) | 210 IPC_MESSAGE_UNHANDLED(handled = false) |
| 211 IPC_END_MESSAGE_MAP() | 211 IPC_END_MESSAGE_MAP() |
| 212 return handled; | 212 return handled; |
| 213 } | 213 } |
| 214 | 214 |
| 215 PP_Bool PPB_Instance_Proxy::BindGraphics(PP_Instance instance, | 215 PP_Bool PPB_Instance_Proxy::BindGraphics(PP_Instance instance, |
| 216 PP_Resource device) { | 216 PP_Resource device) { |
| 217 // If device is 0, pass a null HostResource. This signals the host to unbind | 217 // If device is 0, pass a null HostResource. This signals the host to unbind |
| 218 // all devices. | 218 // all devices. |
| 219 HostResource host_resource; | |
| 220 PP_Resource pp_resource = 0; | 219 PP_Resource pp_resource = 0; |
| 221 if (device) { | 220 if (device) { |
| 222 Resource* resource = | 221 do { |
| 223 PpapiGlobals::Get()->GetResourceTracker()->GetResource(device); | 222 // Try enter device as a Graphics3D deivce. |
| 224 if (!resource || resource->pp_instance() != instance) | 223 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); |
| 224 if (enter_3d.succeeded()) { | |
| 225 if (enter_3d.resource()->pp_instance() != instance) | |
| 226 return PP_FALSE; | |
| 227 pp_resource = enter_3d.resource()->host_resource().host_resource(); | |
| 228 break; | |
| 229 } | |
| 230 | |
| 231 // Try enter device as a Graphics2D device. | |
| 232 EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false); | |
| 233 if (enter_2d.succeeded()) { | |
| 234 if (enter_2d.resource()->pp_instance() != instance) | |
| 235 return PP_FALSE; | |
| 236 pp_resource = enter_2d.resource()->pp_resource(); | |
| 237 break; | |
| 238 } | |
| 239 | |
| 240 // Try enter device as a Compositor device. | |
| 241 EnterResourceNoLock<PPB_Compositor_API> enter_compositor(device, false); | |
| 242 if (enter_compositor.succeeded()) { | |
| 243 if (enter_compositor.resource()->pp_instance() != instance) | |
| 244 return PP_FALSE; | |
| 245 pp_resource = enter_compositor.resource()->pp_resource(); | |
| 246 break; | |
| 247 } | |
| 248 | |
| 225 return PP_FALSE; | 249 return PP_FALSE; |
| 226 host_resource = resource->host_resource(); | 250 } while (false); |
|
piman
2014/06/19 20:44:04
This is not needed any more, right?
Peng
2014/06/19 22:33:41
It is not necessary anymore, but it is an improvem
| |
| 227 pp_resource = resource->pp_resource(); | |
| 228 } else { | |
| 229 // Passing 0 means unbinding all devices. | |
| 230 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics( | |
| 231 API_ID_PPB_INSTANCE, instance, 0)); | |
| 232 return PP_TRUE; | |
| 233 } | 251 } |
| 234 | 252 |
| 235 // We need to pass different resource to Graphics 2D and 3D right now. Once | 253 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics( |
| 236 // 3D is migrated to the new design, we should be able to unify this. | |
| 237 EnterResourceNoLock<PPB_Compositor_API> enter_compositor(device, false); | |
| 238 EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false); | |
| 239 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); | |
| 240 if (enter_compositor.succeeded() || enter_2d.succeeded()) { | |
| 241 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics( | |
| 242 API_ID_PPB_INSTANCE, instance, pp_resource)); | 254 API_ID_PPB_INSTANCE, instance, pp_resource)); |
| 243 return PP_TRUE; | 255 |
| 244 } else if (enter_3d.succeeded()) { | 256 return PP_TRUE; |
| 245 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics( | |
| 246 API_ID_PPB_INSTANCE, instance, host_resource.host_resource())); | |
| 247 return PP_TRUE; | |
| 248 } | |
| 249 return PP_FALSE; | |
| 250 } | 257 } |
| 251 | 258 |
| 252 PP_Bool PPB_Instance_Proxy::IsFullFrame(PP_Instance instance) { | 259 PP_Bool PPB_Instance_Proxy::IsFullFrame(PP_Instance instance) { |
| 253 PP_Bool result = PP_FALSE; | 260 PP_Bool result = PP_FALSE; |
| 254 dispatcher()->Send(new PpapiHostMsg_PPBInstance_IsFullFrame( | 261 dispatcher()->Send(new PpapiHostMsg_PPBInstance_IsFullFrame( |
| 255 API_ID_PPB_INSTANCE, instance, &result)); | 262 API_ID_PPB_INSTANCE, instance, &result)); |
| 256 return result; | 263 return result; |
| 257 } | 264 } |
| 258 | 265 |
| 259 const ViewData* PPB_Instance_Proxy::GetViewData(PP_Instance instance) { | 266 const ViewData* PPB_Instance_Proxy::GetViewData(PP_Instance instance) { |
| (...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1445 PP_Instance instance) { | 1452 PP_Instance instance) { |
| 1446 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> | 1453 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> |
| 1447 GetInstanceData(instance); | 1454 GetInstanceData(instance); |
| 1448 if (!data) | 1455 if (!data) |
| 1449 return; // Instance was probably deleted. | 1456 return; // Instance was probably deleted. |
| 1450 data->should_do_request_surrounding_text = false; | 1457 data->should_do_request_surrounding_text = false; |
| 1451 } | 1458 } |
| 1452 | 1459 |
| 1453 } // namespace proxy | 1460 } // namespace proxy |
| 1454 } // namespace ppapi | 1461 } // namespace ppapi |
| OLD | NEW |