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

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

Issue 8953006: Free the command buffer when tabs are switched (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years 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) 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/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "gpu/command_buffer/client/cmd_buffer_helper.h" 10 #include "gpu/command_buffer/client/cmd_buffer_helper.h"
(...skipping 29 matching lines...) Expand all
40 EXPECT_CALL(*api_mock_, DoCommand(cmd::kNoop, 0, _)) 40 EXPECT_CALL(*api_mock_, DoCommand(cmd::kNoop, 0, _))
41 .WillRepeatedly(Return(error::kNoError)); 41 .WillRepeatedly(Return(error::kNoError));
42 // Forward the SetToken calls to the engine 42 // Forward the SetToken calls to the engine
43 EXPECT_CALL(*api_mock_.get(), DoCommand(cmd::kSetToken, 1, _)) 43 EXPECT_CALL(*api_mock_.get(), DoCommand(cmd::kSetToken, 1, _))
44 .WillRepeatedly(DoAll(Invoke(api_mock_.get(), &AsyncAPIMock::SetToken), 44 .WillRepeatedly(DoAll(Invoke(api_mock_.get(), &AsyncAPIMock::SetToken),
45 Return(error::kNoError))); 45 Return(error::kNoError)));
46 46
47 command_buffer_.reset(new CommandBufferService); 47 command_buffer_.reset(new CommandBufferService);
48 command_buffer_->Initialize(); 48 command_buffer_->Initialize();
49 49
50 parser_ = new CommandParser(api_mock_.get());
51
52 gpu_scheduler_.reset(new GpuScheduler( 50 gpu_scheduler_.reset(new GpuScheduler(
53 command_buffer_.get(), NULL, parser_)); 51 command_buffer_.get(), api_mock_.get(), NULL));
54 command_buffer_->SetPutOffsetChangeCallback(base::Bind( 52 command_buffer_->SetPutOffsetChangeCallback(base::Bind(
55 &GpuScheduler::PutChanged, base::Unretained(gpu_scheduler_.get()))); 53 &GpuScheduler::PutChanged, base::Unretained(gpu_scheduler_.get())));
54 command_buffer_->SetGetBufferChangeCallback(base::Bind(
55 &GpuScheduler::SetGetBuffer, base::Unretained(gpu_scheduler_.get())));
56 56
57 api_mock_->set_engine(gpu_scheduler_.get()); 57 api_mock_->set_engine(gpu_scheduler_.get());
58 58
59 helper_.reset(new CommandBufferHelper(command_buffer_.get())); 59 helper_.reset(new CommandBufferHelper(command_buffer_.get()));
60 helper_->Initialize(kBufferSize); 60 helper_->Initialize(kBufferSize);
61
62 // Note: parser->SetBuffer would normally be called through
63 // helper_->Initialize but currently it needs a GpuCommandBufferStub as the
64 // CommandBuffer instead of the CommandBufferService for that to happen.
65 Buffer ring_buffer = helper_->get_ring_buffer();
66 parser_->SetBuffer(ring_buffer.ptr, ring_buffer.size, 0, ring_buffer.size);
67 } 61 }
68 62
69 int32 GetToken() { 63 int32 GetToken() {
70 return command_buffer_->GetState().token; 64 return command_buffer_->GetState().token;
71 } 65 }
72 66
73 #if defined(OS_MACOSX) 67 #if defined(OS_MACOSX)
74 base::mac::ScopedNSAutoreleasePool autorelease_pool_; 68 base::mac::ScopedNSAutoreleasePool autorelease_pool_;
75 #endif 69 #endif
76 MessageLoop message_loop_; 70 MessageLoop message_loop_;
77 scoped_ptr<AsyncAPIMock> api_mock_; 71 scoped_ptr<AsyncAPIMock> api_mock_;
78 scoped_ptr<CommandBufferService> command_buffer_; 72 scoped_ptr<CommandBufferService> command_buffer_;
79 scoped_ptr<GpuScheduler> gpu_scheduler_; 73 scoped_ptr<GpuScheduler> gpu_scheduler_;
80 CommandParser* parser_;
81 scoped_ptr<CommandBufferHelper> helper_; 74 scoped_ptr<CommandBufferHelper> helper_;
82 }; 75 };
83 76
84 #ifndef _MSC_VER 77 #ifndef _MSC_VER
85 const unsigned int BaseFencedAllocatorTest::kBufferSize; 78 const unsigned int BaseFencedAllocatorTest::kBufferSize;
86 #endif 79 #endif
87 80
88 // Test fixture for FencedAllocator test - Creates a FencedAllocator, using a 81 // Test fixture for FencedAllocator test - Creates a FencedAllocator, using a
89 // CommandBufferHelper with a mock AsyncAPIInterface for its interface (calling 82 // CommandBufferHelper with a mock AsyncAPIInterface for its interface (calling
90 // it directly, not through the RPC mechanism), making sure Noops are ignored 83 // it directly, not through the RPC mechanism), making sure Noops are ignored
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 EXPECT_LE(token, GetToken()); 518 EXPECT_LE(token, GetToken());
526 519
527 // Free up everything. 520 // Free up everything.
528 for (unsigned int i = 0; i < kAllocCount; ++i) { 521 for (unsigned int i = 0; i < kAllocCount; ++i) {
529 allocator_->Free(pointers[i]); 522 allocator_->Free(pointers[i]);
530 EXPECT_TRUE(allocator_->CheckConsistency()); 523 EXPECT_TRUE(allocator_->CheckConsistency());
531 } 524 }
532 } 525 }
533 526
534 } // namespace gpu 527 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/cmd_buffer_helper_test.cc ('k') | gpu/command_buffer/client/gles2_implementation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698