| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 command_buffer_->SetPutOffsetChangeCallback(base::Bind( | 167 command_buffer_->SetPutOffsetChangeCallback(base::Bind( |
| 168 &gpu::CommandExecutor::PutChanged, base::Unretained(executor_.get()))); | 168 &gpu::CommandExecutor::PutChanged, base::Unretained(executor_.get()))); |
| 169 command_buffer_->SetGetBufferChangeCallback(base::Bind( | 169 command_buffer_->SetGetBufferChangeCallback(base::Bind( |
| 170 &gpu::CommandExecutor::SetGetBuffer, base::Unretained(executor_.get()))); | 170 &gpu::CommandExecutor::SetGetBuffer, base::Unretained(executor_.get()))); |
| 171 command_buffer_->SetParseErrorCallback( | 171 command_buffer_->SetParseErrorCallback( |
| 172 base::Bind(&CommandBufferDriver::OnParseError, base::Unretained(this))); | 172 base::Bind(&CommandBufferDriver::OnParseError, base::Unretained(this))); |
| 173 | 173 |
| 174 // TODO(piman): other callbacks | 174 // TODO(piman): other callbacks |
| 175 | 175 |
| 176 const size_t kSize = sizeof(gpu::CommandBufferSharedState); | 176 const size_t kSize = sizeof(gpu::CommandBufferSharedState); |
| 177 scoped_ptr<gpu::BufferBacking> backing( | 177 std::unique_ptr<gpu::BufferBacking> backing( |
| 178 MojoBufferBacking::Create(std::move(shared_state), kSize)); | 178 MojoBufferBacking::Create(std::move(shared_state), kSize)); |
| 179 if (!backing) | 179 if (!backing) |
| 180 return false; | 180 return false; |
| 181 | 181 |
| 182 command_buffer_->SetSharedStateBuffer(std::move(backing)); | 182 command_buffer_->SetSharedStateBuffer(std::move(backing)); |
| 183 gpu_state_->driver_manager()->AddDriver(this); | 183 gpu_state_->driver_manager()->AddDriver(this); |
| 184 return true; | 184 return true; |
| 185 } | 185 } |
| 186 | 186 |
| 187 void CommandBufferDriver::SetGetBuffer(int32_t buffer) { | 187 void CommandBufferDriver::SetGetBuffer(int32_t buffer) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 198 ProcessPendingAndIdleWork(); | 198 ProcessPendingAndIdleWork(); |
| 199 } | 199 } |
| 200 | 200 |
| 201 void CommandBufferDriver::RegisterTransferBuffer( | 201 void CommandBufferDriver::RegisterTransferBuffer( |
| 202 int32_t id, | 202 int32_t id, |
| 203 mojo::ScopedSharedBufferHandle transfer_buffer, | 203 mojo::ScopedSharedBufferHandle transfer_buffer, |
| 204 uint32_t size) { | 204 uint32_t size) { |
| 205 DCHECK(CalledOnValidThread()); | 205 DCHECK(CalledOnValidThread()); |
| 206 // Take ownership of the memory and map it into this process. | 206 // Take ownership of the memory and map it into this process. |
| 207 // This validates the size. | 207 // This validates the size. |
| 208 scoped_ptr<gpu::BufferBacking> backing( | 208 std::unique_ptr<gpu::BufferBacking> backing( |
| 209 MojoBufferBacking::Create(std::move(transfer_buffer), size)); | 209 MojoBufferBacking::Create(std::move(transfer_buffer), size)); |
| 210 if (!backing) { | 210 if (!backing) { |
| 211 DVLOG(0) << "Failed to map shared memory."; | 211 DVLOG(0) << "Failed to map shared memory."; |
| 212 return; | 212 return; |
| 213 } | 213 } |
| 214 command_buffer_->RegisterTransferBuffer(id, std::move(backing)); | 214 command_buffer_->RegisterTransferBuffer(id, std::move(backing)); |
| 215 } | 215 } |
| 216 | 216 |
| 217 void CommandBufferDriver::DestroyTransferBuffer(int32_t id) { | 217 void CommandBufferDriver::DestroyTransferBuffer(int32_t id) { |
| 218 DCHECK(CalledOnValidThread()); | 218 DCHECK(CalledOnValidThread()); |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 } | 545 } |
| 546 | 546 |
| 547 void CommandBufferDriver::OnGpuCompletedSwapBuffers(gfx::SwapResult result) { | 547 void CommandBufferDriver::OnGpuCompletedSwapBuffers(gfx::SwapResult result) { |
| 548 DCHECK(CalledOnValidThread()); | 548 DCHECK(CalledOnValidThread()); |
| 549 if (client_) { | 549 if (client_) { |
| 550 client_->OnGpuCompletedSwapBuffers(result); | 550 client_->OnGpuCompletedSwapBuffers(result); |
| 551 } | 551 } |
| 552 } | 552 } |
| 553 | 553 |
| 554 } // namespace mus | 554 } // namespace mus |
| OLD | NEW |