| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/numerics/safe_conversions.h" | 9 #include "base/numerics/safe_conversions.h" |
| 10 #include "ppapi/proxy/ppapi_messages.h" | 10 #include "ppapi/proxy/ppapi_messages.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 bool PpapiCommandBufferProxy::Initialize() { | 43 bool PpapiCommandBufferProxy::Initialize() { |
| 44 return true; | 44 return true; |
| 45 } | 45 } |
| 46 | 46 |
| 47 gpu::CommandBuffer::State PpapiCommandBufferProxy::GetLastState() { | 47 gpu::CommandBuffer::State PpapiCommandBufferProxy::GetLastState() { |
| 48 ppapi::ProxyLock::AssertAcquiredDebugOnly(); | 48 ppapi::ProxyLock::AssertAcquiredDebugOnly(); |
| 49 return last_state_; | 49 return last_state_; |
| 50 } | 50 } |
| 51 | 51 |
| 52 int32 PpapiCommandBufferProxy::GetLastToken() { | 52 int32_t PpapiCommandBufferProxy::GetLastToken() { |
| 53 ppapi::ProxyLock::AssertAcquiredDebugOnly(); | 53 ppapi::ProxyLock::AssertAcquiredDebugOnly(); |
| 54 TryUpdateState(); | 54 TryUpdateState(); |
| 55 return last_state_.token; | 55 return last_state_.token; |
| 56 } | 56 } |
| 57 | 57 |
| 58 void PpapiCommandBufferProxy::Flush(int32 put_offset) { | 58 void PpapiCommandBufferProxy::Flush(int32_t put_offset) { |
| 59 if (last_state_.error != gpu::error::kNoError) | 59 if (last_state_.error != gpu::error::kNoError) |
| 60 return; | 60 return; |
| 61 | 61 |
| 62 OrderingBarrier(put_offset); | 62 OrderingBarrier(put_offset); |
| 63 FlushInternal(); | 63 FlushInternal(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 void PpapiCommandBufferProxy::OrderingBarrier(int32 put_offset) { | 66 void PpapiCommandBufferProxy::OrderingBarrier(int32_t put_offset) { |
| 67 if (last_state_.error != gpu::error::kNoError) | 67 if (last_state_.error != gpu::error::kNoError) |
| 68 return; | 68 return; |
| 69 | 69 |
| 70 if (flush_info_->flush_pending && flush_info_->resource != resource_) { | 70 if (flush_info_->flush_pending && flush_info_->resource != resource_) { |
| 71 FlushInternal(); | 71 FlushInternal(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 flush_info_->flush_pending = true; | 74 flush_info_->flush_pending = true; |
| 75 flush_info_->resource = resource_; | 75 flush_info_->resource = resource_; |
| 76 flush_info_->put_offset = put_offset; | 76 flush_info_->put_offset = put_offset; |
| 77 pending_fence_sync_release_ = next_fence_sync_release_ - 1; | 77 pending_fence_sync_release_ = next_fence_sync_release_ - 1; |
| 78 } | 78 } |
| 79 | 79 |
| 80 void PpapiCommandBufferProxy::WaitForTokenInRange(int32 start, int32 end) { | 80 void PpapiCommandBufferProxy::WaitForTokenInRange(int32_t start, int32_t end) { |
| 81 TryUpdateState(); | 81 TryUpdateState(); |
| 82 if (!InRange(start, end, last_state_.token) && | 82 if (!InRange(start, end, last_state_.token) && |
| 83 last_state_.error == gpu::error::kNoError) { | 83 last_state_.error == gpu::error::kNoError) { |
| 84 bool success = false; | 84 bool success = false; |
| 85 gpu::CommandBuffer::State state; | 85 gpu::CommandBuffer::State state; |
| 86 if (Send(new PpapiHostMsg_PPBGraphics3D_WaitForTokenInRange( | 86 if (Send(new PpapiHostMsg_PPBGraphics3D_WaitForTokenInRange( |
| 87 ppapi::API_ID_PPB_GRAPHICS_3D, | 87 ppapi::API_ID_PPB_GRAPHICS_3D, |
| 88 resource_, | 88 resource_, |
| 89 start, | 89 start, |
| 90 end, | 90 end, |
| 91 &state, | 91 &state, |
| 92 &success))) | 92 &success))) |
| 93 UpdateState(state, success); | 93 UpdateState(state, success); |
| 94 } | 94 } |
| 95 DCHECK(InRange(start, end, last_state_.token) || | 95 DCHECK(InRange(start, end, last_state_.token) || |
| 96 last_state_.error != gpu::error::kNoError); | 96 last_state_.error != gpu::error::kNoError); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void PpapiCommandBufferProxy::WaitForGetOffsetInRange(int32 start, int32 end) { | 99 void PpapiCommandBufferProxy::WaitForGetOffsetInRange(int32_t start, |
| 100 int32_t end) { |
| 100 TryUpdateState(); | 101 TryUpdateState(); |
| 101 if (!InRange(start, end, last_state_.get_offset) && | 102 if (!InRange(start, end, last_state_.get_offset) && |
| 102 last_state_.error == gpu::error::kNoError) { | 103 last_state_.error == gpu::error::kNoError) { |
| 103 bool success = false; | 104 bool success = false; |
| 104 gpu::CommandBuffer::State state; | 105 gpu::CommandBuffer::State state; |
| 105 if (Send(new PpapiHostMsg_PPBGraphics3D_WaitForGetOffsetInRange( | 106 if (Send(new PpapiHostMsg_PPBGraphics3D_WaitForGetOffsetInRange( |
| 106 ppapi::API_ID_PPB_GRAPHICS_3D, | 107 ppapi::API_ID_PPB_GRAPHICS_3D, |
| 107 resource_, | 108 resource_, |
| 108 start, | 109 start, |
| 109 end, | 110 end, |
| 110 &state, | 111 &state, |
| 111 &success))) | 112 &success))) |
| 112 UpdateState(state, success); | 113 UpdateState(state, success); |
| 113 } | 114 } |
| 114 DCHECK(InRange(start, end, last_state_.get_offset) || | 115 DCHECK(InRange(start, end, last_state_.get_offset) || |
| 115 last_state_.error != gpu::error::kNoError); | 116 last_state_.error != gpu::error::kNoError); |
| 116 } | 117 } |
| 117 | 118 |
| 118 void PpapiCommandBufferProxy::SetGetBuffer(int32 transfer_buffer_id) { | 119 void PpapiCommandBufferProxy::SetGetBuffer(int32_t transfer_buffer_id) { |
| 119 if (last_state_.error == gpu::error::kNoError) { | 120 if (last_state_.error == gpu::error::kNoError) { |
| 120 Send(new PpapiHostMsg_PPBGraphics3D_SetGetBuffer( | 121 Send(new PpapiHostMsg_PPBGraphics3D_SetGetBuffer( |
| 121 ppapi::API_ID_PPB_GRAPHICS_3D, resource_, transfer_buffer_id)); | 122 ppapi::API_ID_PPB_GRAPHICS_3D, resource_, transfer_buffer_id)); |
| 122 } | 123 } |
| 123 } | 124 } |
| 124 | 125 |
| 125 scoped_refptr<gpu::Buffer> PpapiCommandBufferProxy::CreateTransferBuffer( | 126 scoped_refptr<gpu::Buffer> PpapiCommandBufferProxy::CreateTransferBuffer( |
| 126 size_t size, | 127 size_t size, |
| 127 int32* id) { | 128 int32_t* id) { |
| 128 *id = -1; | 129 *id = -1; |
| 129 | 130 |
| 130 if (last_state_.error != gpu::error::kNoError) | 131 if (last_state_.error != gpu::error::kNoError) |
| 131 return NULL; | 132 return NULL; |
| 132 | 133 |
| 133 // Assuming we are in the renderer process, the service is responsible for | 134 // Assuming we are in the renderer process, the service is responsible for |
| 134 // duplicating the handle. This might not be true for NaCl. | 135 // duplicating the handle. This might not be true for NaCl. |
| 135 ppapi::proxy::SerializedHandle handle( | 136 ppapi::proxy::SerializedHandle handle( |
| 136 ppapi::proxy::SerializedHandle::SHARED_MEMORY); | 137 ppapi::proxy::SerializedHandle::SHARED_MEMORY); |
| 137 if (!Send(new PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer( | 138 if (!Send(new PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 158 last_state_.error = gpu::error::kOutOfBounds; | 159 last_state_.error = gpu::error::kOutOfBounds; |
| 159 *id = -1; | 160 *id = -1; |
| 160 return NULL; | 161 return NULL; |
| 161 } | 162 } |
| 162 } | 163 } |
| 163 | 164 |
| 164 return gpu::MakeBufferFromSharedMemory(std::move(shared_memory), | 165 return gpu::MakeBufferFromSharedMemory(std::move(shared_memory), |
| 165 handle.size()); | 166 handle.size()); |
| 166 } | 167 } |
| 167 | 168 |
| 168 void PpapiCommandBufferProxy::DestroyTransferBuffer(int32 id) { | 169 void PpapiCommandBufferProxy::DestroyTransferBuffer(int32_t id) { |
| 169 if (last_state_.error != gpu::error::kNoError) | 170 if (last_state_.error != gpu::error::kNoError) |
| 170 return; | 171 return; |
| 171 | 172 |
| 172 Send(new PpapiHostMsg_PPBGraphics3D_DestroyTransferBuffer( | 173 Send(new PpapiHostMsg_PPBGraphics3D_DestroyTransferBuffer( |
| 173 ppapi::API_ID_PPB_GRAPHICS_3D, resource_, id)); | 174 ppapi::API_ID_PPB_GRAPHICS_3D, resource_, id)); |
| 174 } | 175 } |
| 175 | 176 |
| 176 void PpapiCommandBufferProxy::SetLock(base::Lock*) { | 177 void PpapiCommandBufferProxy::SetLock(base::Lock*) { |
| 177 NOTIMPLEMENTED(); | 178 NOTIMPLEMENTED(); |
| 178 } | 179 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 214 |
| 214 bool PpapiCommandBufferProxy::CanWaitUnverifiedSyncToken( | 215 bool PpapiCommandBufferProxy::CanWaitUnverifiedSyncToken( |
| 215 const gpu::SyncToken* sync_token) { | 216 const gpu::SyncToken* sync_token) { |
| 216 return false; | 217 return false; |
| 217 } | 218 } |
| 218 | 219 |
| 219 int32_t PpapiCommandBufferProxy::GetExtraCommandBufferData() const { | 220 int32_t PpapiCommandBufferProxy::GetExtraCommandBufferData() const { |
| 220 return 0; | 221 return 0; |
| 221 } | 222 } |
| 222 | 223 |
| 223 uint32 PpapiCommandBufferProxy::InsertSyncPoint() { | 224 uint32_t PpapiCommandBufferProxy::InsertSyncPoint() { |
| 224 uint32 sync_point = 0; | 225 uint32_t sync_point = 0; |
| 225 if (last_state_.error == gpu::error::kNoError) { | 226 if (last_state_.error == gpu::error::kNoError) { |
| 226 Send(new PpapiHostMsg_PPBGraphics3D_InsertSyncPoint( | 227 Send(new PpapiHostMsg_PPBGraphics3D_InsertSyncPoint( |
| 227 ppapi::API_ID_PPB_GRAPHICS_3D, resource_, &sync_point)); | 228 ppapi::API_ID_PPB_GRAPHICS_3D, resource_, &sync_point)); |
| 228 } | 229 } |
| 229 return sync_point; | 230 return sync_point; |
| 230 } | 231 } |
| 231 | 232 |
| 232 uint32 PpapiCommandBufferProxy::InsertFutureSyncPoint() { | 233 uint32_t PpapiCommandBufferProxy::InsertFutureSyncPoint() { |
| 233 uint32 sync_point = 0; | 234 uint32_t sync_point = 0; |
| 234 if (last_state_.error == gpu::error::kNoError) { | 235 if (last_state_.error == gpu::error::kNoError) { |
| 235 Send(new PpapiHostMsg_PPBGraphics3D_InsertFutureSyncPoint( | 236 Send(new PpapiHostMsg_PPBGraphics3D_InsertFutureSyncPoint( |
| 236 ppapi::API_ID_PPB_GRAPHICS_3D, resource_, &sync_point)); | 237 ppapi::API_ID_PPB_GRAPHICS_3D, resource_, &sync_point)); |
| 237 } | 238 } |
| 238 return sync_point; | 239 return sync_point; |
| 239 } | 240 } |
| 240 | 241 |
| 241 void PpapiCommandBufferProxy::RetireSyncPoint(uint32 sync_point) { | 242 void PpapiCommandBufferProxy::RetireSyncPoint(uint32_t sync_point) { |
| 242 if (last_state_.error == gpu::error::kNoError) { | 243 if (last_state_.error == gpu::error::kNoError) { |
| 243 Send(new PpapiHostMsg_PPBGraphics3D_RetireSyncPoint( | 244 Send(new PpapiHostMsg_PPBGraphics3D_RetireSyncPoint( |
| 244 ppapi::API_ID_PPB_GRAPHICS_3D, resource_, sync_point)); | 245 ppapi::API_ID_PPB_GRAPHICS_3D, resource_, sync_point)); |
| 245 } | 246 } |
| 246 } | 247 } |
| 247 | 248 |
| 248 void PpapiCommandBufferProxy::SignalSyncPoint(uint32 sync_point, | 249 void PpapiCommandBufferProxy::SignalSyncPoint(uint32_t sync_point, |
| 249 const base::Closure& callback) { | 250 const base::Closure& callback) { |
| 250 NOTREACHED(); | 251 NOTREACHED(); |
| 251 } | 252 } |
| 252 | 253 |
| 253 void PpapiCommandBufferProxy::SignalQuery(uint32 query, | 254 void PpapiCommandBufferProxy::SignalQuery(uint32_t query, |
| 254 const base::Closure& callback) { | 255 const base::Closure& callback) { |
| 255 NOTREACHED(); | 256 NOTREACHED(); |
| 256 } | 257 } |
| 257 | 258 |
| 258 gpu::Capabilities PpapiCommandBufferProxy::GetCapabilities() { | 259 gpu::Capabilities PpapiCommandBufferProxy::GetCapabilities() { |
| 259 return capabilities_; | 260 return capabilities_; |
| 260 } | 261 } |
| 261 | 262 |
| 262 int32 PpapiCommandBufferProxy::CreateImage(ClientBuffer buffer, | 263 int32_t PpapiCommandBufferProxy::CreateImage(ClientBuffer buffer, |
| 263 size_t width, | 264 size_t width, |
| 264 size_t height, | 265 size_t height, |
| 265 unsigned internalformat) { | 266 unsigned internalformat) { |
| 266 NOTREACHED(); | 267 NOTREACHED(); |
| 267 return -1; | 268 return -1; |
| 268 } | 269 } |
| 269 | 270 |
| 270 void PpapiCommandBufferProxy::DestroyImage(int32 id) { | 271 void PpapiCommandBufferProxy::DestroyImage(int32_t id) { |
| 271 NOTREACHED(); | 272 NOTREACHED(); |
| 272 } | 273 } |
| 273 | 274 |
| 274 int32 PpapiCommandBufferProxy::CreateGpuMemoryBufferImage( | 275 int32_t PpapiCommandBufferProxy::CreateGpuMemoryBufferImage( |
| 275 size_t width, | 276 size_t width, |
| 276 size_t height, | 277 size_t height, |
| 277 unsigned internalformat, | 278 unsigned internalformat, |
| 278 unsigned usage) { | 279 unsigned usage) { |
| 279 NOTREACHED(); | 280 NOTREACHED(); |
| 280 return -1; | 281 return -1; |
| 281 } | 282 } |
| 282 | 283 |
| 283 bool PpapiCommandBufferProxy::Send(IPC::Message* msg) { | 284 bool PpapiCommandBufferProxy::Send(IPC::Message* msg) { |
| 284 DCHECK(last_state_.error == gpu::error::kNoError); | 285 DCHECK(last_state_.error == gpu::error::kNoError); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 message->set_unblock(true); | 336 message->set_unblock(true); |
| 336 Send(message); | 337 Send(message); |
| 337 | 338 |
| 338 flush_info_->flush_pending = false; | 339 flush_info_->flush_pending = false; |
| 339 flush_info_->resource.SetHostResource(0, 0); | 340 flush_info_->resource.SetHostResource(0, 0); |
| 340 flushed_fence_sync_release_ = pending_fence_sync_release_; | 341 flushed_fence_sync_release_ = pending_fence_sync_release_; |
| 341 } | 342 } |
| 342 | 343 |
| 343 } // namespace proxy | 344 } // namespace proxy |
| 344 } // namespace ppapi | 345 } // namespace ppapi |
| OLD | NEW |