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