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/threading/thread.h" |
| 6 #include "base/time.h" |
| 7 #include "gpu/command_buffer/service/gpu_scheduler.h" |
5 #include "gpu/command_buffer/service/mocks.h" | 8 #include "gpu/command_buffer/service/mocks.h" |
6 | 9 |
7 namespace gpu { | 10 namespace gpu { |
8 | 11 |
9 AsyncAPIMock::AsyncAPIMock() { | 12 AsyncAPIMock::AsyncAPIMock() { |
10 testing::DefaultValue<error::Error>::Set( | 13 testing::DefaultValue<error::Error>::Set( |
11 error::kNoError); | 14 error::kNoError); |
12 } | 15 } |
13 | 16 |
14 AsyncAPIMock::~AsyncAPIMock() {} | 17 AsyncAPIMock::~AsyncAPIMock() {} |
15 | 18 |
16 void AsyncAPIMock::SetToken(unsigned int command, | 19 void AsyncAPIMock::SetToken(unsigned int command, |
17 unsigned int arg_count, | 20 unsigned int arg_count, |
18 const void* _args) { | 21 const void* _args) { |
19 DCHECK(engine_); | 22 DCHECK(engine_); |
20 DCHECK_EQ(1u, command); | 23 DCHECK_EQ(1u, command); |
21 DCHECK_EQ(1u, arg_count); | 24 DCHECK_EQ(1u, arg_count); |
22 const cmd::SetToken* args = | 25 const cmd::SetToken* args = |
23 static_cast<const cmd::SetToken*>(_args); | 26 static_cast<const cmd::SetToken*>(_args); |
24 engine_->set_token(args->token); | 27 engine_->set_token(args->token); |
25 } | 28 } |
26 | 29 |
| 30 SpecializedDoCommandAsyncAPIMock::SpecializedDoCommandAsyncAPIMock() {} |
| 31 |
| 32 SpecializedDoCommandAsyncAPIMock::~SpecializedDoCommandAsyncAPIMock() {} |
| 33 |
| 34 error::Error SpecializedDoCommandAsyncAPIMock::DoCommand( |
| 35 unsigned int command, |
| 36 unsigned int arg_count, |
| 37 const void* cmd_data) { |
| 38 if (command == kTestQuantumCommand) { |
| 39 // Surpass the GpuScheduler scheduling quantum. |
| 40 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 41 while ((base::TimeTicks::Now() - start_time).InMicroseconds() < |
| 42 GpuScheduler::kMinimumSchedulerQuantumMicros) { |
| 43 base::PlatformThread::Sleep(1); |
| 44 } |
| 45 } |
| 46 return AsyncAPIMock::DoCommand(command, arg_count, cmd_data); |
| 47 } |
| 48 |
27 namespace gles2 { | 49 namespace gles2 { |
28 | 50 |
29 MockShaderTranslator::MockShaderTranslator() {} | 51 MockShaderTranslator::MockShaderTranslator() {} |
30 | 52 |
31 MockShaderTranslator::~MockShaderTranslator() {} | 53 MockShaderTranslator::~MockShaderTranslator() {} |
32 | 54 |
33 } // namespace gles2 | 55 } // namespace gles2 |
34 } // namespace gpu | 56 } // namespace gpu |
OLD | NEW |