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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1384 } | 1384 } |
1385 | 1385 |
1386 TEST_F(TextureTest, GetLevelImage) { | 1386 TEST_F(TextureTest, GetLevelImage) { |
1387 manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D); | 1387 manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D); |
1388 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 1, | 1388 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 1, |
1389 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(2, 2)); | 1389 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(2, 2)); |
1390 Texture* texture = texture_ref_->texture(); | 1390 Texture* texture = texture_ref_->texture(); |
1391 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL); | 1391 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL); |
1392 // Set image. | 1392 // Set image. |
1393 scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub); | 1393 scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub); |
1394 manager_->SetLevelImage(texture_ref_.get(), GL_TEXTURE_2D, 1, image.get()); | 1394 manager_->SetLevelImage(texture_ref_.get(), GL_TEXTURE_2D, 1, image.get(), |
| 1395 Texture::BOUND); |
1395 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL); | 1396 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL); |
1396 // Remove it. | 1397 // Remove it. |
1397 manager_->SetLevelImage(texture_ref_.get(), GL_TEXTURE_2D, 1, NULL); | 1398 manager_->SetLevelImage(texture_ref_.get(), GL_TEXTURE_2D, 1, nullptr, |
| 1399 Texture::UNBOUND); |
1398 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL); | 1400 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL); |
1399 manager_->SetLevelImage(texture_ref_.get(), GL_TEXTURE_2D, 1, image.get()); | 1401 manager_->SetLevelImage(texture_ref_.get(), GL_TEXTURE_2D, 1, image.get(), |
| 1402 Texture::UNBOUND); |
1400 // Image should be reset when SetLevelInfo is called. | 1403 // Image should be reset when SetLevelInfo is called. |
1401 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 1, | 1404 manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 1, |
1402 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(2, 2)); | 1405 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(2, 2)); |
1403 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL); | 1406 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL); |
1404 } | 1407 } |
1405 | 1408 |
1406 namespace { | 1409 namespace { |
1407 | 1410 |
1408 bool InSet(std::set<std::string>* string_set, const std::string& str) { | 1411 bool InSet(std::set<std::string>* string_set, const std::string& str) { |
1409 std::pair<std::set<std::string>::iterator, bool> result = | 1412 std::pair<std::set<std::string>::iterator, bool> result = |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1730 } | 1733 } |
1731 | 1734 |
1732 TEST_P(ProduceConsumeTextureTest, ProduceConsumeTextureWithImage) { | 1735 TEST_P(ProduceConsumeTextureTest, ProduceConsumeTextureWithImage) { |
1733 GLenum target = GetParam(); | 1736 GLenum target = GetParam(); |
1734 manager_->SetTarget(texture_ref_.get(), target); | 1737 manager_->SetTarget(texture_ref_.get(), target); |
1735 Texture* texture = texture_ref_->texture(); | 1738 Texture* texture = texture_ref_->texture(); |
1736 EXPECT_EQ(static_cast<GLenum>(target), texture->target()); | 1739 EXPECT_EQ(static_cast<GLenum>(target), texture->target()); |
1737 scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub); | 1740 scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub); |
1738 manager_->SetLevelInfo(texture_ref_.get(), target, 0, GL_RGBA, 0, 0, 1, 0, | 1741 manager_->SetLevelInfo(texture_ref_.get(), target, 0, GL_RGBA, 0, 0, 1, 0, |
1739 GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect()); | 1742 GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect()); |
1740 manager_->SetLevelImage(texture_ref_.get(), target, 0, image.get()); | 1743 manager_->SetLevelImage(texture_ref_.get(), target, 0, image.get(), |
| 1744 Texture::BOUND); |
1741 GLuint service_id = texture->service_id(); | 1745 GLuint service_id = texture->service_id(); |
1742 Texture* produced_texture = Produce(texture_ref_.get()); | 1746 Texture* produced_texture = Produce(texture_ref_.get()); |
1743 | 1747 |
1744 GLuint client_id = texture2_->client_id(); | 1748 GLuint client_id = texture2_->client_id(); |
1745 manager_->RemoveTexture(client_id); | 1749 manager_->RemoveTexture(client_id); |
1746 Consume(client_id, produced_texture); | 1750 Consume(client_id, produced_texture); |
1747 scoped_refptr<TextureRef> restored_texture = manager_->GetTexture(client_id); | 1751 scoped_refptr<TextureRef> restored_texture = manager_->GetTexture(client_id); |
1748 EXPECT_EQ(produced_texture, restored_texture->texture()); | 1752 EXPECT_EQ(produced_texture, restored_texture->texture()); |
1749 EXPECT_EQ(service_id, restored_texture->service_id()); | 1753 EXPECT_EQ(service_id, restored_texture->service_id()); |
1750 EXPECT_EQ(image.get(), restored_texture->texture()->GetLevelImage(target, 0)); | 1754 EXPECT_EQ(image.get(), restored_texture->texture()->GetLevelImage(target, 0)); |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2050 | 2054 |
2051 texture_manager1_->SetTarget(ref1.get(), GL_TEXTURE_2D); | 2055 texture_manager1_->SetTarget(ref1.get(), GL_TEXTURE_2D); |
2052 texture_manager1_->SetLevelInfo(ref1.get(), GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, | 2056 texture_manager1_->SetLevelInfo(ref1.get(), GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, |
2053 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 2057 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
2054 gfx::Rect(2, 2)); | 2058 gfx::Rect(2, 2)); |
2055 EXPECT_FALSE(ref1->texture()->HasImages()); | 2059 EXPECT_FALSE(ref1->texture()->HasImages()); |
2056 EXPECT_FALSE(ref2->texture()->HasImages()); | 2060 EXPECT_FALSE(ref2->texture()->HasImages()); |
2057 EXPECT_FALSE(texture_manager1_->HaveImages()); | 2061 EXPECT_FALSE(texture_manager1_->HaveImages()); |
2058 EXPECT_FALSE(texture_manager2_->HaveImages()); | 2062 EXPECT_FALSE(texture_manager2_->HaveImages()); |
2059 scoped_refptr<gfx::GLImage> image1(new gfx::GLImageStub); | 2063 scoped_refptr<gfx::GLImage> image1(new gfx::GLImageStub); |
2060 texture_manager1_->SetLevelImage(ref1.get(), GL_TEXTURE_2D, 1, image1.get()); | 2064 texture_manager1_->SetLevelImage(ref1.get(), GL_TEXTURE_2D, 1, image1.get(), |
| 2065 Texture::BOUND); |
2061 EXPECT_TRUE(ref1->texture()->HasImages()); | 2066 EXPECT_TRUE(ref1->texture()->HasImages()); |
2062 EXPECT_TRUE(ref2->texture()->HasImages()); | 2067 EXPECT_TRUE(ref2->texture()->HasImages()); |
2063 EXPECT_TRUE(texture_manager1_->HaveImages()); | 2068 EXPECT_TRUE(texture_manager1_->HaveImages()); |
2064 EXPECT_TRUE(texture_manager2_->HaveImages()); | 2069 EXPECT_TRUE(texture_manager2_->HaveImages()); |
2065 scoped_refptr<gfx::GLImage> image2(new gfx::GLImageStub); | 2070 scoped_refptr<gfx::GLImage> image2(new gfx::GLImageStub); |
2066 texture_manager1_->SetLevelImage(ref1.get(), GL_TEXTURE_2D, 1, image2.get()); | 2071 texture_manager1_->SetLevelImage(ref1.get(), GL_TEXTURE_2D, 1, image2.get(), |
| 2072 Texture::BOUND); |
2067 EXPECT_TRUE(ref1->texture()->HasImages()); | 2073 EXPECT_TRUE(ref1->texture()->HasImages()); |
2068 EXPECT_TRUE(ref2->texture()->HasImages()); | 2074 EXPECT_TRUE(ref2->texture()->HasImages()); |
2069 EXPECT_TRUE(texture_manager1_->HaveImages()); | 2075 EXPECT_TRUE(texture_manager1_->HaveImages()); |
2070 EXPECT_TRUE(texture_manager2_->HaveImages()); | 2076 EXPECT_TRUE(texture_manager2_->HaveImages()); |
2071 texture_manager1_->SetLevelInfo(ref1.get(), GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, | 2077 texture_manager1_->SetLevelInfo(ref1.get(), GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, |
2072 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 2078 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
2073 gfx::Rect(2, 2)); | 2079 gfx::Rect(2, 2)); |
2074 EXPECT_FALSE(ref1->texture()->HasImages()); | 2080 EXPECT_FALSE(ref1->texture()->HasImages()); |
2075 EXPECT_FALSE(ref2->texture()->HasImages()); | 2081 EXPECT_FALSE(ref2->texture()->HasImages()); |
2076 EXPECT_FALSE(texture_manager1_->HaveImages()); | 2082 EXPECT_FALSE(texture_manager1_->HaveImages()); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2323 ExpectValid(GL_DEPTH_COMPONENT, GL_FLOAT, GL_DEPTH_COMPONENT32F); | 2329 ExpectValid(GL_DEPTH_COMPONENT, GL_FLOAT, GL_DEPTH_COMPONENT32F); |
2324 ExpectValid(GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_DEPTH24_STENCIL8); | 2330 ExpectValid(GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_DEPTH24_STENCIL8); |
2325 ExpectValid(GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, | 2331 ExpectValid(GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, |
2326 GL_DEPTH32F_STENCIL8); | 2332 GL_DEPTH32F_STENCIL8); |
2327 | 2333 |
2328 ExpectInvalid(GL_RGB_INTEGER, GL_INT, GL_RGBA8); | 2334 ExpectInvalid(GL_RGB_INTEGER, GL_INT, GL_RGBA8); |
2329 } | 2335 } |
2330 | 2336 |
2331 } // namespace gles2 | 2337 } // namespace gles2 |
2332 } // namespace gpu | 2338 } // namespace gpu |
OLD | NEW |