diff options
Diffstat (limited to 'gpu/command_buffer/client')
-rw-r--r-- | gpu/command_buffer/client/client_test_helper.cc | 19 | ||||
-rw-r--r-- | gpu/command_buffer/client/client_test_helper.h | 5 | ||||
-rw-r--r-- | gpu/command_buffer/client/cmd_buffer_helper.cc | 10 | ||||
-rw-r--r-- | gpu/command_buffer/client/fenced_allocator_test.cc | 2 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation_unittest.cc | 6 | ||||
-rw-r--r-- | gpu/command_buffer/client/mapped_memory.cc | 7 | ||||
-rw-r--r-- | gpu/command_buffer/client/transfer_buffer.cc | 6 | ||||
-rw-r--r-- | gpu/command_buffer/client/transfer_buffer_unittest.cc | 15 |
8 files changed, 28 insertions, 42 deletions
diff --git a/gpu/command_buffer/client/client_test_helper.cc b/gpu/command_buffer/client/client_test_helper.cc index d9942ef..92af99d 100644 --- a/gpu/command_buffer/client/client_test_helper.cc +++ b/gpu/command_buffer/client/client_test_helper.cc @@ -60,16 +60,15 @@ int32 MockCommandBufferBase::GetNextFreeTransferBufferId() { return -1; } -int32 MockCommandBufferBase::CreateTransferBuffer( - size_t size, int32 id_request) { - int32 id = GetNextFreeTransferBufferId(); - if (id >= 0) { - int32 ndx = id - kTransferBufferBaseId; +Buffer MockCommandBufferBase::CreateTransferBuffer(size_t size, int32* id) { + *id = GetNextFreeTransferBufferId(); + if (*id >= 0) { + int32 ndx = *id - kTransferBufferBaseId; transfer_buffers_[ndx].reset(new int8[size]); transfer_buffer_buffers_[ndx].ptr = transfer_buffers_[ndx].get(); transfer_buffer_buffers_[ndx].size = size; } - return id; + return GetTransferBuffer(*id); } void MockCommandBufferBase::DestroyTransferBufferHelper(int32 id) { @@ -86,14 +85,6 @@ Buffer MockCommandBufferBase::GetTransferBuffer(int32 id) { return transfer_buffer_buffers_[id - kTransferBufferBaseId]; } -int32 MockCommandBufferBase::RegisterTransferBuffer( - base::SharedMemory* shared_memory, - size_t size, - int32 id_request) { - GPU_NOTREACHED(); - return -1; -} - void MockCommandBufferBase::FlushHelper(int32 put_offset) { state_.put_offset = put_offset; } diff --git a/gpu/command_buffer/client/client_test_helper.h b/gpu/command_buffer/client/client_test_helper.h index 25d1014..3302b47 100644 --- a/gpu/command_buffer/client/client_test_helper.h +++ b/gpu/command_buffer/client/client_test_helper.h @@ -32,11 +32,8 @@ class MockCommandBufferBase : public CommandBuffer { virtual State FlushSync(int32 put_offset, int32 last_known_get) OVERRIDE; virtual void SetGetBuffer(int transfer_buffer_id) OVERRIDE; virtual void SetGetOffset(int32 get_offset) OVERRIDE; - virtual int32 CreateTransferBuffer(size_t size, int32 id_request) OVERRIDE; + virtual Buffer CreateTransferBuffer(size_t size, int32* id) OVERRIDE; virtual Buffer GetTransferBuffer(int32 id) OVERRIDE; - virtual int32 RegisterTransferBuffer(base::SharedMemory* shared_memory, - size_t size, - int32 id_request) OVERRIDE; virtual void SetToken(int32 token) OVERRIDE; virtual void SetParseError(error::Error error) OVERRIDE; virtual void SetContextLostReason(error::ContextLostReason reason) OVERRIDE; diff --git a/gpu/command_buffer/client/cmd_buffer_helper.cc b/gpu/command_buffer/client/cmd_buffer_helper.cc index f7d31c5..756abd5 100644 --- a/gpu/command_buffer/client/cmd_buffer_helper.cc +++ b/gpu/command_buffer/client/cmd_buffer_helper.cc @@ -52,18 +52,14 @@ bool CommandBufferHelper::AllocateRingBuffer() { return true; } - int32 id = command_buffer_->CreateTransferBuffer(ring_buffer_size_, -1); + int32 id = -1; + Buffer buffer = command_buffer_->CreateTransferBuffer(ring_buffer_size_, &id); if (id < 0) { ClearUsable(); return false; } - ring_buffer_ = command_buffer_->GetTransferBuffer(id); - if (!ring_buffer_.ptr) { - ClearUsable(); - return false; - } - + ring_buffer_ = buffer; ring_buffer_id_ = id; command_buffer_->SetGetBuffer(id); diff --git a/gpu/command_buffer/client/fenced_allocator_test.cc b/gpu/command_buffer/client/fenced_allocator_test.cc index 44fb851..2c6cdc6 100644 --- a/gpu/command_buffer/client/fenced_allocator_test.cc +++ b/gpu/command_buffer/client/fenced_allocator_test.cc @@ -52,7 +52,7 @@ class BaseFencedAllocatorTest : public testing::Test { } command_buffer_.reset( new CommandBufferService(transfer_buffer_manager_.get())); - command_buffer_->Initialize(); + EXPECT_TRUE(command_buffer_->Initialize()); gpu_scheduler_.reset(new GpuScheduler( command_buffer_.get(), api_mock_.get(), NULL)); diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc index 581981e..6176525 100644 --- a/gpu/command_buffer/client/gles2_implementation_unittest.cc +++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc @@ -103,10 +103,10 @@ class MockTransferBuffer : public TransferBufferInterface { // we need to know their address before GLES2Implementation::Initialize // is called. for (int ii = 0; ii < kNumBuffers; ++ii) { - buffer_ids_[ii] = command_buffer_->CreateTransferBuffer( - size_ + ii * alignment_, -1); + buffers_[ii] = command_buffer_->CreateTransferBuffer( + size_ + ii * alignment_, + &buffer_ids_[ii]); EXPECT_NE(-1, buffer_ids_[ii]); - buffers_[ii] = command_buffer_->GetTransferBuffer(buffer_ids_[ii]); } } diff --git a/gpu/command_buffer/client/mapped_memory.cc b/gpu/command_buffer/client/mapped_memory.cc index c8d400e..5278fc8 100644 --- a/gpu/command_buffer/client/mapped_memory.cc +++ b/gpu/command_buffer/client/mapped_memory.cc @@ -56,11 +56,10 @@ void* MappedMemoryManager::Alloc( unsigned int chunk_size = ((size + chunk_size_multiple_ - 1) / chunk_size_multiple_) * chunk_size_multiple_; - int32 id = cmd_buf->CreateTransferBuffer(chunk_size, -1); - if (id == -1) { + int32 id = -1; + gpu::Buffer shm = cmd_buf->CreateTransferBuffer(chunk_size, &id); + if (id < 0) return NULL; - } - gpu::Buffer shm = cmd_buf->GetTransferBuffer(id); MemoryChunk* mc = new MemoryChunk(id, shm, helper_); chunks_.push_back(mc); void* mem = mc->Alloc(size); diff --git a/gpu/command_buffer/client/transfer_buffer.cc b/gpu/command_buffer/client/transfer_buffer.cc index 7e0b25f..8348622 100644 --- a/gpu/command_buffer/client/transfer_buffer.cc +++ b/gpu/command_buffer/client/transfer_buffer.cc @@ -81,9 +81,11 @@ void TransferBuffer::FreePendingToken(void* p, unsigned int token) { void TransferBuffer::AllocateRingBuffer(unsigned int size) { for (;size >= min_buffer_size_; size /= 2) { - int32 id = helper_->command_buffer()->CreateTransferBuffer(size, -1); + int32 id = -1; + gpu::Buffer buffer = + helper_->command_buffer()->CreateTransferBuffer(size, &id); if (id != -1) { - buffer_ = helper_->command_buffer()->GetTransferBuffer(id); + buffer_ = buffer; ring_buffer_.reset(new AlignedRingBuffer( alignment_, id, diff --git a/gpu/command_buffer/client/transfer_buffer_unittest.cc b/gpu/command_buffer/client/transfer_buffer_unittest.cc index 469483b..f40de23 100644 --- a/gpu/command_buffer/client/transfer_buffer_unittest.cc +++ b/gpu/command_buffer/client/transfer_buffer_unittest.cc @@ -16,6 +16,7 @@ using ::testing::_; using ::testing::Invoke; using ::testing::Return; +using ::testing::SetArgPointee; using ::testing::StrictMock; namespace gpu { @@ -211,10 +212,10 @@ class MockClientCommandBufferCanFail : public MockClientCommandBufferMockFlush { virtual ~MockClientCommandBufferCanFail() { } - MOCK_METHOD2(CreateTransferBuffer, int32(size_t size, int32 id_request)); + MOCK_METHOD2(CreateTransferBuffer, Buffer(size_t size, int32* id)); - int32 RealCreateTransferBuffer(size_t size, int32 id_request) { - return MockCommandBufferBase::CreateTransferBuffer(size, id_request); + Buffer RealCreateTransferBuffer(size_t size, int32* id) { + return MockCommandBufferBase::CreateTransferBuffer(size, id); } }; @@ -372,7 +373,7 @@ TEST_F(TransferBufferExpandContractTest, Contract) { // Try to allocate again, fail first request EXPECT_CALL(*command_buffer(), CreateTransferBuffer(kStartTransferBufferSize, _)) - .WillOnce(Return(-1)) + .WillOnce(DoAll(SetArgPointee<1>(-1), Return(Buffer()))) .RetiresOnSaturation(); EXPECT_CALL(*command_buffer(), CreateTransferBuffer(kMinTransferBufferSize, _)) @@ -424,9 +425,9 @@ TEST_F(TransferBufferExpandContractTest, OutOfMemory) { // Try to allocate again, fail both requests. EXPECT_CALL(*command_buffer(), CreateTransferBuffer(_, _)) - .WillOnce(Return(-1)) - .WillOnce(Return(-1)) - .WillOnce(Return(-1)) + .WillOnce(DoAll(SetArgPointee<1>(-1), Return(Buffer()))) + .WillOnce(DoAll(SetArgPointee<1>(-1), Return(Buffer()))) + .WillOnce(DoAll(SetArgPointee<1>(-1), Return(Buffer()))) .RetiresOnSaturation(); const size_t kSize1 = 512 - kStartingOffset; |