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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 resources.push_back((*it)->id()); | 106 resources.push_back((*it)->id()); |
105 return resources; | 107 return resources; |
106 } | 108 } |
107 | 109 |
108 protected: | 110 protected: |
109 FakeProxy proxy_; | 111 FakeProxy proxy_; |
110 const gfx::Size texture_size_; | 112 const gfx::Size texture_size_; |
111 const ResourceFormat texture_format_; | 113 const ResourceFormat texture_format_; |
112 FakeOutputSurfaceClient output_surface_client_; | 114 FakeOutputSurfaceClient output_surface_client_; |
113 scoped_ptr<OutputSurface> output_surface_; | 115 scoped_ptr<OutputSurface> output_surface_; |
| 116 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; |
114 scoped_ptr<ResourceProvider> resource_provider_; | 117 scoped_ptr<ResourceProvider> resource_provider_; |
115 }; | 118 }; |
116 | 119 |
117 namespace { | 120 namespace { |
118 | 121 |
119 TEST_F(PrioritizedResourceTest, RequestTextureExceedingMaxLimit) { | 122 TEST_F(PrioritizedResourceTest, RequestTextureExceedingMaxLimit) { |
120 const size_t kMaxTextures = 8; | 123 const size_t kMaxTextures = 8; |
121 scoped_ptr<PrioritizedResourceManager> resource_manager = | 124 scoped_ptr<PrioritizedResourceManager> resource_manager = |
122 CreateManager(kMaxTextures); | 125 CreateManager(kMaxTextures); |
123 | 126 |
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 resource_manager->MemoryVisibleAndNearbyBytes()); | 1105 resource_manager->MemoryVisibleAndNearbyBytes()); |
1103 } | 1106 } |
1104 | 1107 |
1105 DebugScopedSetImplThreadAndMainThreadBlocked | 1108 DebugScopedSetImplThreadAndMainThreadBlocked |
1106 impl_thread_and_main_thread_blocked(&proxy_); | 1109 impl_thread_and_main_thread_blocked(&proxy_); |
1107 resource_manager->ClearAllMemory(resource_provider()); | 1110 resource_manager->ClearAllMemory(resource_provider()); |
1108 } | 1111 } |
1109 | 1112 |
1110 } // namespace | 1113 } // namespace |
1111 } // namespace cc | 1114 } // namespace cc |
OLD | NEW |