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

Side by Side Diff: gpu/command_buffer/service/gpu_processor_unittest.cc

Issue 551073: Call xglMakeCurrent for each command buffer to allow for multiple GL contexts... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 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/service/gpu_processor.cc ('k') | gpu/command_buffer/service/x_utils.cc » ('j') | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "base/at_exit.h" 5 #include "base/at_exit.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "gpu/command_buffer/common/command_buffer_mock.h" 7 #include "gpu/command_buffer/common/command_buffer_mock.h"
8 #include "gpu/command_buffer/service/mocks.h" 8 #include "gpu/command_buffer/service/mocks.h"
9 #include "gpu/command_buffer/service/gpu_processor.h" 9 #include "gpu/command_buffer/service/gpu_processor.h"
10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
11 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
13 14
14 using testing::_; 15 using testing::_;
15 using testing::DoAll; 16 using testing::DoAll;
16 using testing::Invoke; 17 using testing::Invoke;
17 using testing::NiceMock; 18 using testing::NiceMock;
18 using testing::Return; 19 using testing::Return;
19 using testing::SetArgumentPointee; 20 using testing::SetArgumentPointee;
20 using testing::StrictMock; 21 using testing::StrictMock;
(...skipping 15 matching lines...) Expand all
36 memset(buffer_, 0, kRingBufferSize); 37 memset(buffer_, 0, kRingBufferSize);
37 38
38 command_buffer_.reset(new MockCommandBuffer); 39 command_buffer_.reset(new MockCommandBuffer);
39 ON_CALL(*command_buffer_.get(), GetRingBuffer()) 40 ON_CALL(*command_buffer_.get(), GetRingBuffer())
40 .WillByDefault(Return(shared_memory_buffer_)); 41 .WillByDefault(Return(shared_memory_buffer_));
41 ON_CALL(*command_buffer_.get(), GetSize()) 42 ON_CALL(*command_buffer_.get(), GetSize())
42 .WillByDefault(Return(kRingBufferEntries)); 43 .WillByDefault(Return(kRingBufferEntries));
43 44
44 async_api_.reset(new StrictMock<AsyncAPIMock>); 45 async_api_.reset(new StrictMock<AsyncAPIMock>);
45 46
46 decoder_ = gles2::GLES2Decoder::Create(); 47 decoder_ = new gles2::MockGLES2Decoder();
47 48
48 parser_ = new CommandParser(buffer_, 49 parser_ = new CommandParser(buffer_,
49 kRingBufferEntries, 50 kRingBufferEntries,
50 0, 51 0,
51 kRingBufferEntries, 52 kRingBufferEntries,
52 0, 53 0,
53 async_api_.get()); 54 async_api_.get());
54 55
55 processor_ = new GPUProcessor(command_buffer_.get(), 56 processor_ = new GPUProcessor(command_buffer_.get(),
56 decoder_, 57 decoder_,
57 parser_, 58 parser_,
58 2); 59 2);
59 } 60 }
60 61
61 virtual void TearDown() { 62 virtual void TearDown() {
62 // Ensure that any unexpected tasks posted by the GPU processor are executed 63 // Ensure that any unexpected tasks posted by the GPU processor are executed
63 // in order to fail the test. 64 // in order to fail the test.
64 MessageLoop::current()->RunAllPending(); 65 MessageLoop::current()->RunAllPending();
65 } 66 }
66 67
67 base::AtExitManager at_exit_manager; 68 base::AtExitManager at_exit_manager;
68 MessageLoop message_loop; 69 MessageLoop message_loop;
69 scoped_ptr<MockCommandBuffer> command_buffer_; 70 scoped_ptr<MockCommandBuffer> command_buffer_;
70 scoped_ptr<::base::SharedMemory> shared_memory_; 71 scoped_ptr<::base::SharedMemory> shared_memory_;
71 Buffer shared_memory_buffer_; 72 Buffer shared_memory_buffer_;
72 int32* buffer_; 73 int32* buffer_;
73 gles2::GLES2Decoder* decoder_; 74 gles2::MockGLES2Decoder* decoder_;
74 CommandParser* parser_; 75 CommandParser* parser_;
75 scoped_ptr<AsyncAPIMock> async_api_; 76 scoped_ptr<AsyncAPIMock> async_api_;
76 scoped_refptr<GPUProcessor> processor_; 77 scoped_refptr<GPUProcessor> processor_;
77 }; 78 };
78 79
79 TEST_F(GPUProcessorTest, ProcessorDoesNothingIfRingBufferIsEmpty) { 80 TEST_F(GPUProcessorTest, ProcessorDoesNothingIfRingBufferIsEmpty) {
80 EXPECT_CALL(*command_buffer_, GetPutOffset()) 81 EXPECT_CALL(*command_buffer_, GetPutOffset())
81 .WillOnce(Return(0)); 82 .WillOnce(Return(0));
82 EXPECT_CALL(*command_buffer_, SetGetOffset(0)); 83 EXPECT_CALL(*command_buffer_, SetGetOffset(0));
83 84
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 123
123 EXPECT_CALL(*async_api_, DoCommand(7, 1, &buffer_[0])) 124 EXPECT_CALL(*async_api_, DoCommand(7, 1, &buffer_[0]))
124 .WillOnce(Return(parse_error::kParseNoError)); 125 .WillOnce(Return(parse_error::kParseNoError));
125 126
126 EXPECT_CALL(*async_api_, DoCommand(8, 0, &buffer_[2])) 127 EXPECT_CALL(*async_api_, DoCommand(8, 0, &buffer_[2]))
127 .WillOnce(Return(parse_error::kParseNoError)); 128 .WillOnce(Return(parse_error::kParseNoError));
128 129
129 processor_->ProcessCommands(); 130 processor_->ProcessCommands();
130 } 131 }
131 132
133 TEST_F(GPUProcessorTest, ProcessorSetsAndResetsTheGLContext) {
134 EXPECT_CALL(*decoder_, MakeCurrent())
135 .WillOnce(Return(true));
136 EXPECT_CALL(*command_buffer_, GetPutOffset())
137 .WillOnce(Return(0));
138 EXPECT_CALL(*command_buffer_, SetGetOffset(0));
139
140 processor_->ProcessCommands();
141 }
142
132 TEST_F(GPUProcessorTest, PostsTaskToFinishRemainingCommands) { 143 TEST_F(GPUProcessorTest, PostsTaskToFinishRemainingCommands) {
133 CommandHeader* header = reinterpret_cast<CommandHeader*>(&buffer_[0]); 144 CommandHeader* header = reinterpret_cast<CommandHeader*>(&buffer_[0]);
134 header[0].command = 7; 145 header[0].command = 7;
135 header[0].size = 2; 146 header[0].size = 2;
136 buffer_[1] = 123; 147 buffer_[1] = 123;
137 header[2].command = 8; 148 header[2].command = 8;
138 header[2].size = 1; 149 header[2].size = 1;
139 header[3].command = 9; 150 header[3].command = 9;
140 header[3].size = 1; 151 header[3].size = 1;
141 152
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 269
259 EXPECT_EQ(kRingBufferSize, processor_->GetSharedMemoryBuffer(7).size); 270 EXPECT_EQ(kRingBufferSize, processor_->GetSharedMemoryBuffer(7).size);
260 } 271 }
261 272
262 TEST_F(GPUProcessorTest, SetTokenForwardsToCommandBuffer) { 273 TEST_F(GPUProcessorTest, SetTokenForwardsToCommandBuffer) {
263 EXPECT_CALL(*command_buffer_, SetToken(7)); 274 EXPECT_CALL(*command_buffer_, SetToken(7));
264 processor_->set_token(7); 275 processor_->set_token(7);
265 } 276 }
266 277
267 } // namespace gpu 278 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gpu_processor.cc ('k') | gpu/command_buffer/service/x_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698