| 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/layers/layer.h" | 5 #include "cc/layers/layer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "cc/animation/animation_host.h" | 10 #include "cc/animation/animation_host.h" |
| (...skipping 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1543 // 2. indirectly calls SetNeedsUpdate, exactly once for each call to | 1543 // 2. indirectly calls SetNeedsUpdate, exactly once for each call to |
| 1544 // SetNeedsDisplay. | 1544 // SetNeedsDisplay. |
| 1545 | 1545 |
| 1546 scoped_refptr<Layer> test_layer = Layer::Create(); | 1546 scoped_refptr<Layer> test_layer = Layer::Create(); |
| 1547 EXPECT_SET_NEEDS_FULL_TREE_SYNC( | 1547 EXPECT_SET_NEEDS_FULL_TREE_SYNC( |
| 1548 1, layer_tree_host_->SetRootLayer(test_layer)); | 1548 1, layer_tree_host_->SetRootLayer(test_layer)); |
| 1549 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); | 1549 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); |
| 1550 | 1550 |
| 1551 gfx::Size test_bounds = gfx::Size(501, 508); | 1551 gfx::Size test_bounds = gfx::Size(501, 508); |
| 1552 | 1552 |
| 1553 gfx::Rect dirty1 = gfx::Rect(10, 15, 1, 2); | 1553 gfx::Rect dirty_rect = gfx::Rect(10, 15, 1, 2); |
| 1554 gfx::Rect dirty2 = gfx::Rect(20, 25, 3, 4); | |
| 1555 gfx::Rect out_of_bounds_dirty_rect = gfx::Rect(400, 405, 500, 502); | 1554 gfx::Rect out_of_bounds_dirty_rect = gfx::Rect(400, 405, 500, 502); |
| 1556 | 1555 |
| 1557 // Before anything, test_layer should not be dirty. | 1556 // Before anything, test_layer should not be dirty. |
| 1558 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); | 1557 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); |
| 1559 | 1558 |
| 1560 // This is just initialization, but SetNeedsCommit behavior is verified anyway | 1559 // This is just initialization, but SetNeedsCommit behavior is verified anyway |
| 1561 // to avoid warnings. | 1560 // to avoid warnings. |
| 1562 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetBounds(test_bounds)); | 1561 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetBounds(test_bounds)); |
| 1563 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); | 1562 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); |
| 1564 | 1563 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1584 // Case 3: SetNeedsDisplay() with an empty rect. | 1583 // Case 3: SetNeedsDisplay() with an empty rect. |
| 1585 test_layer->ResetNeedsDisplayForTesting(); | 1584 test_layer->ResetNeedsDisplayForTesting(); |
| 1586 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); | 1585 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); |
| 1587 EXPECT_SET_NEEDS_COMMIT(0, test_layer->SetNeedsDisplayRect(gfx::Rect())); | 1586 EXPECT_SET_NEEDS_COMMIT(0, test_layer->SetNeedsDisplayRect(gfx::Rect())); |
| 1588 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); | 1587 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); |
| 1589 | 1588 |
| 1590 // Case 4: SetNeedsDisplay() with a non-drawable layer | 1589 // Case 4: SetNeedsDisplay() with a non-drawable layer |
| 1591 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(false)); | 1590 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(false)); |
| 1592 test_layer->ResetNeedsDisplayForTesting(); | 1591 test_layer->ResetNeedsDisplayForTesting(); |
| 1593 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); | 1592 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); |
| 1594 EXPECT_SET_NEEDS_UPDATE(0, test_layer->SetNeedsDisplayRect(dirty1)); | 1593 EXPECT_SET_NEEDS_UPDATE(0, test_layer->SetNeedsDisplayRect(dirty_rect)); |
| 1595 EXPECT_TRUE(test_layer->NeedsDisplayForTesting()); | 1594 EXPECT_TRUE(test_layer->NeedsDisplayForTesting()); |
| 1596 } | 1595 } |
| 1597 | 1596 |
| 1598 TEST_F(LayerTest, TestSettingMainThreadScrollingReason) { | 1597 TEST_F(LayerTest, TestSettingMainThreadScrollingReason) { |
| 1599 scoped_refptr<Layer> test_layer = Layer::Create(); | 1598 scoped_refptr<Layer> test_layer = Layer::Create(); |
| 1600 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, | 1599 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, |
| 1601 layer_tree_host_->SetRootLayer(test_layer)); | 1600 layer_tree_host_->SetRootLayer(test_layer)); |
| 1602 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); | 1601 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); |
| 1603 | 1602 |
| 1604 // sanity check of initial test condition | 1603 // sanity check of initial test condition |
| (...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2494 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); | 2493 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); |
| 2495 | 2494 |
| 2496 test_layer->PushPropertiesTo(impl_layer.get()); | 2495 test_layer->PushPropertiesTo(impl_layer.get()); |
| 2497 | 2496 |
| 2498 EXPECT_EQ(2lu, impl_layer->element_id()); | 2497 EXPECT_EQ(2lu, impl_layer->element_id()); |
| 2499 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); | 2498 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); |
| 2500 } | 2499 } |
| 2501 | 2500 |
| 2502 } // namespace | 2501 } // namespace |
| 2503 } // namespace cc | 2502 } // namespace cc |
| OLD | NEW |