| 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/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "ui/gl/gl_bindings.h" | 9 #include "ui/gl/gl_bindings.h" |
| 10 #include "ui/gl/gl_context.h" | 10 #include "ui/gl/gl_context.h" |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 private: | 310 private: |
| 311 ~TimeStampTimerQuery() override {} | 311 ~TimeStampTimerQuery() override {} |
| 312 uint32_t gl_query_id_ = 0; | 312 uint32_t gl_query_id_ = 0; |
| 313 scoped_refptr<QueryResult> query_result_; | 313 scoped_refptr<QueryResult> query_result_; |
| 314 }; | 314 }; |
| 315 | 315 |
| 316 GPUTimingImpl::GPUTimingImpl(GLContextReal* context) { | 316 GPUTimingImpl::GPUTimingImpl(GLContextReal* context) { |
| 317 DCHECK(context); | 317 DCHECK(context); |
| 318 const GLVersionInfo* version_info = context->GetVersionInfo(); | 318 const GLVersionInfo* version_info = context->GetVersionInfo(); |
| 319 DCHECK(version_info); | 319 DCHECK(version_info); |
| 320 if (version_info->is_es3 && // glGetInteger64v is supported under ES3. | 320 if (context->HasExtension("GL_EXT_disjoint_timer_query")) { |
| 321 context->HasExtension("GL_EXT_disjoint_timer_query")) { | |
| 322 timer_type_ = GPUTiming::kTimerTypeDisjoint; | 321 timer_type_ = GPUTiming::kTimerTypeDisjoint; |
| 322 if (!version_info->is_es3) { |
| 323 // Due to a bug in the specification, glGetInteger64v is only supported |
| 324 // under ES3. Since it is only used for timestamps, we workaround this by |
| 325 // emulating timestamps on ES2 so WebGL 1.0 will still have access to the |
| 326 // extension |
| 327 force_time_elapsed_query_ = true; |
| 328 timestamp_bit_count_gl_ = 0; |
| 329 } |
| 323 } else if (context->HasExtension("GL_ARB_timer_query")) { | 330 } else if (context->HasExtension("GL_ARB_timer_query")) { |
| 324 timer_type_ = GPUTiming::kTimerTypeARB; | 331 timer_type_ = GPUTiming::kTimerTypeARB; |
| 325 } else if (context->HasExtension("GL_EXT_timer_query")) { | 332 } else if (context->HasExtension("GL_EXT_timer_query")) { |
| 326 timer_type_ = GPUTiming::kTimerTypeEXT; | 333 timer_type_ = GPUTiming::kTimerTypeEXT; |
| 327 force_time_elapsed_query_ = true; | 334 force_time_elapsed_query_ = true; |
| 328 timestamp_bit_count_gl_ = 0; | 335 timestamp_bit_count_gl_ = 0; |
| 329 } | 336 } |
| 330 } | 337 } |
| 331 | 338 |
| 332 GPUTimingImpl::~GPUTimingImpl() { | 339 GPUTimingImpl::~GPUTimingImpl() { |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 | 659 |
| 653 void GPUTimingClient::ForceTimeElapsedQuery() { | 660 void GPUTimingClient::ForceTimeElapsedQuery() { |
| 654 DCHECK(gpu_timing_); | 661 DCHECK(gpu_timing_); |
| 655 gpu_timing_->ForceTimeElapsedQuery(); | 662 gpu_timing_->ForceTimeElapsedQuery(); |
| 656 } | 663 } |
| 657 | 664 |
| 658 GPUTimingClient::~GPUTimingClient() { | 665 GPUTimingClient::~GPUTimingClient() { |
| 659 } | 666 } |
| 660 | 667 |
| 661 } // namespace gfx | 668 } // namespace gfx |
| OLD | NEW |