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