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