Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: trunk/src/gpu/command_buffer/client/buffer_tracker_unittest.cc

Issue 216673006: Revert 260177 "By keeping track of transfer buffer usage (both s..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // Tests for the BufferTracker. 5 // Tests for the BufferTracker.
6 6
7 #include "gpu/command_buffer/client/buffer_tracker.h" 7 #include "gpu/command_buffer/client/buffer_tracker.h"
8 8
9 #include <GLES2/gl2ext.h> 9 #include <GLES2/gl2ext.h>
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 24 matching lines...) Expand all
35 } 35 }
36 36
37 void set_context_lost(bool context_lost) { 37 void set_context_lost(bool context_lost) {
38 context_lost_ = context_lost; 38 context_lost_ = context_lost;
39 } 39 }
40 40
41 private: 41 private:
42 bool context_lost_; 42 bool context_lost_;
43 }; 43 };
44 44
45 namespace {
46 void EmptyPoll() {
47 }
48 }
49
50 class BufferTrackerTest : public testing::Test { 45 class BufferTrackerTest : public testing::Test {
51 protected: 46 protected:
52 static const int32 kNumCommandEntries = 400; 47 static const int32 kNumCommandEntries = 400;
53 static const int32 kCommandBufferSizeBytes = 48 static const int32 kCommandBufferSizeBytes =
54 kNumCommandEntries * sizeof(CommandBufferEntry); 49 kNumCommandEntries * sizeof(CommandBufferEntry);
55 50
56 virtual void SetUp() { 51 virtual void SetUp() {
57 command_buffer_.reset(new MockClientCommandBufferImpl()); 52 command_buffer_.reset(new MockClientCommandBufferImpl());
58 helper_.reset(new GLES2CmdHelper(command_buffer_.get())); 53 helper_.reset(new GLES2CmdHelper(command_buffer_.get()));
59 helper_->Initialize(kCommandBufferSizeBytes); 54 helper_->Initialize(kCommandBufferSizeBytes);
60 mapped_memory_.reset(new MappedMemoryManager( 55 mapped_memory_.reset(new MappedMemoryManager(
61 helper_.get(), base::Bind(&EmptyPoll), MappedMemoryManager::kNoLimit)); 56 helper_.get(), MappedMemoryManager::kNoLimit));
62 buffer_tracker_.reset(new BufferTracker(mapped_memory_.get())); 57 buffer_tracker_.reset(new BufferTracker(mapped_memory_.get()));
63 } 58 }
64 59
65 virtual void TearDown() { 60 virtual void TearDown() {
66 buffer_tracker_.reset(); 61 buffer_tracker_.reset();
67 mapped_memory_.reset(); 62 mapped_memory_.reset();
68 helper_.reset(); 63 helper_.reset();
69 command_buffer_.reset(); 64 command_buffer_.reset();
70 } 65 }
71 66
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // Check mapped memory address. 120 // Check mapped memory address.
126 EXPECT_EQ(64u, buffer->size()); 121 EXPECT_EQ(64u, buffer->size());
127 // Check mapped memory address. 122 // Check mapped memory address.
128 EXPECT_TRUE(buffer->address() == NULL); 123 EXPECT_TRUE(buffer->address() == NULL);
129 // Check no shared memory was allocated. 124 // Check no shared memory was allocated.
130 EXPECT_EQ(0lu, mapped_memory_->num_chunks()); 125 EXPECT_EQ(0lu, mapped_memory_->num_chunks());
131 // Check we can delete the buffer. 126 // Check we can delete the buffer.
132 buffer_tracker_->RemoveBuffer(kId); 127 buffer_tracker_->RemoveBuffer(kId);
133 } 128 }
134 129
135 TEST_F(BufferTrackerTest, Unmanage) {
136 const GLuint kId = 123;
137 const GLsizeiptr size = 64;
138
139 BufferTracker::Buffer* buffer = buffer_tracker_->CreateBuffer(kId, size);
140 ASSERT_TRUE(buffer != NULL);
141 EXPECT_EQ(mapped_memory_->bytes_in_use(), static_cast<size_t>(size));
142
143 void* mem = buffer->address();
144 buffer_tracker_->Unmanage(buffer);
145 buffer_tracker_->RemoveBuffer(kId);
146 EXPECT_EQ(mapped_memory_->bytes_in_use(), static_cast<size_t>(size));
147
148 mapped_memory_->Free(mem);
149 EXPECT_EQ(mapped_memory_->bytes_in_use(), static_cast<size_t>(0));
150 }
151
152 } // namespace gles2 130 } // namespace gles2
153 } // namespace gpu 131 } // namespace gpu
OLDNEW
« no previous file with comments | « trunk/src/gpu/command_buffer/client/buffer_tracker.cc ('k') | trunk/src/gpu/command_buffer/client/cmd_buffer_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698