OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ui/gl/gpu_timing.h" | 5 #include "ui/gl/gpu_timing.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" |
8 #include "base/time/time.h" | 9 #include "base/time/time.h" |
9 #include "ui/gl/gl_bindings.h" | 10 #include "ui/gl/gl_bindings.h" |
10 #include "ui/gl/gl_context.h" | 11 #include "ui/gl/gl_context.h" |
11 #include "ui/gl/gl_version_info.h" | 12 #include "ui/gl/gl_version_info.h" |
12 | 13 |
13 namespace gfx { | 14 namespace gfx { |
14 | 15 |
15 class TimeElapsedTimerQuery; | 16 class TimeElapsedTimerQuery; |
16 class TimerQuery; | 17 class TimerQuery; |
17 | 18 |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 } | 598 } |
598 | 599 |
599 GPUTimingClient::GPUTimingClient(GPUTimingImpl* gpu_timing) | 600 GPUTimingClient::GPUTimingClient(GPUTimingImpl* gpu_timing) |
600 : gpu_timing_(gpu_timing) { | 601 : gpu_timing_(gpu_timing) { |
601 if (gpu_timing) { | 602 if (gpu_timing) { |
602 timer_type_ = gpu_timing->GetTimerType(); | 603 timer_type_ = gpu_timing->GetTimerType(); |
603 disjoint_counter_ = gpu_timing_->GetDisjointCount(); | 604 disjoint_counter_ = gpu_timing_->GetDisjointCount(); |
604 } | 605 } |
605 } | 606 } |
606 | 607 |
607 scoped_ptr<GPUTimer> GPUTimingClient::CreateGPUTimer(bool prefer_elapsed_time) { | 608 std::unique_ptr<GPUTimer> GPUTimingClient::CreateGPUTimer( |
| 609 bool prefer_elapsed_time) { |
608 prefer_elapsed_time |= (timer_type_ == GPUTiming::kTimerTypeEXT); | 610 prefer_elapsed_time |= (timer_type_ == GPUTiming::kTimerTypeEXT); |
609 if (gpu_timing_) | 611 if (gpu_timing_) |
610 prefer_elapsed_time |= gpu_timing_->IsForceTimeElapsedQuery(); | 612 prefer_elapsed_time |= gpu_timing_->IsForceTimeElapsedQuery(); |
611 | 613 |
612 return make_scoped_ptr(new GPUTimer(this, prefer_elapsed_time)); | 614 return base::WrapUnique(new GPUTimer(this, prefer_elapsed_time)); |
613 } | 615 } |
614 | 616 |
615 bool GPUTimingClient::IsAvailable() { | 617 bool GPUTimingClient::IsAvailable() { |
616 return timer_type_ != GPUTiming::kTimerTypeInvalid; | 618 return timer_type_ != GPUTiming::kTimerTypeInvalid; |
617 } | 619 } |
618 | 620 |
619 const char* GPUTimingClient::GetTimerTypeName() const { | 621 const char* GPUTimingClient::GetTimerTypeName() const { |
620 switch (timer_type_) { | 622 switch (timer_type_) { |
621 case GPUTiming::kTimerTypeDisjoint: | 623 case GPUTiming::kTimerTypeDisjoint: |
622 return "GL_EXT_disjoint_timer_query"; | 624 return "GL_EXT_disjoint_timer_query"; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 | 660 |
659 void GPUTimingClient::ForceTimeElapsedQuery() { | 661 void GPUTimingClient::ForceTimeElapsedQuery() { |
660 DCHECK(gpu_timing_); | 662 DCHECK(gpu_timing_); |
661 gpu_timing_->ForceTimeElapsedQuery(); | 663 gpu_timing_->ForceTimeElapsedQuery(); |
662 } | 664 } |
663 | 665 |
664 GPUTimingClient::~GPUTimingClient() { | 666 GPUTimingClient::~GPUTimingClient() { |
665 } | 667 } |
666 | 668 |
667 } // namespace gfx | 669 } // namespace gfx |
OLD | NEW |