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

Side by Side Diff: content/common/gpu/gpu_memory_manager_unittest.cc

Issue 10801014: Add GetStubStats and related functions in GpuMemoryManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removing hash specialization on win. Created 8 years, 5 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 | « content/common/gpu/gpu_memory_manager.cc ('k') | no next file » | 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 "content/common/gpu/gpu_command_buffer_stub.h" 5 #include "content/common/gpu/gpu_command_buffer_stub.h"
6 #include "content/common/gpu/gpu_memory_allocation.h" 6 #include "content/common/gpu/gpu_memory_allocation.h"
7 #include "content/common/gpu/gpu_memory_manager.h" 7 #include "content/common/gpu/gpu_memory_manager.h"
8 8
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 EXPECT_NE(allocation, GpuMemoryAllocation(sz+1, buffer_allocation)); 592 EXPECT_NE(allocation, GpuMemoryAllocation(sz+1, buffer_allocation));
593 593
594 for(size_t k = 0; k != suggested_buffer_allocation_values.size(); ++k) { 594 for(size_t k = 0; k != suggested_buffer_allocation_values.size(); ++k) {
595 int buffer_allocation_other = suggested_buffer_allocation_values[k]; 595 int buffer_allocation_other = suggested_buffer_allocation_values[k];
596 if (buffer_allocation == buffer_allocation_other) continue; 596 if (buffer_allocation == buffer_allocation_other) continue;
597 EXPECT_NE(allocation, GpuMemoryAllocation(sz, buffer_allocation_other)); 597 EXPECT_NE(allocation, GpuMemoryAllocation(sz, buffer_allocation_other));
598 } 598 }
599 } 599 }
600 } 600 }
601 } 601 }
602
603 // Test GpuMemoryManager Stub Memory Stats functionality:
604 // Creats various surface/non-surface stubs and switches stub visibility and
605 // tests to see that stats data structure values are correct.
606 TEST_F(GpuMemoryManagerTest, StubMemoryStatsForLastManageTests) {
607 GpuMemoryManager::StubMemoryStatMap stats;
608
609 Manage();
610 stats = memory_manager_.stub_memory_stats_for_last_manage();
611 EXPECT_EQ(stats.size(), 0ul);
612
613 FakeCommandBufferStub stub1(GenerateUniqueSurfaceId(), true, older_);
614 client_.stubs_.push_back(&stub1);
615 Manage();
616 stats = memory_manager_.stub_memory_stats_for_last_manage();
617 size_t stub1allocation1 = stats[&stub1].allocation.gpu_resource_size_in_bytes;
618
619 EXPECT_EQ(stats.size(), 1ul);
620 EXPECT_TRUE(stats[&stub1].visible);
621 EXPECT_GT(stub1allocation1, 0ul);
622
623 FakeCommandBufferStubWithoutSurface stub2;
624 client_.stubs_.push_back(&stub2);
625 stub2.share_group_.push_back(&stub1);
626 Manage();
627 stats = memory_manager_.stub_memory_stats_for_last_manage();
628 size_t stub1allocation2 = stats[&stub1].allocation.gpu_resource_size_in_bytes;
629 size_t stub2allocation2 = stats[&stub2].allocation.gpu_resource_size_in_bytes;
630
631 EXPECT_EQ(stats.size(), 2ul);
632 EXPECT_TRUE(stats[&stub1].visible);
633 EXPECT_TRUE(stats[&stub2].visible);
634 EXPECT_GT(stub1allocation2, 0ul);
635 EXPECT_GT(stub2allocation2, 0ul);
636 EXPECT_LT(stub1allocation2, stub1allocation1);
637
638 FakeCommandBufferStub stub3(GenerateUniqueSurfaceId(), true, older_);
639 client_.stubs_.push_back(&stub3);
640 Manage();
641 stats = memory_manager_.stub_memory_stats_for_last_manage();
642 size_t stub1allocation3 = stats[&stub1].allocation.gpu_resource_size_in_bytes;
643 size_t stub2allocation3 = stats[&stub1].allocation.gpu_resource_size_in_bytes;
644 size_t stub3allocation3 = stats[&stub3].allocation.gpu_resource_size_in_bytes;
645
646 EXPECT_EQ(stats.size(), 3ul);
647 EXPECT_TRUE(stats[&stub1].visible);
648 EXPECT_TRUE(stats[&stub2].visible);
649 EXPECT_TRUE(stats[&stub3].visible);
650 EXPECT_GT(stub1allocation3, 0ul);
651 EXPECT_GT(stub2allocation3, 0ul);
652 EXPECT_GT(stub3allocation3, 0ul);
653 EXPECT_LT(stub1allocation3, stub1allocation2);
654
655 stub1.surface_state_.visible = false;
656 Manage();
657 stats = memory_manager_.stub_memory_stats_for_last_manage();
658 size_t stub1allocation4 = stats[&stub1].allocation.gpu_resource_size_in_bytes;
659 size_t stub2allocation4 = stats[&stub2].allocation.gpu_resource_size_in_bytes;
660 size_t stub3allocation4 = stats[&stub3].allocation.gpu_resource_size_in_bytes;
661
662 EXPECT_EQ(stats.size(), 3ul);
663 EXPECT_FALSE(stats[&stub1].visible);
664 EXPECT_FALSE(stats[&stub2].visible);
665 EXPECT_TRUE(stats[&stub3].visible);
666 EXPECT_EQ(stub1allocation4, 0ul);
667 EXPECT_GE(stub2allocation4, 0ul);
668 EXPECT_GT(stub3allocation4, 0ul);
669 EXPECT_GT(stub3allocation4, stub3allocation3);
670 }
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_memory_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698