| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 bool result = command_buffer_->Initialize(); | 121 bool result = command_buffer_->Initialize(); |
| 122 DCHECK(result); | 122 DCHECK(result); |
| 123 | 123 |
| 124 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group.get())); | 124 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group.get())); |
| 125 scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(), decoder_.get(), | 125 scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(), decoder_.get(), |
| 126 decoder_.get())); | 126 decoder_.get())); |
| 127 sync_point_order_data_ = gpu::SyncPointOrderData::Create(); | 127 sync_point_order_data_ = gpu::SyncPointOrderData::Create(); |
| 128 sync_point_client_ = gpu_state_->sync_point_manager()->CreateSyncPointClient( | 128 sync_point_client_ = gpu_state_->sync_point_manager()->CreateSyncPointClient( |
| 129 sync_point_order_data_, GetNamespaceID(), command_buffer_id_); | 129 sync_point_order_data_, GetNamespaceID(), command_buffer_id_); |
| 130 decoder_->set_engine(scheduler_.get()); | 130 decoder_->set_engine(scheduler_.get()); |
| 131 decoder_->SetWaitSyncPointCallback(base::Bind( | |
| 132 &CommandBufferDriver::OnWaitSyncPoint, base::Unretained(this))); | |
| 133 decoder_->SetFenceSyncReleaseCallback(base::Bind( | 131 decoder_->SetFenceSyncReleaseCallback(base::Bind( |
| 134 &CommandBufferDriver::OnFenceSyncRelease, base::Unretained(this))); | 132 &CommandBufferDriver::OnFenceSyncRelease, base::Unretained(this))); |
| 135 decoder_->SetWaitFenceSyncCallback(base::Bind( | 133 decoder_->SetWaitFenceSyncCallback(base::Bind( |
| 136 &CommandBufferDriver::OnWaitFenceSync, base::Unretained(this))); | 134 &CommandBufferDriver::OnWaitFenceSync, base::Unretained(this))); |
| 137 | 135 |
| 138 gpu::gles2::DisallowedFeatures disallowed_features; | 136 gpu::gles2::DisallowedFeatures disallowed_features; |
| 139 | 137 |
| 140 std::vector<int32_t> attrib_vector; | 138 std::vector<int32_t> attrib_vector; |
| 141 attrib_helper.Serialize(&attrib_vector); | 139 attrib_helper.Serialize(&attrib_vector); |
| 142 if (!decoder_->Initialize(surface_, context_, offscreen, gfx::Size(1, 1), | 140 if (!decoder_->Initialize(surface_, context_, offscreen, gfx::Size(1, 1), |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 void CommandBufferDriver::OnUpdateVSyncParameters( | 435 void CommandBufferDriver::OnUpdateVSyncParameters( |
| 438 const base::TimeTicks timebase, | 436 const base::TimeTicks timebase, |
| 439 const base::TimeDelta interval) { | 437 const base::TimeDelta interval) { |
| 440 DCHECK(CalledOnValidThread()); | 438 DCHECK(CalledOnValidThread()); |
| 441 if (client_) { | 439 if (client_) { |
| 442 client_->UpdateVSyncParameters(timebase.ToInternalValue(), | 440 client_->UpdateVSyncParameters(timebase.ToInternalValue(), |
| 443 interval.ToInternalValue()); | 441 interval.ToInternalValue()); |
| 444 } | 442 } |
| 445 } | 443 } |
| 446 | 444 |
| 447 bool CommandBufferDriver::OnWaitSyncPoint(uint32_t sync_point) { | |
| 448 DCHECK(CalledOnValidThread()); | |
| 449 DCHECK(scheduler_->scheduled()); | |
| 450 if (!sync_point) | |
| 451 return true; | |
| 452 | |
| 453 scheduler_->SetScheduled(false); | |
| 454 gpu_state_->sync_point_manager()->AddSyncPointCallback( | |
| 455 sync_point, base::Bind(&gpu::GpuScheduler::SetScheduled, | |
| 456 scheduler_->AsWeakPtr(), true)); | |
| 457 return scheduler_->scheduled(); | |
| 458 } | |
| 459 | |
| 460 void CommandBufferDriver::OnFenceSyncRelease(uint64_t release) { | 445 void CommandBufferDriver::OnFenceSyncRelease(uint64_t release) { |
| 461 DCHECK(CalledOnValidThread()); | 446 DCHECK(CalledOnValidThread()); |
| 462 if (!sync_point_client_->client_state()->IsFenceSyncReleased(release)) | 447 if (!sync_point_client_->client_state()->IsFenceSyncReleased(release)) |
| 463 sync_point_client_->ReleaseFenceSync(release); | 448 sync_point_client_->ReleaseFenceSync(release); |
| 464 } | 449 } |
| 465 | 450 |
| 466 bool CommandBufferDriver::OnWaitFenceSync( | 451 bool CommandBufferDriver::OnWaitFenceSync( |
| 467 gpu::CommandBufferNamespace namespace_id, | 452 gpu::CommandBufferNamespace namespace_id, |
| 468 uint64_t command_buffer_id, | 453 uint64_t command_buffer_id, |
| 469 uint64_t release) { | 454 uint64_t release) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 | 491 |
| 507 gpu::gles2::QueryManager* query_manager = decoder_->GetQueryManager(); | 492 gpu::gles2::QueryManager* query_manager = decoder_->GetQueryManager(); |
| 508 gpu::gles2::QueryManager::Query* query = query_manager->GetQuery(query_id); | 493 gpu::gles2::QueryManager::Query* query = query_manager->GetQuery(query_id); |
| 509 if (query) | 494 if (query) |
| 510 query->AddCallback(callback); | 495 query->AddCallback(callback); |
| 511 else | 496 else |
| 512 callback.Run(); | 497 callback.Run(); |
| 513 } | 498 } |
| 514 | 499 |
| 515 } // namespace mus | 500 } // namespace mus |
| OLD | NEW |