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" | 5 #include "base/threading/thread.h" |
6 #include "base/time.h" | 6 #include "base/time.h" |
7 #include "gpu/command_buffer/service/gpu_scheduler.h" | 7 #include "gpu/command_buffer/service/gpu_scheduler.h" |
8 #include "gpu/command_buffer/service/mocks.h" | 8 #include "gpu/command_buffer/service/mocks.h" |
9 | 9 |
10 namespace gpu { | 10 namespace gpu { |
11 | 11 |
12 AsyncAPIMock::AsyncAPIMock() { | 12 AsyncAPIMock::AsyncAPIMock() { |
13 testing::DefaultValue<error::Error>::Set( | 13 testing::DefaultValue<error::Error>::Set( |
14 error::kNoError); | 14 error::kNoError); |
15 } | 15 } |
16 | 16 |
17 AsyncAPIMock::~AsyncAPIMock() {} | 17 AsyncAPIMock::~AsyncAPIMock() {} |
18 | 18 |
19 void AsyncAPIMock::SetToken(unsigned int command, | 19 void AsyncAPIMock::SetToken(unsigned int command, |
20 unsigned int arg_count, | 20 unsigned int arg_count, |
21 const void* _args) { | 21 const void* _args) { |
22 DCHECK(engine_); | 22 DCHECK(engine_); |
23 DCHECK_EQ(1u, command); | 23 DCHECK_EQ(1u, command); |
24 DCHECK_EQ(1u, arg_count); | 24 DCHECK_EQ(1u, arg_count); |
25 const cmd::SetToken* args = | 25 const cmd::SetToken* args = |
26 static_cast<const cmd::SetToken*>(_args); | 26 static_cast<const cmd::SetToken*>(_args); |
27 engine_->set_token(args->token); | 27 engine_->set_token(args->token); |
28 } | 28 } |
29 | 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 | |
49 namespace gles2 { | 30 namespace gles2 { |
50 | 31 |
51 MockShaderTranslator::MockShaderTranslator() {} | 32 MockShaderTranslator::MockShaderTranslator() {} |
52 | 33 |
53 MockShaderTranslator::~MockShaderTranslator() {} | 34 MockShaderTranslator::~MockShaderTranslator() {} |
54 | 35 |
55 } // namespace gles2 | 36 } // namespace gles2 |
56 } // namespace gpu | 37 } // namespace gpu |
OLD | NEW |