Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: ui/gl/gpu_timing_fake.cc

Issue 1687353002: Force time elapsed queries on certain drivers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor tests Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gl/gpu_timing.cc ('k') | ui/gl/gpu_timing_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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) {
80 EXPECT_CALL(gl, GenQueries(1, NotNull())).Times(Exactly(1)) 83 EXPECT_CALL(gl, GenQueries(1, NotNull())).Times(Exactly(1))
81 .WillRepeatedly(Invoke(this, &GPUTimingFake::FakeGLGenQueries)); 84 .WillRepeatedly(Invoke(this, &GPUTimingFake::FakeGLGenQueries));
82 85
86 EXPECT_CALL(gl, GetQueryiv(GL_TIMESTAMP, GL_QUERY_COUNTER_BITS, NotNull()))
87 .WillRepeatedly(DoAll(SetArgPointee<2>(64), Return()));
83 if (!elapsed_query) { 88 if (!elapsed_query) {
84 // Time Stamp based queries.
David Yen 2016/02/17 21:16:43 Was this accidentally deleted?
85 EXPECT_CALL(gl, GetInteger64v(GL_TIMESTAMP, _)) 89 EXPECT_CALL(gl, GetInteger64v(GL_TIMESTAMP, _))
86 .WillRepeatedly( 90 .WillRepeatedly(
87 Invoke(this, &GPUTimingFake::FakeGLGetInteger64v)); 91 Invoke(this, &GPUTimingFake::FakeGLGetInteger64v));
88 92
89 EXPECT_CALL(gl, QueryCounter(_, GL_TIMESTAMP)).Times(Exactly(1)) 93 EXPECT_CALL(gl, QueryCounter(_, GL_TIMESTAMP)).Times(Exactly(1))
90 .WillRepeatedly( 94 .WillRepeatedly(
91 Invoke(this, &GPUTimingFake::FakeGLQueryCounter)); 95 Invoke(this, &GPUTimingFake::FakeGLQueryCounter));
92 } else { 96 } else {
93 // Time Elapsed based queries. 97 // Time Elapsed based queries.
94 EXPECT_CALL(gl, BeginQuery(GL_TIME_ELAPSED, _)).Times(Exactly(1)) 98 EXPECT_CALL(gl, BeginQuery(GL_TIME_ELAPSED, _)).Times(Exactly(1))
(...skipping 19 matching lines...) Expand all
114 } 118 }
115 119
116 void GPUTimingFake::ExpectGPUTimerQuery( 120 void GPUTimingFake::ExpectGPUTimerQuery(
117 MockGLInterface& gl, bool elapsed_query) { 121 MockGLInterface& gl, bool elapsed_query) {
118 EXPECT_CALL(gl, GenQueries(1, NotNull())) 122 EXPECT_CALL(gl, GenQueries(1, NotNull()))
119 .Times(AtLeast(elapsed_query ? 1 : 2)) 123 .Times(AtLeast(elapsed_query ? 1 : 2))
120 .WillRepeatedly(Invoke(this, &GPUTimingFake::FakeGLGenQueries)); 124 .WillRepeatedly(Invoke(this, &GPUTimingFake::FakeGLGenQueries));
121 125
122 if (!elapsed_query) { 126 if (!elapsed_query) {
123 // Time Stamp based queries. 127 // Time Stamp based queries.
128 EXPECT_CALL(gl, GetQueryiv(GL_TIMESTAMP, GL_QUERY_COUNTER_BITS, NotNull()))
129 .Times(Exactly(1))
David Yen 2016/02/17 21:16:43 nit: Also remove this ".Times(Exactly(1))"
130 .WillRepeatedly(DoAll(SetArgPointee<2>(64), Return()));
131
124 EXPECT_CALL(gl, GetInteger64v(GL_TIMESTAMP, _)) 132 EXPECT_CALL(gl, GetInteger64v(GL_TIMESTAMP, _))
125 .WillRepeatedly( 133 .WillRepeatedly(
126 Invoke(this, &GPUTimingFake::FakeGLGetInteger64v)); 134 Invoke(this, &GPUTimingFake::FakeGLGetInteger64v));
127 135
128 EXPECT_CALL(gl, QueryCounter(_, GL_TIMESTAMP)).Times(AtLeast(1)) 136 EXPECT_CALL(gl, QueryCounter(_, GL_TIMESTAMP)).Times(AtLeast(1))
129 .WillRepeatedly( 137 .WillRepeatedly(
130 Invoke(this, &GPUTimingFake::FakeGLQueryCounter)); 138 Invoke(this, &GPUTimingFake::FakeGLQueryCounter));
131 } 139 }
132 140
133 // Time Elapsed based queries. 141 // Time Elapsed based queries.
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 default: 289 default:
282 FAIL() << "Invalid variable passed to GetIntegerv: " << pname; 290 FAIL() << "Invalid variable passed to GetIntegerv: " << pname;
283 } 291 }
284 } 292 }
285 293
286 GLenum GPUTimingFake::FakeGLGetError() { 294 GLenum GPUTimingFake::FakeGLGetError() {
287 return GL_NO_ERROR; 295 return GL_NO_ERROR;
288 } 296 }
289 297
290 } // namespace gfx 298 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gpu_timing.cc ('k') | ui/gl/gpu_timing_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698