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

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

Issue 11081007: Remove implicit flooring Scale() method from Point and Size. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | 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 "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 #include "ui/gfx/size_conversions.h"
8 9
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 11
11 class FakeCommandBufferStub : public GpuCommandBufferStubBase { 12 class FakeCommandBufferStub : public GpuCommandBufferStubBase {
12 public: 13 public:
13 SurfaceState surface_state_; 14 SurfaceState surface_state_;
14 GpuMemoryAllocation allocation_; 15 GpuMemoryAllocation allocation_;
15 gfx::Size size_; 16 gfx::Size size_;
16 17
17 FakeCommandBufferStub() 18 FakeCommandBufferStub()
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stub.allocation_)); 543 EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stub.allocation_));
543 EXPECT_EQ(stub.allocation_.gpu_resource_size_in_bytes, 544 EXPECT_EQ(stub.allocation_.gpu_resource_size_in_bytes,
544 GetMinimumTabAllocation()); 545 GetMinimumTabAllocation());
545 546
546 // Keep increasing size, making sure allocation is always increasing 547 // Keep increasing size, making sure allocation is always increasing
547 // Until it finally reaches the maximum. 548 // Until it finally reaches the maximum.
548 while (stub.allocation_.gpu_resource_size_in_bytes < 549 while (stub.allocation_.gpu_resource_size_in_bytes <
549 GetAvailableGpuMemory()) { 550 GetAvailableGpuMemory()) {
550 size_t previous_allocation = stub.allocation_.gpu_resource_size_in_bytes; 551 size_t previous_allocation = stub.allocation_.gpu_resource_size_in_bytes;
551 552
552 stub.size_ = stub.size_.Scale(1, 2); 553 stub.size_ = gfx::ToFlooredSize(stub.size_.Scale(1, 2));
553 554
554 Manage(); 555 Manage();
555 EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stub.allocation_)); 556 EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stub.allocation_));
556 EXPECT_GE(stub.allocation_.gpu_resource_size_in_bytes, 557 EXPECT_GE(stub.allocation_.gpu_resource_size_in_bytes,
557 GetMinimumTabAllocation()); 558 GetMinimumTabAllocation());
558 EXPECT_LE(stub.allocation_.gpu_resource_size_in_bytes, 559 EXPECT_LE(stub.allocation_.gpu_resource_size_in_bytes,
559 GetAvailableGpuMemory()); 560 GetAvailableGpuMemory());
560 EXPECT_GE(stub.allocation_.gpu_resource_size_in_bytes, 561 EXPECT_GE(stub.allocation_.gpu_resource_size_in_bytes,
561 previous_allocation); 562 previous_allocation);
562 } 563 }
563 564
564 // One final size increase to confirm it stays capped at maximum. 565 // One final size increase to confirm it stays capped at maximum.
565 stub.size_ = stub.size_.Scale(1, 2); 566 stub.size_ = gfx::ToFlooredSize(stub.size_.Scale(1, 2));
566 567
567 Manage(); 568 Manage();
568 EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stub.allocation_)); 569 EXPECT_TRUE(IsAllocationForegroundForSurfaceYes(stub.allocation_));
569 EXPECT_EQ(stub.allocation_.gpu_resource_size_in_bytes, 570 EXPECT_EQ(stub.allocation_.gpu_resource_size_in_bytes,
570 GetAvailableGpuMemory()); 571 GetAvailableGpuMemory());
571 } 572 }
572 #endif 573 #endif
573 574
574 // Test GpuMemoryAllocation comparison operators: Iterate over all possible 575 // Test GpuMemoryAllocation comparison operators: Iterate over all possible
575 // combinations of gpu_resource_size_in_bytes, suggest_have_backbuffer, and 576 // combinations of gpu_resource_size_in_bytes, suggest_have_backbuffer, and
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 EXPECT_FALSE(stats[&stub1].visible); 684 EXPECT_FALSE(stats[&stub1].visible);
684 EXPECT_FALSE(stats[&stub2].visible); 685 EXPECT_FALSE(stats[&stub2].visible);
685 EXPECT_TRUE(stats[&stub3].visible); 686 EXPECT_TRUE(stats[&stub3].visible);
686 EXPECT_EQ(stub1allocation4, 0ul); 687 EXPECT_EQ(stub1allocation4, 0ul);
687 EXPECT_GE(stub2allocation4, 0ul); 688 EXPECT_GE(stub2allocation4, 0ul);
688 EXPECT_GT(stub3allocation4, 0ul); 689 EXPECT_GT(stub3allocation4, 0ul);
689 if (compositors_get_bonus_allocation && 690 if (compositors_get_bonus_allocation &&
690 stub3allocation3 != GetMaximumTabAllocation()) 691 stub3allocation3 != GetMaximumTabAllocation())
691 EXPECT_GT(stub3allocation4, stub3allocation3); 692 EXPECT_GT(stub3allocation4, stub3allocation3);
692 } 693 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698