OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_testing_proxy.h" | 5 #include "ppapi/proxy/ppb_testing_proxy.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "ppapi/c/dev/ppb_testing_dev.h" | 8 #include "ppapi/c/dev/ppb_testing_dev.h" |
9 #include "ppapi/proxy/image_data.h" | |
10 #include "ppapi/proxy/plugin_dispatcher.h" | 9 #include "ppapi/proxy/plugin_dispatcher.h" |
| 10 #include "ppapi/proxy/plugin_resource.h" |
| 11 #include "ppapi/proxy/plugin_resource_tracker.h" |
11 #include "ppapi/proxy/ppapi_messages.h" | 12 #include "ppapi/proxy/ppapi_messages.h" |
12 | 13 |
13 namespace pp { | 14 namespace pp { |
14 namespace proxy { | 15 namespace proxy { |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 PP_Bool ReadImageData(PP_Resource device_context_2d, | 19 PP_Bool ReadImageData(PP_Resource graphics_2d, |
19 PP_Resource image, | 20 PP_Resource image, |
20 const PP_Point* top_left) { | 21 const PP_Point* top_left) { |
21 ImageData* image_object = PluginResource::GetAs<ImageData>(image); | 22 PluginResource* image_object = PluginResourceTracker::GetInstance()-> |
| 23 GetResourceObject(image); |
22 if (!image_object) | 24 if (!image_object) |
23 return PP_FALSE; | 25 return PP_FALSE; |
| 26 PluginResource* graphics_2d_object = |
| 27 PluginResourceTracker::GetInstance()->GetResourceObject(graphics_2d); |
| 28 if (!graphics_2d_object || |
| 29 image_object->instance() != graphics_2d_object->instance()) |
| 30 return PP_FALSE; |
| 31 |
24 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance( | 32 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance( |
25 image_object->instance()); | 33 image_object->instance()); |
26 if (!dispatcher) | 34 if (!dispatcher) |
27 return PP_FALSE; | 35 return PP_FALSE; |
28 | 36 |
29 PP_Bool result = PP_FALSE; | 37 PP_Bool result = PP_FALSE; |
30 dispatcher->Send(new PpapiHostMsg_PPBTesting_ReadImageData( | 38 dispatcher->Send(new PpapiHostMsg_PPBTesting_ReadImageData( |
31 INTERFACE_ID_PPB_TESTING, device_context_2d, image, *top_left, &result)); | 39 INTERFACE_ID_PPB_TESTING, graphics_2d_object->host_resource(), |
| 40 image_object->host_resource(), *top_left, &result)); |
32 return result; | 41 return result; |
33 } | 42 } |
34 | 43 |
35 void RunMessageLoop() { | 44 void RunMessageLoop() { |
36 bool old_state = MessageLoop::current()->NestableTasksAllowed(); | 45 bool old_state = MessageLoop::current()->NestableTasksAllowed(); |
37 MessageLoop::current()->SetNestableTasksAllowed(true); | 46 MessageLoop::current()->SetNestableTasksAllowed(true); |
38 MessageLoop::current()->Run(); | 47 MessageLoop::current()->Run(); |
39 MessageLoop::current()->SetNestableTasksAllowed(old_state); | 48 MessageLoop::current()->SetNestableTasksAllowed(old_state); |
40 } | 49 } |
41 | 50 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 OnMsgRunMessageLoop) | 97 OnMsgRunMessageLoop) |
89 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_QuitMessageLoop, | 98 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_QuitMessageLoop, |
90 OnMsgQuitMessageLoop) | 99 OnMsgQuitMessageLoop) |
91 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance, | 100 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance, |
92 OnMsgGetLiveObjectsForInstance) | 101 OnMsgGetLiveObjectsForInstance) |
93 IPC_MESSAGE_UNHANDLED(handled = false) | 102 IPC_MESSAGE_UNHANDLED(handled = false) |
94 IPC_END_MESSAGE_MAP() | 103 IPC_END_MESSAGE_MAP() |
95 return handled; | 104 return handled; |
96 } | 105 } |
97 | 106 |
98 void PPB_Testing_Proxy::OnMsgReadImageData(PP_Resource device_context_2d, | 107 void PPB_Testing_Proxy::OnMsgReadImageData( |
99 PP_Resource image, | 108 const HostResource& device_context_2d, |
100 const PP_Point& top_left, | 109 const HostResource& image, |
101 PP_Bool* result) { | 110 const PP_Point& top_left, |
| 111 PP_Bool* result) { |
102 *result = ppb_testing_target()->ReadImageData( | 112 *result = ppb_testing_target()->ReadImageData( |
103 device_context_2d, image, &top_left); | 113 device_context_2d.host_resource(), image.host_resource(), &top_left); |
104 } | 114 } |
105 | 115 |
106 void PPB_Testing_Proxy::OnMsgRunMessageLoop(bool* dummy) { | 116 void PPB_Testing_Proxy::OnMsgRunMessageLoop(bool* dummy) { |
107 ppb_testing_target()->RunMessageLoop(); | 117 ppb_testing_target()->RunMessageLoop(); |
108 *dummy = false; | 118 *dummy = false; |
109 } | 119 } |
110 | 120 |
111 void PPB_Testing_Proxy::OnMsgQuitMessageLoop() { | 121 void PPB_Testing_Proxy::OnMsgQuitMessageLoop() { |
112 ppb_testing_target()->QuitMessageLoop(); | 122 ppb_testing_target()->QuitMessageLoop(); |
113 } | 123 } |
114 | 124 |
115 void PPB_Testing_Proxy::OnMsgGetLiveObjectsForInstance(PP_Instance instance, | 125 void PPB_Testing_Proxy::OnMsgGetLiveObjectsForInstance(PP_Instance instance, |
116 uint32_t* result) { | 126 uint32_t* result) { |
117 *result = ppb_testing_target()->GetLiveObjectsForInstance(instance); | 127 *result = ppb_testing_target()->GetLiveObjectsForInstance(instance); |
118 } | 128 } |
119 | 129 |
120 } // namespace proxy | 130 } // namespace proxy |
121 } // namespace pp | 131 } // namespace pp |
OLD | NEW |