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

Side by Side Diff: gpu/command_buffer/client/mapped_memory_unittest.cc

Issue 8369010: Add GLES2Implemention::FreeUnusedSharedMemory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 2 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
« no previous file with comments | « gpu/command_buffer/client/mapped_memory.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "gpu/command_buffer/client/mapped_memory.h" 5 #include "gpu/command_buffer/client/mapped_memory.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/mac/scoped_nsautorelease_pool.h" 8 #include "base/mac/scoped_nsautorelease_pool.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "gpu/command_buffer/client/cmd_buffer_helper.h" 10 #include "gpu/command_buffer/client/cmd_buffer_helper.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 // Check if we don't free we don't crash. 246 // Check if we don't free we don't crash.
247 TEST_F(MappedMemoryManagerTest, DontFree) { 247 TEST_F(MappedMemoryManagerTest, DontFree) {
248 const unsigned int kSize = 1024; 248 const unsigned int kSize = 1024;
249 // Check we can alloc. 249 // Check we can alloc.
250 int32 id1 = -1; 250 int32 id1 = -1;
251 unsigned int offset1 = 0xFFFFFFFFU; 251 unsigned int offset1 = 0xFFFFFFFFU;
252 void* mem1 = manager_->Alloc(kSize, &id1, &offset1); 252 void* mem1 = manager_->Alloc(kSize, &id1, &offset1);
253 ASSERT_TRUE(mem1); 253 ASSERT_TRUE(mem1);
254 } 254 }
255 255
256 TEST_F(MappedMemoryManagerTest, FreeUnused) {
257 int32 id = -1;
258 unsigned int offset = 0xFFFFFFFFU;
259 void* m1 = manager_->Alloc(kBufferSize, &id, &offset);
260 void* m2 = manager_->Alloc(kBufferSize, &id, &offset);
261 ASSERT_TRUE(m1 != NULL);
262 ASSERT_TRUE(m2 != NULL);
263 EXPECT_EQ(2u, manager_->num_chunks());
264 manager_->FreeUnused();
265 EXPECT_EQ(2u, manager_->num_chunks());
266 manager_->Free(m2);
267 EXPECT_EQ(2u, manager_->num_chunks());
268 manager_->FreeUnused();
269 EXPECT_EQ(1u, manager_->num_chunks());
270 manager_->Free(m1);
271 EXPECT_EQ(1u, manager_->num_chunks());
272 manager_->FreeUnused();
273 EXPECT_EQ(0u, manager_->num_chunks());
274 }
275
256 } // namespace gpu 276 } // namespace gpu
257 277
258 278
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/mapped_memory.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698