| 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 SpecializedAsyncAPIMock::SpecializedAsyncAPIMock() {} |
| 31 |
| 32 SpecializedAsyncAPIMock::~SpecializedAsyncAPIMock() {} |
| 33 |
| 34 error::Error SpecializedAsyncAPIMock::DoCommand(unsigned int command, |
| 35 unsigned int arg_count, |
| 36 const void* cmd_data) { |
| 37 if (command == kTestQuantumCommand) { |
| 38 // Surpass the GpuScheduler scheduling quantum. |
| 39 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 40 while ((base::TimeTicks::Now() - start_time).InMicroseconds() < |
| 41 GpuScheduler::kMinimumSchedulerQuantumMicros) { |
| 42 base::PlatformThread::Sleep(1); |
| 43 } |
| 44 } |
| 45 return AsyncAPIMock::DoCommand(command, arg_count, cmd_data); |
| 46 } |
| 47 |
| 27 namespace gles2 { | 48 namespace gles2 { |
| 28 | 49 |
| 29 MockShaderTranslator::MockShaderTranslator() {} | 50 MockShaderTranslator::MockShaderTranslator() {} |
| 30 | 51 |
| 31 MockShaderTranslator::~MockShaderTranslator() {} | 52 MockShaderTranslator::~MockShaderTranslator() {} |
| 32 | 53 |
| 33 } // namespace gles2 | 54 } // namespace gles2 |
| 34 } // namespace gpu | 55 } // namespace gpu |
| OLD | NEW |