| 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 FencedAllocator class. | 5 // This file contains the tests for the FencedAllocator class. |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "gpu/command_buffer/client/cmd_buffer_helper.h" | 9 #include "gpu/command_buffer/client/cmd_buffer_helper.h" |
| 10 #include "gpu/command_buffer/client/fenced_allocator.h" | 10 #include "gpu/command_buffer/client/fenced_allocator.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 // ignore noops in the mock - we don't want to inspect the internals of the | 37 // ignore noops in the mock - we don't want to inspect the internals of the |
| 38 // helper. | 38 // helper. |
| 39 EXPECT_CALL(*api_mock_, DoCommand(cmd::kNoop, 0, _)) | 39 EXPECT_CALL(*api_mock_, DoCommand(cmd::kNoop, 0, _)) |
| 40 .WillRepeatedly(Return(error::kNoError)); | 40 .WillRepeatedly(Return(error::kNoError)); |
| 41 // Forward the SetToken calls to the engine | 41 // Forward the SetToken calls to the engine |
| 42 EXPECT_CALL(*api_mock_.get(), DoCommand(cmd::kSetToken, 1, _)) | 42 EXPECT_CALL(*api_mock_.get(), DoCommand(cmd::kSetToken, 1, _)) |
| 43 .WillRepeatedly(DoAll(Invoke(api_mock_.get(), &AsyncAPIMock::SetToken), | 43 .WillRepeatedly(DoAll(Invoke(api_mock_.get(), &AsyncAPIMock::SetToken), |
| 44 Return(error::kNoError))); | 44 Return(error::kNoError))); |
| 45 | 45 |
| 46 command_buffer_.reset(new CommandBufferService); | 46 command_buffer_.reset(new CommandBufferService); |
| 47 command_buffer_->Initialize(kBufferSize); | 47 command_buffer_->Initialize(); |
| 48 Buffer ring_buffer = command_buffer_->GetRingBuffer(); | |
| 49 | 48 |
| 50 parser_ = new CommandParser(ring_buffer.ptr, | 49 parser_ = new CommandParser(api_mock_.get()); |
| 51 ring_buffer.size, | |
| 52 0, | |
| 53 ring_buffer.size, | |
| 54 0, | |
| 55 api_mock_.get()); | |
| 56 | 50 |
| 57 gpu_scheduler_.reset(new GpuScheduler( | 51 gpu_scheduler_.reset(new GpuScheduler( |
| 58 command_buffer_.get(), NULL, parser_)); | 52 command_buffer_.get(), NULL, parser_)); |
| 59 command_buffer_->SetPutOffsetChangeCallback(NewCallback( | 53 command_buffer_->SetPutOffsetChangeCallback(NewCallback( |
| 60 gpu_scheduler_.get(), &GpuScheduler::PutChanged)); | 54 gpu_scheduler_.get(), &GpuScheduler::PutChanged)); |
| 61 | 55 |
| 62 api_mock_->set_engine(gpu_scheduler_.get()); | 56 api_mock_->set_engine(gpu_scheduler_.get()); |
| 63 | 57 |
| 64 helper_.reset(new CommandBufferHelper(command_buffer_.get())); | 58 helper_.reset(new CommandBufferHelper(command_buffer_.get())); |
| 65 helper_->Initialize(kBufferSize); | 59 helper_->Initialize(kBufferSize); |
| 60 |
| 61 // Note: parser->SetBuffer would normally be called through |
| 62 // helper_->Initialize but currently it needs a GpuCommandBufferStub as the |
| 63 // CommandBuffer instead of the CommandBufferService for that to happen. |
| 64 Buffer ring_buffer = helper_->get_ring_buffer(); |
| 65 parser_->SetBuffer(ring_buffer.ptr, ring_buffer.size, 0, ring_buffer.size); |
| 66 } | 66 } |
| 67 | 67 |
| 68 int32 GetToken() { | 68 int32 GetToken() { |
| 69 return command_buffer_->GetState().token; | 69 return command_buffer_->GetState().token; |
| 70 } | 70 } |
| 71 | 71 |
| 72 #if defined(OS_MACOSX) | 72 #if defined(OS_MACOSX) |
| 73 base::mac::ScopedNSAutoreleasePool autorelease_pool_; | 73 base::mac::ScopedNSAutoreleasePool autorelease_pool_; |
| 74 #endif | 74 #endif |
| 75 MessageLoop message_loop_; | 75 MessageLoop message_loop_; |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 EXPECT_LE(token, GetToken()); | 524 EXPECT_LE(token, GetToken()); |
| 525 | 525 |
| 526 // Free up everything. | 526 // Free up everything. |
| 527 for (unsigned int i = 0; i < kAllocCount; ++i) { | 527 for (unsigned int i = 0; i < kAllocCount; ++i) { |
| 528 allocator_->Free(pointers[i]); | 528 allocator_->Free(pointers[i]); |
| 529 EXPECT_TRUE(allocator_->CheckConsistency()); | 529 EXPECT_TRUE(allocator_->CheckConsistency()); |
| 530 } | 530 } |
| 531 } | 531 } |
| 532 | 532 |
| 533 } // namespace gpu | 533 } // namespace gpu |
| OLD | NEW |