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

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

Issue 1325433003: command_buffer: Add support for creating non-WebGL ES 3 contexts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: missing hunk Created 5 years, 3 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
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 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 gl_version("2.1"), 153 gl_version("2.1"),
154 has_alpha(false), 154 has_alpha(false),
155 has_depth(false), 155 has_depth(false),
156 has_stencil(false), 156 has_stencil(false),
157 request_alpha(false), 157 request_alpha(false),
158 request_depth(false), 158 request_depth(false),
159 request_stencil(false), 159 request_stencil(false),
160 bind_generates_resource(false), 160 bind_generates_resource(false),
161 lose_context_when_out_of_memory(false), 161 lose_context_when_out_of_memory(false),
162 use_native_vao(true), 162 use_native_vao(true),
163 webgl_version(0) { 163 context_type(CONTEXT_TYPE_OPENGLES2) {}
164 }
165 164
166 void GLES2DecoderTestBase::InitDecoder(const InitState& init) { 165 void GLES2DecoderTestBase::InitDecoder(const InitState& init) {
167 InitDecoderWithCommandLine(init, NULL); 166 InitDecoderWithCommandLine(init, NULL);
168 } 167 }
169 168
170 void GLES2DecoderTestBase::InitDecoderWithCommandLine( 169 void GLES2DecoderTestBase::InitDecoderWithCommandLine(
171 const InitState& init, 170 const InitState& init,
172 const base::CommandLine* command_line) { 171 const base::CommandLine* command_line) {
173 InitState normalized_init = init; 172 InitState normalized_init = init;
174 NormalizeInitState(&normalized_init); 173 NormalizeInitState(&normalized_init);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 // We initialize the ContextGroup with a MockGLES2Decoder so that 217 // We initialize the ContextGroup with a MockGLES2Decoder so that
219 // we can use the ContextGroup to figure out how the real GLES2Decoder 218 // we can use the ContextGroup to figure out how the real GLES2Decoder
220 // will initialize itself. 219 // will initialize itself.
221 mock_decoder_.reset(new MockGLES2Decoder()); 220 mock_decoder_.reset(new MockGLES2Decoder());
222 221
223 // Install FakeDoCommands handler so we can use individual DoCommand() 222 // Install FakeDoCommands handler so we can use individual DoCommand()
224 // expectations. 223 // expectations.
225 EXPECT_CALL(*mock_decoder_, DoCommands(_, _, _, _)).WillRepeatedly( 224 EXPECT_CALL(*mock_decoder_, DoCommands(_, _, _, _)).WillRepeatedly(
226 Invoke(mock_decoder_.get(), &MockGLES2Decoder::FakeDoCommands)); 225 Invoke(mock_decoder_.get(), &MockGLES2Decoder::FakeDoCommands));
227 226
227 EXPECT_TRUE(group_->Initialize(mock_decoder_.get(), init.context_type,
228 DisallowedFeatures()));
228 229
229 EXPECT_TRUE(group_->Initialize( 230 if (init.context_type == CONTEXT_TYPE_WEBGL2 ||
230 mock_decoder_.get(), 231 init.context_type == CONTEXT_TYPE_OPENGLES3) {
231 ContextGroup::GetContextType(init.webgl_version),
232 DisallowedFeatures()));
233
234 if (init.webgl_version == 2) {
235 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_COLOR_ATTACHMENTS, _)) 232 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_COLOR_ATTACHMENTS, _))
236 .WillOnce(SetArgumentPointee<1>(kMaxColorAttachments)) 233 .WillOnce(SetArgumentPointee<1>(kMaxColorAttachments))
237 .RetiresOnSaturation(); 234 .RetiresOnSaturation();
238 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_DRAW_BUFFERS, _)) 235 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_DRAW_BUFFERS, _))
239 .WillOnce(SetArgumentPointee<1>(kMaxDrawBuffers)) 236 .WillOnce(SetArgumentPointee<1>(kMaxDrawBuffers))
240 .RetiresOnSaturation(); 237 .RetiresOnSaturation();
241 } 238 }
242 239
243 if (group_->feature_info()->feature_flags().native_vertex_array_object) { 240 if (group_->feature_info()->feature_flags().native_vertex_array_object) {
244 EXPECT_CALL(*gl_, GenVertexArraysOES(1, _)) 241 EXPECT_CALL(*gl_, GenVertexArraysOES(1, _))
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 engine_->GetSharedMemoryBuffer(kSharedMemoryId); 393 engine_->GetSharedMemoryBuffer(kSharedMemoryId);
397 shared_memory_offset_ = kSharedMemoryOffset; 394 shared_memory_offset_ = kSharedMemoryOffset;
398 shared_memory_address_ = 395 shared_memory_address_ =
399 reinterpret_cast<int8*>(buffer->memory()) + shared_memory_offset_; 396 reinterpret_cast<int8*>(buffer->memory()) + shared_memory_offset_;
400 shared_memory_id_ = kSharedMemoryId; 397 shared_memory_id_ = kSharedMemoryId;
401 shared_memory_base_ = buffer->memory(); 398 shared_memory_base_ = buffer->memory();
402 399
403 static const int32 kLoseContextWhenOutOfMemory = 0x10002; 400 static const int32 kLoseContextWhenOutOfMemory = 0x10002;
404 static const int32 kWebGLVersion = 0x10003; 401 static const int32 kWebGLVersion = 0x10003;
405 402
406 int32 attributes[] = { 403 int32 attributes[] = {EGL_ALPHA_SIZE,
407 EGL_ALPHA_SIZE, 404 normalized_init.request_alpha ? 8 : 0,
408 normalized_init.request_alpha ? 8 : 0, 405 EGL_DEPTH_SIZE,
409 EGL_DEPTH_SIZE, 406 normalized_init.request_depth ? 24 : 0,
410 normalized_init.request_depth ? 24 : 0, 407 EGL_STENCIL_SIZE,
411 EGL_STENCIL_SIZE, 408 normalized_init.request_stencil ? 8 : 0,
412 normalized_init.request_stencil ? 8 : 0, 409 kLoseContextWhenOutOfMemory,
413 kLoseContextWhenOutOfMemory, 410 normalized_init.lose_context_when_out_of_memory ? 1 : 0,
414 normalized_init.lose_context_when_out_of_memory ? 1 : 0, 411 kWebGLVersion,
415 kWebGLVersion, 412 init.context_type};
416 init.webgl_version
417 };
418 std::vector<int32> attribs(attributes, attributes + arraysize(attributes)); 413 std::vector<int32> attribs(attributes, attributes + arraysize(attributes));
419 414
420 decoder_.reset(GLES2Decoder::Create(group_.get())); 415 decoder_.reset(GLES2Decoder::Create(group_.get()));
421 decoder_->SetIgnoreCachedStateForTest(ignore_cached_state_for_test_); 416 decoder_->SetIgnoreCachedStateForTest(ignore_cached_state_for_test_);
422 decoder_->GetLogger()->set_log_synthesized_gl_errors(false); 417 decoder_->GetLogger()->set_log_synthesized_gl_errors(false);
423 decoder_->Initialize(surface_, 418 ASSERT_TRUE(decoder_->Initialize(surface_, context_, false,
424 context_, 419 surface_->GetSize(), DisallowedFeatures(),
425 false, 420 attribs));
426 surface_->GetSize(), 421
427 DisallowedFeatures(),
428 attribs);
429 EXPECT_CALL(*context_, MakeCurrent(surface_.get())).WillOnce(Return(true)); 422 EXPECT_CALL(*context_, MakeCurrent(surface_.get())).WillOnce(Return(true));
430 if (context_->WasAllocatedUsingRobustnessExtension()) { 423 if (context_->WasAllocatedUsingRobustnessExtension()) {
431 EXPECT_CALL(*gl_, GetGraphicsResetStatusARB()) 424 EXPECT_CALL(*gl_, GetGraphicsResetStatusARB())
432 .WillOnce(Return(GL_NO_ERROR)); 425 .WillOnce(Return(GL_NO_ERROR));
433 } 426 }
434 decoder_->MakeCurrent(); 427 decoder_->MakeCurrent();
435 decoder_->set_engine(engine_.get()); 428 decoder_->set_engine(engine_.get());
436 decoder_->BeginDecoding(); 429 decoder_->BeginDecoding();
437 430
438 EXPECT_CALL(*gl_, GenBuffersARB(_, _)) 431 EXPECT_CALL(*gl_, GenBuffersARB(_, _))
(...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1904 SetupDefaultProgram(); 1897 SetupDefaultProgram();
1905 } 1898 }
1906 1899
1907 // Include the auto-generated part of this file. We split this because it means 1900 // Include the auto-generated part of this file. We split this because it means
1908 // we can easily edit the non-auto generated parts right here in this file 1901 // we can easily edit the non-auto generated parts right here in this file
1909 // instead of having to edit some template or the code generator. 1902 // instead of having to edit some template or the code generator.
1910 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h" 1903 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h"
1911 1904
1912 } // namespace gles2 1905 } // namespace gles2
1913 } // namespace gpu 1906 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h ('k') | gpu/command_buffer/service/texture_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698