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