| 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 // This file contains the tests for the RingBuffer class. | 5 // This file contains the tests for the RingBuffer class. |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/ring_buffer.h" | 7 #include "gpu/command_buffer/client/ring_buffer.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "gpu/command_buffer/client/cmd_buffer_helper.h" | 10 #include "gpu/command_buffer/client/cmd_buffer_helper.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 // ignore noops in the mock - we don't want to inspect the internals of the | 57 // ignore noops in the mock - we don't want to inspect the internals of the |
| 58 // helper. | 58 // helper. |
| 59 EXPECT_CALL(*api_mock_, DoCommand(cmd::kNoop, 0, _)) | 59 EXPECT_CALL(*api_mock_, DoCommand(cmd::kNoop, 0, _)) |
| 60 .WillRepeatedly(Return(error::kNoError)); | 60 .WillRepeatedly(Return(error::kNoError)); |
| 61 // Forward the SetToken calls to the engine | 61 // Forward the SetToken calls to the engine |
| 62 EXPECT_CALL(*api_mock_.get(), DoCommand(cmd::kSetToken, 1, _)) | 62 EXPECT_CALL(*api_mock_.get(), DoCommand(cmd::kSetToken, 1, _)) |
| 63 .WillRepeatedly(DoAll(Invoke(api_mock_.get(), &AsyncAPIMock::SetToken), | 63 .WillRepeatedly(DoAll(Invoke(api_mock_.get(), &AsyncAPIMock::SetToken), |
| 64 Return(error::kNoError))); | 64 Return(error::kNoError))); |
| 65 | 65 |
| 66 command_buffer_.reset(new CommandBufferService); | 66 command_buffer_.reset(new CommandBufferService); |
| 67 command_buffer_->Initialize(kBufferSize); | 67 command_buffer_->Initialize(); |
| 68 Buffer ring_buffer = command_buffer_->GetRingBuffer(); | |
| 69 | 68 |
| 70 parser_ = new CommandParser(ring_buffer.ptr, | 69 parser_ = new CommandParser(api_mock_.get()); |
| 71 ring_buffer.size, | |
| 72 0, | |
| 73 ring_buffer.size, | |
| 74 0, | |
| 75 api_mock_.get()); | |
| 76 | 70 |
| 77 gpu_scheduler_.reset(new GpuScheduler( | 71 gpu_scheduler_.reset(new GpuScheduler( |
| 78 command_buffer_.get(), NULL, parser_)); | 72 command_buffer_.get(), NULL, parser_)); |
| 79 command_buffer_->SetPutOffsetChangeCallback(NewCallback( | 73 command_buffer_->SetPutOffsetChangeCallback(NewCallback( |
| 80 gpu_scheduler_.get(), &GpuScheduler::PutChanged)); | 74 gpu_scheduler_.get(), &GpuScheduler::PutChanged)); |
| 81 | 75 |
| 82 api_mock_->set_engine(gpu_scheduler_.get()); | 76 api_mock_->set_engine(gpu_scheduler_.get()); |
| 83 do_jump_command_.reset(new DoJumpCommand(parser_)); | 77 do_jump_command_.reset(new DoJumpCommand(parser_)); |
| 84 EXPECT_CALL(*api_mock_, DoCommand(cmd::kJump, _, _)) | 78 EXPECT_CALL(*api_mock_, DoCommand(cmd::kJump, _, _)) |
| 85 .WillRepeatedly( | 79 .WillRepeatedly( |
| 86 Invoke(do_jump_command_.get(), &DoJumpCommand::DoCommand)); | 80 Invoke(do_jump_command_.get(), &DoJumpCommand::DoCommand)); |
| 87 | 81 |
| 88 helper_.reset(new CommandBufferHelper(command_buffer_.get())); | 82 helper_.reset(new CommandBufferHelper(command_buffer_.get())); |
| 89 helper_->Initialize(kBufferSize); | 83 helper_->Initialize(kBufferSize); |
| 84 |
| 85 // Note: parser->SetBuffer would normally be called through |
| 86 // helper_->Initialize but currently it needs a GpuCommandBufferStub as the |
| 87 // CommandBuffer instead of the CommandBufferService for that to happen. |
| 88 Buffer ring_buffer = helper_->get_ring_buffer(); |
| 89 parser_->SetBuffer(ring_buffer.ptr, ring_buffer.size, 0, ring_buffer.size); |
| 90 } | 90 } |
| 91 | 91 |
| 92 int32 GetToken() { | 92 int32 GetToken() { |
| 93 return command_buffer_->GetState().token; | 93 return command_buffer_->GetState().token; |
| 94 } | 94 } |
| 95 | 95 |
| 96 #if defined(OS_MACOSX) | 96 #if defined(OS_MACOSX) |
| 97 base::mac::ScopedNSAutoreleasePool autorelease_pool_; | 97 base::mac::ScopedNSAutoreleasePool autorelease_pool_; |
| 98 #endif | 98 #endif |
| 99 MessageLoop message_loop_; | 99 MessageLoop message_loop_; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 EXPECT_EQ(buffer_start_, static_cast<int8*>(pointer1)); | 282 EXPECT_EQ(buffer_start_, static_cast<int8*>(pointer1)); |
| 283 | 283 |
| 284 // Check that the token has indeed passed. | 284 // Check that the token has indeed passed. |
| 285 EXPECT_LE(tokens[0], GetToken()); | 285 EXPECT_LE(tokens[0], GetToken()); |
| 286 | 286 |
| 287 allocator_->FreePendingToken(pointer1, helper_->InsertToken()); | 287 allocator_->FreePendingToken(pointer1, helper_->InsertToken()); |
| 288 EXPECT_LE(command_buffer_->GetState().token, helper_->InsertToken()); | 288 EXPECT_LE(command_buffer_->GetState().token, helper_->InsertToken()); |
| 289 } | 289 } |
| 290 | 290 |
| 291 } // namespace gpu | 291 } // namespace gpu |
| OLD | NEW |