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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 feature_info_.get())); | 128 feature_info_.get())); |
129 } | 129 } |
130 ~FramebufferInfoTestBase() override { | 130 ~FramebufferInfoTestBase() override { |
131 manager_.Destroy(false); | 131 manager_.Destroy(false); |
132 texture_manager_->Destroy(false); | 132 texture_manager_->Destroy(false); |
133 renderbuffer_manager_->Destroy(false); | 133 renderbuffer_manager_->Destroy(false); |
134 } | 134 } |
135 | 135 |
136 protected: | 136 protected: |
137 void SetUp() override { | 137 void SetUp() override { |
138 bool is_es3 = false; | 138 InitializeContext("2.0", "GL_EXT_framebuffer_object"); |
139 if (context_type_ == CONTEXT_TYPE_WEBGL2 || | |
140 context_type_ == CONTEXT_TYPE_OPENGLES3) | |
141 is_es3 = true; | |
142 InitializeContext(is_es3 ? "3.0" : "2.0", "GL_EXT_framebuffer_object"); | |
143 } | 139 } |
144 | 140 |
145 void InitializeContext(const char* gl_version, const char* extensions) { | 141 void InitializeContext(const char* gl_version, const char* extensions) { |
146 GpuServiceTest::SetUpWithGLVersion(gl_version, extensions); | 142 GpuServiceTest::SetUpWithGLVersion(gl_version, extensions); |
147 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(gl_.get(), | 143 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(gl_.get(), |
148 extensions, "", gl_version, context_type_); | 144 extensions, "", gl_version, context_type_); |
149 feature_info_->InitializeForTesting(context_type_); | 145 feature_info_->InitializeForTesting(); |
150 decoder_.reset(new MockGLES2Decoder()); | 146 decoder_.reset(new MockGLES2Decoder()); |
151 manager_.CreateFramebuffer(kClient1Id, kService1Id); | 147 manager_.CreateFramebuffer(kClient1Id, kService1Id); |
152 error_state_.reset(new ::testing::StrictMock<gles2::MockErrorState>()); | 148 error_state_.reset(new ::testing::StrictMock<gles2::MockErrorState>()); |
153 framebuffer_ = manager_.GetFramebuffer(kClient1Id); | 149 framebuffer_ = manager_.GetFramebuffer(kClient1Id); |
154 ASSERT_TRUE(framebuffer_ != nullptr); | 150 ASSERT_TRUE(framebuffer_ != nullptr); |
155 } | 151 } |
156 | 152 |
157 ContextType context_type_; | 153 ContextType context_type_; |
158 FramebufferManager manager_; | 154 FramebufferManager manager_; |
159 Framebuffer* framebuffer_; | 155 Framebuffer* framebuffer_; |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 const GLsizei kSamples1 = 0; | 483 const GLsizei kSamples1 = 0; |
488 const GLsizei kWidth2 = 16; | 484 const GLsizei kWidth2 = 16; |
489 const GLsizei kHeight2 = 32; | 485 const GLsizei kHeight2 = 32; |
490 const GLint kLevel2 = 0; | 486 const GLint kLevel2 = 0; |
491 const GLenum kFormat2 = GL_RGB; | 487 const GLenum kFormat2 = GL_RGB; |
492 const GLenum kTarget2 = GL_TEXTURE_2D; | 488 const GLenum kTarget2 = GL_TEXTURE_2D; |
493 const GLsizei kSamples2 = 0; | 489 const GLsizei kSamples2 = 0; |
494 const GLsizei kWidth3 = 75; | 490 const GLsizei kWidth3 = 75; |
495 const GLsizei kHeight3 = 123; | 491 const GLsizei kHeight3 = 123; |
496 const GLint kLevel3 = 0; | 492 const GLint kLevel3 = 0; |
497 const GLenum kFormat3 = GL_RGBA; | 493 const GLenum kFormat3 = GL_RGB565; |
498 const GLsizei kSamples3 = 0; | 494 const GLsizei kSamples3 = 0; |
499 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); | 495 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); |
500 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); | 496 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); |
501 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)); | 497 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)); |
502 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT), | 498 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT), |
503 framebuffer_->IsPossiblyComplete(feature_info_.get())); | 499 framebuffer_->IsPossiblyComplete(feature_info_.get())); |
504 | 500 |
505 texture_manager_->CreateTexture(kTextureClient1Id, kTextureService1Id); | 501 texture_manager_->CreateTexture(kTextureClient1Id, kTextureService1Id); |
506 scoped_refptr<TextureRef> texture1( | 502 scoped_refptr<TextureRef> texture1( |
507 texture_manager_->GetTexture(kTextureClient1Id)); | 503 texture_manager_->GetTexture(kTextureClient1Id)); |
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 .RetiresOnSaturation(); | 1271 .RetiresOnSaturation(); |
1276 EXPECT_TRUE( | 1272 EXPECT_TRUE( |
1277 framebuffer_->ValidateAndAdjustDrawBuffers(0x310u, 0x330u)); | 1273 framebuffer_->ValidateAndAdjustDrawBuffers(0x310u, 0x330u)); |
1278 // Call it a second time - making sure DrawBuffers isn't triggered. | 1274 // Call it a second time - making sure DrawBuffers isn't triggered. |
1279 EXPECT_CALL(*gl_, DrawBuffersARB(kMaxDrawBuffers, _)) | 1275 EXPECT_CALL(*gl_, DrawBuffersARB(kMaxDrawBuffers, _)) |
1280 .Times(0); | 1276 .Times(0); |
1281 EXPECT_TRUE( | 1277 EXPECT_TRUE( |
1282 framebuffer_->ValidateAndAdjustDrawBuffers(0x310u, 0x330u)); | 1278 framebuffer_->ValidateAndAdjustDrawBuffers(0x310u, 0x330u)); |
1283 } | 1279 } |
1284 | 1280 |
1285 class FramebufferInfoFloatTest : public FramebufferInfoTestBase { | 1281 class FramebufferInfoFloatTest : public FramebufferInfoTest { |
1286 public: | 1282 public: |
1287 FramebufferInfoFloatTest() | 1283 FramebufferInfoFloatTest() |
1288 : FramebufferInfoTestBase(CONTEXT_TYPE_OPENGLES2) {} | 1284 : FramebufferInfoTest() { |
| 1285 } |
1289 ~FramebufferInfoFloatTest() override {} | 1286 ~FramebufferInfoFloatTest() override {} |
1290 | 1287 |
1291 protected: | 1288 protected: |
1292 void SetUp() override { | 1289 void SetUp() override { |
1293 InitializeContext("OpenGL ES 3.0", | 1290 InitializeContext("OpenGL ES 3.0", |
1294 "GL_OES_texture_float GL_EXT_color_buffer_float"); | 1291 "GL_OES_texture_float GL_EXT_color_buffer_float"); |
1295 } | 1292 } |
1296 }; | 1293 }; |
1297 | 1294 |
1298 TEST_F(FramebufferInfoFloatTest, AttachFloatTexture) { | 1295 TEST_F(FramebufferInfoFloatTest, AttachFloatTexture) { |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1543 } | 1540 } |
1544 | 1541 |
1545 class FramebufferInfoES3Test : public FramebufferInfoTestBase { | 1542 class FramebufferInfoES3Test : public FramebufferInfoTestBase { |
1546 public: | 1543 public: |
1547 FramebufferInfoES3Test() : FramebufferInfoTestBase(CONTEXT_TYPE_WEBGL2) {} | 1544 FramebufferInfoES3Test() : FramebufferInfoTestBase(CONTEXT_TYPE_WEBGL2) {} |
1548 | 1545 |
1549 protected: | 1546 protected: |
1550 void SetUp() override { | 1547 void SetUp() override { |
1551 InitializeContext("OpenGL ES 3.0", ""); | 1548 InitializeContext("OpenGL ES 3.0", ""); |
1552 } | 1549 } |
| 1550 |
| 1551 void InitializeContext(const char* gl_version, const char* extensions) { |
| 1552 GpuServiceTest::SetUpWithGLVersion(gl_version, extensions); |
| 1553 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(gl_.get(), |
| 1554 extensions, "", gl_version, context_type_); |
| 1555 feature_info_->InitializeForTesting(CONTEXT_TYPE_OPENGLES3); |
| 1556 decoder_.reset(new MockGLES2Decoder()); |
| 1557 manager_.CreateFramebuffer(kClient1Id, kService1Id); |
| 1558 error_state_.reset(new ::testing::StrictMock<gles2::MockErrorState>()); |
| 1559 framebuffer_ = manager_.GetFramebuffer(kClient1Id); |
| 1560 ASSERT_TRUE(framebuffer_ != nullptr); |
| 1561 } |
1553 }; | 1562 }; |
1554 | 1563 |
1555 TEST_F(FramebufferInfoES3Test, DifferentDimensions) { | 1564 TEST_F(FramebufferInfoES3Test, DifferentDimensions) { |
1556 const GLuint kRenderbufferClient1Id = 33; | 1565 const GLuint kRenderbufferClient1Id = 33; |
1557 const GLuint kRenderbufferService1Id = 333; | 1566 const GLuint kRenderbufferService1Id = 333; |
1558 const GLuint kRenderbufferClient2Id = 34; | 1567 const GLuint kRenderbufferClient2Id = 34; |
1559 const GLuint kRenderbufferService2Id = 334; | 1568 const GLuint kRenderbufferService2Id = 334; |
1560 const GLsizei kWidth1 = 16; | 1569 const GLsizei kWidth1 = 16; |
1561 const GLsizei kHeight1 = 32; | 1570 const GLsizei kHeight1 = 32; |
1562 const GLenum kFormat1 = GL_RGBA4; | 1571 const GLenum kFormat1 = GL_RGBA4; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1643 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClientId); | 1652 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClientId); |
1644 ASSERT_TRUE(renderbuffer != nullptr); | 1653 ASSERT_TRUE(renderbuffer != nullptr); |
1645 framebuffer_->AttachRenderbuffer(GL_COLOR_ATTACHMENT1, renderbuffer); | 1654 framebuffer_->AttachRenderbuffer(GL_COLOR_ATTACHMENT1, renderbuffer); |
1646 EXPECT_TRUE(framebuffer_->GetReadBufferAttachment()); | 1655 EXPECT_TRUE(framebuffer_->GetReadBufferAttachment()); |
1647 } | 1656 } |
1648 | 1657 |
1649 } // namespace gles2 | 1658 } // namespace gles2 |
1650 } // namespace gpu | 1659 } // namespace gpu |
1651 | 1660 |
1652 | 1661 |
OLD | NEW |