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

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

Issue 14828011: Mark zero dimension textures as unrenderable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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
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/gles2_cmd_decoder_mock.h" 10 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h"
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 EXPECT_FALSE(manager_->CanRender(texture_)); 477 EXPECT_FALSE(manager_->CanRender(texture_));
478 EXPECT_TRUE(texture_->SafeToRenderFrom()); 478 EXPECT_TRUE(texture_->SafeToRenderFrom());
479 EXPECT_FALSE(texture_->IsImmutable()); 479 EXPECT_FALSE(texture_->IsImmutable());
480 } 480 }
481 481
482 TEST_F(TextureTest, SetTargetTextureExternalOES) { 482 TEST_F(TextureTest, SetTargetTextureExternalOES) {
483 manager_->SetTarget(texture_, GL_TEXTURE_EXTERNAL_OES); 483 manager_->SetTarget(texture_, GL_TEXTURE_EXTERNAL_OES);
484 EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture_)); 484 EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture_));
485 EXPECT_FALSE(TextureTestHelper::IsCubeComplete(texture_)); 485 EXPECT_FALSE(TextureTestHelper::IsCubeComplete(texture_));
486 EXPECT_FALSE(manager_->CanGenerateMipmaps(texture_)); 486 EXPECT_FALSE(manager_->CanGenerateMipmaps(texture_));
487 EXPECT_FALSE(TextureTestHelper::IsNPOT(texture_)); 487 EXPECT_TRUE(TextureTestHelper::IsNPOT(texture_));
488 EXPECT_TRUE(manager_->CanRender(texture_)); 488 EXPECT_FALSE(manager_->CanRender(texture_));
489 EXPECT_TRUE(texture_->SafeToRenderFrom()); 489 EXPECT_TRUE(texture_->SafeToRenderFrom());
490 EXPECT_TRUE(texture_->IsImmutable()); 490 EXPECT_TRUE(texture_->IsImmutable());
491 manager_->SetStreamTexture(texture_, true);
492 EXPECT_TRUE(manager_->CanRender(texture_));
493 }
494
495 TEST_F(TextureTest, ZeroSizeCanNotRender) {
496 manager_->SetTarget(texture_, GL_TEXTURE_2D);
497 EXPECT_FALSE(manager_->CanRender(texture_));
498 manager_->SetLevelInfo(texture_,
499 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
500 EXPECT_TRUE(manager_->CanRender(texture_));
501 manager_->SetLevelInfo(texture_,
502 GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
503 EXPECT_FALSE(manager_->CanRender(texture_));
491 } 504 }
492 505
493 TEST_F(TextureTest, EstimatedSize) { 506 TEST_F(TextureTest, EstimatedSize) {
494 manager_->SetTarget(texture_, GL_TEXTURE_2D); 507 manager_->SetTarget(texture_, GL_TEXTURE_2D);
495 manager_->SetLevelInfo(texture_, 508 manager_->SetLevelInfo(texture_,
496 GL_TEXTURE_2D, 0, GL_RGBA, 8, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true); 509 GL_TEXTURE_2D, 0, GL_RGBA, 8, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
497 EXPECT_EQ(8u * 4u * 4u, texture_->estimated_size()); 510 EXPECT_EQ(8u * 4u * 4u, texture_->estimated_size());
498 manager_->SetLevelInfo(texture_, 511 manager_->SetLevelInfo(texture_,
499 GL_TEXTURE_2D, 2, GL_RGBA, 8, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true); 512 GL_TEXTURE_2D, 2, GL_RGBA, 8, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true);
500 EXPECT_EQ(8u * 4u * 4u * 2u, texture_->estimated_size()); 513 EXPECT_EQ(8u * 4u * 4u * 2u, texture_->estimated_size());
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 EXPECT_EQ(level0, GetLevelInfo(texture2_.get(), GL_TEXTURE_RECTANGLE_ARB, 0)); 1491 EXPECT_EQ(level0, GetLevelInfo(texture2_.get(), GL_TEXTURE_RECTANGLE_ARB, 0));
1479 EXPECT_CALL(*decoder_, ClearLevel(_, _, _, _, _, _, _, _, _)) 1492 EXPECT_CALL(*decoder_, ClearLevel(_, _, _, _, _, _, _, _, _))
1480 .WillRepeatedly(Return(true)); 1493 .WillRepeatedly(Return(true));
1481 EXPECT_TRUE(manager_->ClearTextureLevel( 1494 EXPECT_TRUE(manager_->ClearTextureLevel(
1482 decoder_.get(), texture2_, GL_TEXTURE_RECTANGLE_ARB, 0)); 1495 decoder_.get(), texture2_, GL_TEXTURE_RECTANGLE_ARB, 0));
1483 } 1496 }
1484 1497
1485 TEST_F(SaveRestoreTextureTest, SaveRestoreStreamTexture) { 1498 TEST_F(SaveRestoreTextureTest, SaveRestoreStreamTexture) {
1486 manager_->SetTarget(texture_, GL_TEXTURE_EXTERNAL_OES); 1499 manager_->SetTarget(texture_, GL_TEXTURE_EXTERNAL_OES);
1487 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), texture_->target()); 1500 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), texture_->target());
1488 texture_->SetStreamTexture(true); 1501 manager_->SetStreamTexture(texture_, true);
1489 GLuint service_id = texture_->service_id(); 1502 GLuint service_id = texture_->service_id();
1490 scoped_ptr<TextureDefinition> definition(Save(texture_)); 1503 scoped_ptr<TextureDefinition> definition(Save(texture_));
1491 EXPECT_FALSE(texture_->IsStreamTexture()); 1504 EXPECT_FALSE(texture_->IsStreamTexture());
1492 manager_->SetTarget(texture2_, GL_TEXTURE_EXTERNAL_OES); 1505 manager_->SetTarget(texture2_, GL_TEXTURE_EXTERNAL_OES);
1493 Restore(texture2_, definition.release()); 1506 Restore(texture2_, definition.release());
1494 EXPECT_TRUE(texture2_->IsStreamTexture()); 1507 EXPECT_TRUE(texture2_->IsStreamTexture());
1495 EXPECT_TRUE(texture2_->IsImmutable()); 1508 EXPECT_TRUE(texture2_->IsImmutable());
1496 EXPECT_EQ(service_id, texture2_->service_id()); 1509 EXPECT_EQ(service_id, texture2_->service_id());
1497 } 1510 }
1498 1511
(...skipping 28 matching lines...) Expand all
1527 EXPECT_EQ(face0, 1540 EXPECT_EQ(face0,
1528 GetLevelInfo(texture2_.get(), GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0)); 1541 GetLevelInfo(texture2_.get(), GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0));
1529 EXPECT_EQ(face5, 1542 EXPECT_EQ(face5,
1530 GetLevelInfo(texture2_.get(), GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0)); 1543 GetLevelInfo(texture2_.get(), GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0));
1531 } 1544 }
1532 1545
1533 } // namespace gles2 1546 } // namespace gles2
1534 } // namespace gpu 1547 } // namespace gpu
1535 1548
1536 1549
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698