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" |
11 #include "base/thread_task_runner_handle.h" | 11 #include "base/thread_task_runner_handle.h" |
12 #include "components/mus/gles2/command_buffer_driver.h" | 12 #include "components/mus/gles2/command_buffer_driver.h" |
13 #include "components/mus/gles2/command_buffer_local_client.h" | 13 #include "components/mus/gles2/command_buffer_local_client.h" |
14 #include "components/mus/gles2/command_buffer_type_conversions.h" | 14 #include "components/mus/gles2/command_buffer_type_conversions.h" |
15 #include "components/mus/gles2/gpu_memory_tracker.h" | 15 #include "components/mus/gles2/gpu_memory_tracker.h" |
16 #include "components/mus/gles2/gpu_state.h" | 16 #include "components/mus/gles2/gpu_state.h" |
17 #include "components/mus/gles2/mojo_buffer_backing.h" | 17 #include "components/mus/gles2/mojo_buffer_backing.h" |
18 #include "components/mus/gles2/mojo_gpu_memory_buffer.h" | 18 #include "components/mus/gles2/mojo_gpu_memory_buffer.h" |
| 19 #include "gpu/command_buffer/client/gpu_control_client.h" |
19 #include "gpu/command_buffer/common/gpu_memory_buffer_support.h" | 20 #include "gpu/command_buffer/common/gpu_memory_buffer_support.h" |
20 #include "gpu/command_buffer/common/sync_token.h" | 21 #include "gpu/command_buffer/common/sync_token.h" |
21 #include "gpu/command_buffer/service/command_buffer_service.h" | 22 #include "gpu/command_buffer/service/command_buffer_service.h" |
22 #include "gpu/command_buffer/service/context_group.h" | 23 #include "gpu/command_buffer/service/context_group.h" |
23 #include "gpu/command_buffer/service/image_manager.h" | 24 #include "gpu/command_buffer/service/image_manager.h" |
24 #include "gpu/command_buffer/service/memory_tracking.h" | 25 #include "gpu/command_buffer/service/memory_tracking.h" |
25 #include "gpu/command_buffer/service/shader_translator_cache.h" | 26 #include "gpu/command_buffer/service/shader_translator_cache.h" |
26 #include "gpu/command_buffer/service/transfer_buffer_manager.h" | 27 #include "gpu/command_buffer/service/transfer_buffer_manager.h" |
27 #include "gpu/command_buffer/service/valuebuffer_manager.h" | 28 #include "gpu/command_buffer/service/valuebuffer_manager.h" |
28 #include "mojo/platform_handle/platform_handle_functions.h" | 29 #include "mojo/platform_handle/platform_handle_functions.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 70 |
70 const unsigned int GL_READ_WRITE_CHROMIUM = 0x78F2; | 71 const unsigned int GL_READ_WRITE_CHROMIUM = 0x78F2; |
71 | 72 |
72 CommandBufferLocal::CommandBufferLocal(CommandBufferLocalClient* client, | 73 CommandBufferLocal::CommandBufferLocal(CommandBufferLocalClient* client, |
73 gfx::AcceleratedWidget widget, | 74 gfx::AcceleratedWidget widget, |
74 const scoped_refptr<GpuState>& gpu_state) | 75 const scoped_refptr<GpuState>& gpu_state) |
75 : widget_(widget), | 76 : widget_(widget), |
76 gpu_state_(gpu_state), | 77 gpu_state_(gpu_state), |
77 client_(client), | 78 client_(client), |
78 client_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 79 client_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 80 gpu_control_client_(nullptr), |
79 next_transfer_buffer_id_(0), | 81 next_transfer_buffer_id_(0), |
80 next_image_id_(0), | 82 next_image_id_(0), |
81 next_fence_sync_release_(1), | 83 next_fence_sync_release_(1), |
82 flushed_fence_sync_release_(0), | 84 flushed_fence_sync_release_(0), |
| 85 lost_context_(false), |
83 sync_point_client_waiter_( | 86 sync_point_client_waiter_( |
84 gpu_state->sync_point_manager()->CreateSyncPointClientWaiter()), | 87 gpu_state->sync_point_manager()->CreateSyncPointClientWaiter()), |
85 weak_factory_(this) { | 88 weak_factory_(this) { |
86 weak_ptr_ = weak_factory_.GetWeakPtr(); | 89 weak_ptr_ = weak_factory_.GetWeakPtr(); |
87 } | 90 } |
88 | 91 |
89 void CommandBufferLocal::Destroy() { | 92 void CommandBufferLocal::Destroy() { |
90 DCHECK(CalledOnValidThread()); | 93 DCHECK(CalledOnValidThread()); |
91 // After this |Destroy()| call, this object will not be used by client anymore | 94 // After this |Destroy()| call, this object will not be used by client anymore |
92 // and it will be deleted on the GPU thread. So we have to detach it from the | 95 // and it will be deleted on the GPU thread. So we have to detach it from the |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 } | 212 } |
210 | 213 |
211 void CommandBufferLocal::DestroyTransferBuffer(int32_t id) { | 214 void CommandBufferLocal::DestroyTransferBuffer(int32_t id) { |
212 DCHECK(CalledOnValidThread()); | 215 DCHECK(CalledOnValidThread()); |
213 gpu_state_->command_buffer_task_runner()->PostTask( | 216 gpu_state_->command_buffer_task_runner()->PostTask( |
214 driver_.get(), | 217 driver_.get(), |
215 base::Bind(&CommandBufferLocal::DestroyTransferBufferOnGpuThread, | 218 base::Bind(&CommandBufferLocal::DestroyTransferBufferOnGpuThread, |
216 base::Unretained(this), id)); | 219 base::Unretained(this), id)); |
217 } | 220 } |
218 | 221 |
| 222 void CommandBufferLocal::SetGpuControlClient(gpu::GpuControlClient* client) { |
| 223 gpu_control_client_ = client; |
| 224 } |
| 225 |
219 gpu::Capabilities CommandBufferLocal::GetCapabilities() { | 226 gpu::Capabilities CommandBufferLocal::GetCapabilities() { |
220 DCHECK(CalledOnValidThread()); | 227 DCHECK(CalledOnValidThread()); |
221 return capabilities_; | 228 return capabilities_; |
222 } | 229 } |
223 | 230 |
224 int32_t CommandBufferLocal::CreateImage(ClientBuffer buffer, | 231 int32_t CommandBufferLocal::CreateImage(ClientBuffer buffer, |
225 size_t width, | 232 size_t width, |
226 size_t height, | 233 size_t height, |
227 unsigned internal_format) { | 234 unsigned internal_format) { |
228 DCHECK(CalledOnValidThread()); | 235 DCHECK(CalledOnValidThread()); |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 | 541 |
535 bool CommandBufferLocal::SignalQueryOnGpuThread(uint32_t query_id, | 542 bool CommandBufferLocal::SignalQueryOnGpuThread(uint32_t query_id, |
536 const base::Closure& callback) { | 543 const base::Closure& callback) { |
537 // |callback| should run on the client thread. | 544 // |callback| should run on the client thread. |
538 driver_->SignalQuery( | 545 driver_->SignalQuery( |
539 query_id, base::Bind(&PostTask, client_thread_task_runner_, callback)); | 546 query_id, base::Bind(&PostTask, client_thread_task_runner_, callback)); |
540 return true; | 547 return true; |
541 } | 548 } |
542 | 549 |
543 void CommandBufferLocal::DidLoseContextOnClientThread(uint32_t reason) { | 550 void CommandBufferLocal::DidLoseContextOnClientThread(uint32_t reason) { |
544 if (client_) | 551 DCHECK(gpu_control_client_); |
545 client_->DidLoseContext(); | 552 if (!lost_context_) |
| 553 gpu_control_client_->OnGpuControlLostContext(); |
| 554 lost_context_ = true; |
546 } | 555 } |
547 | 556 |
548 void CommandBufferLocal::UpdateVSyncParametersOnClientThread(int64_t timebase, | 557 void CommandBufferLocal::UpdateVSyncParametersOnClientThread(int64_t timebase, |
549 int64_t interval) { | 558 int64_t interval) { |
550 if (client_) | 559 if (client_) |
551 client_->UpdateVSyncParameters(timebase, interval); | 560 client_->UpdateVSyncParameters(timebase, interval); |
552 } | 561 } |
553 | 562 |
554 void CommandBufferLocal::OnGpuCompletedSwapBuffersOnClientThread( | 563 void CommandBufferLocal::OnGpuCompletedSwapBuffersOnClientThread( |
555 gfx::SwapResult result) { | 564 gfx::SwapResult result) { |
556 if (client_) | 565 if (client_) |
557 client_->GpuCompletedSwapBuffers(result); | 566 client_->GpuCompletedSwapBuffers(result); |
558 } | 567 } |
559 | 568 |
560 } // namespace mus | 569 } // namespace mus |
OLD | NEW |