| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/gl/gl_context_stub_with_extensions.h" | 10 #include "ui/gl/gl_context_stub_with_extensions.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 scoped_refptr<GPUTimingClient> client2 = CreateGPUTimingClient(); | 100 scoped_refptr<GPUTimingClient> client2 = CreateGPUTimingClient(); |
| 101 EXPECT_TRUE(client2->IsForceTimeElapsedQuery()); | 101 EXPECT_TRUE(client2->IsForceTimeElapsedQuery()); |
| 102 } | 102 } |
| 103 | 103 |
| 104 TEST_F(GPUTimingTest, QueryTimeStampTest) { | 104 TEST_F(GPUTimingTest, QueryTimeStampTest) { |
| 105 SetupGLContext("3.2", "GL_ARB_timer_query"); | 105 SetupGLContext("3.2", "GL_ARB_timer_query"); |
| 106 scoped_refptr<GPUTimingClient> client = CreateGPUTimingClient(); | 106 scoped_refptr<GPUTimingClient> client = CreateGPUTimingClient(); |
| 107 scoped_ptr<GPUTimer> gpu_timer = client->CreateGPUTimer(false); | 107 scoped_ptr<GPUTimer> gpu_timer = client->CreateGPUTimer(false); |
| 108 | 108 |
| 109 const int64_t begin_cpu_time = 123; | 109 const int64_t begin_cpu_time = 1230; |
| 110 const int64_t begin_gl_time = 10 * base::Time::kNanosecondsPerMicrosecond; | 110 const int64_t begin_gl_time = 10 * base::Time::kNanosecondsPerMicrosecond; |
| 111 const int64_t cpu_gl_offset = | 111 const int64_t cpu_gl_offset = |
| 112 begin_gl_time / base::Time::kNanosecondsPerMicrosecond - begin_cpu_time; | 112 begin_gl_time / base::Time::kNanosecondsPerMicrosecond - begin_cpu_time; |
| 113 gpu_timing_fake_queries_.SetCPUGLOffset(cpu_gl_offset); | 113 gpu_timing_fake_queries_.SetCPUGLOffset(cpu_gl_offset); |
| 114 gpu_timing_fake_queries_.SetCurrentCPUTime(begin_cpu_time); | 114 gpu_timing_fake_queries_.SetCurrentCPUTime(begin_cpu_time); |
| 115 gpu_timing_fake_queries_.ExpectGPUTimeStampQuery(*gl_, false); | 115 gpu_timing_fake_queries_.ExpectGPUTimeStampQuery(*gl_, false); |
| 116 | 116 |
| 117 gpu_timer->QueryTimeStamp(); | 117 gpu_timer->QueryTimeStamp(); |
| 118 | 118 |
| 119 gpu_timing_fake_queries_.SetCurrentCPUTime(begin_cpu_time - 1); | 119 gpu_timing_fake_queries_.SetCurrentCPUTime(begin_cpu_time - 1); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 EXPECT_TRUE(gpu_timer->IsAvailable()); | 157 EXPECT_TRUE(gpu_timer->IsAvailable()); |
| 158 EXPECT_EQ(0, gpu_timer->GetDeltaElapsed()); | 158 EXPECT_EQ(0, gpu_timer->GetDeltaElapsed()); |
| 159 | 159 |
| 160 int64_t start, end; | 160 int64_t start, end; |
| 161 gpu_timer->GetStartEndTimestamps(&start, &end); | 161 gpu_timer->GetStartEndTimestamps(&start, &end); |
| 162 EXPECT_EQ(begin_cpu_time, start); | 162 EXPECT_EQ(begin_cpu_time, start); |
| 163 EXPECT_EQ(begin_cpu_time, end); | 163 EXPECT_EQ(begin_cpu_time, end); |
| 164 } | 164 } |
| 165 | 165 |
| 166 } // namespace gpu | 166 } // namespace gpu |
| OLD | NEW |