| 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 "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
| 9 #include "ppapi/c/pp_time.h" | 9 #include "ppapi/c/pp_time.h" |
| 10 #include "ppapi/c/pp_var.h" | 10 #include "ppapi/c/pp_var.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "ppapi/proxy/plugin_dispatcher.h" | 22 #include "ppapi/proxy/plugin_dispatcher.h" |
| 23 #include "ppapi/proxy/plugin_proxy_delegate.h" | 23 #include "ppapi/proxy/plugin_proxy_delegate.h" |
| 24 #include "ppapi/proxy/ppapi_messages.h" | 24 #include "ppapi/proxy/ppapi_messages.h" |
| 25 #include "ppapi/proxy/ppb_flash_proxy.h" | 25 #include "ppapi/proxy/ppb_flash_proxy.h" |
| 26 #include "ppapi/proxy/serialized_var.h" | 26 #include "ppapi/proxy/serialized_var.h" |
| 27 #include "ppapi/shared_impl/ppapi_globals.h" | 27 #include "ppapi/shared_impl/ppapi_globals.h" |
| 28 #include "ppapi/shared_impl/ppb_url_util_shared.h" | 28 #include "ppapi/shared_impl/ppb_url_util_shared.h" |
| 29 #include "ppapi/shared_impl/ppb_view_shared.h" | 29 #include "ppapi/shared_impl/ppb_view_shared.h" |
| 30 #include "ppapi/shared_impl/var.h" | 30 #include "ppapi/shared_impl/var.h" |
| 31 #include "ppapi/thunk/enter.h" | 31 #include "ppapi/thunk/enter.h" |
| 32 #include "ppapi/thunk/ppb_graphics_2d_api.h" |
| 33 #include "ppapi/thunk/ppb_graphics_3d_api.h" |
| 32 #include "ppapi/thunk/thunk.h" | 34 #include "ppapi/thunk/thunk.h" |
| 33 | 35 |
| 34 // Windows headers interfere with this file. | 36 // Windows headers interfere with this file. |
| 35 #ifdef PostMessage | 37 #ifdef PostMessage |
| 36 #undef PostMessage | 38 #undef PostMessage |
| 37 #endif | 39 #endif |
| 38 | 40 |
| 39 using ppapi::thunk::EnterInstanceNoLock; | 41 using ppapi::thunk::EnterInstanceNoLock; |
| 40 using ppapi::thunk::EnterResourceNoLock; | 42 using ppapi::thunk::EnterResourceNoLock; |
| 43 using ppapi::thunk::PPB_Graphics2D_API; |
| 44 using ppapi::thunk::PPB_Graphics3D_API; |
| 41 using ppapi::thunk::PPB_Instance_API; | 45 using ppapi::thunk::PPB_Instance_API; |
| 42 | 46 |
| 43 namespace ppapi { | 47 namespace ppapi { |
| 44 namespace proxy { | 48 namespace proxy { |
| 45 | 49 |
| 46 namespace { | 50 namespace { |
| 47 | 51 |
| 48 InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher) { | 52 InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher) { |
| 49 return new PPB_Instance_Proxy(dispatcher); | 53 return new PPB_Instance_Proxy(dispatcher); |
| 50 } | 54 } |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 IPC_MESSAGE_UNHANDLED(handled = false) | 195 IPC_MESSAGE_UNHANDLED(handled = false) |
| 192 IPC_END_MESSAGE_MAP() | 196 IPC_END_MESSAGE_MAP() |
| 193 return handled; | 197 return handled; |
| 194 } | 198 } |
| 195 | 199 |
| 196 PP_Bool PPB_Instance_Proxy::BindGraphics(PP_Instance instance, | 200 PP_Bool PPB_Instance_Proxy::BindGraphics(PP_Instance instance, |
| 197 PP_Resource device) { | 201 PP_Resource device) { |
| 198 // If device is 0, pass a null HostResource. This signals the host to unbind | 202 // If device is 0, pass a null HostResource. This signals the host to unbind |
| 199 // all devices. | 203 // all devices. |
| 200 HostResource host_resource; | 204 HostResource host_resource; |
| 205 PP_Resource pp_resource = 0; |
| 206 PP_Bool result = PP_FALSE; |
| 201 if (device) { | 207 if (device) { |
| 202 Resource* resource = | 208 Resource* resource = |
| 203 PpapiGlobals::Get()->GetResourceTracker()->GetResource(device); | 209 PpapiGlobals::Get()->GetResourceTracker()->GetResource(device); |
| 204 if (!resource || resource->pp_instance() != instance) | 210 if (!resource || resource->pp_instance() != instance) |
| 205 return PP_FALSE; | 211 return PP_FALSE; |
| 206 host_resource = resource->host_resource(); | 212 host_resource = resource->host_resource(); |
| 213 pp_resource = resource->pp_resource(); |
| 214 } else { |
| 215 // Passing 0 means unbinding all devices. |
| 216 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics( |
| 217 API_ID_PPB_INSTANCE, instance, 0, &result)); |
| 218 return result; |
| 207 } | 219 } |
| 208 | 220 |
| 209 PP_Bool result = PP_FALSE; | 221 // We need to pass different resource to Graphics 2D and 3D right now. Once |
| 210 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics( | 222 // 3D is migrated to the new design, we should be able to unify this. |
| 211 API_ID_PPB_INSTANCE, instance, host_resource, &result)); | 223 EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false); |
| 224 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); |
| 225 if (enter_2d.succeeded()) { |
| 226 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics( |
| 227 API_ID_PPB_INSTANCE, instance, pp_resource, |
| 228 &result)); |
| 229 } else if (enter_3d.succeeded()) { |
| 230 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics( |
| 231 API_ID_PPB_INSTANCE, instance, host_resource.host_resource(), |
| 232 &result)); |
| 233 } |
| 212 return result; | 234 return result; |
| 213 } | 235 } |
| 214 | 236 |
| 215 PP_Bool PPB_Instance_Proxy::IsFullFrame(PP_Instance instance) { | 237 PP_Bool PPB_Instance_Proxy::IsFullFrame(PP_Instance instance) { |
| 216 PP_Bool result = PP_FALSE; | 238 PP_Bool result = PP_FALSE; |
| 217 dispatcher()->Send(new PpapiHostMsg_PPBInstance_IsFullFrame( | 239 dispatcher()->Send(new PpapiHostMsg_PPBInstance_IsFullFrame( |
| 218 API_ID_PPB_INSTANCE, instance, &result)); | 240 API_ID_PPB_INSTANCE, instance, &result)); |
| 219 return result; | 241 return result; |
| 220 } | 242 } |
| 221 | 243 |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 PP_Instance instance, | 823 PP_Instance instance, |
| 802 SerializedVarReturnValue result) { | 824 SerializedVarReturnValue result) { |
| 803 EnterInstanceNoLock enter(instance); | 825 EnterInstanceNoLock enter(instance); |
| 804 if (enter.succeeded()) { | 826 if (enter.succeeded()) { |
| 805 result.Return(dispatcher(), | 827 result.Return(dispatcher(), |
| 806 enter.functions()->GetOwnerElementObject(instance)); | 828 enter.functions()->GetOwnerElementObject(instance)); |
| 807 } | 829 } |
| 808 } | 830 } |
| 809 | 831 |
| 810 void PPB_Instance_Proxy::OnHostMsgBindGraphics(PP_Instance instance, | 832 void PPB_Instance_Proxy::OnHostMsgBindGraphics(PP_Instance instance, |
| 811 const HostResource& device, | 833 PP_Resource device, |
| 812 PP_Bool* result) { | 834 PP_Bool* result) { |
| 813 EnterInstanceNoLock enter(instance); | 835 EnterInstanceNoLock enter(instance); |
| 814 if (enter.succeeded()) { | 836 if (enter.succeeded()) { |
| 815 *result = enter.functions()->BindGraphics(instance, | 837 *result = enter.functions()->BindGraphics(instance, device); |
| 816 device.host_resource()); | |
| 817 } | 838 } |
| 818 } | 839 } |
| 819 | 840 |
| 820 void PPB_Instance_Proxy::OnHostMsgGetAudioHardwareOutputSampleRate( | 841 void PPB_Instance_Proxy::OnHostMsgGetAudioHardwareOutputSampleRate( |
| 821 PP_Instance instance, uint32_t* result) { | 842 PP_Instance instance, uint32_t* result) { |
| 822 EnterInstanceNoLock enter(instance); | 843 EnterInstanceNoLock enter(instance); |
| 823 if (enter.succeeded()) | 844 if (enter.succeeded()) |
| 824 *result = enter.functions()->GetAudioHardwareOutputSampleRate(instance); | 845 *result = enter.functions()->GetAudioHardwareOutputSampleRate(instance); |
| 825 } | 846 } |
| 826 | 847 |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 PP_Instance instance) { | 1213 PP_Instance instance) { |
| 1193 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> | 1214 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> |
| 1194 GetInstanceData(instance); | 1215 GetInstanceData(instance); |
| 1195 if (!data) | 1216 if (!data) |
| 1196 return; // Instance was probably deleted. | 1217 return; // Instance was probably deleted. |
| 1197 data->should_do_request_surrounding_text = false; | 1218 data->should_do_request_surrounding_text = false; |
| 1198 } | 1219 } |
| 1199 | 1220 |
| 1200 } // namespace proxy | 1221 } // namespace proxy |
| 1201 } // namespace ppapi | 1222 } // namespace ppapi |
| OLD | NEW |