| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/gles2/command_buffer_client_impl.h" | 5 #include "mojo/gles2/command_buffer_client_impl.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/process/process_handle.h" | 10 #include "base/process/process_handle.h" |
| 11 #include "mojo/public/cpp/bindings/allocation_scope.h" | |
| 12 #include "mojo/public/cpp/bindings/sync_dispatcher.h" | 11 #include "mojo/public/cpp/bindings/sync_dispatcher.h" |
| 13 #include "mojo/services/gles2/command_buffer_type_conversions.h" | 12 #include "mojo/services/gles2/command_buffer_type_conversions.h" |
| 14 #include "mojo/services/gles2/mojo_buffer_backing.h" | 13 #include "mojo/services/gles2/mojo_buffer_backing.h" |
| 15 | 14 |
| 16 namespace mojo { | 15 namespace mojo { |
| 17 namespace gles2 { | 16 namespace gles2 { |
| 18 | 17 |
| 19 namespace { | 18 namespace { |
| 20 | 19 |
| 21 bool CreateMapAndDupSharedBuffer(size_t size, | 20 bool CreateMapAndDupSharedBuffer(size_t size, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 77 |
| 79 shared_state()->Initialize(); | 78 shared_state()->Initialize(); |
| 80 | 79 |
| 81 // TODO(darin): We need better sugar for sync calls. | 80 // TODO(darin): We need better sugar for sync calls. |
| 82 MessagePipe sync_pipe; | 81 MessagePipe sync_pipe; |
| 83 sync_dispatcher_.reset(new SyncDispatcher<CommandBufferSyncClient>( | 82 sync_dispatcher_.reset(new SyncDispatcher<CommandBufferSyncClient>( |
| 84 sync_pipe.handle0.Pass(), this)); | 83 sync_pipe.handle0.Pass(), this)); |
| 85 CommandBufferSyncClientPtr sync_client = | 84 CommandBufferSyncClientPtr sync_client = |
| 86 MakeProxy<CommandBufferSyncClient>(sync_pipe.handle1.Pass(), | 85 MakeProxy<CommandBufferSyncClient>(sync_pipe.handle1.Pass(), |
| 87 async_waiter_); | 86 async_waiter_); |
| 88 AllocationScope scope; | |
| 89 command_buffer_->Initialize(sync_client.Pass(), duped.Pass()); | 87 command_buffer_->Initialize(sync_client.Pass(), duped.Pass()); |
| 90 // Wait for DidInitialize to come on the sync client pipe. | 88 // Wait for DidInitialize to come on the sync client pipe. |
| 91 if (!sync_dispatcher_->WaitAndDispatchOneMessage()) { | 89 if (!sync_dispatcher_->WaitAndDispatchOneMessage()) { |
| 92 VLOG(1) << "Channel encountered error while creating command buffer"; | 90 VLOG(1) << "Channel encountered error while creating command buffer"; |
| 93 return false; | 91 return false; |
| 94 } | 92 } |
| 95 return initialize_result_; | 93 return initialize_result_; |
| 96 } | 94 } |
| 97 | 95 |
| 98 gpu::CommandBuffer::State CommandBufferClientImpl::GetLastState() { | 96 gpu::CommandBuffer::State CommandBufferClientImpl::GetLastState() { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 return NULL; | 140 return NULL; |
| 143 | 141 |
| 144 void* memory = NULL; | 142 void* memory = NULL; |
| 145 mojo::ScopedSharedBufferHandle handle; | 143 mojo::ScopedSharedBufferHandle handle; |
| 146 mojo::ScopedSharedBufferHandle duped; | 144 mojo::ScopedSharedBufferHandle duped; |
| 147 if (!CreateMapAndDupSharedBuffer(size, &memory, &handle, &duped)) | 145 if (!CreateMapAndDupSharedBuffer(size, &memory, &handle, &duped)) |
| 148 return NULL; | 146 return NULL; |
| 149 | 147 |
| 150 *id = ++next_transfer_buffer_id_; | 148 *id = ++next_transfer_buffer_id_; |
| 151 | 149 |
| 152 AllocationScope scope; | |
| 153 command_buffer_->RegisterTransferBuffer( | 150 command_buffer_->RegisterTransferBuffer( |
| 154 *id, duped.Pass(), static_cast<uint32_t>(size)); | 151 *id, duped.Pass(), static_cast<uint32_t>(size)); |
| 155 | 152 |
| 156 scoped_ptr<gpu::BufferBacking> backing( | 153 scoped_ptr<gpu::BufferBacking> backing( |
| 157 new MojoBufferBacking(handle.Pass(), memory, size)); | 154 new MojoBufferBacking(handle.Pass(), memory, size)); |
| 158 scoped_refptr<gpu::Buffer> buffer(new gpu::Buffer(backing.Pass())); | 155 scoped_refptr<gpu::Buffer> buffer(new gpu::Buffer(backing.Pass())); |
| 159 return buffer; | 156 return buffer; |
| 160 } | 157 } |
| 161 | 158 |
| 162 void CommandBufferClientImpl::DestroyTransferBuffer(int32 id) { | 159 void CommandBufferClientImpl::DestroyTransferBuffer(int32 id) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 } | 226 } |
| 230 | 227 |
| 231 void CommandBufferClientImpl::CancelAnimationFrames() { | 228 void CommandBufferClientImpl::CancelAnimationFrames() { |
| 232 command_buffer_->CancelAnimationFrames(); | 229 command_buffer_->CancelAnimationFrames(); |
| 233 } | 230 } |
| 234 | 231 |
| 235 void CommandBufferClientImpl::DidInitialize(bool success) { | 232 void CommandBufferClientImpl::DidInitialize(bool success) { |
| 236 initialize_result_ = success; | 233 initialize_result_ = success; |
| 237 } | 234 } |
| 238 | 235 |
| 239 void CommandBufferClientImpl::DidMakeProgress(const CommandBufferState& state) { | 236 void CommandBufferClientImpl::DidMakeProgress(CommandBufferStatePtr state) { |
| 240 if (state.generation() - last_state_.generation < 0x80000000U) | 237 if (state->generation - last_state_.generation < 0x80000000U) |
| 241 last_state_ = state; | 238 last_state_ = state.To<State>(); |
| 242 } | 239 } |
| 243 | 240 |
| 244 void CommandBufferClientImpl::DidDestroy() { | 241 void CommandBufferClientImpl::DidDestroy() { |
| 245 LostContext(gpu::error::kUnknown); | 242 LostContext(gpu::error::kUnknown); |
| 246 } | 243 } |
| 247 | 244 |
| 248 void CommandBufferClientImpl::LostContext(int32_t lost_reason) { | 245 void CommandBufferClientImpl::LostContext(int32_t lost_reason) { |
| 249 last_state_.error = gpu::error::kLostContext; | 246 last_state_.error = gpu::error::kLostContext; |
| 250 last_state_.context_lost_reason = | 247 last_state_.context_lost_reason = |
| 251 static_cast<gpu::error::ContextLostReason>(lost_reason); | 248 static_cast<gpu::error::ContextLostReason>(lost_reason); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 270 return; | 267 return; |
| 271 } | 268 } |
| 272 } | 269 } |
| 273 | 270 |
| 274 void CommandBufferClientImpl::DrawAnimationFrame() { | 271 void CommandBufferClientImpl::DrawAnimationFrame() { |
| 275 delegate_->DrawAnimationFrame(); | 272 delegate_->DrawAnimationFrame(); |
| 276 } | 273 } |
| 277 | 274 |
| 278 } // namespace gles2 | 275 } // namespace gles2 |
| 279 } // namespace mojo | 276 } // namespace mojo |
| OLD | NEW |