| 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 "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/gl/gl_mock.h" | 8 #include "ui/gl/gl_mock.h" |
| 9 | 9 |
| 10 namespace gfx { | 10 namespace gfx { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 void GPUTimingFake::ExpectDisjointCalls(MockGLInterface& gl) { | 47 void GPUTimingFake::ExpectDisjointCalls(MockGLInterface& gl) { |
| 48 EXPECT_CALL(gl, GetIntegerv(GL_GPU_DISJOINT_EXT, _)).Times(AtLeast(1)) | 48 EXPECT_CALL(gl, GetIntegerv(GL_GPU_DISJOINT_EXT, _)).Times(AtLeast(1)) |
| 49 .WillRepeatedly(Invoke(this, &GPUTimingFake::FakeGLGetIntegerv)); | 49 .WillRepeatedly(Invoke(this, &GPUTimingFake::FakeGLGetIntegerv)); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void GPUTimingFake::ExpectNoDisjointCalls(MockGLInterface& gl) { | 52 void GPUTimingFake::ExpectNoDisjointCalls(MockGLInterface& gl) { |
| 53 EXPECT_CALL(gl, GetIntegerv(GL_GPU_DISJOINT_EXT, _)).Times(Exactly(0)); | 53 EXPECT_CALL(gl, GetIntegerv(GL_GPU_DISJOINT_EXT, _)).Times(Exactly(0)); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void GPUTimingFake::ExpectGPUTimeStampQuery( |
| 57 MockGLInterface& gl, bool elapsed_query) { |
| 58 EXPECT_CALL(gl, GenQueries(1, NotNull())).Times(Exactly(1)) |
| 59 .WillRepeatedly(Invoke(this, &GPUTimingFake::FakeGLGenQueries)); |
| 60 |
| 61 if (!elapsed_query) { |
| 62 // Time Stamp based queries. |
| 63 EXPECT_CALL(gl, GetInteger64v(GL_TIMESTAMP, _)) |
| 64 .WillRepeatedly( |
| 65 Invoke(this, &GPUTimingFake::FakeGLGetInteger64v)); |
| 66 |
| 67 EXPECT_CALL(gl, QueryCounter(_, GL_TIMESTAMP)).Times(Exactly(1)) |
| 68 .WillRepeatedly( |
| 69 Invoke(this, &GPUTimingFake::FakeGLQueryCounter)); |
| 70 } else { |
| 71 // Time Elapsed based queries. |
| 72 EXPECT_CALL(gl, BeginQuery(GL_TIME_ELAPSED, _)).Times(Exactly(1)) |
| 73 .WillRepeatedly( |
| 74 Invoke(this, &GPUTimingFake::FakeGLBeginQuery)); |
| 75 |
| 76 EXPECT_CALL(gl, EndQuery(GL_TIME_ELAPSED)).Times(Exactly(1)) |
| 77 .WillRepeatedly(Invoke(this, &GPUTimingFake::FakeGLEndQuery)); |
| 78 } |
| 79 |
| 80 EXPECT_CALL(gl, GetQueryObjectuiv(_, GL_QUERY_RESULT_AVAILABLE, |
| 81 NotNull())) |
| 82 .WillRepeatedly( |
| 83 Invoke(this, &GPUTimingFake::FakeGLGetQueryObjectuiv)); |
| 84 |
| 85 EXPECT_CALL(gl, GetQueryObjectui64v(_, GL_QUERY_RESULT, NotNull())) |
| 86 .WillRepeatedly( |
| 87 Invoke(this, &GPUTimingFake::FakeGLGetQueryObjectui64v)); |
| 88 |
| 89 EXPECT_CALL(gl, DeleteQueries(1, NotNull())).Times(AtLeast(1)) |
| 90 .WillRepeatedly( |
| 91 Invoke(this, &GPUTimingFake::FakeGLDeleteQueries)); |
| 92 } |
| 93 |
| 56 void GPUTimingFake::ExpectGPUTimerQuery( | 94 void GPUTimingFake::ExpectGPUTimerQuery( |
| 57 MockGLInterface& gl, bool elapsed_query) { | 95 MockGLInterface& gl, bool elapsed_query) { |
| 58 EXPECT_CALL(gl, GenQueries(1, NotNull())).Times(AtLeast(2)) | 96 EXPECT_CALL(gl, GenQueries(1, NotNull())) |
| 97 .Times(AtLeast(elapsed_query ? 1 : 2)) |
| 59 .WillRepeatedly(Invoke(this, &GPUTimingFake::FakeGLGenQueries)); | 98 .WillRepeatedly(Invoke(this, &GPUTimingFake::FakeGLGenQueries)); |
| 60 | 99 |
| 61 if (!elapsed_query) { | 100 if (!elapsed_query) { |
| 62 // Time Stamp based queries. | 101 // Time Stamp based queries. |
| 63 EXPECT_CALL(gl, GetInteger64v(GL_TIMESTAMP, _)) | 102 EXPECT_CALL(gl, GetInteger64v(GL_TIMESTAMP, _)) |
| 64 .WillRepeatedly( | 103 .WillRepeatedly( |
| 65 Invoke(this, &GPUTimingFake::FakeGLGetInteger64v)); | 104 Invoke(this, &GPUTimingFake::FakeGLGetInteger64v)); |
| 66 | 105 |
| 67 EXPECT_CALL(gl, QueryCounter(_, GL_TIMESTAMP)).Times(AtLeast(1)) | 106 EXPECT_CALL(gl, QueryCounter(_, GL_TIMESTAMP)).Times(AtLeast(1)) |
| 68 .WillRepeatedly( | 107 .WillRepeatedly( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 79 | 118 |
| 80 EXPECT_CALL(gl, GetQueryObjectuiv(_, GL_QUERY_RESULT_AVAILABLE, | 119 EXPECT_CALL(gl, GetQueryObjectuiv(_, GL_QUERY_RESULT_AVAILABLE, |
| 81 NotNull())) | 120 NotNull())) |
| 82 .WillRepeatedly( | 121 .WillRepeatedly( |
| 83 Invoke(this, &GPUTimingFake::FakeGLGetQueryObjectuiv)); | 122 Invoke(this, &GPUTimingFake::FakeGLGetQueryObjectuiv)); |
| 84 | 123 |
| 85 EXPECT_CALL(gl, GetQueryObjectui64v(_, GL_QUERY_RESULT, NotNull())) | 124 EXPECT_CALL(gl, GetQueryObjectui64v(_, GL_QUERY_RESULT, NotNull())) |
| 86 .WillRepeatedly( | 125 .WillRepeatedly( |
| 87 Invoke(this, &GPUTimingFake::FakeGLGetQueryObjectui64v)); | 126 Invoke(this, &GPUTimingFake::FakeGLGetQueryObjectui64v)); |
| 88 | 127 |
| 89 EXPECT_CALL(gl, DeleteQueries(1, NotNull())).Times(AtLeast(2)) | 128 EXPECT_CALL(gl, DeleteQueries(1, NotNull())) |
| 129 .Times(AtLeast(elapsed_query ? 1 : 2)) |
| 90 .WillRepeatedly( | 130 .WillRepeatedly( |
| 91 Invoke(this, &GPUTimingFake::FakeGLDeleteQueries)); | 131 Invoke(this, &GPUTimingFake::FakeGLDeleteQueries)); |
| 92 } | 132 } |
| 93 | 133 |
| 94 void GPUTimingFake::ExpectOffsetCalculationQuery( | 134 void GPUTimingFake::ExpectOffsetCalculationQuery( |
| 95 MockGLInterface& gl) { | 135 MockGLInterface& gl) { |
| 96 EXPECT_CALL(gl, GetInteger64v(GL_TIMESTAMP, NotNull())) | 136 EXPECT_CALL(gl, GetInteger64v(GL_TIMESTAMP, NotNull())) |
| 97 .Times(AtMost(1)) | 137 .Times(AtMost(1)) |
| 98 .WillRepeatedly( | 138 .WillRepeatedly( |
| 99 Invoke(this, &GPUTimingFake::FakeGLGetInteger64v)); | 139 Invoke(this, &GPUTimingFake::FakeGLGetInteger64v)); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 default: | 259 default: |
| 220 FAIL() << "Invalid variable passed to GetIntegerv: " << pname; | 260 FAIL() << "Invalid variable passed to GetIntegerv: " << pname; |
| 221 } | 261 } |
| 222 } | 262 } |
| 223 | 263 |
| 224 GLenum GPUTimingFake::FakeGLGetError() { | 264 GLenum GPUTimingFake::FakeGLGetError() { |
| 225 return GL_NO_ERROR; | 265 return GL_NO_ERROR; |
| 226 } | 266 } |
| 227 | 267 |
| 228 } // namespace gfx | 268 } // namespace gfx |
| OLD | NEW |