OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_local.h" | 5 #include "components/mus/gles2/command_buffer_local.h" |
6 | 6 |
7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 int32_t* id) { | 184 int32_t* id) { |
185 DCHECK(CalledOnValidThread()); | 185 DCHECK(CalledOnValidThread()); |
186 if (size >= std::numeric_limits<uint32_t>::max()) | 186 if (size >= std::numeric_limits<uint32_t>::max()) |
187 return nullptr; | 187 return nullptr; |
188 | 188 |
189 void* memory = nullptr; | 189 void* memory = nullptr; |
190 mojo::ScopedSharedBufferHandle handle; | 190 mojo::ScopedSharedBufferHandle handle; |
191 mojo::ScopedSharedBufferHandle duped; | 191 mojo::ScopedSharedBufferHandle duped; |
192 if (!CreateMapAndDupSharedBuffer(size, &memory, &handle, &duped)) { | 192 if (!CreateMapAndDupSharedBuffer(size, &memory, &handle, &duped)) { |
193 if (last_state_.error == gpu::error::kNoError) | 193 if (last_state_.error == gpu::error::kNoError) |
194 last_state_.error = gpu::error::kLostContext; | 194 last_state_.error = gpu::error::kLostContext; |
danakj
2016/04/07 20:26:38
I mean, this never had callbacks before, but maybe
| |
195 return nullptr; | 195 return nullptr; |
196 } | 196 } |
197 | 197 |
198 *id = ++next_transfer_buffer_id_; | 198 *id = ++next_transfer_buffer_id_; |
199 | 199 |
200 gpu_state_->command_buffer_task_runner()->PostTask( | 200 gpu_state_->command_buffer_task_runner()->PostTask( |
201 driver_.get(), | 201 driver_.get(), |
202 base::Bind(&CommandBufferLocal::RegisterTransferBufferOnGpuThread, | 202 base::Bind(&CommandBufferLocal::RegisterTransferBufferOnGpuThread, |
203 base::Unretained(this), *id, base::Passed(&duped), | 203 base::Unretained(this), *id, base::Passed(&duped), |
204 static_cast<uint32_t>(size))); | 204 static_cast<uint32_t>(size))); |
205 scoped_ptr<gpu::BufferBacking> backing( | 205 scoped_ptr<gpu::BufferBacking> backing( |
206 new mus::MojoBufferBacking(std::move(handle), memory, size)); | 206 new mus::MojoBufferBacking(std::move(handle), memory, size)); |
207 scoped_refptr<gpu::Buffer> buffer(new gpu::Buffer(std::move(backing))); | 207 scoped_refptr<gpu::Buffer> buffer(new gpu::Buffer(std::move(backing))); |
208 return buffer; | 208 return buffer; |
209 } | 209 } |
210 | 210 |
211 void CommandBufferLocal::DestroyTransferBuffer(int32_t id) { | 211 void CommandBufferLocal::DestroyTransferBuffer(int32_t id) { |
212 DCHECK(CalledOnValidThread()); | 212 DCHECK(CalledOnValidThread()); |
213 gpu_state_->command_buffer_task_runner()->PostTask( | 213 gpu_state_->command_buffer_task_runner()->PostTask( |
214 driver_.get(), | 214 driver_.get(), |
215 base::Bind(&CommandBufferLocal::DestroyTransferBufferOnGpuThread, | 215 base::Bind(&CommandBufferLocal::DestroyTransferBufferOnGpuThread, |
216 base::Unretained(this), id)); | 216 base::Unretained(this), id)); |
217 } | 217 } |
218 | 218 |
219 void CommandBufferLocal::SetGpuControlClient(gpu::GpuControlClient*) { | |
220 // This implementation of GpuControl has no concept of losing the context | |
221 // (see IsGpuChannelLost), and no error messages, so we don't bother storing | |
222 // the client. | |
no sievers
2016/04/07 21:07:58
It does handle lost contexts and trigger the callb
danakj
2016/04/07 21:45:18
Ooops thanks, I was looking for "Lost" not "Lose".
| |
223 } | |
224 | |
219 gpu::Capabilities CommandBufferLocal::GetCapabilities() { | 225 gpu::Capabilities CommandBufferLocal::GetCapabilities() { |
220 DCHECK(CalledOnValidThread()); | 226 DCHECK(CalledOnValidThread()); |
221 return capabilities_; | 227 return capabilities_; |
222 } | 228 } |
223 | 229 |
224 int32_t CommandBufferLocal::CreateImage(ClientBuffer buffer, | 230 int32_t CommandBufferLocal::CreateImage(ClientBuffer buffer, |
225 size_t width, | 231 size_t width, |
226 size_t height, | 232 size_t height, |
227 unsigned internal_format) { | 233 unsigned internal_format) { |
228 DCHECK(CalledOnValidThread()); | 234 DCHECK(CalledOnValidThread()); |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
551 client_->UpdateVSyncParameters(timebase, interval); | 557 client_->UpdateVSyncParameters(timebase, interval); |
552 } | 558 } |
553 | 559 |
554 void CommandBufferLocal::OnGpuCompletedSwapBuffersOnClientThread( | 560 void CommandBufferLocal::OnGpuCompletedSwapBuffersOnClientThread( |
555 gfx::SwapResult result) { | 561 gfx::SwapResult result) { |
556 if (client_) | 562 if (client_) |
557 client_->GpuCompletedSwapBuffers(result); | 563 client_->GpuCompletedSwapBuffers(result); |
558 } | 564 } |
559 | 565 |
560 } // namespace mus | 566 } // namespace mus |
OLD | NEW |