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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 executor_.reset(new gpu::CommandExecutor(command_buffer_.get(), | 146 executor_.reset(new gpu::CommandExecutor(command_buffer_.get(), |
147 decoder_.get(), decoder_.get())); | 147 decoder_.get(), decoder_.get())); |
148 sync_point_order_data_ = gpu::SyncPointOrderData::Create(); | 148 sync_point_order_data_ = gpu::SyncPointOrderData::Create(); |
149 sync_point_client_ = gpu_state_->sync_point_manager()->CreateSyncPointClient( | 149 sync_point_client_ = gpu_state_->sync_point_manager()->CreateSyncPointClient( |
150 sync_point_order_data_, GetNamespaceID(), command_buffer_id_); | 150 sync_point_order_data_, GetNamespaceID(), command_buffer_id_); |
151 decoder_->set_engine(executor_.get()); | 151 decoder_->set_engine(executor_.get()); |
152 decoder_->SetFenceSyncReleaseCallback(base::Bind( | 152 decoder_->SetFenceSyncReleaseCallback(base::Bind( |
153 &CommandBufferDriver::OnFenceSyncRelease, base::Unretained(this))); | 153 &CommandBufferDriver::OnFenceSyncRelease, base::Unretained(this))); |
154 decoder_->SetWaitFenceSyncCallback(base::Bind( | 154 decoder_->SetWaitFenceSyncCallback(base::Bind( |
155 &CommandBufferDriver::OnWaitFenceSync, base::Unretained(this))); | 155 &CommandBufferDriver::OnWaitFenceSync, base::Unretained(this))); |
| 156 decoder_->SetDescheduleUntilFinishedCallback(base::Bind( |
| 157 &CommandBufferDriver::OnDescheduleUntilFinished, base::Unretained(this))); |
| 158 decoder_->SetRescheduleAfterFinishedCallback(base::Bind( |
| 159 &CommandBufferDriver::OnRescheduleAfterFinished, base::Unretained(this))); |
156 | 160 |
157 gpu::gles2::DisallowedFeatures disallowed_features; | 161 gpu::gles2::DisallowedFeatures disallowed_features; |
158 | 162 |
159 if (!decoder_->Initialize(surface_, context_, offscreen, gfx::Size(1, 1), | 163 if (!decoder_->Initialize(surface_, context_, offscreen, gfx::Size(1, 1), |
160 disallowed_features, attrib_helper)) | 164 disallowed_features, attrib_helper)) |
161 return false; | 165 return false; |
162 | 166 |
163 command_buffer_->SetPutOffsetChangeCallback(base::Bind( | 167 command_buffer_->SetPutOffsetChangeCallback(base::Bind( |
164 &gpu::CommandExecutor::PutChanged, base::Unretained(executor_.get()))); | 168 &gpu::CommandExecutor::PutChanged, base::Unretained(executor_.get()))); |
165 command_buffer_->SetGetBufferChangeCallback(base::Bind( | 169 command_buffer_->SetGetBufferChangeCallback(base::Bind( |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 if (!release_state) | 513 if (!release_state) |
510 return true; | 514 return true; |
511 | 515 |
512 executor_->SetScheduled(false); | 516 executor_->SetScheduled(false); |
513 sync_point_client_->Wait(release_state.get(), release, | 517 sync_point_client_->Wait(release_state.get(), release, |
514 base::Bind(&gpu::CommandExecutor::SetScheduled, | 518 base::Bind(&gpu::CommandExecutor::SetScheduled, |
515 executor_->AsWeakPtr(), true)); | 519 executor_->AsWeakPtr(), true)); |
516 return executor_->scheduled(); | 520 return executor_->scheduled(); |
517 } | 521 } |
518 | 522 |
| 523 void CommandBufferDriver::OnDescheduleUntilFinished() { |
| 524 DCHECK(CalledOnValidThread()); |
| 525 DCHECK(IsScheduled()); |
| 526 DCHECK(executor_->HasMoreIdleWork()); |
| 527 |
| 528 executor_->SetScheduled(false); |
| 529 } |
| 530 |
| 531 void CommandBufferDriver::OnRescheduleAfterFinished() { |
| 532 DCHECK(CalledOnValidThread()); |
| 533 DCHECK(!executor_->scheduled()); |
| 534 |
| 535 executor_->SetScheduled(true); |
| 536 } |
| 537 |
519 void CommandBufferDriver::OnParseError() { | 538 void CommandBufferDriver::OnParseError() { |
520 DCHECK(CalledOnValidThread()); | 539 DCHECK(CalledOnValidThread()); |
521 gpu::CommandBuffer::State state = GetLastState(); | 540 gpu::CommandBuffer::State state = GetLastState(); |
522 OnContextLost(state.context_lost_reason); | 541 OnContextLost(state.context_lost_reason); |
523 } | 542 } |
524 | 543 |
525 void CommandBufferDriver::OnContextLost(uint32_t reason) { | 544 void CommandBufferDriver::OnContextLost(uint32_t reason) { |
526 DCHECK(CalledOnValidThread()); | 545 DCHECK(CalledOnValidThread()); |
527 if (client_) | 546 if (client_) |
528 client_->DidLoseContext(reason); | 547 client_->DidLoseContext(reason); |
(...skipping 12 matching lines...) Expand all Loading... |
541 } | 560 } |
542 | 561 |
543 void CommandBufferDriver::OnGpuCompletedSwapBuffers(gfx::SwapResult result) { | 562 void CommandBufferDriver::OnGpuCompletedSwapBuffers(gfx::SwapResult result) { |
544 DCHECK(CalledOnValidThread()); | 563 DCHECK(CalledOnValidThread()); |
545 if (client_) { | 564 if (client_) { |
546 client_->OnGpuCompletedSwapBuffers(result); | 565 client_->OnGpuCompletedSwapBuffers(result); |
547 } | 566 } |
548 } | 567 } |
549 | 568 |
550 } // namespace mus | 569 } // namespace mus |
OLD | NEW |