OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 2018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2029 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 2029 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
2030 | 2030 |
2031 scoped_ptr<FakeProxy> proxy(new FakeProxy); | 2031 scoped_ptr<FakeProxy> proxy(new FakeProxy); |
2032 proxy->GetRendererCapabilities().allow_partial_texture_updates = false; | 2032 proxy->GetRendererCapabilities().allow_partial_texture_updates = false; |
2033 proxy->SetMaxPartialTextureUpdates(5); | 2033 proxy->SetMaxPartialTextureUpdates(5); |
2034 | 2034 |
2035 LayerTreeSettings settings; | 2035 LayerTreeSettings settings; |
2036 settings.max_partial_texture_updates = 10; | 2036 settings.max_partial_texture_updates = 10; |
2037 | 2037 |
2038 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); | 2038 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); |
2039 EXPECT_TRUE(host.InitializeOutputSurfaceIfNeeded()); | 2039 host.OnCreateAndInitializeOutputSurfaceAttempted(true); |
2040 | 2040 |
2041 EXPECT_EQ(0u, host.MaxPartialTextureUpdates()); | 2041 EXPECT_EQ(0u, host.MaxPartialTextureUpdates()); |
2042 } | 2042 } |
2043 | 2043 |
2044 // When partial updates are allowed, | 2044 // When partial updates are allowed, |
2045 // max updates should be limited by the proxy. | 2045 // max updates should be limited by the proxy. |
2046 { | 2046 { |
2047 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 2047 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
2048 | 2048 |
2049 scoped_ptr<FakeProxy> proxy(new FakeProxy); | 2049 scoped_ptr<FakeProxy> proxy(new FakeProxy); |
2050 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; | 2050 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; |
2051 proxy->SetMaxPartialTextureUpdates(5); | 2051 proxy->SetMaxPartialTextureUpdates(5); |
2052 | 2052 |
2053 LayerTreeSettings settings; | 2053 LayerTreeSettings settings; |
2054 settings.max_partial_texture_updates = 10; | 2054 settings.max_partial_texture_updates = 10; |
2055 | 2055 |
2056 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); | 2056 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); |
2057 EXPECT_TRUE(host.InitializeOutputSurfaceIfNeeded()); | 2057 host.OnCreateAndInitializeOutputSurfaceAttempted(true); |
2058 | 2058 |
2059 EXPECT_EQ(5u, host.MaxPartialTextureUpdates()); | 2059 EXPECT_EQ(5u, host.MaxPartialTextureUpdates()); |
2060 } | 2060 } |
2061 | 2061 |
2062 // When partial updates are allowed, | 2062 // When partial updates are allowed, |
2063 // max updates should also be limited by the settings. | 2063 // max updates should also be limited by the settings. |
2064 { | 2064 { |
2065 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 2065 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
2066 | 2066 |
2067 scoped_ptr<FakeProxy> proxy(new FakeProxy); | 2067 scoped_ptr<FakeProxy> proxy(new FakeProxy); |
2068 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; | 2068 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; |
2069 proxy->SetMaxPartialTextureUpdates(20); | 2069 proxy->SetMaxPartialTextureUpdates(20); |
2070 | 2070 |
2071 LayerTreeSettings settings; | 2071 LayerTreeSettings settings; |
2072 settings.max_partial_texture_updates = 10; | 2072 settings.max_partial_texture_updates = 10; |
2073 | 2073 |
2074 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); | 2074 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); |
2075 EXPECT_TRUE(host.InitializeOutputSurfaceIfNeeded()); | 2075 host.OnCreateAndInitializeOutputSurfaceAttempted(true); |
2076 | 2076 |
2077 EXPECT_EQ(10u, host.MaxPartialTextureUpdates()); | 2077 EXPECT_EQ(10u, host.MaxPartialTextureUpdates()); |
2078 } | 2078 } |
2079 } | 2079 } |
2080 | 2080 |
2081 TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) { | 2081 TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) { |
2082 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 2082 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
2083 | 2083 |
2084 LayerTreeSettings settings; | 2084 LayerTreeSettings settings; |
2085 settings.max_partial_texture_updates = 4; | 2085 settings.max_partial_texture_updates = 4; |
2086 | 2086 |
2087 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 2087 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
2088 new TestSharedBitmapManager()); | 2088 new TestSharedBitmapManager()); |
2089 scoped_ptr<LayerTreeHost> host = LayerTreeHost::CreateSingleThreaded( | 2089 scoped_ptr<LayerTreeHost> host = LayerTreeHost::CreateSingleThreaded( |
2090 &client, &client, shared_bitmap_manager.get(), settings); | 2090 &client, &client, shared_bitmap_manager.get(), settings); |
2091 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); | 2091 host->Composite(base::TimeTicks::Now()); |
| 2092 |
2092 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); | 2093 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); |
2093 } | 2094 } |
2094 | 2095 |
2095 TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) { | 2096 TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) { |
2096 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_SOFTWARE); | 2097 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_SOFTWARE); |
2097 | 2098 |
2098 LayerTreeSettings settings; | 2099 LayerTreeSettings settings; |
2099 settings.max_partial_texture_updates = 4; | 2100 settings.max_partial_texture_updates = 4; |
2100 | 2101 |
2101 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 2102 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
2102 new TestSharedBitmapManager()); | 2103 new TestSharedBitmapManager()); |
2103 scoped_ptr<LayerTreeHost> host = LayerTreeHost::CreateSingleThreaded( | 2104 scoped_ptr<LayerTreeHost> host = LayerTreeHost::CreateSingleThreaded( |
2104 &client, &client, shared_bitmap_manager.get(), settings); | 2105 &client, &client, shared_bitmap_manager.get(), settings); |
2105 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); | 2106 host->Composite(base::TimeTicks::Now()); |
| 2107 |
2106 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); | 2108 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); |
2107 } | 2109 } |
2108 | 2110 |
2109 TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) { | 2111 TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) { |
2110 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_3D); | 2112 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_3D); |
2111 | 2113 |
2112 LayerTreeSettings settings; | 2114 LayerTreeSettings settings; |
2113 settings.max_partial_texture_updates = 4; | 2115 settings.max_partial_texture_updates = 4; |
2114 | 2116 |
2115 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 2117 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
2116 new TestSharedBitmapManager()); | 2118 new TestSharedBitmapManager()); |
2117 scoped_ptr<LayerTreeHost> host = LayerTreeHost::CreateSingleThreaded( | 2119 scoped_ptr<LayerTreeHost> host = LayerTreeHost::CreateSingleThreaded( |
2118 &client, &client, shared_bitmap_manager.get(), settings); | 2120 &client, &client, shared_bitmap_manager.get(), settings); |
2119 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); | 2121 host->Composite(base::TimeTicks::Now()); |
| 2122 |
2120 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); | 2123 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); |
2121 } | 2124 } |
2122 | 2125 |
2123 TEST(LayerTreeHostTest, | 2126 TEST(LayerTreeHostTest, |
2124 PartialUpdatesWithDelegatingRendererAndSoftwareContent) { | 2127 PartialUpdatesWithDelegatingRendererAndSoftwareContent) { |
2125 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_SOFTWARE); | 2128 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_SOFTWARE); |
2126 | 2129 |
2127 LayerTreeSettings settings; | 2130 LayerTreeSettings settings; |
2128 settings.max_partial_texture_updates = 4; | 2131 settings.max_partial_texture_updates = 4; |
2129 | 2132 |
2130 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 2133 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
2131 new TestSharedBitmapManager()); | 2134 new TestSharedBitmapManager()); |
2132 scoped_ptr<LayerTreeHost> host = LayerTreeHost::CreateSingleThreaded( | 2135 scoped_ptr<LayerTreeHost> host = LayerTreeHost::CreateSingleThreaded( |
2133 &client, &client, shared_bitmap_manager.get(), settings); | 2136 &client, &client, shared_bitmap_manager.get(), settings); |
2134 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); | 2137 host->Composite(base::TimeTicks::Now()); |
| 2138 |
2135 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); | 2139 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); |
2136 } | 2140 } |
2137 | 2141 |
2138 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted | 2142 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted |
2139 : public LayerTreeHostTest { | 2143 : public LayerTreeHostTest { |
2140 public: | 2144 public: |
2141 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted() | 2145 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted() |
2142 : root_layer_(FakeContentLayer::Create(&client_)), | 2146 : root_layer_(FakeContentLayer::Create(&client_)), |
2143 child_layer1_(FakeContentLayer::Create(&client_)), | 2147 child_layer1_(FakeContentLayer::Create(&client_)), |
2144 child_layer2_(FakeContentLayer::Create(&client_)), | 2148 child_layer2_(FakeContentLayer::Create(&client_)), |
(...skipping 2789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4934 const gfx::Size bounds_; | 4938 const gfx::Size bounds_; |
4935 FakeContentLayerClient client_; | 4939 FakeContentLayerClient client_; |
4936 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; | 4940 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; |
4937 scoped_refptr<FakePictureLayer> picture_layer_; | 4941 scoped_refptr<FakePictureLayer> picture_layer_; |
4938 Layer* child_layer_; | 4942 Layer* child_layer_; |
4939 }; | 4943 }; |
4940 | 4944 |
4941 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | 4945 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); |
4942 | 4946 |
4943 } // namespace cc | 4947 } // namespace cc |
OLD | NEW |