| 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_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 8311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8322 AddOpacityTransitionToElementWithPlayer(child->element_id(), timeline_impl(), | 8322 AddOpacityTransitionToElementWithPlayer(child->element_id(), timeline_impl(), |
| 8323 10.0, 1.f, 0.2f, false); | 8323 10.0, 1.f, 0.2f, false); |
| 8324 ExecuteCalculateDrawProperties(root); | 8324 ExecuteCalculateDrawProperties(root); |
| 8325 | 8325 |
| 8326 EXPECT_EQ(1.f, child->Opacity()); | 8326 EXPECT_EQ(1.f, child->Opacity()); |
| 8327 EXPECT_TRUE(GetRenderSurface(root)); | 8327 EXPECT_TRUE(GetRenderSurface(root)); |
| 8328 EXPECT_NE(GetRenderSurface(child), GetRenderSurface(root)); | 8328 EXPECT_NE(GetRenderSurface(child), GetRenderSurface(root)); |
| 8329 EXPECT_EQ(GetRenderSurface(grandchild), GetRenderSurface(child)); | 8329 EXPECT_EQ(GetRenderSurface(grandchild), GetRenderSurface(child)); |
| 8330 } | 8330 } |
| 8331 | 8331 |
| 8332 static bool FilterIsAnimating(LayerImpl* layer) { |
| 8333 return layer->GetMutatorHost()->IsAnimatingFilterProperty( |
| 8334 layer->element_id(), layer->GetElementTypeForAnimation()); |
| 8335 } |
| 8336 |
| 8332 // Verify that having an animated filter (but no current filter, as these | 8337 // Verify that having an animated filter (but no current filter, as these |
| 8333 // are mutually exclusive) correctly creates a render surface. | 8338 // are mutually exclusive) correctly creates a render surface. |
| 8334 TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) { | 8339 TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) { |
| 8335 LayerImpl* root = root_layer_for_testing(); | 8340 LayerImpl* root = root_layer_for_testing(); |
| 8336 LayerImpl* child = AddChild<LayerImpl>(root); | 8341 LayerImpl* child = AddChild<LayerImpl>(root); |
| 8337 LayerImpl* grandchild = AddChild<LayerImpl>(child); | 8342 LayerImpl* grandchild = AddChild<LayerImpl>(child); |
| 8338 | 8343 |
| 8339 root->SetBounds(gfx::Size(50, 50)); | 8344 root->SetBounds(gfx::Size(50, 50)); |
| 8340 child->SetBounds(gfx::Size(50, 50)); | 8345 child->SetBounds(gfx::Size(50, 50)); |
| 8341 grandchild->SetBounds(gfx::Size(50, 50)); | 8346 grandchild->SetBounds(gfx::Size(50, 50)); |
| 8342 | 8347 |
| 8343 SetElementIdsForTesting(); | 8348 SetElementIdsForTesting(); |
| 8344 AddAnimatedFilterToElementWithPlayer(child->element_id(), timeline_impl(), | 8349 AddAnimatedFilterToElementWithPlayer(child->element_id(), timeline_impl(), |
| 8345 10.0, 0.1f, 0.2f); | 8350 10.0, 0.1f, 0.2f); |
| 8346 ExecuteCalculateDrawProperties(root); | 8351 ExecuteCalculateDrawProperties(root); |
| 8347 | 8352 |
| 8348 EXPECT_TRUE(GetRenderSurface(root)); | 8353 EXPECT_TRUE(GetRenderSurface(root)); |
| 8349 EXPECT_NE(GetRenderSurface(child), GetRenderSurface(root)); | 8354 EXPECT_NE(GetRenderSurface(child), GetRenderSurface(root)); |
| 8350 EXPECT_EQ(GetRenderSurface(grandchild), GetRenderSurface(child)); | 8355 EXPECT_EQ(GetRenderSurface(grandchild), GetRenderSurface(child)); |
| 8351 | 8356 |
| 8352 EXPECT_TRUE(GetRenderSurface(root)->Filters().IsEmpty()); | 8357 EXPECT_TRUE(GetRenderSurface(root)->Filters().IsEmpty()); |
| 8353 EXPECT_TRUE(GetRenderSurface(child)->Filters().IsEmpty()); | 8358 EXPECT_TRUE(GetRenderSurface(child)->Filters().IsEmpty()); |
| 8354 | 8359 |
| 8355 EXPECT_FALSE(root->FilterIsAnimating()); | 8360 EXPECT_FALSE(FilterIsAnimating(root)); |
| 8356 EXPECT_TRUE(child->FilterIsAnimating()); | 8361 EXPECT_TRUE(FilterIsAnimating(child)); |
| 8357 EXPECT_FALSE(grandchild->FilterIsAnimating()); | 8362 EXPECT_FALSE(FilterIsAnimating(grandchild)); |
| 8358 } | 8363 } |
| 8359 | 8364 |
| 8360 // Verify that having a filter animation with a delayed start time creates a | 8365 // Verify that having a filter animation with a delayed start time creates a |
| 8361 // render surface. | 8366 // render surface. |
| 8362 TEST_F(LayerTreeHostCommonTest, DelayedFilterAnimationCreatesRenderSurface) { | 8367 TEST_F(LayerTreeHostCommonTest, DelayedFilterAnimationCreatesRenderSurface) { |
| 8363 LayerImpl* root = root_layer_for_testing(); | 8368 LayerImpl* root = root_layer_for_testing(); |
| 8364 LayerImpl* child = AddChild<LayerImpl>(root); | 8369 LayerImpl* child = AddChild<LayerImpl>(root); |
| 8365 LayerImpl* grandchild = AddChild<LayerImpl>(child); | 8370 LayerImpl* grandchild = AddChild<LayerImpl>(child); |
| 8366 | 8371 |
| 8367 root->SetBounds(gfx::Size(50, 50)); | 8372 root->SetBounds(gfx::Size(50, 50)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 8389 std::move(animation)); | 8394 std::move(animation)); |
| 8390 ExecuteCalculateDrawProperties(root); | 8395 ExecuteCalculateDrawProperties(root); |
| 8391 | 8396 |
| 8392 EXPECT_TRUE(GetRenderSurface(root)); | 8397 EXPECT_TRUE(GetRenderSurface(root)); |
| 8393 EXPECT_NE(GetRenderSurface(child), GetRenderSurface(root)); | 8398 EXPECT_NE(GetRenderSurface(child), GetRenderSurface(root)); |
| 8394 EXPECT_EQ(GetRenderSurface(grandchild), GetRenderSurface(child)); | 8399 EXPECT_EQ(GetRenderSurface(grandchild), GetRenderSurface(child)); |
| 8395 | 8400 |
| 8396 EXPECT_TRUE(GetRenderSurface(root)->Filters().IsEmpty()); | 8401 EXPECT_TRUE(GetRenderSurface(root)->Filters().IsEmpty()); |
| 8397 EXPECT_TRUE(GetRenderSurface(child)->Filters().IsEmpty()); | 8402 EXPECT_TRUE(GetRenderSurface(child)->Filters().IsEmpty()); |
| 8398 | 8403 |
| 8399 EXPECT_FALSE(root->FilterIsAnimating()); | 8404 EXPECT_FALSE(FilterIsAnimating(root)); |
| 8400 EXPECT_FALSE(root->HasPotentiallyRunningFilterAnimation()); | 8405 EXPECT_FALSE(root->HasPotentiallyRunningFilterAnimation()); |
| 8401 EXPECT_FALSE(child->FilterIsAnimating()); | 8406 EXPECT_FALSE(FilterIsAnimating(child)); |
| 8402 EXPECT_TRUE(child->HasPotentiallyRunningFilterAnimation()); | 8407 EXPECT_TRUE(child->HasPotentiallyRunningFilterAnimation()); |
| 8403 EXPECT_FALSE(grandchild->FilterIsAnimating()); | 8408 EXPECT_FALSE(FilterIsAnimating(grandchild)); |
| 8404 EXPECT_FALSE(grandchild->HasPotentiallyRunningFilterAnimation()); | 8409 EXPECT_FALSE(grandchild->HasPotentiallyRunningFilterAnimation()); |
| 8405 } | 8410 } |
| 8406 | 8411 |
| 8407 // Ensures that the property tree code accounts for offsets between fixed | 8412 // Ensures that the property tree code accounts for offsets between fixed |
| 8408 // position layers and their respective containers. | 8413 // position layers and their respective containers. |
| 8409 TEST_F(LayerTreeHostCommonTest, PropertyTreesAccountForFixedParentOffset) { | 8414 TEST_F(LayerTreeHostCommonTest, PropertyTreesAccountForFixedParentOffset) { |
| 8410 LayerImpl* root = root_layer_for_testing(); | 8415 LayerImpl* root = root_layer_for_testing(); |
| 8411 LayerImpl* child = AddChild<LayerImpl>(root); | 8416 LayerImpl* child = AddChild<LayerImpl>(root); |
| 8412 LayerImpl* grandchild = AddChild<LayerImpl>(child); | 8417 LayerImpl* grandchild = AddChild<LayerImpl>(child); |
| 8413 | 8418 |
| (...skipping 1700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10114 | 10119 |
| 10115 // Check child layer draw properties. | 10120 // Check child layer draw properties. |
| 10116 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); | 10121 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); |
| 10117 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); | 10122 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); |
| 10118 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); | 10123 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); |
| 10119 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); | 10124 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); |
| 10120 } | 10125 } |
| 10121 | 10126 |
| 10122 } // namespace | 10127 } // namespace |
| 10123 } // namespace cc | 10128 } // namespace cc |
| OLD | NEW |