OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/mac/scoped_nsautorelease_pool.h" | 5 #include "base/mac/scoped_nsautorelease_pool.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "gpu/command_buffer/common/command_buffer_mock.h" | 7 #include "gpu/command_buffer/common/command_buffer_mock.h" |
8 #include "gpu/command_buffer/service/gpu_scheduler.h" | 8 #include "gpu/command_buffer/service/gpu_scheduler.h" |
9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
10 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" | 10 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 command_buffer_.reset(new MockCommandBuffer); | 38 command_buffer_.reset(new MockCommandBuffer); |
39 ON_CALL(*command_buffer_.get(), GetRingBuffer()) | 39 ON_CALL(*command_buffer_.get(), GetRingBuffer()) |
40 .WillByDefault(Return(shared_memory_buffer_)); | 40 .WillByDefault(Return(shared_memory_buffer_)); |
41 | 41 |
42 CommandBuffer::State default_state; | 42 CommandBuffer::State default_state; |
43 default_state.num_entries = kRingBufferEntries; | 43 default_state.num_entries = kRingBufferEntries; |
44 ON_CALL(*command_buffer_.get(), GetState()) | 44 ON_CALL(*command_buffer_.get(), GetState()) |
45 .WillByDefault(Return(default_state)); | 45 .WillByDefault(Return(default_state)); |
46 | 46 |
47 async_api_.reset(new StrictMock<AsyncAPIMock>); | 47 async_api_.reset(new StrictMock<SpecializedDoCommandAsyncAPIMock>); |
48 | 48 |
49 decoder_ = new gles2::MockGLES2Decoder(); | 49 decoder_ = new gles2::MockGLES2Decoder(); |
50 | 50 |
51 parser_ = new CommandParser(buffer_, | 51 parser_ = new CommandParser(buffer_, |
52 kRingBufferEntries, | 52 kRingBufferEntries, |
53 0, | 53 0, |
54 kRingBufferEntries, | 54 kRingBufferEntries, |
55 0, | 55 0, |
56 async_api_.get()); | 56 async_api_.get()); |
57 | 57 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 154 |
155 CommandBuffer::State state; | 155 CommandBuffer::State state; |
156 state.put_offset = 0; | 156 state.put_offset = 0; |
157 EXPECT_CALL(*command_buffer_, GetState()) | 157 EXPECT_CALL(*command_buffer_, GetState()) |
158 .WillRepeatedly(Return(state)); | 158 .WillRepeatedly(Return(state)); |
159 | 159 |
160 scheduler_->PutChanged(true); | 160 scheduler_->PutChanged(true); |
161 } | 161 } |
162 | 162 |
163 TEST_F(GpuSchedulerTest, PostsTaskToFinishRemainingCommands) { | 163 TEST_F(GpuSchedulerTest, PostsTaskToFinishRemainingCommands) { |
| 164 unsigned int pauseCmd = SpecializedDoCommandAsyncAPIMock::kTestQuantumCommand; |
164 CommandHeader* header = reinterpret_cast<CommandHeader*>(&buffer_[0]); | 165 CommandHeader* header = reinterpret_cast<CommandHeader*>(&buffer_[0]); |
165 header[0].command = 7; | 166 header[0].command = 7; |
166 header[0].size = 2; | 167 header[0].size = 2; |
167 buffer_[1] = 123; | 168 buffer_[1] = 123; |
168 header[2].command = 8; | 169 header[2].command = pauseCmd; |
169 header[2].size = 1; | 170 header[2].size = 1; |
170 header[3].command = 9; | 171 header[3].command = 9; |
171 header[3].size = 1; | 172 header[3].size = 1; |
172 | 173 |
173 CommandBuffer::State state; | 174 CommandBuffer::State state; |
174 | 175 |
175 state.put_offset = 4; | 176 state.put_offset = 4; |
176 EXPECT_CALL(*command_buffer_, GetState()) | 177 EXPECT_CALL(*command_buffer_, GetState()) |
177 .WillRepeatedly(Return(state)); | 178 .WillRepeatedly(Return(state)); |
178 | 179 |
179 EXPECT_CALL(*async_api_, DoCommand(7, 1, &buffer_[0])) | 180 EXPECT_CALL(*async_api_, DoCommand(7, 1, &buffer_[0])) |
180 .WillOnce(Return(error::kNoError)); | 181 .WillOnce(Return(error::kNoError)); |
181 EXPECT_CALL(*command_buffer_, SetGetOffset(2)); | 182 EXPECT_CALL(*command_buffer_, SetGetOffset(2)); |
182 | 183 |
183 EXPECT_CALL(*async_api_, DoCommand(8, 0, &buffer_[2])) | 184 EXPECT_CALL(*async_api_, DoCommand(pauseCmd, 0, &buffer_[2])) |
184 .WillOnce(Return(error::kNoError)); | 185 .WillOnce(Return(error::kNoError)); |
185 EXPECT_CALL(*command_buffer_, SetGetOffset(3)); | 186 EXPECT_CALL(*command_buffer_, SetGetOffset(3)); |
186 | 187 |
187 scheduler_->PutChanged(true); | 188 scheduler_->PutChanged(true); |
188 | 189 |
189 // ProcessCommands is called a second time when the pending task is run. | 190 // ProcessCommands is called a second time when the pending task is run. |
190 | 191 |
191 state.put_offset = 4; | 192 state.put_offset = 4; |
192 EXPECT_CALL(*command_buffer_, GetState()) | 193 EXPECT_CALL(*command_buffer_, GetState()) |
193 .WillRepeatedly(Return(state)); | 194 .WillRepeatedly(Return(state)); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 250 |
250 EXPECT_EQ(kRingBufferSize, scheduler_->GetSharedMemoryBuffer(7).size); | 251 EXPECT_EQ(kRingBufferSize, scheduler_->GetSharedMemoryBuffer(7).size); |
251 } | 252 } |
252 | 253 |
253 TEST_F(GpuSchedulerTest, SetTokenForwardsToCommandBuffer) { | 254 TEST_F(GpuSchedulerTest, SetTokenForwardsToCommandBuffer) { |
254 EXPECT_CALL(*command_buffer_, SetToken(7)); | 255 EXPECT_CALL(*command_buffer_, SetToken(7)); |
255 scheduler_->set_token(7); | 256 scheduler_->set_token(7); |
256 } | 257 } |
257 | 258 |
258 } // namespace gpu | 259 } // namespace gpu |
OLD | NEW |