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 "ui/gl/gpu_timing_fake.h" | 5 #include "ui/gl/gpu_timing_fake.h" |
6 | 6 |
7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/gl/gl_mock.h" | 9 #include "ui/gl/gl_mock.h" |
10 | 10 |
11 namespace gfx { | 11 namespace gfx { |
12 | 12 |
13 using ::testing::_; | 13 using ::testing::_; |
14 using ::testing::AtLeast; | 14 using ::testing::AtLeast; |
15 using ::testing::AtMost; | 15 using ::testing::AtMost; |
16 using ::testing::Exactly; | 16 using ::testing::Exactly; |
17 using ::testing::Invoke; | 17 using ::testing::Invoke; |
18 using ::testing::NotNull; | 18 using ::testing::NotNull; |
19 using ::testing::DoAll; | |
20 using ::testing::Return; | |
21 using ::testing::SetArgPointee; | |
19 | 22 |
20 int64_t GPUTimingFake::fake_cpu_time_ = 0; | 23 int64_t GPUTimingFake::fake_cpu_time_ = 0; |
21 | 24 |
22 GPUTimingFake::GPUTimingFake() { | 25 GPUTimingFake::GPUTimingFake() { |
23 Reset(); | 26 Reset(); |
24 } | 27 } |
25 | 28 |
26 GPUTimingFake::~GPUTimingFake() { | 29 GPUTimingFake::~GPUTimingFake() { |
27 } | 30 } |
28 | 31 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 | 71 |
69 void GPUTimingFake::ExpectDisjointCalls(MockGLInterface& gl) { | 72 void GPUTimingFake::ExpectDisjointCalls(MockGLInterface& gl) { |
70 EXPECT_CALL(gl, GetIntegerv(GL_GPU_DISJOINT_EXT, _)).Times(AtLeast(1)) | 73 EXPECT_CALL(gl, GetIntegerv(GL_GPU_DISJOINT_EXT, _)).Times(AtLeast(1)) |
71 .WillRepeatedly(Invoke(this, &GPUTimingFake::FakeGLGetIntegerv)); | 74 .WillRepeatedly(Invoke(this, &GPUTimingFake::FakeGLGetIntegerv)); |
72 } | 75 } |
73 | 76 |
74 void GPUTimingFake::ExpectNoDisjointCalls(MockGLInterface& gl) { | 77 void GPUTimingFake::ExpectNoDisjointCalls(MockGLInterface& gl) { |
75 EXPECT_CALL(gl, GetIntegerv(GL_GPU_DISJOINT_EXT, _)).Times(Exactly(0)); | 78 EXPECT_CALL(gl, GetIntegerv(GL_GPU_DISJOINT_EXT, _)).Times(Exactly(0)); |
76 } | 79 } |
77 | 80 |
78 void GPUTimingFake::ExpectGPUTimeStampQuery( | 81 void GPUTimingFake::ExpectGPUTimeStampQuery(MockGLInterface& gl, |
79 MockGLInterface& gl, bool elapsed_query) { | 82 bool elapsed_query, |
83 bool query_timestamp_counter_bits) { | |
David Yen
2016/02/17 19:04:55
Whether or not timestamp counter bits is actually
Ian Ewell
2016/02/17 21:06:30
Done.
| |
80 EXPECT_CALL(gl, GenQueries(1, NotNull())).Times(Exactly(1)) | 84 EXPECT_CALL(gl, GenQueries(1, NotNull())).Times(Exactly(1)) |
81 .WillRepeatedly(Invoke(this, &GPUTimingFake::FakeGLGenQueries)); | 85 .WillRepeatedly(Invoke(this, &GPUTimingFake::FakeGLGenQueries)); |
82 | 86 |
83 if (!elapsed_query) { | 87 if (!elapsed_query) { |
84 // Time Stamp based queries. | 88 // Time Stamp based queries. |
89 if (query_timestamp_counter_bits) { | |
90 EXPECT_CALL(gl, | |
91 GetQueryiv(GL_TIMESTAMP, GL_QUERY_COUNTER_BITS, NotNull())) | |
92 .Times(Exactly(1)) | |
93 .WillRepeatedly(DoAll(SetArgPointee<2>(64), Return())); | |
94 } | |
85 EXPECT_CALL(gl, GetInteger64v(GL_TIMESTAMP, _)) | 95 EXPECT_CALL(gl, GetInteger64v(GL_TIMESTAMP, _)) |
86 .WillRepeatedly( | 96 .WillRepeatedly( |
87 Invoke(this, &GPUTimingFake::FakeGLGetInteger64v)); | 97 Invoke(this, &GPUTimingFake::FakeGLGetInteger64v)); |
88 | 98 |
89 EXPECT_CALL(gl, QueryCounter(_, GL_TIMESTAMP)).Times(Exactly(1)) | 99 EXPECT_CALL(gl, QueryCounter(_, GL_TIMESTAMP)).Times(Exactly(1)) |
90 .WillRepeatedly( | 100 .WillRepeatedly( |
91 Invoke(this, &GPUTimingFake::FakeGLQueryCounter)); | 101 Invoke(this, &GPUTimingFake::FakeGLQueryCounter)); |
92 } else { | 102 } else { |
93 // Time Elapsed based queries. | 103 // Time Elapsed based queries. |
104 if (query_timestamp_counter_bits) { | |
105 EXPECT_CALL(gl, | |
106 GetQueryiv(GL_TIMESTAMP, GL_QUERY_COUNTER_BITS, NotNull())) | |
107 .Times(Exactly(1)) | |
108 .WillRepeatedly(DoAll(SetArgPointee<2>(0), Return())); | |
109 } | |
94 EXPECT_CALL(gl, BeginQuery(GL_TIME_ELAPSED, _)).Times(Exactly(1)) | 110 EXPECT_CALL(gl, BeginQuery(GL_TIME_ELAPSED, _)).Times(Exactly(1)) |
95 .WillRepeatedly( | 111 .WillRepeatedly( |
96 Invoke(this, &GPUTimingFake::FakeGLBeginQuery)); | 112 Invoke(this, &GPUTimingFake::FakeGLBeginQuery)); |
97 | 113 |
98 EXPECT_CALL(gl, EndQuery(GL_TIME_ELAPSED)).Times(Exactly(1)) | 114 EXPECT_CALL(gl, EndQuery(GL_TIME_ELAPSED)).Times(Exactly(1)) |
99 .WillRepeatedly(Invoke(this, &GPUTimingFake::FakeGLEndQuery)); | 115 .WillRepeatedly(Invoke(this, &GPUTimingFake::FakeGLEndQuery)); |
100 } | 116 } |
101 | 117 |
102 EXPECT_CALL(gl, GetQueryObjectuiv(_, GL_QUERY_RESULT_AVAILABLE, | 118 EXPECT_CALL(gl, GetQueryObjectuiv(_, GL_QUERY_RESULT_AVAILABLE, |
103 NotNull())) | 119 NotNull())) |
(...skipping 10 matching lines...) Expand all Loading... | |
114 } | 130 } |
115 | 131 |
116 void GPUTimingFake::ExpectGPUTimerQuery( | 132 void GPUTimingFake::ExpectGPUTimerQuery( |
117 MockGLInterface& gl, bool elapsed_query) { | 133 MockGLInterface& gl, bool elapsed_query) { |
118 EXPECT_CALL(gl, GenQueries(1, NotNull())) | 134 EXPECT_CALL(gl, GenQueries(1, NotNull())) |
119 .Times(AtLeast(elapsed_query ? 1 : 2)) | 135 .Times(AtLeast(elapsed_query ? 1 : 2)) |
120 .WillRepeatedly(Invoke(this, &GPUTimingFake::FakeGLGenQueries)); | 136 .WillRepeatedly(Invoke(this, &GPUTimingFake::FakeGLGenQueries)); |
121 | 137 |
122 if (!elapsed_query) { | 138 if (!elapsed_query) { |
123 // Time Stamp based queries. | 139 // Time Stamp based queries. |
140 EXPECT_CALL(gl, GetQueryiv(GL_TIMESTAMP, GL_QUERY_COUNTER_BITS, NotNull())) | |
141 .Times(Exactly(1)) | |
142 .WillRepeatedly(DoAll(SetArgPointee<2>(64), Return())); | |
143 | |
124 EXPECT_CALL(gl, GetInteger64v(GL_TIMESTAMP, _)) | 144 EXPECT_CALL(gl, GetInteger64v(GL_TIMESTAMP, _)) |
125 .WillRepeatedly( | 145 .WillRepeatedly( |
126 Invoke(this, &GPUTimingFake::FakeGLGetInteger64v)); | 146 Invoke(this, &GPUTimingFake::FakeGLGetInteger64v)); |
127 | 147 |
128 EXPECT_CALL(gl, QueryCounter(_, GL_TIMESTAMP)).Times(AtLeast(1)) | 148 EXPECT_CALL(gl, QueryCounter(_, GL_TIMESTAMP)).Times(AtLeast(1)) |
129 .WillRepeatedly( | 149 .WillRepeatedly( |
130 Invoke(this, &GPUTimingFake::FakeGLQueryCounter)); | 150 Invoke(this, &GPUTimingFake::FakeGLQueryCounter)); |
131 } | 151 } |
132 | 152 |
133 // Time Elapsed based queries. | 153 // Time Elapsed based queries. |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
281 default: | 301 default: |
282 FAIL() << "Invalid variable passed to GetIntegerv: " << pname; | 302 FAIL() << "Invalid variable passed to GetIntegerv: " << pname; |
283 } | 303 } |
284 } | 304 } |
285 | 305 |
286 GLenum GPUTimingFake::FakeGLGetError() { | 306 GLenum GPUTimingFake::FakeGLGetError() { |
287 return GL_NO_ERROR; | 307 return GL_NO_ERROR; |
288 } | 308 } |
289 | 309 |
290 } // namespace gfx | 310 } // namespace gfx |
OLD | NEW |