OLD | NEW |
---|---|
1 // Copyright (c) 2011 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_surface_3d_proxy.h" | 5 #include "ppapi/proxy/ppb_surface_3d_proxy.h" |
6 | 6 |
7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
9 #include "ppapi/c/pp_resource.h" | 9 #include "ppapi/c/pp_resource.h" |
10 #include "ppapi/c/dev/ppb_surface_3d_dev.h" | 10 #include "ppapi/c/dev/ppb_surface_3d_dev.h" |
11 #include "ppapi/proxy/plugin_dispatcher.h" | 11 #include "ppapi/proxy/plugin_dispatcher.h" |
12 #include "ppapi/proxy/plugin_resource.h" | 12 #include "ppapi/proxy/plugin_resource.h" |
13 #include "ppapi/proxy/ppapi_messages.h" | 13 #include "ppapi/proxy/ppapi_messages.h" |
14 #include "ppapi/proxy/ppb_context_3d_proxy.h" | 14 #include "ppapi/proxy/ppb_context_3d_proxy.h" |
15 #include "ppapi/thunk/common.h" | |
15 | 16 |
16 namespace pp { | 17 namespace pp { |
17 namespace proxy { | 18 namespace proxy { |
18 | 19 |
19 Surface3D::~Surface3D() { | 20 Surface3D::~Surface3D() { |
20 if (context_) | 21 if (context_) |
21 context_->BindSurfaces(NULL, NULL); | 22 context_->BindSurfaces(NULL, NULL); |
22 } | 23 } |
23 | 24 |
24 namespace { | 25 namespace { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 int32_t attribute, | 70 int32_t attribute, |
70 int32_t* value) { | 71 int32_t* value) { |
71 // TODO(alokp): Implement me. | 72 // TODO(alokp): Implement me. |
72 return 0; | 73 return 0; |
73 } | 74 } |
74 | 75 |
75 int32_t SwapBuffers(PP_Resource surface_id, | 76 int32_t SwapBuffers(PP_Resource surface_id, |
76 PP_CompletionCallback callback) { | 77 PP_CompletionCallback callback) { |
77 Surface3D* object = PluginResource::GetAs<Surface3D>(surface_id); | 78 Surface3D* object = PluginResource::GetAs<Surface3D>(surface_id); |
78 if (!object) | 79 if (!object) |
79 return PP_ERROR_BADRESOURCE; | 80 return ppapi::thunk::MayForceCallback(callback, PP_ERROR_BADRESOURCE); |
80 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance( | 81 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance( |
81 object->instance()); | 82 object->instance()); |
82 if (!dispatcher) | 83 if (!dispatcher) |
83 return PP_ERROR_FAILED; | 84 return ppapi::thunk::MayForceCallback(callback, PP_ERROR_FAILED); |
84 | 85 |
85 // For now, disallow blocking calls. We'll need to add support for other | 86 // For now, disallow blocking calls. We'll need to add support for other |
86 // threads to this later. | 87 // threads to this later. |
87 if (!callback.func) | 88 if (!callback.func) |
88 return PP_ERROR_BADARGUMENT; | 89 return ppapi::thunk::MayForceCallback(callback, PP_ERROR_BADARGUMENT); |
89 | 90 |
90 if (object->is_flush_pending()) | 91 if (object->is_flush_pending()) |
piman
2011/06/07 17:32:14
Add braces around the next 2 lines
polina
2011/06/09 23:53:51
Done.
| |
91 return PP_ERROR_INPROGRESS; // Can't have >1 flush pending. | 92 // Can't have >1 flush pending. |
93 return ppapi::thunk::MayForceCallback(callback, PP_ERROR_INPROGRESS); | |
92 | 94 |
93 if (!object->context()) | 95 if (!object->context()) |
94 return PP_ERROR_FAILED; | 96 return ppapi::thunk::MayForceCallback(callback, PP_ERROR_FAILED); |
95 | 97 |
96 object->set_current_flush_callback(callback); | 98 object->set_current_flush_callback(callback); |
97 | 99 |
98 IPC::Message* msg = new PpapiHostMsg_PPBSurface3D_SwapBuffers( | 100 IPC::Message* msg = new PpapiHostMsg_PPBSurface3D_SwapBuffers( |
99 INTERFACE_ID_PPB_SURFACE_3D, object->host_resource()); | 101 INTERFACE_ID_PPB_SURFACE_3D, object->host_resource()); |
100 msg->set_unblock(true); | 102 msg->set_unblock(true); |
101 dispatcher->Send(msg); | 103 dispatcher->Send(msg); |
102 | 104 |
103 object->context()->gles2_impl()->SwapBuffers(); | 105 object->context()->gles2_impl()->SwapBuffers(); |
104 | 106 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 | 206 |
205 void PPB_Surface3D_Proxy::SendSwapBuffersACKToPlugin( | 207 void PPB_Surface3D_Proxy::SendSwapBuffersACKToPlugin( |
206 int32_t result, | 208 int32_t result, |
207 const HostResource& surface_3d) { | 209 const HostResource& surface_3d) { |
208 dispatcher()->Send(new PpapiMsg_PPBSurface3D_SwapBuffersACK( | 210 dispatcher()->Send(new PpapiMsg_PPBSurface3D_SwapBuffersACK( |
209 INTERFACE_ID_PPB_SURFACE_3D, surface_3d, result)); | 211 INTERFACE_ID_PPB_SURFACE_3D, surface_3d, result)); |
210 } | 212 } |
211 | 213 |
212 } // namespace proxy | 214 } // namespace proxy |
213 } // namespace pp | 215 } // namespace pp |
OLD | NEW |