| 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_output_surface_client.h" |
| 10 #include "cc/test/fake_proxy.h" | 11 #include "cc/test/fake_proxy.h" |
| 11 #include "cc/test/tiled_layer_test_common.h" | 12 #include "cc/test/tiled_layer_test_common.h" |
| 12 #include "cc/trees/single_thread_proxy.h" // For DebugScopedSetImplThread | 13 #include "cc/trees/single_thread_proxy.h" // For DebugScopedSetImplThread |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 15 |
| 15 namespace cc { | 16 namespace cc { |
| 16 | 17 |
| 17 class PrioritizedResourceTest : public testing::Test { | 18 class PrioritizedResourceTest : public testing::Test { |
| 18 public: | 19 public: |
| 19 PrioritizedResourceTest() | 20 PrioritizedResourceTest() |
| 20 : texture_size_(256, 256), | 21 : texture_size_(256, 256), |
| 21 texture_format_(GL_RGBA), | 22 texture_format_(GL_RGBA), |
| 22 output_surface_(CreateFakeOutputSurface()) { | 23 output_surface_(FakeOutputSurface::Create3d()) { |
| 23 DebugScopedSetImplThread impl_thread(&proxy_); | 24 DebugScopedSetImplThread impl_thread(&proxy_); |
| 25 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
| 24 resource_provider_ = cc::ResourceProvider::Create(output_surface_.get(), 0); | 26 resource_provider_ = cc::ResourceProvider::Create(output_surface_.get(), 0); |
| 25 } | 27 } |
| 26 | 28 |
| 27 virtual ~PrioritizedResourceTest() { | 29 virtual ~PrioritizedResourceTest() { |
| 28 DebugScopedSetImplThread impl_thread(&proxy_); | 30 DebugScopedSetImplThread impl_thread(&proxy_); |
| 29 resource_provider_.reset(); | 31 resource_provider_.reset(); |
| 30 } | 32 } |
| 31 | 33 |
| 32 size_t TexturesMemorySize(size_t texture_count) { | 34 size_t TexturesMemorySize(size_t texture_count) { |
| 33 return Resource::MemorySizeBytes(texture_size_, texture_format_) * | 35 return Resource::MemorySizeBytes(texture_size_, texture_format_) * |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 87 } |
| 86 | 88 |
| 87 size_t EvictedBackingCount(PrioritizedResourceManager* resource_manager) { | 89 size_t EvictedBackingCount(PrioritizedResourceManager* resource_manager) { |
| 88 return resource_manager->evicted_backings_.size(); | 90 return resource_manager->evicted_backings_.size(); |
| 89 } | 91 } |
| 90 | 92 |
| 91 protected: | 93 protected: |
| 92 FakeProxy proxy_; | 94 FakeProxy proxy_; |
| 93 const gfx::Size texture_size_; | 95 const gfx::Size texture_size_; |
| 94 const GLenum texture_format_; | 96 const GLenum texture_format_; |
| 97 FakeOutputSurfaceClient output_surface_client_; |
| 95 scoped_ptr<OutputSurface> output_surface_; | 98 scoped_ptr<OutputSurface> output_surface_; |
| 96 scoped_ptr<cc::ResourceProvider> resource_provider_; | 99 scoped_ptr<cc::ResourceProvider> resource_provider_; |
| 97 }; | 100 }; |
| 98 | 101 |
| 99 namespace { | 102 namespace { |
| 100 | 103 |
| 101 TEST_F(PrioritizedResourceTest, RequestTextureExceedingMaxLimit) { | 104 TEST_F(PrioritizedResourceTest, RequestTextureExceedingMaxLimit) { |
| 102 const size_t kMaxTextures = 8; | 105 const size_t kMaxTextures = 8; |
| 103 scoped_ptr<PrioritizedResourceManager> resource_manager = | 106 scoped_ptr<PrioritizedResourceManager> resource_manager = |
| 104 CreateManager(kMaxTextures); | 107 CreateManager(kMaxTextures); |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 resource_manager->MemoryVisibleAndNearbyBytes()); | 795 resource_manager->MemoryVisibleAndNearbyBytes()); |
| 793 } | 796 } |
| 794 | 797 |
| 795 DebugScopedSetImplThreadAndMainThreadBlocked | 798 DebugScopedSetImplThreadAndMainThreadBlocked |
| 796 impl_thread_and_main_thread_blocked(&proxy_); | 799 impl_thread_and_main_thread_blocked(&proxy_); |
| 797 resource_manager->ClearAllMemory(ResourceProvider()); | 800 resource_manager->ClearAllMemory(ResourceProvider()); |
| 798 } | 801 } |
| 799 | 802 |
| 800 } // namespace | 803 } // namespace |
| 801 } // namespace cc | 804 } // namespace cc |
| OLD | NEW |