Chromium Code Reviews| 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 "gpu/command_buffer/service/command_buffer_service.h" | 5 #include "gpu/command_buffer/service/command_buffer_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <limits> | 10 #include <limits> |
|
no sievers
2016/04/05 19:02:40
#include <memory>
Mostyn Bramley-Moore
2016/04/05 21:35:31
Done.
| |
| 11 | 11 |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
| 14 #include "gpu/command_buffer/common/cmd_buffer_common.h" | 14 #include "gpu/command_buffer/common/cmd_buffer_common.h" |
| 15 #include "gpu/command_buffer/common/command_buffer_shared.h" | 15 #include "gpu/command_buffer/common/command_buffer_shared.h" |
| 16 #include "gpu/command_buffer/service/transfer_buffer_manager.h" | 16 #include "gpu/command_buffer/service/transfer_buffer_manager.h" |
| 17 | 17 |
| 18 using ::base::SharedMemory; | 18 using ::base::SharedMemory; |
| 19 | 19 |
| 20 namespace gpu { | 20 namespace gpu { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 put_offset_ = 0; | 98 put_offset_ = 0; |
| 99 SetGetOffset(0); | 99 SetGetOffset(0); |
| 100 if (!get_buffer_change_callback_.is_null()) { | 100 if (!get_buffer_change_callback_.is_null()) { |
| 101 get_buffer_change_callback_.Run(ring_buffer_id_); | 101 get_buffer_change_callback_.Run(ring_buffer_id_); |
| 102 } | 102 } |
| 103 | 103 |
| 104 UpdateState(); | 104 UpdateState(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void CommandBufferService::SetSharedStateBuffer( | 107 void CommandBufferService::SetSharedStateBuffer( |
| 108 scoped_ptr<BufferBacking> shared_state_buffer) { | 108 std::unique_ptr<BufferBacking> shared_state_buffer) { |
| 109 shared_state_buffer_ = std::move(shared_state_buffer); | 109 shared_state_buffer_ = std::move(shared_state_buffer); |
| 110 DCHECK(shared_state_buffer_->GetSize() >= sizeof(*shared_state_)); | 110 DCHECK(shared_state_buffer_->GetSize() >= sizeof(*shared_state_)); |
| 111 | 111 |
| 112 shared_state_ = | 112 shared_state_ = |
| 113 static_cast<CommandBufferSharedState*>(shared_state_buffer_->GetMemory()); | 113 static_cast<CommandBufferSharedState*>(shared_state_buffer_->GetMemory()); |
| 114 | 114 |
| 115 UpdateState(); | 115 UpdateState(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void CommandBufferService::SetGetOffset(int32_t get_offset) { | 118 void CommandBufferService::SetGetOffset(int32_t get_offset) { |
| 119 DCHECK(get_offset >= 0 && get_offset < num_entries_); | 119 DCHECK(get_offset >= 0 && get_offset < num_entries_); |
| 120 get_offset_ = get_offset; | 120 get_offset_ = get_offset; |
| 121 } | 121 } |
| 122 | 122 |
| 123 scoped_refptr<Buffer> CommandBufferService::CreateTransferBuffer(size_t size, | 123 scoped_refptr<Buffer> CommandBufferService::CreateTransferBuffer(size_t size, |
| 124 int32_t* id) { | 124 int32_t* id) { |
| 125 *id = -1; | 125 *id = -1; |
| 126 | 126 |
| 127 scoped_ptr<SharedMemory> shared_memory(new SharedMemory()); | 127 std::unique_ptr<SharedMemory> shared_memory(new SharedMemory()); |
| 128 if (!shared_memory->CreateAndMapAnonymous(size)) { | 128 if (!shared_memory->CreateAndMapAnonymous(size)) { |
| 129 if (error_ == error::kNoError) | 129 if (error_ == error::kNoError) |
| 130 error_ = gpu::error::kOutOfBounds; | 130 error_ = gpu::error::kOutOfBounds; |
| 131 return NULL; | 131 return NULL; |
| 132 } | 132 } |
| 133 | 133 |
| 134 static int32_t next_id = 1; | 134 static int32_t next_id = 1; |
| 135 *id = next_id++; | 135 *id = next_id++; |
| 136 | 136 |
| 137 if (!RegisterTransferBuffer( | 137 if (!RegisterTransferBuffer( |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 155 put_offset_ = 0; | 155 put_offset_ = 0; |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 | 158 |
| 159 scoped_refptr<Buffer> CommandBufferService::GetTransferBuffer(int32_t id) { | 159 scoped_refptr<Buffer> CommandBufferService::GetTransferBuffer(int32_t id) { |
| 160 return transfer_buffer_manager_->GetTransferBuffer(id); | 160 return transfer_buffer_manager_->GetTransferBuffer(id); |
| 161 } | 161 } |
| 162 | 162 |
| 163 bool CommandBufferService::RegisterTransferBuffer( | 163 bool CommandBufferService::RegisterTransferBuffer( |
| 164 int32_t id, | 164 int32_t id, |
| 165 scoped_ptr<BufferBacking> buffer) { | 165 std::unique_ptr<BufferBacking> buffer) { |
| 166 return transfer_buffer_manager_->RegisterTransferBuffer(id, | 166 return transfer_buffer_manager_->RegisterTransferBuffer(id, |
| 167 std::move(buffer)); | 167 std::move(buffer)); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void CommandBufferService::SetToken(int32_t token) { | 170 void CommandBufferService::SetToken(int32_t token) { |
| 171 token_ = token; | 171 token_ = token; |
| 172 UpdateState(); | 172 UpdateState(); |
| 173 } | 173 } |
| 174 | 174 |
| 175 void CommandBufferService::SetParseError(error::Error error) { | 175 void CommandBufferService::SetParseError(error::Error error) { |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 198 const GetBufferChangedCallback& callback) { | 198 const GetBufferChangedCallback& callback) { |
| 199 get_buffer_change_callback_ = callback; | 199 get_buffer_change_callback_ = callback; |
| 200 } | 200 } |
| 201 | 201 |
| 202 void CommandBufferService::SetParseErrorCallback( | 202 void CommandBufferService::SetParseErrorCallback( |
| 203 const base::Closure& callback) { | 203 const base::Closure& callback) { |
| 204 parse_error_callback_ = callback; | 204 parse_error_callback_ = callback; |
| 205 } | 205 } |
| 206 | 206 |
| 207 } // namespace gpu | 207 } // namespace gpu |
| OLD | NEW |