| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/mus/gles2/command_buffer_driver.h" | 5 #include "components/mus/gles2/command_buffer_driver.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
| 10 #include "base/process/process_handle.h" | 10 #include "base/process/process_handle.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 CommandBufferDriver::Client::~Client() {} | 37 CommandBufferDriver::Client::~Client() {} |
| 38 | 38 |
| 39 CommandBufferDriver::CommandBufferDriver(scoped_refptr<GpuState> gpu_state) | 39 CommandBufferDriver::CommandBufferDriver(scoped_refptr<GpuState> gpu_state) |
| 40 : client_(nullptr), gpu_state_(gpu_state), weak_factory_(this) {} | 40 : client_(nullptr), gpu_state_(gpu_state), weak_factory_(this) {} |
| 41 | 41 |
| 42 CommandBufferDriver::~CommandBufferDriver() { | 42 CommandBufferDriver::~CommandBufferDriver() { |
| 43 DestroyDecoder(); | 43 DestroyDecoder(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void CommandBufferDriver::Initialize( | 46 void CommandBufferDriver::Initialize( |
| 47 mojo::InterfacePtrInfo<mojo::CommandBufferSyncClient> sync_client, | 47 mojo::InterfacePtrInfo<mojom::CommandBufferSyncClient> sync_client, |
| 48 mojo::InterfacePtrInfo<mojo::CommandBufferLostContextObserver> | 48 mojo::InterfacePtrInfo<mojom::CommandBufferLostContextObserver> |
| 49 loss_observer, | 49 loss_observer, |
| 50 mojo::ScopedSharedBufferHandle shared_state, | 50 mojo::ScopedSharedBufferHandle shared_state, |
| 51 mojo::Array<int32_t> attribs) { | 51 mojo::Array<int32_t> attribs) { |
| 52 sync_client_ = mojo::MakeProxy(sync_client.Pass()); | 52 sync_client_ = mojo::MakeProxy(sync_client.Pass()); |
| 53 loss_observer_ = mojo::MakeProxy(loss_observer.Pass()); | 53 loss_observer_ = mojo::MakeProxy(loss_observer.Pass()); |
| 54 bool success = DoInitialize(shared_state.Pass(), attribs.Pass()); | 54 bool success = DoInitialize(shared_state.Pass(), attribs.Pass()); |
| 55 mojo::GpuCapabilitiesPtr capabilities = | 55 mojom::GpuCapabilitiesPtr capabilities = |
| 56 success ? mojo::GpuCapabilities::From(decoder_->GetCapabilities()) | 56 success ? mojom::GpuCapabilities::From(decoder_->GetCapabilities()) |
| 57 : nullptr; | 57 : nullptr; |
| 58 sync_client_->DidInitialize(success, capabilities.Pass()); | 58 sync_client_->DidInitialize(success, capabilities.Pass()); |
| 59 } | 59 } |
| 60 | 60 |
| 61 bool CommandBufferDriver::MakeCurrent() { | 61 bool CommandBufferDriver::MakeCurrent() { |
| 62 if (!decoder_) | 62 if (!decoder_) |
| 63 return false; | 63 return false; |
| 64 if (decoder_->MakeCurrent()) | 64 if (decoder_->MakeCurrent()) |
| 65 return true; | 65 return true; |
| 66 DLOG(ERROR) << "Context lost because MakeCurrent failed."; | 66 DLOG(ERROR) << "Context lost because MakeCurrent failed."; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 DLOG(WARNING) << "Context lost"; | 161 DLOG(WARNING) << "Context lost"; |
| 162 OnContextLost(gpu::error::kUnknown); | 162 OnContextLost(gpu::error::kUnknown); |
| 163 return; | 163 return; |
| 164 } | 164 } |
| 165 command_buffer_->Flush(put_offset); | 165 command_buffer_->Flush(put_offset); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void CommandBufferDriver::MakeProgress(int32_t last_get_offset) { | 168 void CommandBufferDriver::MakeProgress(int32_t last_get_offset) { |
| 169 // TODO(piman): handle out-of-order. | 169 // TODO(piman): handle out-of-order. |
| 170 sync_client_->DidMakeProgress( | 170 sync_client_->DidMakeProgress( |
| 171 mojo::CommandBufferState::From(command_buffer_->GetLastState())); | 171 mojom::CommandBufferState::From(command_buffer_->GetLastState())); |
| 172 } | 172 } |
| 173 | 173 |
| 174 void CommandBufferDriver::RegisterTransferBuffer( | 174 void CommandBufferDriver::RegisterTransferBuffer( |
| 175 int32_t id, | 175 int32_t id, |
| 176 mojo::ScopedSharedBufferHandle transfer_buffer, | 176 mojo::ScopedSharedBufferHandle transfer_buffer, |
| 177 uint32_t size) { | 177 uint32_t size) { |
| 178 // Take ownership of the memory and map it into this process. | 178 // Take ownership of the memory and map it into this process. |
| 179 // This validates the size. | 179 // This validates the size. |
| 180 scoped_ptr<gpu::BufferBacking> backing( | 180 scoped_ptr<gpu::BufferBacking> backing( |
| 181 MojoBufferBacking::Create(transfer_buffer.Pass(), size)); | 181 MojoBufferBacking::Create(transfer_buffer.Pass(), size)); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 | 342 |
| 343 void CommandBufferDriver::DestroyDecoder() { | 343 void CommandBufferDriver::DestroyDecoder() { |
| 344 if (decoder_) { | 344 if (decoder_) { |
| 345 bool have_context = decoder_->MakeCurrent(); | 345 bool have_context = decoder_->MakeCurrent(); |
| 346 decoder_->Destroy(have_context); | 346 decoder_->Destroy(have_context); |
| 347 decoder_.reset(); | 347 decoder_.reset(); |
| 348 } | 348 } |
| 349 } | 349 } |
| 350 | 350 |
| 351 } // namespace mus | 351 } // namespace mus |
| OLD | NEW |