OLD | NEW |
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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 scoped_refptr<FeatureInfo> feature_info; | 109 scoped_refptr<FeatureInfo> feature_info; |
110 if (command_line) | 110 if (command_line) |
111 feature_info = new FeatureInfo(*command_line); | 111 feature_info = new FeatureInfo(*command_line); |
112 group_ = scoped_refptr<ContextGroup>( | 112 group_ = scoped_refptr<ContextGroup>( |
113 new ContextGroup(NULL, | 113 new ContextGroup(NULL, |
114 NULL, | 114 NULL, |
115 memory_tracker_, | 115 memory_tracker_, |
116 new ShaderTranslatorCache, | 116 new ShaderTranslatorCache, |
117 feature_info.get(), | 117 feature_info.get(), |
118 init.bind_generates_resource)); | 118 init.bind_generates_resource)); |
| 119 bool use_default_textures = init.bind_generates_resource; |
119 | 120 |
120 InSequence sequence; | 121 InSequence sequence; |
121 | 122 |
122 surface_ = new gfx::GLSurfaceStub; | 123 surface_ = new gfx::GLSurfaceStub; |
123 surface_->SetSize(gfx::Size(kBackBufferWidth, kBackBufferHeight)); | 124 surface_->SetSize(gfx::Size(kBackBufferWidth, kBackBufferHeight)); |
124 | 125 |
125 // Context needs to be created before initializing ContextGroup, which will | 126 // Context needs to be created before initializing ContextGroup, which will |
126 // in turn initialize FeatureInfo, which needs a context to determine | 127 // in turn initialize FeatureInfo, which needs a context to determine |
127 // extension support. | 128 // extension support. |
128 context_ = new gfx::GLContextStubWithExtensions; | 129 context_ = new gfx::GLContextStubWithExtensions; |
129 context_->AddExtensionsString(init.extensions.c_str()); | 130 context_->AddExtensionsString(init.extensions.c_str()); |
130 context_->SetGLVersionString(init.gl_version.c_str()); | 131 context_->SetGLVersionString(init.gl_version.c_str()); |
131 | 132 |
132 context_->MakeCurrent(surface_.get()); | 133 context_->MakeCurrent(surface_.get()); |
133 gfx::GLSurface::InitializeDynamicMockBindingsForTests(context_); | 134 gfx::GLSurface::InitializeDynamicMockBindingsForTests(context_); |
134 | 135 |
135 TestHelper::SetupContextGroupInitExpectations(gl_.get(), | 136 TestHelper::SetupContextGroupInitExpectations(gl_.get(), |
136 DisallowedFeatures(), | 137 DisallowedFeatures(), |
137 init.extensions.c_str(), | 138 init.extensions.c_str(), |
138 init.gl_version.c_str()); | 139 init.gl_version.c_str(), |
| 140 init.bind_generates_resource); |
139 | 141 |
140 // We initialize the ContextGroup with a MockGLES2Decoder so that | 142 // We initialize the ContextGroup with a MockGLES2Decoder so that |
141 // we can use the ContextGroup to figure out how the real GLES2Decoder | 143 // we can use the ContextGroup to figure out how the real GLES2Decoder |
142 // will initialize itself. | 144 // will initialize itself. |
143 mock_decoder_.reset(new MockGLES2Decoder()); | 145 mock_decoder_.reset(new MockGLES2Decoder()); |
144 EXPECT_TRUE( | 146 EXPECT_TRUE( |
145 group_->Initialize(mock_decoder_.get(), DisallowedFeatures())); | 147 group_->Initialize(mock_decoder_.get(), DisallowedFeatures())); |
146 | 148 |
147 if (group_->feature_info()->workarounds().init_vertex_attributes) | 149 if (group_->feature_info()->workarounds().init_vertex_attributes) |
148 AddExpectationsForVertexAttribManager(); | 150 AddExpectationsForVertexAttribManager(); |
(...skipping 26 matching lines...) Expand all Loading... |
175 .WillOnce(SetArrayArgument<1>( | 177 .WillOnce(SetArrayArgument<1>( |
176 fixed_attrib_buffer_id, | 178 fixed_attrib_buffer_id, |
177 fixed_attrib_buffer_id + arraysize(fixed_attrib_buffer_id))) | 179 fixed_attrib_buffer_id + arraysize(fixed_attrib_buffer_id))) |
178 .RetiresOnSaturation(); | 180 .RetiresOnSaturation(); |
179 | 181 |
180 for (GLint tt = 0; tt < TestHelper::kNumTextureUnits; ++tt) { | 182 for (GLint tt = 0; tt < TestHelper::kNumTextureUnits; ++tt) { |
181 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0 + tt)) | 183 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0 + tt)) |
182 .Times(1) | 184 .Times(1) |
183 .RetiresOnSaturation(); | 185 .RetiresOnSaturation(); |
184 if (group_->feature_info()->feature_flags().oes_egl_image_external) { | 186 if (group_->feature_info()->feature_flags().oes_egl_image_external) { |
185 EXPECT_CALL(*gl_, BindTexture( | 187 EXPECT_CALL(*gl_, |
186 GL_TEXTURE_EXTERNAL_OES, | 188 BindTexture(GL_TEXTURE_EXTERNAL_OES, |
187 TestHelper::kServiceDefaultExternalTextureId)) | 189 use_default_textures |
| 190 ? TestHelper::kServiceDefaultExternalTextureId |
| 191 : 0)) |
188 .Times(1) | 192 .Times(1) |
189 .RetiresOnSaturation(); | 193 .RetiresOnSaturation(); |
190 } | 194 } |
191 if (group_->feature_info()->feature_flags().arb_texture_rectangle) { | 195 if (group_->feature_info()->feature_flags().arb_texture_rectangle) { |
192 EXPECT_CALL(*gl_, BindTexture( | 196 EXPECT_CALL( |
193 GL_TEXTURE_RECTANGLE_ARB, | 197 *gl_, |
194 TestHelper::kServiceDefaultRectangleTextureId)) | 198 BindTexture(GL_TEXTURE_RECTANGLE_ARB, |
| 199 use_default_textures |
| 200 ? TestHelper::kServiceDefaultRectangleTextureId |
| 201 : 0)) |
195 .Times(1) | 202 .Times(1) |
196 .RetiresOnSaturation(); | 203 .RetiresOnSaturation(); |
197 } | 204 } |
198 EXPECT_CALL(*gl_, BindTexture( | 205 EXPECT_CALL(*gl_, |
199 GL_TEXTURE_CUBE_MAP, TestHelper::kServiceDefaultTextureCubemapId)) | 206 BindTexture(GL_TEXTURE_CUBE_MAP, |
| 207 use_default_textures |
| 208 ? TestHelper::kServiceDefaultTextureCubemapId |
| 209 : 0)) |
200 .Times(1) | 210 .Times(1) |
201 .RetiresOnSaturation(); | 211 .RetiresOnSaturation(); |
202 EXPECT_CALL(*gl_, BindTexture( | 212 EXPECT_CALL( |
203 GL_TEXTURE_2D, TestHelper::kServiceDefaultTexture2dId)) | 213 *gl_, |
| 214 BindTexture( |
| 215 GL_TEXTURE_2D, |
| 216 use_default_textures ? TestHelper::kServiceDefaultTexture2dId : 0)) |
204 .Times(1) | 217 .Times(1) |
205 .RetiresOnSaturation(); | 218 .RetiresOnSaturation(); |
206 } | 219 } |
207 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) | 220 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) |
208 .Times(1) | 221 .Times(1) |
209 .RetiresOnSaturation(); | 222 .RetiresOnSaturation(); |
210 | 223 |
211 EXPECT_CALL(*gl_, BindFramebufferEXT(GL_FRAMEBUFFER, 0)) | 224 EXPECT_CALL(*gl_, BindFramebufferEXT(GL_FRAMEBUFFER, 0)) |
212 .Times(1) | 225 .Times(1) |
213 .RetiresOnSaturation(); | 226 .RetiresOnSaturation(); |
(...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1453 SetupDefaultProgram(); | 1466 SetupDefaultProgram(); |
1454 } | 1467 } |
1455 | 1468 |
1456 // Include the auto-generated part of this file. We split this because it means | 1469 // Include the auto-generated part of this file. We split this because it means |
1457 // we can easily edit the non-auto generated parts right here in this file | 1470 // we can easily edit the non-auto generated parts right here in this file |
1458 // instead of having to edit some template or the code generator. | 1471 // instead of having to edit some template or the code generator. |
1459 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h" | 1472 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h" |
1460 | 1473 |
1461 } // namespace gles2 | 1474 } // namespace gles2 |
1462 } // namespace gpu | 1475 } // namespace gpu |
OLD | NEW |