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

Side by Side Diff: ppapi/proxy/ppb_instance_proxy.cc

Issue 11053003: Migrate Graphics2D to new design. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: temp dependencies Created 8 years, 1 month 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 "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
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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 IPC_MESSAGE_UNHANDLED(handled = false) 191 IPC_MESSAGE_UNHANDLED(handled = false)
188 IPC_END_MESSAGE_MAP() 192 IPC_END_MESSAGE_MAP()
189 return handled; 193 return handled;
190 } 194 }
191 195
192 PP_Bool PPB_Instance_Proxy::BindGraphics(PP_Instance instance, 196 PP_Bool PPB_Instance_Proxy::BindGraphics(PP_Instance instance,
193 PP_Resource device) { 197 PP_Resource device) {
194 // If device is 0, pass a null HostResource. This signals the host to unbind 198 // If device is 0, pass a null HostResource. This signals the host to unbind
195 // all devices. 199 // all devices.
196 HostResource host_resource; 200 HostResource host_resource;
201 PP_Resource pp_resource = 0;
197 if (device) { 202 if (device) {
198 Resource* resource = 203 Resource* resource =
199 PpapiGlobals::Get()->GetResourceTracker()->GetResource(device); 204 PpapiGlobals::Get()->GetResourceTracker()->GetResource(device);
200 if (!resource || resource->pp_instance() != instance) 205 if (!resource || resource->pp_instance() != instance)
201 return PP_FALSE; 206 return PP_FALSE;
202 host_resource = resource->host_resource(); 207 host_resource = resource->host_resource();
208 pp_resource = resource->pp_resource();
203 } 209 }
204 210
211 // We need to pass different resource to Graphics 2D and 3D right now. Once
212 // 3D is migrated to the new design, we should be able to unify this.
205 PP_Bool result = PP_FALSE; 213 PP_Bool result = PP_FALSE;
206 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics( 214 EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false);
207 API_ID_PPB_INSTANCE, instance, host_resource, &result)); 215 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false);
216 if (enter_2d.succeeded()) {
217 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics(
218 API_ID_PPB_INSTANCE, instance, pp_resource,
219 &result));
220 } else if (enter_3d.succeeded()) {
221 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics(
222 API_ID_PPB_INSTANCE, instance, host_resource.host_resource(),
223 &result));
224 }
208 return result; 225 return result;
209 } 226 }
210 227
211 PP_Bool PPB_Instance_Proxy::IsFullFrame(PP_Instance instance) { 228 PP_Bool PPB_Instance_Proxy::IsFullFrame(PP_Instance instance) {
212 PP_Bool result = PP_FALSE; 229 PP_Bool result = PP_FALSE;
213 dispatcher()->Send(new PpapiHostMsg_PPBInstance_IsFullFrame( 230 dispatcher()->Send(new PpapiHostMsg_PPBInstance_IsFullFrame(
214 API_ID_PPB_INSTANCE, instance, &result)); 231 API_ID_PPB_INSTANCE, instance, &result));
215 return result; 232 return result;
216 } 233 }
217 234
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 PP_Instance instance, 813 PP_Instance instance,
797 SerializedVarReturnValue result) { 814 SerializedVarReturnValue result) {
798 EnterInstanceNoLock enter(instance); 815 EnterInstanceNoLock enter(instance);
799 if (enter.succeeded()) { 816 if (enter.succeeded()) {
800 result.Return(dispatcher(), 817 result.Return(dispatcher(),
801 enter.functions()->GetOwnerElementObject(instance)); 818 enter.functions()->GetOwnerElementObject(instance));
802 } 819 }
803 } 820 }
804 821
805 void PPB_Instance_Proxy::OnHostMsgBindGraphics(PP_Instance instance, 822 void PPB_Instance_Proxy::OnHostMsgBindGraphics(PP_Instance instance,
806 const HostResource& device, 823 PP_Resource device,
807 PP_Bool* result) { 824 PP_Bool* result) {
808 EnterInstanceNoLock enter(instance); 825 EnterInstanceNoLock enter(instance);
809 if (enter.succeeded()) { 826 if (enter.succeeded()) {
810 *result = enter.functions()->BindGraphics(instance, 827 *result = enter.functions()->BindGraphics(instance, device);
811 device.host_resource());
812 } 828 }
813 } 829 }
814 830
815 void PPB_Instance_Proxy::OnHostMsgGetAudioHardwareOutputSampleRate( 831 void PPB_Instance_Proxy::OnHostMsgGetAudioHardwareOutputSampleRate(
816 PP_Instance instance, uint32_t* result) { 832 PP_Instance instance, uint32_t* result) {
817 EnterInstanceNoLock enter(instance); 833 EnterInstanceNoLock enter(instance);
818 if (enter.succeeded()) 834 if (enter.succeeded())
819 *result = enter.functions()->GetAudioHardwareOutputSampleRate(instance); 835 *result = enter.functions()->GetAudioHardwareOutputSampleRate(instance);
820 } 836 }
821 837
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 PP_Instance instance) { 1200 PP_Instance instance) {
1185 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> 1201 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())->
1186 GetInstanceData(instance); 1202 GetInstanceData(instance);
1187 if (!data) 1203 if (!data)
1188 return; // Instance was probably deleted. 1204 return; // Instance was probably deleted.
1189 data->should_do_request_surrounding_text = false; 1205 data->should_do_request_surrounding_text = false;
1190 } 1206 }
1191 1207
1192 } // namespace proxy 1208 } // namespace proxy
1193 } // namespace ppapi 1209 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698