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 2192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2203 } | 2203 } |
2204 virtual bool FillsBoundsCompletely() const OVERRIDE { return false; } | 2204 virtual bool FillsBoundsCompletely() const OVERRIDE { return false; } |
2205 | 2205 |
2206 private: | 2206 private: |
2207 Layer* layer_; | 2207 Layer* layer_; |
2208 int paint_count_; | 2208 int paint_count_; |
2209 int lcd_notification_count_; | 2209 int lcd_notification_count_; |
2210 }; | 2210 }; |
2211 | 2211 |
2212 virtual void SetupTree() OVERRIDE { | 2212 virtual void SetupTree() OVERRIDE { |
2213 scoped_refptr<ContentLayer> root_layer = ContentLayer::Create(&client_); | 2213 scoped_refptr<Layer> root_layer; |
| 2214 if (layer_tree_host()->settings().impl_side_painting) |
| 2215 root_layer = PictureLayer::Create(&client_); |
| 2216 else |
| 2217 root_layer = ContentLayer::Create(&client_); |
2214 root_layer->SetIsDrawable(true); | 2218 root_layer->SetIsDrawable(true); |
2215 root_layer->SetBounds(gfx::Size(1, 1)); | 2219 root_layer->SetBounds(gfx::Size(1, 1)); |
2216 | 2220 |
2217 layer_tree_host()->SetRootLayer(root_layer); | 2221 layer_tree_host()->SetRootLayer(root_layer); |
2218 client_.set_layer(root_layer.get()); | 2222 client_.set_layer(root_layer.get()); |
2219 | 2223 |
2220 // The expecations are based on the assumption that the default | 2224 // The expecations are based on the assumption that the default |
2221 // LCD settings are: | 2225 // LCD settings are: |
2222 EXPECT_TRUE(layer_tree_host()->settings().can_use_lcd_text); | 2226 EXPECT_TRUE(layer_tree_host()->settings().can_use_lcd_text); |
2223 EXPECT_FALSE(root_layer->can_use_lcd_text()); | 2227 EXPECT_FALSE(root_layer->can_use_lcd_text()); |
2224 | 2228 |
2225 LayerTreeHostTest::SetupTree(); | 2229 LayerTreeHostTest::SetupTree(); |
2226 } | 2230 } |
2227 | 2231 |
2228 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 2232 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
2229 virtual void AfterTest() OVERRIDE {} | 2233 virtual void AfterTest() OVERRIDE {} |
2230 | 2234 |
2231 virtual void DidCommit() OVERRIDE { | 2235 virtual void DidCommit() OVERRIDE { |
2232 switch (layer_tree_host()->source_frame_number()) { | 2236 switch (layer_tree_host()->source_frame_number()) { |
2233 case 1: | 2237 case 1: |
2234 // The first update consists one LCD notification and one paint. | 2238 // The first update consists of one LCD notification and one paint. |
2235 EXPECT_EQ(1, client_.lcd_notification_count()); | 2239 EXPECT_EQ(1, client_.lcd_notification_count()); |
2236 EXPECT_EQ(1, client_.paint_count()); | 2240 EXPECT_EQ(1, client_.paint_count()); |
2237 // LCD text must have been enabled on the layer. | 2241 // LCD text must have been enabled on the layer. |
2238 EXPECT_TRUE(layer_tree_host()->root_layer()->can_use_lcd_text()); | 2242 EXPECT_TRUE(layer_tree_host()->root_layer()->can_use_lcd_text()); |
2239 PostSetNeedsCommitToMainThread(); | 2243 PostSetNeedsCommitToMainThread(); |
2240 break; | 2244 break; |
2241 case 2: | 2245 case 2: |
2242 // Since nothing changed on layer, there should be no notification | 2246 // Since nothing changed on layer, there should be no notification |
2243 // or paint on the second update. | 2247 // or paint on the second update. |
2244 EXPECT_EQ(1, client_.lcd_notification_count()); | 2248 EXPECT_EQ(1, client_.lcd_notification_count()); |
2245 EXPECT_EQ(1, client_.paint_count()); | 2249 EXPECT_EQ(1, client_.paint_count()); |
2246 // LCD text must not have changed. | 2250 // LCD text must not have changed. |
2247 EXPECT_TRUE(layer_tree_host()->root_layer()->can_use_lcd_text()); | 2251 EXPECT_TRUE(layer_tree_host()->root_layer()->can_use_lcd_text()); |
2248 // Change layer opacity that should trigger lcd notification. | 2252 // Change layer opacity that should trigger lcd notification. |
2249 layer_tree_host()->root_layer()->SetOpacity(.5f); | 2253 layer_tree_host()->root_layer()->SetOpacity(.5f); |
2250 // No need to request a commit - setting opacity will do it. | 2254 // No need to request a commit - setting opacity will do it. |
2251 break; | 2255 break; |
2252 default: | 2256 default: |
2253 // Verify that there is not extra commit due to layer invalidation. | 2257 // Verify that there is no extra commit due to layer invalidation. |
2254 EXPECT_EQ(3, layer_tree_host()->source_frame_number()); | 2258 EXPECT_EQ(3, layer_tree_host()->source_frame_number()); |
2255 // LCD notification count should have incremented due to | 2259 // LCD notification count should have incremented due to |
2256 // change in layer opacity. | 2260 // change in layer opacity. |
2257 EXPECT_EQ(2, client_.lcd_notification_count()); | 2261 EXPECT_EQ(2, client_.lcd_notification_count()); |
2258 // Paint count should be incremented due to invalidation. | 2262 // Paint count should be incremented due to invalidation. |
2259 EXPECT_EQ(2, client_.paint_count()); | 2263 EXPECT_EQ(2, client_.paint_count()); |
2260 // LCD text must have been disabled on the layer due to opacity. | 2264 // LCD text must have been disabled on the layer due to opacity. |
2261 EXPECT_FALSE(layer_tree_host()->root_layer()->can_use_lcd_text()); | 2265 EXPECT_FALSE(layer_tree_host()->root_layer()->can_use_lcd_text()); |
2262 EndTest(); | 2266 EndTest(); |
2263 break; | 2267 break; |
2264 } | 2268 } |
2265 } | 2269 } |
2266 | 2270 |
2267 private: | 2271 private: |
2268 NotificationClient client_; | 2272 NotificationClient client_; |
2269 }; | 2273 }; |
2270 | 2274 |
2271 SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification); | 2275 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLCDNotification); |
2272 | 2276 |
2273 // Verify that the BeginFrame notification is used to initiate rendering. | 2277 // Verify that the BeginFrame notification is used to initiate rendering. |
2274 class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest { | 2278 class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest { |
2275 public: | 2279 public: |
2276 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 2280 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
2277 settings->begin_frame_scheduling_enabled = true; | 2281 settings->begin_frame_scheduling_enabled = true; |
2278 } | 2282 } |
2279 | 2283 |
2280 virtual void BeginTest() OVERRIDE { | 2284 virtual void BeginTest() OVERRIDE { |
2281 // This will trigger a SetNeedsBeginFrame which will trigger a | 2285 // This will trigger a SetNeedsBeginFrame which will trigger a |
(...skipping 2606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4888 const gfx::Size bounds_; | 4892 const gfx::Size bounds_; |
4889 FakeContentLayerClient client_; | 4893 FakeContentLayerClient client_; |
4890 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; | 4894 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; |
4891 scoped_refptr<FakePictureLayer> picture_layer_; | 4895 scoped_refptr<FakePictureLayer> picture_layer_; |
4892 Layer* child_layer_; | 4896 Layer* child_layer_; |
4893 }; | 4897 }; |
4894 | 4898 |
4895 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | 4899 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); |
4896 | 4900 |
4897 } // namespace cc | 4901 } // namespace cc |
OLD | NEW |