OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/resources/prioritized_resource.h" | 5 #include "cc/resources/prioritized_resource.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "cc/resources/prioritized_resource_manager.h" | 9 #include "cc/resources/prioritized_resource_manager.h" |
10 #include "cc/resources/resource.h" | 10 #include "cc/resources/resource.h" |
11 #include "cc/resources/resource_provider.h" | 11 #include "cc/resources/resource_provider.h" |
12 #include "cc/test/fake_output_surface.h" | 12 #include "cc/test/fake_output_surface.h" |
13 #include "cc/test/fake_output_surface_client.h" | 13 #include "cc/test/fake_output_surface_client.h" |
14 #include "cc/test/fake_proxy.h" | 14 #include "cc/test/fake_proxy.h" |
| 15 #include "cc/test/test_shared_bitmap_manager.h" |
15 #include "cc/test/tiled_layer_test_common.h" | 16 #include "cc/test/tiled_layer_test_common.h" |
16 #include "cc/trees/single_thread_proxy.h" // For DebugScopedSetImplThread | 17 #include "cc/trees/single_thread_proxy.h" // For DebugScopedSetImplThread |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 | 19 |
19 namespace cc { | 20 namespace cc { |
20 | 21 |
21 class PrioritizedResourceTest : public testing::Test { | 22 class PrioritizedResourceTest : public testing::Test { |
22 public: | 23 public: |
23 PrioritizedResourceTest() | 24 PrioritizedResourceTest() |
24 : texture_size_(256, 256), | 25 : texture_size_(256, 256), |
25 texture_format_(RGBA_8888), | 26 texture_format_(RGBA_8888), |
26 output_surface_(FakeOutputSurface::Create3d()) { | 27 output_surface_(FakeOutputSurface::Create3d()) { |
27 DebugScopedSetImplThread impl_thread(&proxy_); | 28 DebugScopedSetImplThread impl_thread(&proxy_); |
28 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 29 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
29 resource_provider_ = | 30 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); |
30 ResourceProvider::Create(output_surface_.get(), NULL, 0, false, 1); | 31 resource_provider_ = ResourceProvider::Create( |
| 32 output_surface_.get(), shared_bitmap_manager_.get(), 0, false, 1); |
31 } | 33 } |
32 | 34 |
33 virtual ~PrioritizedResourceTest() { | 35 virtual ~PrioritizedResourceTest() { |
34 DebugScopedSetImplThread impl_thread(&proxy_); | 36 DebugScopedSetImplThread impl_thread(&proxy_); |
35 resource_provider_.reset(); | 37 resource_provider_.reset(); |
36 } | 38 } |
37 | 39 |
38 size_t TexturesMemorySize(size_t texture_count) { | 40 size_t TexturesMemorySize(size_t texture_count) { |
39 return Resource::MemorySizeBytes(texture_size_, texture_format_) * | 41 return Resource::MemorySizeBytes(texture_size_, texture_format_) * |
40 texture_count; | 42 texture_count; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 resources.push_back((*it)->id()); | 104 resources.push_back((*it)->id()); |
103 return resources; | 105 return resources; |
104 } | 106 } |
105 | 107 |
106 protected: | 108 protected: |
107 FakeProxy proxy_; | 109 FakeProxy proxy_; |
108 const gfx::Size texture_size_; | 110 const gfx::Size texture_size_; |
109 const ResourceFormat texture_format_; | 111 const ResourceFormat texture_format_; |
110 FakeOutputSurfaceClient output_surface_client_; | 112 FakeOutputSurfaceClient output_surface_client_; |
111 scoped_ptr<OutputSurface> output_surface_; | 113 scoped_ptr<OutputSurface> output_surface_; |
| 114 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; |
112 scoped_ptr<ResourceProvider> resource_provider_; | 115 scoped_ptr<ResourceProvider> resource_provider_; |
113 }; | 116 }; |
114 | 117 |
115 namespace { | 118 namespace { |
116 | 119 |
117 TEST_F(PrioritizedResourceTest, RequestTextureExceedingMaxLimit) { | 120 TEST_F(PrioritizedResourceTest, RequestTextureExceedingMaxLimit) { |
118 const size_t kMaxTextures = 8; | 121 const size_t kMaxTextures = 8; |
119 scoped_ptr<PrioritizedResourceManager> resource_manager = | 122 scoped_ptr<PrioritizedResourceManager> resource_manager = |
120 CreateManager(kMaxTextures); | 123 CreateManager(kMaxTextures); |
121 | 124 |
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1100 resource_manager->MemoryVisibleAndNearbyBytes()); | 1103 resource_manager->MemoryVisibleAndNearbyBytes()); |
1101 } | 1104 } |
1102 | 1105 |
1103 DebugScopedSetImplThreadAndMainThreadBlocked | 1106 DebugScopedSetImplThreadAndMainThreadBlocked |
1104 impl_thread_and_main_thread_blocked(&proxy_); | 1107 impl_thread_and_main_thread_blocked(&proxy_); |
1105 resource_manager->ClearAllMemory(resource_provider()); | 1108 resource_manager->ClearAllMemory(resource_provider()); |
1106 } | 1109 } |
1107 | 1110 |
1108 } // namespace | 1111 } // namespace |
1109 } // namespace cc | 1112 } // namespace cc |
OLD | NEW |