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/ppapi_command_buffer_proxy.h" | 5 #include "ppapi/proxy/ppapi_command_buffer_proxy.h" |
6 | 6 |
7 #include "ppapi/proxy/ppapi_messages.h" | 7 #include "ppapi/proxy/ppapi_messages.h" |
8 #include "ppapi/proxy/proxy_channel.h" | 8 #include "ppapi/proxy/proxy_channel.h" |
9 #include "ppapi/shared_impl/api_id.h" | 9 #include "ppapi/shared_impl/api_id.h" |
10 #include "ppapi/shared_impl/host_resource.h" | 10 #include "ppapi/shared_impl/host_resource.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 218 |
219 // Check local cache to see if there is already a client side shared memory | 219 // Check local cache to see if there is already a client side shared memory |
220 // object for this id. | 220 // object for this id. |
221 TransferBufferMap::iterator it = transfer_buffers_.find(id); | 221 TransferBufferMap::iterator it = transfer_buffers_.find(id); |
222 if (it != transfer_buffers_.end()) { | 222 if (it != transfer_buffers_.end()) { |
223 return it->second; | 223 return it->second; |
224 } | 224 } |
225 | 225 |
226 // Assuming we are in the renderer process, the service is responsible for | 226 // Assuming we are in the renderer process, the service is responsible for |
227 // duplicating the handle. This might not be true for NaCl. | 227 // duplicating the handle. This might not be true for NaCl. |
228 base::SharedMemoryHandle handle; | 228 ppapi::proxy::SerializedHandle handle( |
229 uint32 size; | 229 ppapi::proxy::SerializedHandle::SHARED_MEMORY); |
230 if (!Send(new PpapiHostMsg_PPBGraphics3D_GetTransferBuffer( | 230 if (!Send(new PpapiHostMsg_PPBGraphics3D_GetTransferBuffer( |
231 ppapi::API_ID_PPB_GRAPHICS_3D, resource_, id, &handle, &size))) { | 231 ppapi::API_ID_PPB_GRAPHICS_3D, resource_, id, &handle))) { |
232 return gpu::Buffer(); | 232 return gpu::Buffer(); |
233 } | 233 } |
| 234 if (!handle.is_shmem()) |
| 235 return gpu::Buffer(); |
234 | 236 |
235 // Cache the transfer buffer shared memory object client side. | 237 // Cache the transfer buffer shared memory object client side. |
236 scoped_ptr<base::SharedMemory> shared_memory( | 238 scoped_ptr<base::SharedMemory> shared_memory( |
237 new base::SharedMemory(handle, false)); | 239 new base::SharedMemory(handle.shmem(), false)); |
238 | 240 |
239 // Map the shared memory on demand. | 241 // Map the shared memory on demand. |
240 if (!shared_memory->memory()) { | 242 if (!shared_memory->memory()) { |
241 if (!shared_memory->Map(size)) { | 243 if (!shared_memory->Map(handle.size())) { |
242 return gpu::Buffer(); | 244 return gpu::Buffer(); |
243 } | 245 } |
244 } | 246 } |
245 | 247 |
246 gpu::Buffer buffer; | 248 gpu::Buffer buffer; |
247 buffer.ptr = shared_memory->memory(); | 249 buffer.ptr = shared_memory->memory(); |
248 buffer.size = size; | 250 buffer.size = handle.size(); |
249 buffer.shared_memory = shared_memory.release(); | 251 buffer.shared_memory = shared_memory.release(); |
250 transfer_buffers_[id] = buffer; | 252 transfer_buffers_[id] = buffer; |
251 | 253 |
252 return buffer; | 254 return buffer; |
253 } | 255 } |
254 | 256 |
255 void PpapiCommandBufferProxy::SetToken(int32 token) { | 257 void PpapiCommandBufferProxy::SetToken(int32 token) { |
256 NOTREACHED(); | 258 NOTREACHED(); |
257 } | 259 } |
258 | 260 |
(...skipping 26 matching lines...) Expand all Loading... |
285 last_state_ = state; | 287 last_state_ = state; |
286 } | 288 } |
287 } else { | 289 } else { |
288 last_state_.error = gpu::error::kLostContext; | 290 last_state_.error = gpu::error::kLostContext; |
289 ++last_state_.generation; | 291 ++last_state_.generation; |
290 } | 292 } |
291 } | 293 } |
292 | 294 |
293 } // namespace proxy | 295 } // namespace proxy |
294 } // namespace ppapi | 296 } // namespace ppapi |
OLD | NEW |