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

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

Issue 11053003: Migrate Graphics2D to new design. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 8 years 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
« no previous file with comments | « ppapi/proxy/ppb_instance_proxy.cc ('k') | ppapi/proxy/resource_creation_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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 EnterResourceNoLock<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 CHECK(PpapiGlobals::Get()->GetMainThreadMessageLoop()-> 55 CHECK(PpapiGlobals::Get()->GetMainThreadMessageLoop()->
57 BelongsToCurrentThread()); 56 BelongsToCurrentThread());
58 MessageLoop::current()->Run(); 57 MessageLoop::current()->Run();
59 } 58 }
60 59
61 void QuitMessageLoop(PP_Instance instance) { 60 void QuitMessageLoop(PP_Instance instance) {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 PP_Instance instance, 195 PP_Instance instance,
197 const InputEventData& input_event) { 196 const InputEventData& input_event) {
198 scoped_refptr<PPB_InputEvent_Shared> input_event_impl( 197 scoped_refptr<PPB_InputEvent_Shared> input_event_impl(
199 new PPB_InputEvent_Shared(OBJECT_IS_PROXY, instance, input_event)); 198 new PPB_InputEvent_Shared(OBJECT_IS_PROXY, instance, input_event));
200 ppb_testing_impl_->SimulateInputEvent(instance, 199 ppb_testing_impl_->SimulateInputEvent(instance,
201 input_event_impl->pp_resource()); 200 input_event_impl->pp_resource());
202 } 201 }
203 202
204 } // namespace proxy 203 } // namespace proxy
205 } // namespace ppapi 204 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_instance_proxy.cc ('k') | ppapi/proxy/resource_creation_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698