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

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

Issue 1998723002: Move code in ui/gl/* from gfx:: to gl:: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 10 matching lines...) Expand all
21 #include "gpu/command_buffer/service/logger.h" 21 #include "gpu/command_buffer/service/logger.h"
22 #include "gpu/command_buffer/service/mailbox_manager.h" 22 #include "gpu/command_buffer/service/mailbox_manager.h"
23 #include "gpu/command_buffer/service/program_manager.h" 23 #include "gpu/command_buffer/service/program_manager.h"
24 #include "gpu/command_buffer/service/test_helper.h" 24 #include "gpu/command_buffer/service/test_helper.h"
25 #include "gpu/command_buffer/service/vertex_attrib_manager.h" 25 #include "gpu/command_buffer/service/vertex_attrib_manager.h"
26 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
27 #include "ui/gl/gl_implementation.h" 27 #include "ui/gl/gl_implementation.h"
28 #include "ui/gl/gl_mock.h" 28 #include "ui/gl/gl_mock.h"
29 #include "ui/gl/test/gl_surface_test_support.h" 29 #include "ui/gl/test/gl_surface_test_support.h"
30 30
31 using ::gfx::MockGLInterface; 31 using ::gl::MockGLInterface;
32 using ::testing::_; 32 using ::testing::_;
33 using ::testing::AnyNumber; 33 using ::testing::AnyNumber;
34 using ::testing::AtMost; 34 using ::testing::AtMost;
35 using ::testing::DoAll; 35 using ::testing::DoAll;
36 using ::testing::InSequence; 36 using ::testing::InSequence;
37 using ::testing::Invoke; 37 using ::testing::Invoke;
38 using ::testing::InvokeWithoutArgs; 38 using ::testing::InvokeWithoutArgs;
39 using ::testing::MatcherCast; 39 using ::testing::MatcherCast;
40 using ::testing::Pointee; 40 using ::testing::Pointee;
41 using ::testing::Return; 41 using ::testing::Return;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 173 }
174 174
175 void GLES2DecoderTestBase::InitDecoderWithCommandLine( 175 void GLES2DecoderTestBase::InitDecoderWithCommandLine(
176 const InitState& init, 176 const InitState& init,
177 const base::CommandLine* command_line) { 177 const base::CommandLine* command_line) {
178 InitState normalized_init = init; 178 InitState normalized_init = init;
179 NormalizeInitState(&normalized_init); 179 NormalizeInitState(&normalized_init);
180 // For easier substring/extension matching 180 // For easier substring/extension matching
181 DCHECK(normalized_init.extensions.empty() || 181 DCHECK(normalized_init.extensions.empty() ||
182 *normalized_init.extensions.rbegin() == ' '); 182 *normalized_init.extensions.rbegin() == ' ');
183 gfx::SetGLGetProcAddressProc(gfx::MockGLInterface::GetGLProcAddress); 183 gl::SetGLGetProcAddressProc(gl::MockGLInterface::GetGLProcAddress);
184 gfx::GLSurfaceTestSupport::InitializeOneOffWithMockBindings(); 184 gl::GLSurfaceTestSupport::InitializeOneOffWithMockBindings();
185 185
186 gl_.reset(new StrictMock<MockGLInterface>()); 186 gl_.reset(new StrictMock<MockGLInterface>());
187 ::gfx::MockGLInterface::SetGLInterface(gl_.get()); 187 ::gl::MockGLInterface::SetGLInterface(gl_.get());
188 188
189 SetupMockGLBehaviors(); 189 SetupMockGLBehaviors();
190 190
191 scoped_refptr<FeatureInfo> feature_info = new FeatureInfo; 191 scoped_refptr<FeatureInfo> feature_info = new FeatureInfo;
192 if (command_line) { 192 if (command_line) {
193 GpuDriverBugWorkarounds gpu_driver_bug_workaround(command_line); 193 GpuDriverBugWorkarounds gpu_driver_bug_workaround(command_line);
194 feature_info = new FeatureInfo(*command_line, gpu_driver_bug_workaround); 194 feature_info = new FeatureInfo(*command_line, gpu_driver_bug_workaround);
195 } 195 }
196 196
197 group_ = scoped_refptr<ContextGroup>(new ContextGroup( 197 group_ = scoped_refptr<ContextGroup>(new ContextGroup(
198 gpu_preferences_, NULL, memory_tracker_, 198 gpu_preferences_, NULL, memory_tracker_,
199 new ShaderTranslatorCache(gpu_preferences_), 199 new ShaderTranslatorCache(gpu_preferences_),
200 new FramebufferCompletenessCache, feature_info, 200 new FramebufferCompletenessCache, feature_info,
201 normalized_init.bind_generates_resource)); 201 normalized_init.bind_generates_resource));
202 bool use_default_textures = normalized_init.bind_generates_resource; 202 bool use_default_textures = normalized_init.bind_generates_resource;
203 203
204 InSequence sequence; 204 InSequence sequence;
205 205
206 surface_ = new gfx::GLSurfaceStub; 206 surface_ = new gl::GLSurfaceStub;
207 surface_->SetSize(gfx::Size(kBackBufferWidth, kBackBufferHeight)); 207 surface_->SetSize(gfx::Size(kBackBufferWidth, kBackBufferHeight));
208 208
209 // Context needs to be created before initializing ContextGroup, which will 209 // Context needs to be created before initializing ContextGroup, which will
210 // in turn initialize FeatureInfo, which needs a context to determine 210 // in turn initialize FeatureInfo, which needs a context to determine
211 // extension support. 211 // extension support.
212 context_ = new StrictMock<GLContextMock>(); 212 context_ = new StrictMock<GLContextMock>();
213 context_->AddExtensionsString(normalized_init.extensions.c_str()); 213 context_->AddExtensionsString(normalized_init.extensions.c_str());
214 context_->SetGLVersionString(normalized_init.gl_version.c_str()); 214 context_->SetGLVersionString(normalized_init.gl_version.c_str());
215 215
216 context_->GLContextStubWithExtensions::MakeCurrent(surface_.get()); 216 context_->GLContextStubWithExtensions::MakeCurrent(surface_.get());
217 gfx::GLSurfaceTestSupport::InitializeDynamicMockBindings(context_.get()); 217 gl::GLSurfaceTestSupport::InitializeDynamicMockBindings(context_.get());
218 218
219 TestHelper::SetupContextGroupInitExpectations( 219 TestHelper::SetupContextGroupInitExpectations(
220 gl_.get(), 220 gl_.get(),
221 DisallowedFeatures(), 221 DisallowedFeatures(),
222 normalized_init.extensions.c_str(), 222 normalized_init.extensions.c_str(),
223 normalized_init.gl_version.c_str(), 223 normalized_init.gl_version.c_str(),
224 normalized_init.bind_generates_resource); 224 normalized_init.bind_generates_resource);
225 225
226 // We initialize the ContextGroup with a MockGLES2Decoder so that 226 // We initialize the ContextGroup with a MockGLES2Decoder so that
227 // we can use the ContextGroup to figure out how the real GLES2Decoder 227 // we can use the ContextGroup to figure out how the real GLES2Decoder
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 DoCreateProgram(client_program_id_, kServiceProgramId); 505 DoCreateProgram(client_program_id_, kServiceProgramId);
506 DoCreateShader(GL_VERTEX_SHADER, client_shader_id_, kServiceShaderId); 506 DoCreateShader(GL_VERTEX_SHADER, client_shader_id_, kServiceShaderId);
507 507
508 // Unsafe commands. 508 // Unsafe commands.
509 bool reset_unsafe_es3_apis_enabled = false; 509 bool reset_unsafe_es3_apis_enabled = false;
510 if (!decoder_->unsafe_es3_apis_enabled()) { 510 if (!decoder_->unsafe_es3_apis_enabled()) {
511 decoder_->set_unsafe_es3_apis_enabled(true); 511 decoder_->set_unsafe_es3_apis_enabled(true);
512 reset_unsafe_es3_apis_enabled = true; 512 reset_unsafe_es3_apis_enabled = true;
513 } 513 }
514 514
515 const gfx::GLVersionInfo* version = context_->GetVersionInfo(); 515 const gl::GLVersionInfo* version = context_->GetVersionInfo();
516 if (version->IsAtLeastGL(3, 3) || version->IsAtLeastGLES(3, 0)) { 516 if (version->IsAtLeastGL(3, 3) || version->IsAtLeastGLES(3, 0)) {
517 EXPECT_CALL(*gl_, GenSamplers(_, _)) 517 EXPECT_CALL(*gl_, GenSamplers(_, _))
518 .WillOnce(SetArgumentPointee<1>(kServiceSamplerId)) 518 .WillOnce(SetArgumentPointee<1>(kServiceSamplerId))
519 .RetiresOnSaturation(); 519 .RetiresOnSaturation();
520 GenHelper<cmds::GenSamplersImmediate>(client_sampler_id_); 520 GenHelper<cmds::GenSamplersImmediate>(client_sampler_id_);
521 } 521 }
522 if (version->IsAtLeastGL(4, 0) || version->IsAtLeastGLES(3, 0)) { 522 if (version->IsAtLeastGL(4, 0) || version->IsAtLeastGLES(3, 0)) {
523 EXPECT_CALL(*gl_, GenTransformFeedbacks(_, _)) 523 EXPECT_CALL(*gl_, GenTransformFeedbacks(_, _))
524 .WillOnce(SetArgumentPointee<1>(kServiceTransformFeedbackId)) 524 .WillOnce(SetArgumentPointee<1>(kServiceTransformFeedbackId))
525 .RetiresOnSaturation(); 525 .RetiresOnSaturation();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 .Times(1) 565 .Times(1)
566 .RetiresOnSaturation(); 566 .RetiresOnSaturation();
567 } 567 }
568 } 568 }
569 569
570 decoder_->EndDecoding(); 570 decoder_->EndDecoding();
571 decoder_->Destroy(!decoder_->WasContextLost()); 571 decoder_->Destroy(!decoder_->WasContextLost());
572 decoder_.reset(); 572 decoder_.reset();
573 group_->Destroy(mock_decoder_.get(), false); 573 group_->Destroy(mock_decoder_.get(), false);
574 engine_.reset(); 574 engine_.reset();
575 ::gfx::MockGLInterface::SetGLInterface(NULL); 575 ::gl::MockGLInterface::SetGLInterface(NULL);
576 gl_.reset(); 576 gl_.reset();
577 gfx::ClearGLBindings(); 577 gl::ClearGLBindings();
578 } 578 }
579 579
580 void GLES2DecoderTestBase::TearDown() { 580 void GLES2DecoderTestBase::TearDown() {
581 ResetDecoder(); 581 ResetDecoder();
582 } 582 }
583 583
584 void GLES2DecoderTestBase::ExpectEnableDisable(GLenum cap, bool enable) { 584 void GLES2DecoderTestBase::ExpectEnableDisable(GLenum cap, bool enable) {
585 if (enable) { 585 if (enable) {
586 EXPECT_CALL(*gl_, Enable(cap)) 586 EXPECT_CALL(*gl_, Enable(cap))
587 .Times(1) 587 .Times(1)
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 1472
1473 EXPECT_CALL(*gl_, VertexAttribDivisorANGLE(attrib, _)) 1473 EXPECT_CALL(*gl_, VertexAttribDivisorANGLE(attrib, _))
1474 .Times(testing::AtMost(1)) 1474 .Times(testing::AtMost(1))
1475 .RetiresOnSaturation(); 1475 .RetiresOnSaturation();
1476 1476
1477 EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER, _)) 1477 EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER, _))
1478 .Times(1) 1478 .Times(1)
1479 .RetiresOnSaturation(); 1479 .RetiresOnSaturation();
1480 1480
1481 if (attrib != 0 || 1481 if (attrib != 0 ||
1482 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { 1482 gl::GetGLImplementation() == gl::kGLImplementationEGLGLES2) {
1483 // TODO(bajones): Not sure if I can tell which of these will be called
1484 EXPECT_CALL(*gl_, EnableVertexAttribArray(attrib))
1485 .Times(testing::AtMost(1))
1486 .RetiresOnSaturation();
1483 1487
1484 // TODO(bajones): Not sure if I can tell which of these will be called 1488 EXPECT_CALL(*gl_, DisableVertexAttribArray(attrib))
1485 EXPECT_CALL(*gl_, EnableVertexAttribArray(attrib)) 1489 .Times(testing::AtMost(1))
1486 .Times(testing::AtMost(1)) 1490 .RetiresOnSaturation();
1487 .RetiresOnSaturation();
1488
1489 EXPECT_CALL(*gl_, DisableVertexAttribArray(attrib))
1490 .Times(testing::AtMost(1))
1491 .RetiresOnSaturation();
1492 } 1491 }
1493 } 1492 }
1494 1493
1495 // GCC requires these declarations, but MSVC requires they not be present 1494 // GCC requires these declarations, but MSVC requires they not be present
1496 #ifndef COMPILER_MSVC 1495 #ifndef COMPILER_MSVC
1497 const int GLES2DecoderTestBase::kBackBufferWidth; 1496 const int GLES2DecoderTestBase::kBackBufferWidth;
1498 const int GLES2DecoderTestBase::kBackBufferHeight; 1497 const int GLES2DecoderTestBase::kBackBufferHeight;
1499 1498
1500 const GLint GLES2DecoderTestBase::kMaxTextureSize; 1499 const GLint GLES2DecoderTestBase::kMaxTextureSize;
1501 const GLint GLES2DecoderTestBase::kMaxCubeMapTextureSize; 1500 const GLint GLES2DecoderTestBase::kMaxCubeMapTextureSize;
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
2081 SetupDefaultProgram(); 2080 SetupDefaultProgram();
2082 } 2081 }
2083 2082
2084 // Include the auto-generated part of this file. We split this because it means 2083 // Include the auto-generated part of this file. We split this because it means
2085 // we can easily edit the non-auto generated parts right here in this file 2084 // we can easily edit the non-auto generated parts right here in this file
2086 // instead of having to edit some template or the code generator. 2085 // instead of having to edit some template or the code generator.
2087 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h" 2086 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h"
2088 2087
2089 } // namespace gles2 2088 } // namespace gles2
2090 } // namespace gpu 2089 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698