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 "base/numerics/safe_conversions.h" |
7 #include "ppapi/proxy/ppapi_messages.h" | 8 #include "ppapi/proxy/ppapi_messages.h" |
8 #include "ppapi/proxy/proxy_channel.h" | 9 #include "ppapi/proxy/proxy_channel.h" |
9 #include "ppapi/shared_impl/api_id.h" | 10 #include "ppapi/shared_impl/api_id.h" |
10 #include "ppapi/shared_impl/host_resource.h" | 11 #include "ppapi/shared_impl/host_resource.h" |
11 #include "ppapi/shared_impl/proxy_lock.h" | 12 #include "ppapi/shared_impl/proxy_lock.h" |
12 | 13 |
13 namespace ppapi { | 14 namespace ppapi { |
14 namespace proxy { | 15 namespace proxy { |
15 | 16 |
16 PpapiCommandBufferProxy::PpapiCommandBufferProxy( | 17 PpapiCommandBufferProxy::PpapiCommandBufferProxy( |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 *id = -1; | 116 *id = -1; |
116 | 117 |
117 if (last_state_.error != gpu::error::kNoError) | 118 if (last_state_.error != gpu::error::kNoError) |
118 return NULL; | 119 return NULL; |
119 | 120 |
120 // Assuming we are in the renderer process, the service is responsible for | 121 // Assuming we are in the renderer process, the service is responsible for |
121 // duplicating the handle. This might not be true for NaCl. | 122 // duplicating the handle. This might not be true for NaCl. |
122 ppapi::proxy::SerializedHandle handle( | 123 ppapi::proxy::SerializedHandle handle( |
123 ppapi::proxy::SerializedHandle::SHARED_MEMORY); | 124 ppapi::proxy::SerializedHandle::SHARED_MEMORY); |
124 if (!Send(new PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer( | 125 if (!Send(new PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer( |
125 ppapi::API_ID_PPB_GRAPHICS_3D, resource_, size, id, &handle))) { | 126 ppapi::API_ID_PPB_GRAPHICS_3D, resource_, |
| 127 base::checked_cast<uint32_t>(size), id, &handle))) { |
126 return NULL; | 128 return NULL; |
127 } | 129 } |
128 | 130 |
129 if (*id <= 0 || !handle.is_shmem()) | 131 if (*id <= 0 || !handle.is_shmem()) |
130 return NULL; | 132 return NULL; |
131 | 133 |
132 scoped_ptr<base::SharedMemory> shared_memory( | 134 scoped_ptr<base::SharedMemory> shared_memory( |
133 new base::SharedMemory(handle.shmem(), false)); | 135 new base::SharedMemory(handle.shmem(), false)); |
134 | 136 |
135 // Map the shared memory on demand. | 137 // Map the shared memory on demand. |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 shared_state()->Read(&last_state_); | 256 shared_state()->Read(&last_state_); |
255 } | 257 } |
256 | 258 |
257 gpu::CommandBufferSharedState* PpapiCommandBufferProxy::shared_state() const { | 259 gpu::CommandBufferSharedState* PpapiCommandBufferProxy::shared_state() const { |
258 return reinterpret_cast<gpu::CommandBufferSharedState*>( | 260 return reinterpret_cast<gpu::CommandBufferSharedState*>( |
259 shared_state_shm_->memory()); | 261 shared_state_shm_->memory()); |
260 } | 262 } |
261 | 263 |
262 } // namespace proxy | 264 } // namespace proxy |
263 } // namespace ppapi | 265 } // namespace ppapi |
OLD | NEW |