| Index: ppapi/proxy/ppb_instance_proxy.cc
|
| diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc
|
| index 2b1a9889026c0474cb3b966871f8d0907cfe91b5..3f28b365a3154174fb2ad8eab2aaae5dc09e1314 100644
|
| --- a/ppapi/proxy/ppb_instance_proxy.cc
|
| +++ b/ppapi/proxy/ppb_instance_proxy.cc
|
| @@ -215,37 +215,59 @@ PP_Bool PPB_Instance_Proxy::BindGraphics(PP_Instance instance,
|
| PP_Resource device) {
|
| // If device is 0, pass a null HostResource. This signals the host to unbind
|
| // all devices.
|
| - HostResource host_resource;
|
| PP_Resource pp_resource = 0;
|
| + InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())->
|
| + GetInstanceData(instance);
|
| + scoped_refptr<Resource> old_compositor = data->bound_compositor;
|
| +
|
| if (device) {
|
| - Resource* resource =
|
| - PpapiGlobals::Get()->GetResourceTracker()->GetResource(device);
|
| - if (!resource || resource->pp_instance() != instance)
|
| + do {
|
| + // Try enter device as a Graphics3D deivce.
|
| + EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false);
|
| + if (enter_3d.succeeded()) {
|
| + if (enter_3d.resource()->pp_instance() != instance)
|
| + return PP_FALSE;
|
| + data->bound_compositor = NULL;
|
| + pp_resource = enter_3d.resource()->host_resource().host_resource();
|
| + break;
|
| + }
|
| +
|
| + // Try enter device as a Graphics2D device.
|
| + EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false);
|
| + if (enter_2d.succeeded()) {
|
| + if (enter_2d.resource()->pp_instance() != instance)
|
| + return PP_FALSE;
|
| + data->bound_compositor = NULL;
|
| + pp_resource = enter_2d.resource()->pp_resource();
|
| + break;
|
| + }
|
| +
|
| + // Try enter device as a Compositor device.
|
| + EnterResourceNoLock<PPB_Compositor_API> enter_compositor(device, false);
|
| + if (enter_compositor.succeeded()) {
|
| + if (enter_compositor.resource()->pp_instance() != instance)
|
| + return PP_FALSE;
|
| + data->bound_compositor = enter_compositor.resource();
|
| + pp_resource = enter_compositor.resource()->pp_resource();
|
| + break;
|
| + }
|
| +
|
| return PP_FALSE;
|
| - host_resource = resource->host_resource();
|
| - pp_resource = resource->pp_resource();
|
| + } while (false);
|
| } else {
|
| - // Passing 0 means unbinding all devices.
|
| - dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics(
|
| - API_ID_PPB_INSTANCE, instance, 0));
|
| - return PP_TRUE;
|
| + data->bound_compositor = NULL;
|
| }
|
|
|
| - // We need to pass different resource to Graphics 2D and 3D right now. Once
|
| - // 3D is migrated to the new design, we should be able to unify this.
|
| - EnterResourceNoLock<PPB_Compositor_API> enter_compositor(device, false);
|
| - EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false);
|
| - EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false);
|
| - if (enter_compositor.succeeded() || enter_2d.succeeded()) {
|
| - dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics(
|
| + if (old_compositor)
|
| + old_compositor->AsPPB_Compositor_API()->BindToInstance(0);
|
| +
|
| + if (data->bound_compositor)
|
| + data->bound_compositor->AsPPB_Compositor_API()->BindToInstance(instance);
|
| +
|
| + dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics(
|
| API_ID_PPB_INSTANCE, instance, pp_resource));
|
| - return PP_TRUE;
|
| - } else if (enter_3d.succeeded()) {
|
| - dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics(
|
| - API_ID_PPB_INSTANCE, instance, host_resource.host_resource()));
|
| - return PP_TRUE;
|
| - }
|
| - return PP_FALSE;
|
| +
|
| + return PP_TRUE;
|
| }
|
|
|
| PP_Bool PPB_Instance_Proxy::IsFullFrame(PP_Instance instance) {
|
|
|