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" |
11 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" | 11 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" |
12 #include "gpu/command_buffer/service/mailbox_manager.h" | 12 #include "gpu/command_buffer/service/mailbox_manager.h" |
13 #include "gpu/command_buffer/service/memory_tracking.h" | 13 #include "gpu/command_buffer/service/memory_tracking.h" |
14 #include "gpu/command_buffer/service/mocks.h" | 14 #include "gpu/command_buffer/service/mocks.h" |
15 #include "gpu/command_buffer/service/test_helper.h" | 15 #include "gpu/command_buffer/service/test_helper.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "ui/gl/gl_image_stub.h" |
17 #include "ui/gl/gl_mock.h" | 18 #include "ui/gl/gl_mock.h" |
18 | 19 |
19 using ::testing::AtLeast; | 20 using ::testing::AtLeast; |
20 using ::testing::Pointee; | 21 using ::testing::Pointee; |
21 using ::testing::Return; | 22 using ::testing::Return; |
22 using ::testing::SetArgumentPointee; | 23 using ::testing::SetArgumentPointee; |
23 using ::testing::StrictMock; | 24 using ::testing::StrictMock; |
24 using ::testing::_; | 25 using ::testing::_; |
25 | 26 |
26 namespace gpu { | 27 namespace gpu { |
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1634 2, | 1635 2, |
1635 2, | 1636 2, |
1636 1, | 1637 1, |
1637 0, | 1638 0, |
1638 GL_RGBA, | 1639 GL_RGBA, |
1639 GL_UNSIGNED_BYTE, | 1640 GL_UNSIGNED_BYTE, |
1640 true); | 1641 true); |
1641 Texture* texture = texture_ref_->texture(); | 1642 Texture* texture = texture_ref_->texture(); |
1642 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL); | 1643 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL); |
1643 // Set image. | 1644 // Set image. |
1644 manager_->SetLevelImage(texture_ref_.get(), | 1645 scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub); |
1645 GL_TEXTURE_2D, | 1646 manager_->SetLevelImage(texture_ref_.get(), GL_TEXTURE_2D, 1, image.get()); |
1646 1, | |
1647 gfx::GLImage::CreateGLImage(0).get()); | |
1648 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL); | 1647 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL); |
1649 // Remove it. | 1648 // Remove it. |
1650 manager_->SetLevelImage(texture_ref_.get(), GL_TEXTURE_2D, 1, NULL); | 1649 manager_->SetLevelImage(texture_ref_.get(), GL_TEXTURE_2D, 1, NULL); |
1651 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL); | 1650 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL); |
1652 manager_->SetLevelImage(texture_ref_.get(), | 1651 manager_->SetLevelImage(texture_ref_.get(), GL_TEXTURE_2D, 1, image.get()); |
1653 GL_TEXTURE_2D, | |
1654 1, | |
1655 gfx::GLImage::CreateGLImage(0).get()); | |
1656 // Image should be reset when SetLevelInfo is called. | 1652 // Image should be reset when SetLevelInfo is called. |
1657 manager_->SetLevelInfo(texture_ref_.get(), | 1653 manager_->SetLevelInfo(texture_ref_.get(), |
1658 GL_TEXTURE_2D, | 1654 GL_TEXTURE_2D, |
1659 1, | 1655 1, |
1660 GL_RGBA, | 1656 GL_RGBA, |
1661 2, | 1657 2, |
1662 2, | 1658 2, |
1663 1, | 1659 1, |
1664 0, | 1660 0, |
1665 GL_RGBA, | 1661 GL_RGBA, |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2093 EXPECT_EQ(produced_texture, restored_texture->texture()); | 2089 EXPECT_EQ(produced_texture, restored_texture->texture()); |
2094 EXPECT_EQ(level0, | 2090 EXPECT_EQ(level0, |
2095 GetLevelInfo(restored_texture.get(), GL_TEXTURE_EXTERNAL_OES, 0)); | 2091 GetLevelInfo(restored_texture.get(), GL_TEXTURE_EXTERNAL_OES, 0)); |
2096 } | 2092 } |
2097 | 2093 |
2098 TEST_P(ProduceConsumeTextureTest, ProduceConsumeTextureWithImage) { | 2094 TEST_P(ProduceConsumeTextureTest, ProduceConsumeTextureWithImage) { |
2099 GLenum target = GetParam(); | 2095 GLenum target = GetParam(); |
2100 manager_->SetTarget(texture_ref_.get(), target); | 2096 manager_->SetTarget(texture_ref_.get(), target); |
2101 Texture* texture = texture_ref_->texture(); | 2097 Texture* texture = texture_ref_->texture(); |
2102 EXPECT_EQ(static_cast<GLenum>(target), texture->target()); | 2098 EXPECT_EQ(static_cast<GLenum>(target), texture->target()); |
2103 scoped_refptr<gfx::GLImage> image(gfx::GLImage::CreateGLImage(0)); | 2099 scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub); |
2104 manager_->SetLevelInfo(texture_ref_.get(), | 2100 manager_->SetLevelInfo(texture_ref_.get(), |
2105 target, | 2101 target, |
2106 0, | 2102 0, |
2107 GL_RGBA, | 2103 GL_RGBA, |
2108 0, | 2104 0, |
2109 0, | 2105 0, |
2110 1, | 2106 1, |
2111 0, | 2107 0, |
2112 GL_RGBA, | 2108 GL_RGBA, |
2113 GL_UNSIGNED_BYTE, | 2109 GL_UNSIGNED_BYTE, |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2478 2, | 2474 2, |
2479 1, | 2475 1, |
2480 0, | 2476 0, |
2481 GL_RGBA, | 2477 GL_RGBA, |
2482 GL_UNSIGNED_BYTE, | 2478 GL_UNSIGNED_BYTE, |
2483 true); | 2479 true); |
2484 EXPECT_FALSE(ref1->texture()->HasImages()); | 2480 EXPECT_FALSE(ref1->texture()->HasImages()); |
2485 EXPECT_FALSE(ref2->texture()->HasImages()); | 2481 EXPECT_FALSE(ref2->texture()->HasImages()); |
2486 EXPECT_FALSE(texture_manager1_->HaveImages()); | 2482 EXPECT_FALSE(texture_manager1_->HaveImages()); |
2487 EXPECT_FALSE(texture_manager2_->HaveImages()); | 2483 EXPECT_FALSE(texture_manager2_->HaveImages()); |
2488 texture_manager1_->SetLevelImage(ref1.get(), | 2484 scoped_refptr<gfx::GLImage> image1(new gfx::GLImageStub); |
2489 GL_TEXTURE_2D, | 2485 texture_manager1_->SetLevelImage(ref1.get(), GL_TEXTURE_2D, 1, image1.get()); |
2490 1, | |
2491 gfx::GLImage::CreateGLImage(0).get()); | |
2492 EXPECT_TRUE(ref1->texture()->HasImages()); | 2486 EXPECT_TRUE(ref1->texture()->HasImages()); |
2493 EXPECT_TRUE(ref2->texture()->HasImages()); | 2487 EXPECT_TRUE(ref2->texture()->HasImages()); |
2494 EXPECT_TRUE(texture_manager1_->HaveImages()); | 2488 EXPECT_TRUE(texture_manager1_->HaveImages()); |
2495 EXPECT_TRUE(texture_manager2_->HaveImages()); | 2489 EXPECT_TRUE(texture_manager2_->HaveImages()); |
2496 texture_manager1_->SetLevelImage(ref1.get(), | 2490 scoped_refptr<gfx::GLImage> image2(new gfx::GLImageStub); |
2497 GL_TEXTURE_2D, | 2491 texture_manager1_->SetLevelImage(ref1.get(), GL_TEXTURE_2D, 1, image2.get()); |
2498 1, | |
2499 gfx::GLImage::CreateGLImage(0).get()); | |
2500 EXPECT_TRUE(ref1->texture()->HasImages()); | 2492 EXPECT_TRUE(ref1->texture()->HasImages()); |
2501 EXPECT_TRUE(ref2->texture()->HasImages()); | 2493 EXPECT_TRUE(ref2->texture()->HasImages()); |
2502 EXPECT_TRUE(texture_manager1_->HaveImages()); | 2494 EXPECT_TRUE(texture_manager1_->HaveImages()); |
2503 EXPECT_TRUE(texture_manager2_->HaveImages()); | 2495 EXPECT_TRUE(texture_manager2_->HaveImages()); |
2504 texture_manager1_->SetLevelInfo(ref1.get(), | 2496 texture_manager1_->SetLevelInfo(ref1.get(), |
2505 GL_TEXTURE_2D, | 2497 GL_TEXTURE_2D, |
2506 1, | 2498 1, |
2507 GL_RGBA, | 2499 GL_RGBA, |
2508 2, | 2500 2, |
2509 2, | 2501 2, |
2510 1, | 2502 1, |
2511 0, | 2503 0, |
2512 GL_RGBA, | 2504 GL_RGBA, |
2513 GL_UNSIGNED_BYTE, | 2505 GL_UNSIGNED_BYTE, |
2514 true); | 2506 true); |
2515 EXPECT_FALSE(ref1->texture()->HasImages()); | 2507 EXPECT_FALSE(ref1->texture()->HasImages()); |
2516 EXPECT_FALSE(ref2->texture()->HasImages()); | 2508 EXPECT_FALSE(ref2->texture()->HasImages()); |
2517 EXPECT_FALSE(texture_manager1_->HaveImages()); | 2509 EXPECT_FALSE(texture_manager1_->HaveImages()); |
2518 EXPECT_FALSE(texture_manager1_->HaveImages()); | 2510 EXPECT_FALSE(texture_manager1_->HaveImages()); |
2519 | 2511 |
2520 EXPECT_CALL(*gl_, DeleteTextures(1, _)) | 2512 EXPECT_CALL(*gl_, DeleteTextures(1, _)) |
2521 .Times(1) | 2513 .Times(1) |
2522 .RetiresOnSaturation(); | 2514 .RetiresOnSaturation(); |
2523 texture_manager1_->RemoveTexture(10); | 2515 texture_manager1_->RemoveTexture(10); |
2524 texture_manager2_->RemoveTexture(20); | 2516 texture_manager2_->RemoveTexture(20); |
2525 } | 2517 } |
2526 | 2518 |
2527 } // namespace gles2 | 2519 } // namespace gles2 |
2528 } // namespace gpu | 2520 } // namespace gpu |
OLD | NEW |