Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Side by Side Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 2018983003: cc: Use FilterOperations::MapRect in RenderSurfaceImpl::DrawableContentRect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove logging Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/render_surface_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 1401
1401 LayerImplList render_surface_layer_list; 1402 LayerImplList render_surface_layer_list;
1402 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1403 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1403 root, root->bounds(), &render_surface_layer_list); 1404 root, root->bounds(), &render_surface_layer_list);
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
1412 // The rectangle enclosing child1 and child2 (0,0 50x50), expanded for the
1413 // blur (-30,-30 110x110), and then scaled by the scale matrix
1414 // (-60,-60 220x220).
ajuma 2016/06/06 18:08:21 Thanks for adding this comment (and for the simila
1415 EXPECT_EQ(gfx::RectF(-60, -60, 220, 220),
1411 parent->render_surface()->DrawableContentRect()); 1416 parent->render_surface()->DrawableContentRect());
1412 } 1417 }
1413 1418
1419 TEST_F(LayerTreeHostCommonTest, DrawableContentRectForReferenceFilter) {
1420 LayerImpl* root = root_layer();
1421 LayerImpl* child = AddChild<LayerImpl>(root);
1422 child->SetDrawsContent(true);
1423
1424 SetLayerPropertiesForTesting(root, gfx::Transform(), gfx::Point3F(),
1425 gfx::PointF(), gfx::Size(100, 100), true, false,
1426 true);
1427 SetLayerPropertiesForTesting(child, gfx::Transform(), gfx::Point3F(),
1428 gfx::PointF(), gfx::Size(25, 25), true, false,
1429 true);
1430
1431 FilterOperations filters;
1432 filters.Append(FilterOperation::CreateReferenceFilter(
1433 SkOffsetImageFilter::Make(50, 50, nullptr)));
1434 child->SetFilters(filters);
1435
1436 ExecuteCalculateDrawProperties(root);
1437
1438 // The render surface's size should be unaffected by the offset image filter;
1439 // it need only have a drawable content rect large enough to contain the
1440 // contents (at the new offset).
1441 ASSERT_TRUE(child->render_surface());
1442 EXPECT_EQ(gfx::RectF(50, 50, 25, 25),
1443 child->render_surface()->DrawableContentRect());
1444 }
1445
1446 TEST_F(LayerTreeHostCommonTest, DrawableContentRectForReferenceFilterHighDpi) {
1447 const float device_scale_factor = 2.0f;
1448
1449 LayerImpl* root = root_layer();
1450 root->layer_tree_impl()->SetDeviceScaleFactor(device_scale_factor);
1451 LayerImpl* child = AddChild<LayerImpl>(root);
1452 child->SetDrawsContent(true);
1453
1454 SetLayerPropertiesForTesting(root, gfx::Transform(), gfx::Point3F(),
1455 gfx::PointF(), gfx::Size(100, 100), true, false,
1456 true);
1457 SetLayerPropertiesForTesting(child, gfx::Transform(), gfx::Point3F(),
1458 gfx::PointF(), gfx::Size(25, 25), true, false,
1459 true);
1460
1461 FilterOperations filters;
1462 filters.Append(FilterOperation::CreateReferenceFilter(
1463 SkOffsetImageFilter::Make(50, 50, nullptr)));
1464 child->SetFilters(filters);
1465
1466 ExecuteCalculateDrawProperties(root, device_scale_factor);
1467
1468 // The render surface's size should be unaffected by the offset image filter;
1469 // it need only have a drawable content rect large enough to contain the
1470 // contents (at the new offset). All coordinates should be scaled by 2,
1471 // corresponding to the device scale factor.
1472 ASSERT_TRUE(child->render_surface());
1473 EXPECT_EQ(gfx::RectF(100, 100, 50, 50),
1474 child->render_surface()->DrawableContentRect());
1475 }
1476
1414 TEST_F(LayerTreeHostCommonTest, RenderSurfaceForBlendMode) { 1477 TEST_F(LayerTreeHostCommonTest, RenderSurfaceForBlendMode) {
1415 LayerImpl* parent = root_layer(); 1478 LayerImpl* parent = root_layer();
1416 LayerImpl* child = AddChild<LayerImpl>(parent); 1479 LayerImpl* child = AddChild<LayerImpl>(parent);
1417 child->SetDrawsContent(true); 1480 child->SetDrawsContent(true);
1418 1481
1419 const gfx::Transform identity_matrix; 1482 const gfx::Transform identity_matrix;
1420 const SkXfermode::Mode blend_mode = SkXfermode::kMultiply_Mode; 1483 const SkXfermode::Mode blend_mode = SkXfermode::kMultiply_Mode;
1421 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 1484 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
1422 gfx::PointF(), gfx::Size(10, 10), true, false, 1485 gfx::PointF(), gfx::Size(10, 10), true, false,
1423 true); 1486 true);
(...skipping 8712 matching lines...) Expand 10 before | Expand all | Expand 10 after
10136 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); 10199 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
10137 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 10200 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10138 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 10201 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10139 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 10202 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10140 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 10203 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10141 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 10204 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10142 } 10205 }
10143 10206
10144 } // namespace 10207 } // namespace
10145 } // namespace cc 10208 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/render_surface_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698