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_graphics_3d_proxy.h" | 5 #include "ppapi/proxy/ppb_graphics_3d_proxy.h" |
6 | 6 |
7 #include "base/numerics/safe_conversions.h" | 7 #include "base/numerics/safe_conversions.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "gpu/command_buffer/client/gles2_implementation.h" | 9 #include "gpu/command_buffer/client/gles2_implementation.h" |
10 #include "gpu/command_buffer/common/command_buffer.h" | 10 #include "gpu/command_buffer/common/command_buffer.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 : PPB_Graphics3D_Shared(resource) { | 52 : PPB_Graphics3D_Shared(resource) { |
53 } | 53 } |
54 | 54 |
55 Graphics3D::~Graphics3D() { | 55 Graphics3D::~Graphics3D() { |
56 DestroyGLES2Impl(); | 56 DestroyGLES2Impl(); |
57 } | 57 } |
58 | 58 |
59 bool Graphics3D::Init(gpu::gles2::GLES2Implementation* share_gles2, | 59 bool Graphics3D::Init(gpu::gles2::GLES2Implementation* share_gles2, |
60 const gpu::Capabilities& capabilities, | 60 const gpu::Capabilities& capabilities, |
61 const SerializedHandle& shared_state, | 61 const SerializedHandle& shared_state, |
62 uint64_t command_buffer_id) { | 62 gpu::CommandBufferId command_buffer_id) { |
63 PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(this); | 63 PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(this); |
64 if (!dispatcher) | 64 if (!dispatcher) |
65 return false; | 65 return false; |
66 | 66 |
67 command_buffer_.reset(new PpapiCommandBufferProxy( | 67 command_buffer_.reset(new PpapiCommandBufferProxy( |
68 host_resource(), dispatcher, capabilities, shared_state, | 68 host_resource(), dispatcher, capabilities, shared_state, |
69 command_buffer_id)); | 69 command_buffer_id)); |
70 | 70 |
71 return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize, | 71 return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize, |
72 share_gles2); | 72 share_gles2); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 attr += 2) { | 170 attr += 2) { |
171 attribs.push_back(attr[0]); | 171 attribs.push_back(attr[0]); |
172 attribs.push_back(attr[1]); | 172 attribs.push_back(attr[1]); |
173 } | 173 } |
174 } | 174 } |
175 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); | 175 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); |
176 | 176 |
177 HostResource result; | 177 HostResource result; |
178 gpu::Capabilities capabilities; | 178 gpu::Capabilities capabilities; |
179 ppapi::proxy::SerializedHandle shared_state; | 179 ppapi::proxy::SerializedHandle shared_state; |
180 uint64_t command_buffer_id = 0; | 180 gpu::CommandBufferId command_buffer_id; |
181 dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create(API_ID_PPB_GRAPHICS_3D, | 181 dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create(API_ID_PPB_GRAPHICS_3D, |
182 instance, share_host, attribs, &result, &capabilities, &shared_state, | 182 instance, share_host, attribs, &result, &capabilities, &shared_state, |
183 &command_buffer_id)); | 183 &command_buffer_id)); |
184 | 184 |
185 if (result.is_null()) | 185 if (result.is_null()) |
186 return 0; | 186 return 0; |
187 | 187 |
188 scoped_refptr<Graphics3D> graphics_3d(new Graphics3D(result)); | 188 scoped_refptr<Graphics3D> graphics_3d(new Graphics3D(result)); |
189 if (!graphics_3d->Init(share_gles2, capabilities, shared_state, | 189 if (!graphics_3d->Init(share_gles2, capabilities, shared_state, |
190 command_buffer_id)) { | 190 command_buffer_id)) { |
(...skipping 28 matching lines...) Expand all Loading... |
219 IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics3D_SwapBuffersACK, | 219 IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics3D_SwapBuffersACK, |
220 OnMsgSwapBuffersACK) | 220 OnMsgSwapBuffersACK) |
221 IPC_MESSAGE_UNHANDLED(handled = false) | 221 IPC_MESSAGE_UNHANDLED(handled = false) |
222 | 222 |
223 IPC_END_MESSAGE_MAP() | 223 IPC_END_MESSAGE_MAP() |
224 // FIXME(brettw) handle bad messages! | 224 // FIXME(brettw) handle bad messages! |
225 return handled; | 225 return handled; |
226 } | 226 } |
227 | 227 |
228 #if !defined(OS_NACL) | 228 #if !defined(OS_NACL) |
229 void PPB_Graphics3D_Proxy::OnMsgCreate(PP_Instance instance, | 229 void PPB_Graphics3D_Proxy::OnMsgCreate( |
230 HostResource share_context, | 230 PP_Instance instance, |
231 const std::vector<int32_t>& attribs, | 231 HostResource share_context, |
232 HostResource* result, | 232 const std::vector<int32_t>& attribs, |
233 gpu::Capabilities* capabilities, | 233 HostResource* result, |
234 SerializedHandle* shared_state, | 234 gpu::Capabilities* capabilities, |
235 uint64_t* command_buffer_id) { | 235 SerializedHandle* shared_state, |
| 236 gpu::CommandBufferId* command_buffer_id) { |
236 shared_state->set_null_shmem(); | 237 shared_state->set_null_shmem(); |
237 if (attribs.empty() || | 238 if (attribs.empty() || |
238 attribs.back() != PP_GRAPHICS3DATTRIB_NONE || | 239 attribs.back() != PP_GRAPHICS3DATTRIB_NONE || |
239 !(attribs.size() & 1)) | 240 !(attribs.size() & 1)) |
240 return; // Bad message. | 241 return; // Bad message. |
241 | 242 |
242 thunk::EnterResourceCreation enter(instance); | 243 thunk::EnterResourceCreation enter(instance); |
243 | 244 |
244 if (!enter.succeeded()) | 245 if (!enter.succeeded()) |
245 return; | 246 return; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( | 362 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( |
362 int32_t result, | 363 int32_t result, |
363 const HostResource& context) { | 364 const HostResource& context) { |
364 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( | 365 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( |
365 API_ID_PPB_GRAPHICS_3D, context, result)); | 366 API_ID_PPB_GRAPHICS_3D, context, result)); |
366 } | 367 } |
367 #endif // !defined(OS_NACL) | 368 #endif // !defined(OS_NACL) |
368 | 369 |
369 } // namespace proxy | 370 } // namespace proxy |
370 } // namespace ppapi | 371 } // namespace ppapi |
OLD | NEW |