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 "gpu/ipc/in_process_command_buffer.h" | 5 #include "gpu/ipc/in_process_command_buffer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <queue> | 10 #include <queue> |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 completion.Wait(); | 277 completion.Wait(); |
278 | 278 |
279 gpu_memory_buffer_manager_ = gpu_memory_buffer_manager; | 279 gpu_memory_buffer_manager_ = gpu_memory_buffer_manager; |
280 | 280 |
281 if (result) | 281 if (result) |
282 capabilities_ = capabilities; | 282 capabilities_ = capabilities; |
283 | 283 |
284 return result; | 284 return result; |
285 } | 285 } |
286 | 286 |
| 287 void InProcessCommandBuffer::SetLatencyInfo(const std::vector<ui::LatencyInfo>&
latency_info) { |
| 288 latency_info_.insert(latency_info_.end(), latency_info.begin(), latency_info.e
nd()); |
| 289 } |
| 290 |
287 bool InProcessCommandBuffer::InitializeOnGpuThread( | 291 bool InProcessCommandBuffer::InitializeOnGpuThread( |
288 const InitializeOnGpuThreadParams& params) { | 292 const InitializeOnGpuThreadParams& params) { |
289 CheckSequencedThread(); | 293 CheckSequencedThread(); |
290 gpu_thread_weak_ptr_ = gpu_thread_weak_ptr_factory_.GetWeakPtr(); | 294 gpu_thread_weak_ptr_ = gpu_thread_weak_ptr_factory_.GetWeakPtr(); |
291 | 295 |
292 TransferBufferManager* manager = new TransferBufferManager(nullptr); | 296 TransferBufferManager* manager = new TransferBufferManager(nullptr); |
293 transfer_buffer_manager_ = manager; | 297 transfer_buffer_manager_ = manager; |
294 manager->Initialize(); | 298 manager->Initialize(); |
295 | 299 |
296 std::unique_ptr<CommandBufferService> command_buffer( | 300 std::unique_ptr<CommandBufferService> command_buffer( |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 State state = command_buffer_->GetLastState(); | 552 State state = command_buffer_->GetLastState(); |
549 if (state.generation - last_state_.generation < 0x80000000U) | 553 if (state.generation - last_state_.generation < 0x80000000U) |
550 last_state_ = state; | 554 last_state_ = state; |
551 } | 555 } |
552 | 556 |
553 void InProcessCommandBuffer::FlushOnGpuThread(int32_t put_offset) { | 557 void InProcessCommandBuffer::FlushOnGpuThread(int32_t put_offset) { |
554 CheckSequencedThread(); | 558 CheckSequencedThread(); |
555 ScopedEvent handle_flush(&flush_event_); | 559 ScopedEvent handle_flush(&flush_event_); |
556 base::AutoLock lock(command_buffer_lock_); | 560 base::AutoLock lock(command_buffer_lock_); |
557 | 561 |
| 562 if (ui::LatencyInfo::Verify(latency_info_, |
| 563 "InProcessCommandBuffer::FlushOnGpuThread") && |
| 564 !latency_info_callback_.is_null()) { |
| 565 latency_info_callback_.Run(latency_info_); |
| 566 } |
| 567 latency_info_.clear(); |
| 568 |
558 command_buffer_->Flush(put_offset); | 569 command_buffer_->Flush(put_offset); |
559 // Update state before signaling the flush event. | 570 // Update state before signaling the flush event. |
560 UpdateLastStateOnGpuThread(); | 571 UpdateLastStateOnGpuThread(); |
561 | 572 |
562 // If we've processed all pending commands but still have pending queries, | 573 // If we've processed all pending commands but still have pending queries, |
563 // pump idle work until the query is passed. | 574 // pump idle work until the query is passed. |
564 if (put_offset == command_buffer_->GetLastState().get_offset && | 575 if (put_offset == command_buffer_->GetLastState().get_offset && |
565 (executor_->HasMoreIdleWork() || executor_->HasPendingQueries())) { | 576 (executor_->HasMoreIdleWork() || executor_->HasPendingQueries())) { |
566 ScheduleDelayedWorkOnGpuThread(); | 577 ScheduleDelayedWorkOnGpuThread(); |
567 } | 578 } |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 base::Bind(&InProcessCommandBuffer::DidSwapBuffersCompleteOnOriginThread, | 1018 base::Bind(&InProcessCommandBuffer::DidSwapBuffersCompleteOnOriginThread, |
1008 client_thread_weak_ptr_, base::Passed(¶ms))); | 1019 client_thread_weak_ptr_, base::Passed(¶ms))); |
1009 } | 1020 } |
1010 | 1021 |
1011 const gles2::FeatureInfo* InProcessCommandBuffer::GetFeatureInfo() const { | 1022 const gles2::FeatureInfo* InProcessCommandBuffer::GetFeatureInfo() const { |
1012 return context_group_->feature_info(); | 1023 return context_group_->feature_info(); |
1013 } | 1024 } |
1014 | 1025 |
1015 void InProcessCommandBuffer::SetLatencyInfoCallback( | 1026 void InProcessCommandBuffer::SetLatencyInfoCallback( |
1016 const LatencyInfoCallback& callback) { | 1027 const LatencyInfoCallback& callback) { |
1017 // TODO(fsamuel): Implement this. | 1028 latency_info_callback_ = callback; |
1018 } | 1029 } |
1019 | 1030 |
1020 void InProcessCommandBuffer::UpdateVSyncParameters(base::TimeTicks timebase, | 1031 void InProcessCommandBuffer::UpdateVSyncParameters(base::TimeTicks timebase, |
1021 base::TimeDelta interval) { | 1032 base::TimeDelta interval) { |
1022 if (!origin_task_runner_) { | 1033 if (!origin_task_runner_) { |
1023 UpdateVSyncParametersOnOriginThread(timebase, interval); | 1034 UpdateVSyncParametersOnOriginThread(timebase, interval); |
1024 return; | 1035 return; |
1025 } | 1036 } |
1026 origin_task_runner_->PostTask( | 1037 origin_task_runner_->PostTask( |
1027 FROM_HERE, | 1038 FROM_HERE, |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1121 return wrapped_callback; | 1132 return wrapped_callback; |
1122 } | 1133 } |
1123 | 1134 |
1124 InProcessCommandBuffer::GpuTask::GpuTask(const base::Closure& callback, | 1135 InProcessCommandBuffer::GpuTask::GpuTask(const base::Closure& callback, |
1125 uint32_t order_number) | 1136 uint32_t order_number) |
1126 : callback(callback), order_number(order_number) {} | 1137 : callback(callback), order_number(order_number) {} |
1127 | 1138 |
1128 InProcessCommandBuffer::GpuTask::~GpuTask() {} | 1139 InProcessCommandBuffer::GpuTask::~GpuTask() {} |
1129 | 1140 |
1130 } // namespace gpu | 1141 } // namespace gpu |
OLD | NEW |