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

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: gn 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 gl_version("2.1"), 152 gl_version("2.1"),
153 has_alpha(false), 153 has_alpha(false),
154 has_depth(false), 154 has_depth(false),
155 has_stencil(false), 155 has_stencil(false),
156 request_alpha(false), 156 request_alpha(false),
157 request_depth(false), 157 request_depth(false),
158 request_stencil(false), 158 request_stencil(false),
159 bind_generates_resource(false), 159 bind_generates_resource(false),
160 lose_context_when_out_of_memory(false), 160 lose_context_when_out_of_memory(false),
161 use_native_vao(true), 161 use_native_vao(true),
162 webgl_version(0) { 162 context_type(ContextCreationAttribHelper::CONTEXT_TYPE_OPENGLES2) {}
163 }
164 163
165 void GLES2DecoderTestBase::InitDecoder(const InitState& init) { 164 void GLES2DecoderTestBase::InitDecoder(const InitState& init) {
166 InitDecoderWithCommandLine(init, NULL); 165 InitDecoderWithCommandLine(init, NULL);
167 } 166 }
168 167
169 void GLES2DecoderTestBase::InitDecoderWithCommandLine( 168 void GLES2DecoderTestBase::InitDecoderWithCommandLine(
170 const InitState& init, 169 const InitState& init,
171 const base::CommandLine* command_line) { 170 const base::CommandLine* command_line) {
172 InitState normalized_init = init; 171 InitState normalized_init = init;
173 NormalizeInitState(&normalized_init); 172 NormalizeInitState(&normalized_init);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // We initialize the ContextGroup with a MockGLES2Decoder so that 216 // We initialize the ContextGroup with a MockGLES2Decoder so that
218 // we can use the ContextGroup to figure out how the real GLES2Decoder 217 // we can use the ContextGroup to figure out how the real GLES2Decoder
219 // will initialize itself. 218 // will initialize itself.
220 mock_decoder_.reset(new MockGLES2Decoder()); 219 mock_decoder_.reset(new MockGLES2Decoder());
221 220
222 // Install FakeDoCommands handler so we can use individual DoCommand() 221 // Install FakeDoCommands handler so we can use individual DoCommand()
223 // expectations. 222 // expectations.
224 EXPECT_CALL(*mock_decoder_, DoCommands(_, _, _, _)).WillRepeatedly( 223 EXPECT_CALL(*mock_decoder_, DoCommands(_, _, _, _)).WillRepeatedly(
225 Invoke(mock_decoder_.get(), &MockGLES2Decoder::FakeDoCommands)); 224 Invoke(mock_decoder_.get(), &MockGLES2Decoder::FakeDoCommands));
226 225
226 ContextGroup::ContextType context_type;
227 switch (init.context_type) {
228 case ContextCreationAttribHelper::CONTEXT_TYPE_WEBGL1:
229 context_type = ContextGroup::CONTEXT_TYPE_WEBGL1;
230 break;
231 case ContextCreationAttribHelper::CONTEXT_TYPE_WEBGL2:
232 context_type = ContextGroup::CONTEXT_TYPE_WEBGL2;
233 break;
234 default:
Zhenyao Mo 2015/08/28 17:16:25 nit: move default to the last.
235 NOTREACHED();
236 case ContextCreationAttribHelper::CONTEXT_TYPE_OPENGLES2:
237 context_type = ContextGroup::CONTEXT_TYPE_OPENGLES2;
238 break;
239 case ContextCreationAttribHelper::CONTEXT_TYPE_OPENGLES3:
240 context_type = ContextGroup::CONTEXT_TYPE_OPENGLES3;
241 break;
242 }
227 243
228 EXPECT_TRUE(group_->Initialize( 244 EXPECT_TRUE(group_->Initialize(mock_decoder_.get(), context_type,
229 mock_decoder_.get(), 245 DisallowedFeatures()));
230 ContextGroup::GetContextType(init.webgl_version),
231 DisallowedFeatures()));
232 246
233 if (init.webgl_version == 2) { 247 if (context_type == ContextGroup::CONTEXT_TYPE_WEBGL2 ||
248 context_type == ContextGroup::CONTEXT_TYPE_OPENGLES3) {
234 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_COLOR_ATTACHMENTS, _)) 249 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_COLOR_ATTACHMENTS, _))
235 .WillOnce(SetArgumentPointee<1>(kMaxColorAttachments)) 250 .WillOnce(SetArgumentPointee<1>(kMaxColorAttachments))
236 .RetiresOnSaturation(); 251 .RetiresOnSaturation();
237 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_DRAW_BUFFERS, _)) 252 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_DRAW_BUFFERS, _))
238 .WillOnce(SetArgumentPointee<1>(kMaxDrawBuffers)) 253 .WillOnce(SetArgumentPointee<1>(kMaxDrawBuffers))
239 .RetiresOnSaturation(); 254 .RetiresOnSaturation();
240 } 255 }
241 256
242 if (group_->feature_info()->feature_flags().native_vertex_array_object) { 257 if (group_->feature_info()->feature_flags().native_vertex_array_object) {
243 EXPECT_CALL(*gl_, GenVertexArraysOES(1, _)) 258 EXPECT_CALL(*gl_, GenVertexArraysOES(1, _))
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 engine_->GetSharedMemoryBuffer(kSharedMemoryId); 410 engine_->GetSharedMemoryBuffer(kSharedMemoryId);
396 shared_memory_offset_ = kSharedMemoryOffset; 411 shared_memory_offset_ = kSharedMemoryOffset;
397 shared_memory_address_ = 412 shared_memory_address_ =
398 reinterpret_cast<int8*>(buffer->memory()) + shared_memory_offset_; 413 reinterpret_cast<int8*>(buffer->memory()) + shared_memory_offset_;
399 shared_memory_id_ = kSharedMemoryId; 414 shared_memory_id_ = kSharedMemoryId;
400 shared_memory_base_ = buffer->memory(); 415 shared_memory_base_ = buffer->memory();
401 416
402 static const int32 kLoseContextWhenOutOfMemory = 0x10002; 417 static const int32 kLoseContextWhenOutOfMemory = 0x10002;
403 static const int32 kWebGLVersion = 0x10003; 418 static const int32 kWebGLVersion = 0x10003;
404 419
405 int32 attributes[] = { 420 int32 attributes[] = {EGL_ALPHA_SIZE,
406 EGL_ALPHA_SIZE, 421 normalized_init.request_alpha ? 8 : 0,
407 normalized_init.request_alpha ? 8 : 0, 422 EGL_DEPTH_SIZE,
408 EGL_DEPTH_SIZE, 423 normalized_init.request_depth ? 24 : 0,
409 normalized_init.request_depth ? 24 : 0, 424 EGL_STENCIL_SIZE,
410 EGL_STENCIL_SIZE, 425 normalized_init.request_stencil ? 8 : 0,
411 normalized_init.request_stencil ? 8 : 0, 426 kLoseContextWhenOutOfMemory,
412 kLoseContextWhenOutOfMemory, 427 normalized_init.lose_context_when_out_of_memory ? 1 : 0,
413 normalized_init.lose_context_when_out_of_memory ? 1 : 0, 428 kWebGLVersion,
414 kWebGLVersion, 429 init.context_type};
415 init.webgl_version
416 };
417 std::vector<int32> attribs(attributes, attributes + arraysize(attributes)); 430 std::vector<int32> attribs(attributes, attributes + arraysize(attributes));
418 431
419 decoder_.reset(GLES2Decoder::Create(group_.get())); 432 decoder_.reset(GLES2Decoder::Create(group_.get()));
420 decoder_->SetIgnoreCachedStateForTest(ignore_cached_state_for_test_); 433 decoder_->SetIgnoreCachedStateForTest(ignore_cached_state_for_test_);
421 decoder_->GetLogger()->set_log_synthesized_gl_errors(false); 434 decoder_->GetLogger()->set_log_synthesized_gl_errors(false);
422 decoder_->Initialize(surface_, 435 ASSERT_TRUE(decoder_->Initialize(surface_, context_, false,
423 context_, 436 surface_->GetSize(), DisallowedFeatures(),
424 false, 437 attribs));
425 surface_->GetSize(), 438
426 DisallowedFeatures(),
427 attribs);
428 EXPECT_CALL(*context_, MakeCurrent(surface_.get())).WillOnce(Return(true)); 439 EXPECT_CALL(*context_, MakeCurrent(surface_.get())).WillOnce(Return(true));
429 if (context_->WasAllocatedUsingRobustnessExtension()) { 440 if (context_->WasAllocatedUsingRobustnessExtension()) {
430 EXPECT_CALL(*gl_, GetGraphicsResetStatusARB()) 441 EXPECT_CALL(*gl_, GetGraphicsResetStatusARB())
431 .WillOnce(Return(GL_NO_ERROR)); 442 .WillOnce(Return(GL_NO_ERROR));
432 } 443 }
433 decoder_->MakeCurrent(); 444 decoder_->MakeCurrent();
434 decoder_->set_engine(engine_.get()); 445 decoder_->set_engine(engine_.get());
435 decoder_->BeginDecoding(); 446 decoder_->BeginDecoding();
436 447
437 EXPECT_CALL(*gl_, GenBuffersARB(_, _)) 448 EXPECT_CALL(*gl_, GenBuffersARB(_, _))
(...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1832 SetupDefaultProgram(); 1843 SetupDefaultProgram();
1833 } 1844 }
1834 1845
1835 // Include the auto-generated part of this file. We split this because it means 1846 // Include the auto-generated part of this file. We split this because it means
1836 // we can easily edit the non-auto generated parts right here in this file 1847 // we can easily edit the non-auto generated parts right here in this file
1837 // instead of having to edit some template or the code generator. 1848 // instead of having to edit some template or the code generator.
1838 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h" 1849 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h"
1839 1850
1840 } // namespace gles2 1851 } // namespace gles2
1841 } // namespace gpu 1852 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698