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_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/enter_proxy.h" | 9 #include "ppapi/proxy/enter_proxy.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 #include "ppapi/shared_impl/ppapi_globals.h" | 12 #include "ppapi/shared_impl/ppapi_globals.h" |
13 #include "ppapi/shared_impl/proxy_lock.h" | 13 #include "ppapi/shared_impl/proxy_lock.h" |
14 #include "ppapi/shared_impl/resource.h" | 14 #include "ppapi/shared_impl/resource.h" |
15 #include "ppapi/shared_impl/resource_tracker.h" | 15 #include "ppapi/shared_impl/resource_tracker.h" |
16 #include "ppapi/thunk/enter.h" | 16 #include "ppapi/thunk/enter.h" |
| 17 #include "ppapi/thunk/ppb_graphics_2d_api.h" |
17 #include "ppapi/thunk/ppb_input_event_api.h" | 18 #include "ppapi/thunk/ppb_input_event_api.h" |
18 | 19 |
19 using ppapi::thunk::EnterInstance; | 20 using ppapi::thunk::EnterInstance; |
| 21 using ppapi::thunk::EnterResource; |
20 using ppapi::thunk::EnterResourceNoLock; | 22 using ppapi::thunk::EnterResourceNoLock; |
| 23 using ppapi::thunk::PPB_Graphics2D_API; |
21 using ppapi::thunk::PPB_InputEvent_API; | 24 using ppapi::thunk::PPB_InputEvent_API; |
22 | 25 |
23 namespace ppapi { | 26 namespace ppapi { |
24 namespace proxy { | 27 namespace proxy { |
25 | 28 |
26 namespace { | 29 namespace { |
27 | 30 |
28 PP_Bool ReadImageData(PP_Resource graphics_2d, | 31 PP_Bool ReadImageData(PP_Resource graphics_2d, |
29 PP_Resource image, | 32 PP_Resource image, |
30 const PP_Point* top_left) { | 33 const PP_Point* top_left) { |
31 ProxyAutoLock lock; | 34 ProxyAutoLock lock; |
32 Resource* image_object = | 35 Resource* image_object = |
33 PpapiGlobals::Get()->GetResourceTracker()->GetResource(image); | 36 PpapiGlobals::Get()->GetResourceTracker()->GetResource(image); |
34 if (!image_object) | 37 if (!image_object) |
35 return PP_FALSE; | 38 return PP_FALSE; |
36 Resource* graphics_2d_object = | 39 Resource* graphics_2d_object = |
37 PpapiGlobals::Get()->GetResourceTracker()->GetResource(graphics_2d); | 40 PpapiGlobals::Get()->GetResourceTracker()->GetResource(graphics_2d); |
38 if (!graphics_2d_object || | 41 if (!graphics_2d_object || |
39 image_object->pp_instance() != graphics_2d_object->pp_instance()) | 42 image_object->pp_instance() != graphics_2d_object->pp_instance()) |
40 return PP_FALSE; | 43 return PP_FALSE; |
41 | 44 |
42 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance( | 45 EnterResource<PPB_Graphics2D_API> enter(graphics_2d, true); |
43 image_object->pp_instance()); | 46 if (enter.failed()) |
44 if (!dispatcher) | |
45 return PP_FALSE; | 47 return PP_FALSE; |
46 | 48 const HostResource& host_image = image_object->host_resource(); |
47 PP_Bool result = PP_FALSE; | 49 return enter.object()->ReadImageData(host_image.host_resource(), top_left) ? |
48 dispatcher->Send(new PpapiHostMsg_PPBTesting_ReadImageData( | 50 PP_TRUE : PP_FALSE; |
49 API_ID_PPB_TESTING, graphics_2d_object->host_resource(), | |
50 image_object->host_resource(), *top_left, &result)); | |
51 return result; | |
52 } | 51 } |
53 | 52 |
54 void RunMessageLoop(PP_Instance instance) { | 53 void RunMessageLoop(PP_Instance instance) { |
55 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); | 54 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); |
56 // TODO(dmichael): We should probably assert that this is the main thread. | 55 // TODO(dmichael): We should probably assert that this is the main thread. |
57 MessageLoop::current()->Run(); | 56 MessageLoop::current()->Run(); |
58 } | 57 } |
59 | 58 |
60 void QuitMessageLoop(PP_Instance instance) { | 59 void QuitMessageLoop(PP_Instance instance) { |
61 // TODO(dmichael): We should probably assert that this is the main thread. | 60 // TODO(dmichael): We should probably assert that this is the main thread. |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 PP_Instance instance, | 199 PP_Instance instance, |
201 const InputEventData& input_event) { | 200 const InputEventData& input_event) { |
202 scoped_refptr<PPB_InputEvent_Shared> input_event_impl( | 201 scoped_refptr<PPB_InputEvent_Shared> input_event_impl( |
203 new PPB_InputEvent_Shared(OBJECT_IS_PROXY, instance, input_event)); | 202 new PPB_InputEvent_Shared(OBJECT_IS_PROXY, instance, input_event)); |
204 ppb_testing_impl_->SimulateInputEvent(instance, | 203 ppb_testing_impl_->SimulateInputEvent(instance, |
205 input_event_impl->pp_resource()); | 204 input_event_impl->pp_resource()); |
206 } | 205 } |
207 | 206 |
208 } // namespace proxy | 207 } // namespace proxy |
209 } // namespace ppapi | 208 } // namespace ppapi |
OLD | NEW |