Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: gpu/command_buffer/service/texture_manager_unittest.cc

Issue 1401423003: Re-land: ui: Move GLImage::BindTexImage fallback from GLImage implementations to GLES2CmdDecoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unit tests and avoid unnecessary teximage2d call in decoder Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 .Times(1) 1381 .Times(1)
1382 .RetiresOnSaturation(); 1382 .RetiresOnSaturation();
1383 texture_ref = NULL; 1383 texture_ref = NULL;
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, nullptr) == nullptr);
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 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL); 1395 Texture::BOUND);
1396 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 1, nullptr) == nullptr);
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,
1398 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1) == NULL); 1399 Texture::UNBOUND);
1399 manager_->SetLevelImage(texture_ref_.get(), GL_TEXTURE_2D, 1, image.get()); 1400 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 1, nullptr) == nullptr);
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, nullptr) == nullptr);
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 =
1410 string_set->insert(str); 1413 string_set->insert(str);
1411 return !result.second; 1414 return !result.second;
1412 } 1415 }
1413 1416
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(),
1755 restored_texture->texture()->GetLevelImage(target, 0, nullptr));
1751 } 1756 }
1752 1757
1753 static const GLenum kTextureTargets[] = {GL_TEXTURE_2D, GL_TEXTURE_EXTERNAL_OES, 1758 static const GLenum kTextureTargets[] = {GL_TEXTURE_2D, GL_TEXTURE_EXTERNAL_OES,
1754 GL_TEXTURE_RECTANGLE_ARB, }; 1759 GL_TEXTURE_RECTANGLE_ARB, };
1755 1760
1756 INSTANTIATE_TEST_CASE_P(Target, 1761 INSTANTIATE_TEST_CASE_P(Target,
1757 ProduceConsumeTextureTest, 1762 ProduceConsumeTextureTest,
1758 ::testing::ValuesIn(kTextureTargets)); 1763 ::testing::ValuesIn(kTextureTargets));
1759 1764
1760 TEST_F(ProduceConsumeTextureTest, ProduceConsumeCube) { 1765 TEST_F(ProduceConsumeTextureTest, ProduceConsumeCube) {
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
2050 2055
2051 texture_manager1_->SetTarget(ref1.get(), GL_TEXTURE_2D); 2056 texture_manager1_->SetTarget(ref1.get(), GL_TEXTURE_2D);
2052 texture_manager1_->SetLevelInfo(ref1.get(), GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 2057 texture_manager1_->SetLevelInfo(ref1.get(), GL_TEXTURE_2D, 1, GL_RGBA, 2, 2,
2053 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 2058 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
2054 gfx::Rect(2, 2)); 2059 gfx::Rect(2, 2));
2055 EXPECT_FALSE(ref1->texture()->HasImages()); 2060 EXPECT_FALSE(ref1->texture()->HasImages());
2056 EXPECT_FALSE(ref2->texture()->HasImages()); 2061 EXPECT_FALSE(ref2->texture()->HasImages());
2057 EXPECT_FALSE(texture_manager1_->HaveImages()); 2062 EXPECT_FALSE(texture_manager1_->HaveImages());
2058 EXPECT_FALSE(texture_manager2_->HaveImages()); 2063 EXPECT_FALSE(texture_manager2_->HaveImages());
2059 scoped_refptr<gfx::GLImage> image1(new gfx::GLImageStub); 2064 scoped_refptr<gfx::GLImage> image1(new gfx::GLImageStub);
2060 texture_manager1_->SetLevelImage(ref1.get(), GL_TEXTURE_2D, 1, image1.get()); 2065 texture_manager1_->SetLevelImage(ref1.get(), GL_TEXTURE_2D, 1, image1.get(),
2066 Texture::BOUND);
2061 EXPECT_TRUE(ref1->texture()->HasImages()); 2067 EXPECT_TRUE(ref1->texture()->HasImages());
2062 EXPECT_TRUE(ref2->texture()->HasImages()); 2068 EXPECT_TRUE(ref2->texture()->HasImages());
2063 EXPECT_TRUE(texture_manager1_->HaveImages()); 2069 EXPECT_TRUE(texture_manager1_->HaveImages());
2064 EXPECT_TRUE(texture_manager2_->HaveImages()); 2070 EXPECT_TRUE(texture_manager2_->HaveImages());
2065 scoped_refptr<gfx::GLImage> image2(new gfx::GLImageStub); 2071 scoped_refptr<gfx::GLImage> image2(new gfx::GLImageStub);
2066 texture_manager1_->SetLevelImage(ref1.get(), GL_TEXTURE_2D, 1, image2.get()); 2072 texture_manager1_->SetLevelImage(ref1.get(), GL_TEXTURE_2D, 1, image2.get(),
2073 Texture::BOUND);
2067 EXPECT_TRUE(ref1->texture()->HasImages()); 2074 EXPECT_TRUE(ref1->texture()->HasImages());
2068 EXPECT_TRUE(ref2->texture()->HasImages()); 2075 EXPECT_TRUE(ref2->texture()->HasImages());
2069 EXPECT_TRUE(texture_manager1_->HaveImages()); 2076 EXPECT_TRUE(texture_manager1_->HaveImages());
2070 EXPECT_TRUE(texture_manager2_->HaveImages()); 2077 EXPECT_TRUE(texture_manager2_->HaveImages());
2071 texture_manager1_->SetLevelInfo(ref1.get(), GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 2078 texture_manager1_->SetLevelInfo(ref1.get(), GL_TEXTURE_2D, 1, GL_RGBA, 2, 2,
2072 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 2079 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
2073 gfx::Rect(2, 2)); 2080 gfx::Rect(2, 2));
2074 EXPECT_FALSE(ref1->texture()->HasImages()); 2081 EXPECT_FALSE(ref1->texture()->HasImages());
2075 EXPECT_FALSE(ref2->texture()->HasImages()); 2082 EXPECT_FALSE(ref2->texture()->HasImages());
2076 EXPECT_FALSE(texture_manager1_->HaveImages()); 2083 EXPECT_FALSE(texture_manager1_->HaveImages());
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
2323 ExpectValid(GL_DEPTH_COMPONENT, GL_FLOAT, GL_DEPTH_COMPONENT32F); 2330 ExpectValid(GL_DEPTH_COMPONENT, GL_FLOAT, GL_DEPTH_COMPONENT32F);
2324 ExpectValid(GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_DEPTH24_STENCIL8); 2331 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, 2332 ExpectValid(GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV,
2326 GL_DEPTH32F_STENCIL8); 2333 GL_DEPTH32F_STENCIL8);
2327 2334
2328 ExpectInvalid(GL_RGB_INTEGER, GL_INT, GL_RGBA8); 2335 ExpectInvalid(GL_RGB_INTEGER, GL_INT, GL_RGBA8);
2329 } 2336 }
2330 2337
2331 } // namespace gles2 2338 } // namespace gles2
2332 } // namespace gpu 2339 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698