OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <map> | 5 #include <map> |
6 #include <set> | 6 #include <set> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" | 9 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" |
10 #include "gpu/command_buffer/service/gpu_service_test.h" | 10 #include "gpu/command_buffer/service/gpu_service_test.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 void Reset() { | 54 void Reset() { |
55 current_time_ = 0; | 55 current_time_ = 0; |
56 next_query_id_ = 23; | 56 next_query_id_ = 23; |
57 alloced_queries_.clear(); | 57 alloced_queries_.clear(); |
58 query_timestamp_.clear(); | 58 query_timestamp_.clear(); |
59 } | 59 } |
60 | 60 |
61 void SetCurrentGLTime(GLint64 current_time) { current_time_ = current_time; } | 61 void SetCurrentGLTime(GLint64 current_time) { current_time_ = current_time; } |
62 void SetDisjoint() { disjointed_ = true; } | 62 void SetDisjoint() { disjointed_ = true; } |
63 | 63 |
64 void GenQueriesARB(GLsizei n, GLuint* ids) { | 64 void GenQueries(GLsizei n, GLuint* ids) { |
65 for (GLsizei i = 0; i < n; i++) { | 65 for (GLsizei i = 0; i < n; i++) { |
66 ids[i] = next_query_id_++; | 66 ids[i] = next_query_id_++; |
67 alloced_queries_.insert(ids[i]); | 67 alloced_queries_.insert(ids[i]); |
68 } | 68 } |
69 } | 69 } |
70 | 70 |
71 void DeleteQueriesARB(GLsizei n, const GLuint* ids) { | 71 void DeleteQueries(GLsizei n, const GLuint* ids) { |
72 for (GLsizei i = 0; i < n; i++) { | 72 for (GLsizei i = 0; i < n; i++) { |
73 alloced_queries_.erase(ids[i]); | 73 alloced_queries_.erase(ids[i]); |
74 query_timestamp_.erase(ids[i]); | 74 query_timestamp_.erase(ids[i]); |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 void GetQueryObjectivARB(GLuint id, GLenum pname, GLint* params) { | 78 void GetQueryObjectiv(GLuint id, GLenum pname, GLint* params) { |
79 switch (pname) { | 79 switch (pname) { |
80 case GL_QUERY_RESULT_AVAILABLE: { | 80 case GL_QUERY_RESULT_AVAILABLE: { |
81 std::map<GLuint, GLint64>::iterator it = query_timestamp_.find(id); | 81 std::map<GLuint, GLint64>::iterator it = query_timestamp_.find(id); |
82 if (it != query_timestamp_.end() && it->second <= current_time_) | 82 if (it != query_timestamp_.end() && it->second <= current_time_) |
83 *params = 1; | 83 *params = 1; |
84 else | 84 else |
85 *params = 0; | 85 *params = 0; |
86 break; | 86 break; |
87 } | 87 } |
88 default: | 88 default: |
89 FAIL() << "Invalid variable passed to GetQueryObjectivARB: " << pname; | 89 FAIL() << "Invalid variable passed to GetQueryObjectiv: " << pname; |
90 } | 90 } |
91 } | 91 } |
92 | 92 |
93 void QueryCounter(GLuint id, GLenum target) { | 93 void QueryCounter(GLuint id, GLenum target) { |
94 switch (target) { | 94 switch (target) { |
95 case GL_TIMESTAMP: | 95 case GL_TIMESTAMP: |
96 ASSERT_TRUE(alloced_queries_.find(id) != alloced_queries_.end()); | 96 ASSERT_TRUE(alloced_queries_.find(id) != alloced_queries_.end()); |
97 query_timestamp_[id] = current_time_; | 97 query_timestamp_[id] = current_time_; |
98 break; | 98 break; |
99 default: | 99 default: |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 outputter_ref_ = NULL; | 230 outputter_ref_ = NULL; |
231 | 231 |
232 gl_fake_queries_.Reset(); | 232 gl_fake_queries_.Reset(); |
233 GpuServiceTest::TearDown(); | 233 GpuServiceTest::TearDown(); |
234 } | 234 } |
235 | 235 |
236 void ExpectTraceQueryMocks() { | 236 void ExpectTraceQueryMocks() { |
237 if (gpu_timing_client_->IsAvailable() && | 237 if (gpu_timing_client_->IsAvailable() && |
238 gpu_timing_client_->IsTimerOffsetAvailable()) { | 238 gpu_timing_client_->IsTimerOffsetAvailable()) { |
239 // Delegate query APIs used by GPUTrace to a GlFakeQueries | 239 // Delegate query APIs used by GPUTrace to a GlFakeQueries |
240 EXPECT_CALL(*gl_, GenQueriesARB(2, NotNull())).Times(AtLeast(1)) | 240 EXPECT_CALL(*gl_, GenQueries(2, NotNull())).Times(AtLeast(1)) |
241 .WillRepeatedly( | 241 .WillRepeatedly( |
242 Invoke(&gl_fake_queries_, &GlFakeQueries::GenQueriesARB)); | 242 Invoke(&gl_fake_queries_, &GlFakeQueries::GenQueries)); |
243 | 243 |
244 EXPECT_CALL(*gl_, GetQueryObjectivARB(_, GL_QUERY_RESULT_AVAILABLE, | 244 EXPECT_CALL(*gl_, GetQueryObjectiv(_, GL_QUERY_RESULT_AVAILABLE, |
245 NotNull())) | 245 NotNull())) |
246 .WillRepeatedly( | 246 .WillRepeatedly( |
247 Invoke(&gl_fake_queries_, &GlFakeQueries::GetQueryObjectivARB)); | 247 Invoke(&gl_fake_queries_, &GlFakeQueries::GetQueryObjectiv)); |
248 | 248 |
249 EXPECT_CALL(*gl_, GetInteger64v(GL_TIMESTAMP, _)) | 249 EXPECT_CALL(*gl_, GetInteger64v(GL_TIMESTAMP, _)) |
250 .WillRepeatedly( | 250 .WillRepeatedly( |
251 Invoke(&gl_fake_queries_, &GlFakeQueries::GetInteger64v)); | 251 Invoke(&gl_fake_queries_, &GlFakeQueries::GetInteger64v)); |
252 | 252 |
253 EXPECT_CALL(*gl_, QueryCounter(_, GL_TIMESTAMP)).Times(AtLeast(2)) | 253 EXPECT_CALL(*gl_, QueryCounter(_, GL_TIMESTAMP)).Times(AtLeast(2)) |
254 .WillRepeatedly( | 254 .WillRepeatedly( |
255 Invoke(&gl_fake_queries_, &GlFakeQueries::QueryCounter)); | 255 Invoke(&gl_fake_queries_, &GlFakeQueries::QueryCounter)); |
256 | 256 |
257 EXPECT_CALL(*gl_, GetQueryObjectui64v(_, GL_QUERY_RESULT, NotNull())) | 257 EXPECT_CALL(*gl_, GetQueryObjectui64v(_, GL_QUERY_RESULT, NotNull())) |
258 .WillRepeatedly( | 258 .WillRepeatedly( |
259 Invoke(&gl_fake_queries_, | 259 Invoke(&gl_fake_queries_, |
260 &GlFakeQueries::GetQueryObjectui64v)); | 260 &GlFakeQueries::GetQueryObjectui64v)); |
261 | 261 |
262 EXPECT_CALL(*gl_, DeleteQueriesARB(2, NotNull())).Times(AtLeast(1)) | 262 EXPECT_CALL(*gl_, DeleteQueries(2, NotNull())).Times(AtLeast(1)) |
263 .WillRepeatedly( | 263 .WillRepeatedly( |
264 Invoke(&gl_fake_queries_, &GlFakeQueries::DeleteQueriesARB)); | 264 Invoke(&gl_fake_queries_, &GlFakeQueries::DeleteQueries)); |
265 } | 265 } |
266 } | 266 } |
267 | 267 |
268 void ExpectOutputterBeginMocks(MockOutputter* outputter, | 268 void ExpectOutputterBeginMocks(MockOutputter* outputter, |
269 const std::string& category, | 269 const std::string& category, |
270 const std::string& name) { | 270 const std::string& name) { |
271 EXPECT_CALL(*outputter, | 271 EXPECT_CALL(*outputter, |
272 TraceServiceBegin(category, name)); | 272 TraceServiceBegin(category, name)); |
273 } | 273 } |
274 | 274 |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 scoped_refptr<gfx::GPUTimingClient> client3 = | 698 scoped_refptr<gfx::GPUTimingClient> client3 = |
699 GetGLContext()->CreateGPUTimingClient(); | 699 GetGLContext()->CreateGPUTimingClient(); |
700 ASSERT_TRUE(client1->CheckAndResetTimerErrors()); | 700 ASSERT_TRUE(client1->CheckAndResetTimerErrors()); |
701 ASSERT_TRUE(client2->CheckAndResetTimerErrors()); | 701 ASSERT_TRUE(client2->CheckAndResetTimerErrors()); |
702 ASSERT_FALSE(client3->CheckAndResetTimerErrors()); | 702 ASSERT_FALSE(client3->CheckAndResetTimerErrors()); |
703 } | 703 } |
704 | 704 |
705 } // namespace | 705 } // namespace |
706 } // namespace gles2 | 706 } // namespace gles2 |
707 } // namespace gpu | 707 } // namespace gpu |
OLD | NEW |