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

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: high-dpi 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
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 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
1442 TEST_F(LayerTreeHostCommonTest, DrawableContentRectForReferenceFilterHighDpi) {
1443 const float device_scale_factor = 2.0f;
1444
1445 LayerImpl* root = root_layer();
1446 root->layer_tree_impl()->SetDeviceScaleFactor(device_scale_factor);
1447 LayerImpl* child = AddChild<LayerImpl>(root);
1448 child->SetDrawsContent(true);
1449
1450 SetLayerPropertiesForTesting(root, gfx::Transform(), gfx::Point3F(),
1451 gfx::PointF(), gfx::Size(100, 100), true, false,
1452 true);
1453 SetLayerPropertiesForTesting(child, gfx::Transform(), gfx::Point3F(),
1454 gfx::PointF(), gfx::Size(25, 25), true, false,
1455 true);
1456
1457 FilterOperations filters;
1458 filters.Append(FilterOperation::CreateReferenceFilter(
1459 SkOffsetImageFilter::Make(50, 50, nullptr)));
1460 child->SetFilters(filters);
1461
1462 ExecuteCalculateDrawProperties(root, device_scale_factor);
1463
1464 // The render surface's size should be unaffected by the offset image filter;
1465 // it need only have a drawable content rect large enough to contain the
1466 // contents (at the new offset). All coordinates should be scaled by 2,
1467 // corresponding to the device scale factor.
1468 ASSERT_TRUE(child->render_surface());
1469 EXPECT_EQ(gfx::RectF(100, 100, 50, 50),
1470 child->render_surface()->DrawableContentRect());
1471 }
1472
1414 TEST_F(LayerTreeHostCommonTest, RenderSurfaceForBlendMode) { 1473 TEST_F(LayerTreeHostCommonTest, RenderSurfaceForBlendMode) {
1415 LayerImpl* parent = root_layer(); 1474 LayerImpl* parent = root_layer();
1416 LayerImpl* child = AddChild<LayerImpl>(parent); 1475 LayerImpl* child = AddChild<LayerImpl>(parent);
1417 child->SetDrawsContent(true); 1476 child->SetDrawsContent(true);
1418 1477
1419 const gfx::Transform identity_matrix; 1478 const gfx::Transform identity_matrix;
1420 const SkXfermode::Mode blend_mode = SkXfermode::kMultiply_Mode; 1479 const SkXfermode::Mode blend_mode = SkXfermode::kMultiply_Mode;
1421 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 1480 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
1422 gfx::PointF(), gfx::Size(10, 10), true, false, 1481 gfx::PointF(), gfx::Size(10, 10), true, false,
1423 true); 1482 true);
(...skipping 8712 matching lines...) Expand 10 before | Expand all | Expand 10 after
10136 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); 10195 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
10137 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 10196 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10138 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 10197 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10139 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 10198 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10140 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 10199 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10141 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 10200 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10142 } 10201 }
10143 10202
10144 } // namespace 10203 } // namespace
10145 } // namespace cc 10204 } // namespace cc
OLDNEW
« cc/layers/render_surface_impl.cc ('K') | « cc/layers/render_surface_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698