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

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

Issue 22824009: Remove StreamTextureManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « gpu/command_buffer/service/texture_manager.cc ('k') | gpu/command_buffer/tests/gl_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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"
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 TEST_F(TextureTest, SetTargetTextureExternalOES) { 462 TEST_F(TextureTest, SetTargetTextureExternalOES) {
463 Texture* texture = texture_ref_->texture(); 463 Texture* texture = texture_ref_->texture();
464 manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_EXTERNAL_OES); 464 manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_EXTERNAL_OES);
465 EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture)); 465 EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture));
466 EXPECT_FALSE(TextureTestHelper::IsCubeComplete(texture)); 466 EXPECT_FALSE(TextureTestHelper::IsCubeComplete(texture));
467 EXPECT_FALSE(manager_->CanGenerateMipmaps(texture_ref_.get())); 467 EXPECT_FALSE(manager_->CanGenerateMipmaps(texture_ref_.get()));
468 EXPECT_TRUE(TextureTestHelper::IsNPOT(texture)); 468 EXPECT_TRUE(TextureTestHelper::IsNPOT(texture));
469 EXPECT_FALSE(manager_->CanRender(texture_ref_.get())); 469 EXPECT_FALSE(manager_->CanRender(texture_ref_.get()));
470 EXPECT_TRUE(texture->SafeToRenderFrom()); 470 EXPECT_TRUE(texture->SafeToRenderFrom());
471 EXPECT_TRUE(texture->IsImmutable()); 471 EXPECT_TRUE(texture->IsImmutable());
472 manager_->SetStreamTexture(texture_ref_.get(), true); 472 manager_->SetLevelInfo(texture_ref_.get(),
473 GL_TEXTURE_EXTERNAL_OES,
474 0,
475 GL_RGBA,
476 0,
477 0,
478 1,
479 0,
480 GL_RGBA,
481 GL_UNSIGNED_BYTE,
482 true);
483 manager_->SetLevelImage(texture_ref_.get(),
484 GL_TEXTURE_EXTERNAL_OES,
485 0,
486 gfx::GLImage::CreateGLImage(0).get());
473 EXPECT_TRUE(manager_->CanRender(texture_ref_.get())); 487 EXPECT_TRUE(manager_->CanRender(texture_ref_.get()));
488 EXPECT_TRUE(texture->IsImmutable());
474 } 489 }
475 490
476 TEST_F(TextureTest, ZeroSizeCanNotRender) { 491 TEST_F(TextureTest, ZeroSizeCanNotRender) {
477 manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D); 492 manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D);
478 EXPECT_FALSE(manager_->CanRender(texture_ref_.get())); 493 EXPECT_FALSE(manager_->CanRender(texture_ref_.get()));
479 manager_->SetLevelInfo(texture_ref_.get(), 494 manager_->SetLevelInfo(texture_ref_.get(),
480 GL_TEXTURE_2D, 495 GL_TEXTURE_2D,
481 0, 496 0,
482 GL_RGBA, 497 GL_RGBA,
483 1, 498 1,
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1800 // Check putting it back genenerates the same signature 1815 // Check putting it back genenerates the same signature
1801 SetParameter(texture_ref_.get(), GL_TEXTURE_WRAP_T, GL_REPEAT, GL_NO_ERROR); 1816 SetParameter(texture_ref_.get(), GL_TEXTURE_WRAP_T, GL_REPEAT, GL_NO_ERROR);
1802 signature2.clear(); 1817 signature2.clear();
1803 manager_->AddToSignature(texture_ref_.get(), GL_TEXTURE_2D, 1, &signature2); 1818 manager_->AddToSignature(texture_ref_.get(), GL_TEXTURE_2D, 1, &signature2);
1804 EXPECT_EQ(signature1, signature2); 1819 EXPECT_EQ(signature1, signature2);
1805 1820
1806 // Check the set was acutally getting different signatures. 1821 // Check the set was acutally getting different signatures.
1807 EXPECT_EQ(11u, string_set.size()); 1822 EXPECT_EQ(11u, string_set.size());
1808 } 1823 }
1809 1824
1810 class ProduceConsumeTextureTest : public TextureTest { 1825 class ProduceConsumeTextureTest : public TextureTest,
1826 public ::testing::WithParamInterface<GLenum> {
1811 public: 1827 public:
1812 virtual void SetUp() { 1828 virtual void SetUp() {
1813 TextureTest::SetUpBase(NULL, "GL_OES_EGL_image_external"); 1829 TextureTest::SetUpBase(NULL, "GL_OES_EGL_image_external");
1814 manager_->CreateTexture(kClient2Id, kService2Id); 1830 manager_->CreateTexture(kClient2Id, kService2Id);
1815 texture2_ = manager_->GetTexture(kClient2Id); 1831 texture2_ = manager_->GetTexture(kClient2Id);
1816 1832
1817 EXPECT_CALL(*decoder_.get(), GetErrorState()) 1833 EXPECT_CALL(*decoder_.get(), GetErrorState())
1818 .WillRepeatedly(Return(error_state_.get())); 1834 .WillRepeatedly(Return(error_state_.get()));
1819 } 1835 }
1820 1836
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1995 2011
1996 // See if we can clear the previously uncleared level now. 2012 // See if we can clear the previously uncleared level now.
1997 EXPECT_EQ(level0, 2013 EXPECT_EQ(level0,
1998 GetLevelInfo(restored_texture.get(), GL_TEXTURE_RECTANGLE_ARB, 0)); 2014 GetLevelInfo(restored_texture.get(), GL_TEXTURE_RECTANGLE_ARB, 0));
1999 EXPECT_CALL(*decoder_, ClearLevel(_, _, _, _, _, _, _, _, _)) 2015 EXPECT_CALL(*decoder_, ClearLevel(_, _, _, _, _, _, _, _, _))
2000 .WillRepeatedly(Return(true)); 2016 .WillRepeatedly(Return(true));
2001 EXPECT_TRUE(manager_->ClearTextureLevel( 2017 EXPECT_TRUE(manager_->ClearTextureLevel(
2002 decoder_.get(), restored_texture.get(), GL_TEXTURE_RECTANGLE_ARB, 0)); 2018 decoder_.get(), restored_texture.get(), GL_TEXTURE_RECTANGLE_ARB, 0));
2003 } 2019 }
2004 2020
2005 TEST_F(ProduceConsumeTextureTest, ProduceConsumeStreamTexture) { 2021 TEST_P(ProduceConsumeTextureTest, ProduceConsumeTextureWithImage) {
2006 manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_EXTERNAL_OES); 2022 GLenum target = GetParam();
2023 manager_->SetTarget(texture_ref_.get(), target);
2007 Texture* texture = texture_ref_->texture(); 2024 Texture* texture = texture_ref_->texture();
2008 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), texture->target()); 2025 EXPECT_EQ(static_cast<GLenum>(target), texture->target());
2009 manager_->SetStreamTexture(texture_ref_.get(), true); 2026 scoped_refptr<gfx::GLImage> image(gfx::GLImage::CreateGLImage(0));
2027 manager_->SetLevelInfo(texture_ref_.get(),
2028 target,
2029 0,
2030 GL_RGBA,
2031 0,
2032 0,
2033 1,
2034 0,
2035 GL_RGBA,
2036 GL_UNSIGNED_BYTE,
2037 true);
2038 manager_->SetLevelImage(texture_ref_.get(),
2039 target,
2040 0,
2041 image);
2010 GLuint service_id = texture->service_id(); 2042 GLuint service_id = texture->service_id();
2011 Texture* produced_texture = Produce(texture_ref_.get()); 2043 Texture* produced_texture = Produce(texture_ref_.get());
2012 EXPECT_TRUE(texture->IsStreamTexture());
2013 2044
2014 GLuint client_id = texture2_->client_id(); 2045 GLuint client_id = texture2_->client_id();
2015 manager_->RemoveTexture(client_id); 2046 manager_->RemoveTexture(client_id);
2016 Consume(client_id, produced_texture); 2047 Consume(client_id, produced_texture);
2017 scoped_refptr<TextureRef> restored_texture = manager_->GetTexture(client_id); 2048 scoped_refptr<TextureRef> restored_texture = manager_->GetTexture(client_id);
2018 EXPECT_EQ(produced_texture, restored_texture->texture()); 2049 EXPECT_EQ(produced_texture, restored_texture->texture());
2019 EXPECT_TRUE(restored_texture->texture()->IsStreamTexture());
2020 EXPECT_TRUE(restored_texture->texture()->IsImmutable());
2021 EXPECT_EQ(service_id, restored_texture->service_id()); 2050 EXPECT_EQ(service_id, restored_texture->service_id());
2051 EXPECT_EQ(image.get(), restored_texture->texture()->GetLevelImage(target, 0));
2022 } 2052 }
2023 2053
2054 static const GLenum kTextureTargets[] = {
2055 GL_TEXTURE_2D,
2056 GL_TEXTURE_EXTERNAL_OES,
2057 GL_TEXTURE_RECTANGLE_ARB,
2058 };
2059
2060 INSTANTIATE_TEST_CASE_P(Target,
2061 ProduceConsumeTextureTest,
2062 ::testing::ValuesIn(kTextureTargets));
2063
2024 TEST_F(ProduceConsumeTextureTest, ProduceConsumeCube) { 2064 TEST_F(ProduceConsumeTextureTest, ProduceConsumeCube) {
2025 manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_CUBE_MAP); 2065 manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_CUBE_MAP);
2026 Texture* texture = texture_ref_->texture(); 2066 Texture* texture = texture_ref_->texture();
2027 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_CUBE_MAP), texture->target()); 2067 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_CUBE_MAP), texture->target());
2028 LevelInfo face0(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 2068 LevelInfo face0(GL_TEXTURE_CUBE_MAP_POSITIVE_X,
2029 GL_RGBA, 2069 GL_RGBA,
2030 1, 2070 1,
2031 1, 2071 1,
2032 1, 2072 1,
2033 0, 2073 0,
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
2344 .Times(1) 2384 .Times(1)
2345 .RetiresOnSaturation(); 2385 .RetiresOnSaturation();
2346 ref2 = NULL; 2386 ref2 = NULL;
2347 texture_manager2_->RemoveTexture(20); 2387 texture_manager2_->RemoveTexture(20);
2348 EXPECT_EQ(initial_memory2, 2388 EXPECT_EQ(initial_memory2,
2349 memory_tracker2_->GetSize(MemoryTracker::kUnmanaged)); 2389 memory_tracker2_->GetSize(MemoryTracker::kUnmanaged));
2350 } 2390 }
2351 2391
2352 } // namespace gles2 2392 } // namespace gles2
2353 } // namespace gpu 2393 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/texture_manager.cc ('k') | gpu/command_buffer/tests/gl_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698