OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "cc/resources/resource_pool.h" | 5 #include "cc/resources/resource_pool.h" |
6 | 6 |
| 7 #include "cc/resources/resource_util.h" |
7 #include "cc/resources/scoped_resource.h" | 8 #include "cc/resources/scoped_resource.h" |
8 #include "cc/test/fake_output_surface.h" | 9 #include "cc/test/fake_output_surface.h" |
9 #include "cc/test/fake_output_surface_client.h" | 10 #include "cc/test/fake_output_surface_client.h" |
10 #include "cc/test/fake_resource_provider.h" | 11 #include "cc/test/fake_resource_provider.h" |
11 #include "cc/test/test_shared_bitmap_manager.h" | 12 #include "cc/test/test_shared_bitmap_manager.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 | 14 |
14 namespace cc { | 15 namespace cc { |
15 namespace { | 16 namespace { |
16 | 17 |
(...skipping 30 matching lines...) Expand all Loading... |
47 } | 48 } |
48 | 49 |
49 TEST_F(ResourcePoolTest, AccountingSingleResource) { | 50 TEST_F(ResourcePoolTest, AccountingSingleResource) { |
50 // Limits high enough to not be hit by this test. | 51 // Limits high enough to not be hit by this test. |
51 size_t bytes_limit = 10 * 1024 * 1024; | 52 size_t bytes_limit = 10 * 1024 * 1024; |
52 size_t count_limit = 100; | 53 size_t count_limit = 100; |
53 resource_pool_->SetResourceUsageLimits(bytes_limit, bytes_limit, count_limit); | 54 resource_pool_->SetResourceUsageLimits(bytes_limit, bytes_limit, count_limit); |
54 | 55 |
55 gfx::Size size(100, 100); | 56 gfx::Size size(100, 100); |
56 ResourceFormat format = RGBA_8888; | 57 ResourceFormat format = RGBA_8888; |
57 size_t resource_bytes = Resource::UncheckedMemorySizeBytes(size, format); | 58 size_t resource_bytes = |
| 59 ResourceUtil::UncheckedSizeInBytes<size_t>(size, format); |
58 scoped_ptr<ScopedResource> resource = | 60 scoped_ptr<ScopedResource> resource = |
59 resource_pool_->AcquireResource(size, format); | 61 resource_pool_->AcquireResource(size, format); |
60 | 62 |
61 EXPECT_EQ(resource_bytes, resource_pool_->total_memory_usage_bytes()); | 63 EXPECT_EQ(resource_bytes, resource_pool_->total_memory_usage_bytes()); |
62 EXPECT_EQ(resource_bytes, resource_pool_->acquired_memory_usage_bytes()); | 64 EXPECT_EQ(resource_bytes, resource_pool_->acquired_memory_usage_bytes()); |
63 EXPECT_EQ(1u, resource_pool_->total_resource_count()); | 65 EXPECT_EQ(1u, resource_pool_->total_resource_count()); |
64 EXPECT_EQ(1u, resource_pool_->acquired_resource_count()); | 66 EXPECT_EQ(1u, resource_pool_->acquired_resource_count()); |
65 EXPECT_EQ(0u, resource_pool_->busy_resource_count()); | 67 EXPECT_EQ(0u, resource_pool_->busy_resource_count()); |
66 | 68 |
67 resource_pool_->ReleaseResource(resource.Pass(), 0u); | 69 resource_pool_->ReleaseResource(resource.Pass(), 0u); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 EXPECT_EQ(1u, resource_provider_->num_resources()); | 134 EXPECT_EQ(1u, resource_provider_->num_resources()); |
133 | 135 |
134 resource_provider_->LoseResourceForTesting(resource->id()); | 136 resource_provider_->LoseResourceForTesting(resource->id()); |
135 resource_pool_->ReleaseResource(resource.Pass(), 0u); | 137 resource_pool_->ReleaseResource(resource.Pass(), 0u); |
136 resource_pool_->CheckBusyResources(wait_if_needed); | 138 resource_pool_->CheckBusyResources(wait_if_needed); |
137 EXPECT_EQ(0u, resource_provider_->num_resources()); | 139 EXPECT_EQ(0u, resource_provider_->num_resources()); |
138 } | 140 } |
139 | 141 |
140 } // namespace | 142 } // namespace |
141 } // namespace cc | 143 } // namespace cc |
OLD | NEW |