| 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 "cc/resources/prioritized_resource_manager.h" | 7 #include "cc/resources/prioritized_resource_manager.h" |
| 8 #include "cc/resources/resource.h" | 8 #include "cc/resources/resource.h" |
| 9 #include "cc/test/fake_output_surface.h" | 9 #include "cc/test/fake_output_surface.h" |
| 10 #include "cc/test/fake_proxy.h" | 10 #include "cc/test/fake_proxy.h" |
| 11 #include "cc/test/tiled_layer_test_common.h" | 11 #include "cc/test/tiled_layer_test_common.h" |
| 12 #include "cc/trees/single_thread_proxy.h" // For DebugScopedSetImplThread | 12 #include "cc/trees/single_thread_proxy.h" // For DebugScopedSetImplThread |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 namespace cc { | 15 namespace cc { |
| 16 | 16 |
| 17 class PrioritizedResourceTest : public testing::Test { | 17 class PrioritizedResourceTest : public testing::Test { |
| 18 public: | 18 public: |
| 19 PrioritizedResourceTest() | 19 PrioritizedResourceTest() |
| 20 : proxy_(scoped_ptr<Thread>(NULL)), | 20 : proxy_(scoped_ptr<Thread>(NULL)), |
| 21 texture_size_(256, 256), | 21 texture_size_(256, 256), |
| 22 texture_format_(GL_RGBA), | 22 texture_format_(GL_RGBA), |
| 23 output_surface_(CreateFakeOutputSurface()) { | 23 output_surface_(CreateFakeOutputSurface()) { |
| 24 DebugScopedSetImplThread impl_thread(&proxy_); | 24 DebugScopedSetImplThread impl_thread(&proxy_); |
| 25 resource_provider_ = cc::ResourceProvider::Create(output_surface_.get()); | 25 resource_provider_ = cc::ResourceProvider::Create(output_surface_.get(), 0); |
| 26 } | 26 } |
| 27 | 27 |
| 28 virtual ~PrioritizedResourceTest() { | 28 virtual ~PrioritizedResourceTest() { |
| 29 DebugScopedSetImplThread impl_thread(&proxy_); | 29 DebugScopedSetImplThread impl_thread(&proxy_); |
| 30 resource_provider_.reset(); | 30 resource_provider_.reset(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 size_t TexturesMemorySize(size_t texture_count) { | 33 size_t TexturesMemorySize(size_t texture_count) { |
| 34 return Resource::MemorySizeBytes(texture_size_, texture_format_) * | 34 return Resource::MemorySizeBytes(texture_size_, texture_format_) * |
| 35 texture_count; | 35 texture_count; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 66 PrioritizedResourceManager* resource_manager) { | 66 PrioritizedResourceManager* resource_manager) { |
| 67 DebugScopedSetImplThreadAndMainThreadBlocked | 67 DebugScopedSetImplThreadAndMainThreadBlocked |
| 68 impl_thread_and_main_thread_blocked(&proxy_); | 68 impl_thread_and_main_thread_blocked(&proxy_); |
| 69 resource_manager->PushTexturePrioritiesToBackings(); | 69 resource_manager->PushTexturePrioritiesToBackings(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 cc::ResourceProvider* ResourceProvider() { return resource_provider_.get(); } | 72 cc::ResourceProvider* ResourceProvider() { return resource_provider_.get(); } |
| 73 | 73 |
| 74 void ResourceManagerAssertInvariants( | 74 void ResourceManagerAssertInvariants( |
| 75 PrioritizedResourceManager* resource_manager) { | 75 PrioritizedResourceManager* resource_manager) { |
| 76 |
| 76 #ifndef NDEBUG | 77 #ifndef NDEBUG |
| 77 DebugScopedSetImplThreadAndMainThreadBlocked | 78 DebugScopedSetImplThreadAndMainThreadBlocked |
| 78 impl_thread_and_main_thread_blocked(&proxy_); | 79 impl_thread_and_main_thread_blocked(&proxy_); |
| 79 resource_manager->AssertInvariants(); | 80 resource_manager->AssertInvariants(); |
| 80 #endif | 81 #endif |
| 81 } | 82 } |
| 82 | 83 |
| 83 bool TextureBackingIsAbovePriorityCutoff(PrioritizedResource* texture) { | 84 bool TextureBackingIsAbovePriorityCutoff(PrioritizedResource* texture) { |
| 84 return texture->backing()-> | 85 return texture->backing()-> |
| 85 was_above_priority_cutoff_at_last_priority_update(); | 86 was_above_priority_cutoff_at_last_priority_update(); |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 resource_manager->MemoryVisibleAndNearbyBytes()); | 794 resource_manager->MemoryVisibleAndNearbyBytes()); |
| 794 } | 795 } |
| 795 | 796 |
| 796 DebugScopedSetImplThreadAndMainThreadBlocked | 797 DebugScopedSetImplThreadAndMainThreadBlocked |
| 797 impl_thread_and_main_thread_blocked(&proxy_); | 798 impl_thread_and_main_thread_blocked(&proxy_); |
| 798 resource_manager->ClearAllMemory(ResourceProvider()); | 799 resource_manager->ClearAllMemory(ResourceProvider()); |
| 799 } | 800 } |
| 800 | 801 |
| 801 } // namespace | 802 } // namespace |
| 802 } // namespace cc | 803 } // namespace cc |
| OLD | NEW |