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 28 matching lines...) Expand all Loading... |
39 #include "cc/test/fake_picture_layer_impl.h" | 39 #include "cc/test/fake_picture_layer_impl.h" |
40 #include "cc/test/geometry_test_utils.h" | 40 #include "cc/test/geometry_test_utils.h" |
41 #include "cc/test/layer_tree_host_common_test.h" | 41 #include "cc/test/layer_tree_host_common_test.h" |
42 #include "cc/test/test_task_graph_runner.h" | 42 #include "cc/test/test_task_graph_runner.h" |
43 #include "cc/trees/draw_property_utils.h" | 43 #include "cc/trees/draw_property_utils.h" |
44 #include "cc/trees/layer_tree_impl.h" | 44 #include "cc/trees/layer_tree_impl.h" |
45 #include "cc/trees/single_thread_proxy.h" | 45 #include "cc/trees/single_thread_proxy.h" |
46 #include "cc/trees/task_runner_provider.h" | 46 #include "cc/trees/task_runner_provider.h" |
47 #include "testing/gmock/include/gmock/gmock.h" | 47 #include "testing/gmock/include/gmock/gmock.h" |
48 #include "testing/gtest/include/gtest/gtest.h" | 48 #include "testing/gtest/include/gtest/gtest.h" |
| 49 #include "third_party/skia/include/effects/SkOffsetImageFilter.h" |
49 #include "ui/gfx/geometry/quad_f.h" | 50 #include "ui/gfx/geometry/quad_f.h" |
50 #include "ui/gfx/geometry/vector2d_conversions.h" | 51 #include "ui/gfx/geometry/vector2d_conversions.h" |
51 #include "ui/gfx/transform.h" | 52 #include "ui/gfx/transform.h" |
52 | 53 |
53 namespace cc { | 54 namespace cc { |
54 namespace { | 55 namespace { |
55 | 56 |
56 class LayerWithForcedDrawsContent : public Layer { | 57 class LayerWithForcedDrawsContent : public Layer { |
57 public: | 58 public: |
58 LayerWithForcedDrawsContent() {} | 59 LayerWithForcedDrawsContent() {} |
(...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1404 inputs.can_adjust_raster_scales = true; | 1405 inputs.can_adjust_raster_scales = true; |
1405 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1406 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
1406 | 1407 |
1407 ASSERT_TRUE(parent->render_surface()); | 1408 ASSERT_TRUE(parent->render_surface()); |
1408 EXPECT_EQ(2U, parent->render_surface()->layer_list().size()); | 1409 EXPECT_EQ(2U, parent->render_surface()->layer_list().size()); |
1409 EXPECT_EQ(4U, render_surface_layer_list.size()); | 1410 EXPECT_EQ(4U, render_surface_layer_list.size()); |
1410 EXPECT_EQ(gfx::RectF(-30, -30, 160, 160), | 1411 EXPECT_EQ(gfx::RectF(-30, -30, 160, 160), |
1411 parent->render_surface()->DrawableContentRect()); | 1412 parent->render_surface()->DrawableContentRect()); |
1412 } | 1413 } |
1413 | 1414 |
| 1415 TEST_F(LayerTreeHostCommonTest, DrawableContentRectForReferenceFilter) { |
| 1416 LayerImpl* root = root_layer(); |
| 1417 LayerImpl* child = AddChild<LayerImpl>(root); |
| 1418 child->SetDrawsContent(true); |
| 1419 |
| 1420 SetLayerPropertiesForTesting(root, gfx::Transform(), gfx::Point3F(), |
| 1421 gfx::PointF(), gfx::Size(100, 100), true, false, |
| 1422 true); |
| 1423 SetLayerPropertiesForTesting(child, gfx::Transform(), gfx::Point3F(), |
| 1424 gfx::PointF(), gfx::Size(25, 25), true, false, |
| 1425 true); |
| 1426 |
| 1427 FilterOperations filters; |
| 1428 filters.Append(FilterOperation::CreateReferenceFilter( |
| 1429 SkOffsetImageFilter::Make(50, 50, nullptr))); |
| 1430 child->SetFilters(filters); |
| 1431 |
| 1432 ExecuteCalculateDrawProperties(root); |
| 1433 |
| 1434 // The render surface's size should be unaffected by the offset image filter; |
| 1435 // it need only have a drawable content rect large enough to contain the |
| 1436 // contents (at the new offset). |
| 1437 ASSERT_TRUE(child->render_surface()); |
| 1438 EXPECT_EQ(gfx::RectF(50, 50, 25, 25), |
| 1439 child->render_surface()->DrawableContentRect()); |
| 1440 } |
| 1441 |
1414 TEST_F(LayerTreeHostCommonTest, RenderSurfaceForBlendMode) { | 1442 TEST_F(LayerTreeHostCommonTest, RenderSurfaceForBlendMode) { |
1415 LayerImpl* parent = root_layer(); | 1443 LayerImpl* parent = root_layer(); |
1416 LayerImpl* child = AddChild<LayerImpl>(parent); | 1444 LayerImpl* child = AddChild<LayerImpl>(parent); |
1417 child->SetDrawsContent(true); | 1445 child->SetDrawsContent(true); |
1418 | 1446 |
1419 const gfx::Transform identity_matrix; | 1447 const gfx::Transform identity_matrix; |
1420 const SkXfermode::Mode blend_mode = SkXfermode::kMultiply_Mode; | 1448 const SkXfermode::Mode blend_mode = SkXfermode::kMultiply_Mode; |
1421 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), | 1449 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), |
1422 gfx::PointF(), gfx::Size(10, 10), true, false, | 1450 gfx::PointF(), gfx::Size(10, 10), true, false, |
1423 true); | 1451 true); |
(...skipping 8676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10100 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10128 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
10101 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10129 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
10102 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10130 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
10103 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10131 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
10104 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10132 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
10105 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10133 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
10106 } | 10134 } |
10107 | 10135 |
10108 } // namespace | 10136 } // namespace |
10109 } // namespace cc | 10137 } // namespace cc |
OLD | NEW |