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/texture_manager.h" | 5 #include "gpu/command_buffer/service/texture_manager.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "gpu/command_buffer/service/error_state_mock.h" | 8 #include "gpu/command_buffer/service/error_state_mock.h" |
9 #include "gpu/command_buffer/service/feature_info.h" | 9 #include "gpu/command_buffer/service/feature_info.h" |
10 #include "gpu/command_buffer/service/framebuffer_manager.h" | 10 #include "gpu/command_buffer/service/framebuffer_manager.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 70 |
71 virtual void TearDown() { | 71 virtual void TearDown() { |
72 manager_->Destroy(false); | 72 manager_->Destroy(false); |
73 manager_.reset(); | 73 manager_.reset(); |
74 ::gfx::MockGLInterface::SetGLInterface(NULL); | 74 ::gfx::MockGLInterface::SetGLInterface(NULL); |
75 gl_.reset(); | 75 gl_.reset(); |
76 } | 76 } |
77 | 77 |
78 void SetParameter( | 78 void SetParameter( |
79 TextureRef* texture_ref, GLenum pname, GLint value, GLenum error) { | 79 TextureRef* texture_ref, GLenum pname, GLint value, GLenum error) { |
80 TestHelper::SetTexParameterWithExpectations( | 80 TestHelper::SetTexParameteriWithExpectations( |
81 gl_.get(), error_state_.get(), manager_.get(), | 81 gl_.get(), error_state_.get(), manager_.get(), |
82 texture_ref, pname, value, error); | 82 texture_ref, pname, value, error); |
83 } | 83 } |
84 | 84 |
85 // Use StrictMock to make 100% sure we know how GL will be called. | 85 // Use StrictMock to make 100% sure we know how GL will be called. |
86 scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_; | 86 scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_; |
87 scoped_refptr<FeatureInfo> feature_info_; | 87 scoped_refptr<FeatureInfo> feature_info_; |
88 scoped_ptr<TextureManager> manager_; | 88 scoped_ptr<TextureManager> manager_; |
89 scoped_ptr<MockErrorState> error_state_; | 89 scoped_ptr<MockErrorState> error_state_; |
90 }; | 90 }; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 TextureManager manager( | 168 TextureManager manager( |
169 NULL, feature_info_.get(), kMaxTextureSize, kMaxCubeMapTextureSize); | 169 NULL, feature_info_.get(), kMaxTextureSize, kMaxCubeMapTextureSize); |
170 manager.Initialize(); | 170 manager.Initialize(); |
171 const GLuint kClient1Id = 1; | 171 const GLuint kClient1Id = 1; |
172 const GLuint kService1Id = 11; | 172 const GLuint kService1Id = 11; |
173 // Check we can create texture. | 173 // Check we can create texture. |
174 manager.CreateTexture(kClient1Id, kService1Id); | 174 manager.CreateTexture(kClient1Id, kService1Id); |
175 // Check texture got created. | 175 // Check texture got created. |
176 TextureRef* texture_ref = manager.GetTexture(kClient1Id); | 176 TextureRef* texture_ref = manager.GetTexture(kClient1Id); |
177 ASSERT_TRUE(texture_ref != NULL); | 177 ASSERT_TRUE(texture_ref != NULL); |
178 TestHelper::SetTexParameterWithExpectations( | 178 TestHelper::SetTexParameteriWithExpectations( |
179 gl_.get(), error_state_.get(), &manager, texture_ref, | 179 gl_.get(), error_state_.get(), &manager, texture_ref, |
180 GL_TEXTURE_USAGE_ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE,GL_NO_ERROR); | 180 GL_TEXTURE_USAGE_ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE,GL_NO_ERROR); |
181 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_ATTACHMENT_ANGLE), | 181 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_ATTACHMENT_ANGLE), |
182 texture_ref->texture()->usage()); | 182 texture_ref->texture()->usage()); |
183 manager.Destroy(false); | 183 manager.Destroy(false); |
184 } | 184 } |
185 | 185 |
186 TEST_F(TextureManagerTest, Destroy) { | 186 TEST_F(TextureManagerTest, Destroy) { |
187 const GLuint kClient1Id = 1; | 187 const GLuint kClient1Id = 1; |
188 const GLuint kService1Id = 11; | 188 const GLuint kService1Id = 11; |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 texture_ref_ = NULL; | 383 texture_ref_ = NULL; |
384 } | 384 } |
385 manager_->Destroy(false); | 385 manager_->Destroy(false); |
386 manager_.reset(); | 386 manager_.reset(); |
387 ::gfx::MockGLInterface::SetGLInterface(NULL); | 387 ::gfx::MockGLInterface::SetGLInterface(NULL); |
388 gl_.reset(); | 388 gl_.reset(); |
389 } | 389 } |
390 | 390 |
391 void SetParameter( | 391 void SetParameter( |
392 TextureRef* texture_ref, GLenum pname, GLint value, GLenum error) { | 392 TextureRef* texture_ref, GLenum pname, GLint value, GLenum error) { |
393 TestHelper::SetTexParameterWithExpectations( | 393 TestHelper::SetTexParameteriWithExpectations( |
394 gl_.get(), error_state_.get(), manager_.get(), | 394 gl_.get(), error_state_.get(), manager_.get(), |
395 texture_ref, pname, value, error); | 395 texture_ref, pname, value, error); |
396 } | 396 } |
397 | 397 |
398 scoped_ptr<MockGLES2Decoder> decoder_; | 398 scoped_ptr<MockGLES2Decoder> decoder_; |
399 scoped_ptr<MockErrorState> error_state_; | 399 scoped_ptr<MockErrorState> error_state_; |
400 // Use StrictMock to make 100% sure we know how GL will be called. | 400 // Use StrictMock to make 100% sure we know how GL will be called. |
401 scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_; | 401 scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_; |
402 scoped_refptr<FeatureInfo> feature_info_; | 402 scoped_refptr<FeatureInfo> feature_info_; |
403 scoped_ptr<TextureManager> manager_; | 403 scoped_ptr<TextureManager> manager_; |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 NULL, feature_info.get(), kMaxTextureSize, kMaxCubeMapTextureSize); | 1087 NULL, feature_info.get(), kMaxTextureSize, kMaxCubeMapTextureSize); |
1088 manager.CreateTexture(kClient1Id, kService1Id); | 1088 manager.CreateTexture(kClient1Id, kService1Id); |
1089 TextureRef* texture_ref = manager.GetTexture(kClient1Id); | 1089 TextureRef* texture_ref = manager.GetTexture(kClient1Id); |
1090 ASSERT_TRUE(texture_ref != NULL); | 1090 ASSERT_TRUE(texture_ref != NULL); |
1091 manager.SetTarget(texture_ref, GL_TEXTURE_2D); | 1091 manager.SetTarget(texture_ref, GL_TEXTURE_2D); |
1092 Texture* texture = texture_ref->texture(); | 1092 Texture* texture = texture_ref->texture(); |
1093 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), texture->target()); | 1093 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), texture->target()); |
1094 manager.SetLevelInfo(texture_ref, | 1094 manager.SetLevelInfo(texture_ref, |
1095 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_FLOAT, true); | 1095 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_FLOAT, true); |
1096 EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture)); | 1096 EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture)); |
1097 TestHelper::SetTexParameterWithExpectations( | 1097 TestHelper::SetTexParameteriWithExpectations( |
1098 gl_.get(), error_state_.get(), &manager, | 1098 gl_.get(), error_state_.get(), &manager, |
1099 texture_ref, GL_TEXTURE_MAG_FILTER, GL_NEAREST, GL_NO_ERROR); | 1099 texture_ref, GL_TEXTURE_MAG_FILTER, GL_NEAREST, GL_NO_ERROR); |
1100 EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture)); | 1100 EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture)); |
1101 TestHelper::SetTexParameterWithExpectations( | 1101 TestHelper::SetTexParameteriWithExpectations( |
1102 gl_.get(), error_state_.get(), &manager, texture_ref, | 1102 gl_.get(), error_state_.get(), &manager, texture_ref, |
1103 GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST, GL_NO_ERROR); | 1103 GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST, GL_NO_ERROR); |
1104 EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture)); | 1104 EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture)); |
1105 manager.Destroy(false); | 1105 manager.Destroy(false); |
1106 } | 1106 } |
1107 | 1107 |
1108 TEST_F(TextureTest, FloatLinear) { | 1108 TEST_F(TextureTest, FloatLinear) { |
1109 TestHelper::SetupFeatureInfoInitExpectations( | 1109 TestHelper::SetupFeatureInfoInitExpectations( |
1110 gl_.get(), "GL_OES_texture_float GL_OES_texture_float_linear"); | 1110 gl_.get(), "GL_OES_texture_float GL_OES_texture_float_linear"); |
1111 scoped_refptr<FeatureInfo> feature_info(new FeatureInfo()); | 1111 scoped_refptr<FeatureInfo> feature_info(new FeatureInfo()); |
(...skipping 21 matching lines...) Expand all Loading... |
1133 NULL, feature_info.get(), kMaxTextureSize, kMaxCubeMapTextureSize); | 1133 NULL, feature_info.get(), kMaxTextureSize, kMaxCubeMapTextureSize); |
1134 manager.CreateTexture(kClient1Id, kService1Id); | 1134 manager.CreateTexture(kClient1Id, kService1Id); |
1135 TextureRef* texture_ref = manager.GetTexture(kClient1Id); | 1135 TextureRef* texture_ref = manager.GetTexture(kClient1Id); |
1136 ASSERT_TRUE(texture_ref != NULL); | 1136 ASSERT_TRUE(texture_ref != NULL); |
1137 manager.SetTarget(texture_ref, GL_TEXTURE_2D); | 1137 manager.SetTarget(texture_ref, GL_TEXTURE_2D); |
1138 Texture* texture = texture_ref->texture(); | 1138 Texture* texture = texture_ref->texture(); |
1139 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), texture->target()); | 1139 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), texture->target()); |
1140 manager.SetLevelInfo(texture_ref, | 1140 manager.SetLevelInfo(texture_ref, |
1141 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_HALF_FLOAT_OES, true); | 1141 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_HALF_FLOAT_OES, true); |
1142 EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture)); | 1142 EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture)); |
1143 TestHelper::SetTexParameterWithExpectations( | 1143 TestHelper::SetTexParameteriWithExpectations( |
1144 gl_.get(), error_state_.get(), &manager, | 1144 gl_.get(), error_state_.get(), &manager, |
1145 texture_ref, GL_TEXTURE_MAG_FILTER, GL_NEAREST, GL_NO_ERROR); | 1145 texture_ref, GL_TEXTURE_MAG_FILTER, GL_NEAREST, GL_NO_ERROR); |
1146 EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture)); | 1146 EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture)); |
1147 TestHelper::SetTexParameterWithExpectations( | 1147 TestHelper::SetTexParameteriWithExpectations( |
1148 gl_.get(), error_state_.get(), &manager, texture_ref, | 1148 gl_.get(), error_state_.get(), &manager, texture_ref, |
1149 GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST, GL_NO_ERROR); | 1149 GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST, GL_NO_ERROR); |
1150 EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture)); | 1150 EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture)); |
1151 manager.Destroy(false); | 1151 manager.Destroy(false); |
1152 } | 1152 } |
1153 | 1153 |
1154 TEST_F(TextureTest, HalfFloatLinear) { | 1154 TEST_F(TextureTest, HalfFloatLinear) { |
1155 TestHelper::SetupFeatureInfoInitExpectations( | 1155 TestHelper::SetupFeatureInfoInitExpectations( |
1156 gl_.get(), "GL_OES_texture_half_float GL_OES_texture_half_float_linear"); | 1156 gl_.get(), "GL_OES_texture_half_float GL_OES_texture_half_float_linear"); |
1157 scoped_refptr<FeatureInfo> feature_info(new FeatureInfo()); | 1157 scoped_refptr<FeatureInfo> feature_info(new FeatureInfo()); |
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2438 | 2438 |
2439 EXPECT_CALL(*gl_, DeleteTextures(1, _)) | 2439 EXPECT_CALL(*gl_, DeleteTextures(1, _)) |
2440 .Times(1) | 2440 .Times(1) |
2441 .RetiresOnSaturation(); | 2441 .RetiresOnSaturation(); |
2442 texture_manager1_->RemoveTexture(10); | 2442 texture_manager1_->RemoveTexture(10); |
2443 texture_manager2_->RemoveTexture(20); | 2443 texture_manager2_->RemoveTexture(20); |
2444 } | 2444 } |
2445 | 2445 |
2446 } // namespace gles2 | 2446 } // namespace gles2 |
2447 } // namespace gpu | 2447 } // namespace gpu |
OLD | NEW |