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