OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "gpu/command_buffer/client/mapped_memory.h" | 5 #include "gpu/command_buffer/client/mapped_memory.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // CommandBufferHelper with a mock AsyncAPIInterface for its interface (calling | 95 // CommandBufferHelper with a mock AsyncAPIInterface for its interface (calling |
96 // it directly, not through the RPC mechanism), making sure Noops are ignored | 96 // it directly, not through the RPC mechanism), making sure Noops are ignored |
97 // and SetToken are properly forwarded to the engine. | 97 // and SetToken are properly forwarded to the engine. |
98 class MemoryChunkTest : public MappedMemoryTestBase { | 98 class MemoryChunkTest : public MappedMemoryTestBase { |
99 protected: | 99 protected: |
100 static const int32 kShmId = 123; | 100 static const int32 kShmId = 123; |
101 virtual void SetUp() { | 101 virtual void SetUp() { |
102 MappedMemoryTestBase::SetUp(); | 102 MappedMemoryTestBase::SetUp(); |
103 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory()); | 103 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory()); |
104 shared_memory->CreateAndMapAnonymous(kBufferSize); | 104 shared_memory->CreateAndMapAnonymous(kBufferSize); |
105 buffer_ = new gpu::Buffer(shared_memory.Pass(), kBufferSize); | 105 buffer_ = MakeBufferFromSharedMemory(shared_memory.Pass(), kBufferSize); |
106 chunk_.reset(new MemoryChunk(kShmId, | 106 chunk_.reset(new MemoryChunk(kShmId, |
107 buffer_, | 107 buffer_, |
108 helper_.get(), | 108 helper_.get(), |
109 base::Bind(&EmptyPoll))); | 109 base::Bind(&EmptyPoll))); |
110 } | 110 } |
111 | 111 |
112 virtual void TearDown() { | 112 virtual void TearDown() { |
113 // If the GpuScheduler posts any tasks, this forces them to run. | 113 // If the GpuScheduler posts any tasks, this forces them to run. |
114 base::MessageLoop::current()->RunUntilIdle(); | 114 base::MessageLoop::current()->RunUntilIdle(); |
115 | 115 |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 unsigned int offset3; | 447 unsigned int offset3; |
448 void* mem3 = manager_->Alloc(kSize, &id3, &offset3); | 448 void* mem3 = manager_->Alloc(kSize, &id3, &offset3); |
449 EXPECT_EQ(manager_->bytes_in_use(), kSize * 2); | 449 EXPECT_EQ(manager_->bytes_in_use(), kSize * 2); |
450 | 450 |
451 manager_->Free(mem2); | 451 manager_->Free(mem2); |
452 manager_->Free(mem3); | 452 manager_->Free(mem3); |
453 EXPECT_EQ(manager_->bytes_in_use(), static_cast<size_t>(0)); | 453 EXPECT_EQ(manager_->bytes_in_use(), static_cast<size_t>(0)); |
454 } | 454 } |
455 | 455 |
456 } // namespace gpu | 456 } // namespace gpu |
OLD | NEW |