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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp

Issue 2798513002: Revert of Make GeometryMapper fully static (Closed)
Patch Set: Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "platform/graphics/compositing/PaintArtifactCompositor.h" 5 #include "platform/graphics/compositing/PaintArtifactCompositor.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/test/test_simple_task_runner.h" 9 #include "base/test/test_simple_task_runner.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
11 #include "cc/layers/layer.h" 11 #include "cc/layers/layer.h"
12 #include "cc/test/fake_compositor_frame_sink.h" 12 #include "cc/test/fake_compositor_frame_sink.h"
13 #include "cc/test/geometry_test_utils.h" 13 #include "cc/test/geometry_test_utils.h"
14 #include "cc/trees/clip_node.h" 14 #include "cc/trees/clip_node.h"
15 #include "cc/trees/effect_node.h" 15 #include "cc/trees/effect_node.h"
16 #include "cc/trees/layer_tree_host.h" 16 #include "cc/trees/layer_tree_host.h"
17 #include "cc/trees/layer_tree_settings.h" 17 #include "cc/trees/layer_tree_settings.h"
18 #include "cc/trees/scroll_node.h" 18 #include "cc/trees/scroll_node.h"
19 #include "cc/trees/transform_node.h" 19 #include "cc/trees/transform_node.h"
20 #include "platform/graphics/paint/EffectPaintPropertyNode.h" 20 #include "platform/graphics/paint/EffectPaintPropertyNode.h"
21 #include "platform/graphics/paint/GeometryMapper.h"
21 #include "platform/graphics/paint/PaintArtifact.h" 22 #include "platform/graphics/paint/PaintArtifact.h"
22 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" 23 #include "platform/graphics/paint/ScrollPaintPropertyNode.h"
23 #include "platform/testing/PaintPropertyTestHelpers.h" 24 #include "platform/testing/PaintPropertyTestHelpers.h"
24 #include "platform/testing/PictureMatchers.h" 25 #include "platform/testing/PictureMatchers.h"
25 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" 26 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
26 #include "platform/testing/TestPaintArtifact.h" 27 #include "platform/testing/TestPaintArtifact.h"
27 #include "platform/testing/WebLayerTreeViewImplForTesting.h" 28 #include "platform/testing/WebLayerTreeViewImplForTesting.h"
28 #include "public/platform/WebLayerScrollClient.h" 29 #include "public/platform/WebLayerScrollClient.h"
29 #include "testing/gmock/include/gmock/gmock.h" 30 #include "testing/gmock/include/gmock/gmock.h"
30 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 return m_webLayerTreeView->layerTreeHost() 113 return m_webLayerTreeView->layerTreeHost()
113 ->property_trees() 114 ->property_trees()
114 ->element_id_to_scroll_node_index[elementId]; 115 ->element_id_to_scroll_node_index[elementId];
115 } 116 }
116 117
117 const cc::TransformNode& transformNode(const cc::Layer* layer) { 118 const cc::TransformNode& transformNode(const cc::Layer* layer) {
118 return *propertyTrees().transform_tree.Node(layer->transform_tree_index()); 119 return *propertyTrees().transform_tree.Node(layer->transform_tree_index());
119 } 120 }
120 121
121 void update(const PaintArtifact& artifact) { 122 void update(const PaintArtifact& artifact) {
122 m_paintArtifactCompositor->update(artifact, nullptr, false); 123 std::unique_ptr<GeometryMapper> geometryMapper = GeometryMapper::create();
124 m_paintArtifactCompositor->update(artifact, nullptr, false,
125 *geometryMapper);
123 m_webLayerTreeView->layerTreeHost()->LayoutAndUpdateLayers(); 126 m_webLayerTreeView->layerTreeHost()->LayoutAndUpdateLayers();
124 } 127 }
125 128
126 cc::Layer* rootLayer() { return m_paintArtifactCompositor->rootLayer(); } 129 cc::Layer* rootLayer() { return m_paintArtifactCompositor->rootLayer(); }
127 130
128 size_t contentLayerCount() { 131 size_t contentLayerCount() {
129 return m_paintArtifactCompositor->getExtraDataForTesting() 132 return m_paintArtifactCompositor->getExtraDataForTesting()
130 ->contentLayers.size(); 133 ->contentLayers.size();
131 } 134 }
132 135
(...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, MightOverlap) { 1438 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, MightOverlap) {
1436 PaintChunk paintChunk; 1439 PaintChunk paintChunk;
1437 paintChunk.properties = defaultPaintChunkProperties(); 1440 paintChunk.properties = defaultPaintChunkProperties();
1438 paintChunk.bounds = FloatRect(0, 0, 100, 100); 1441 paintChunk.bounds = FloatRect(0, 0, 100, 100);
1439 PaintArtifactCompositor::PendingLayer pendingLayer(paintChunk, false); 1442 PaintArtifactCompositor::PendingLayer pendingLayer(paintChunk, false);
1440 1443
1441 PaintChunk paintChunk2; 1444 PaintChunk paintChunk2;
1442 paintChunk2.properties = defaultPaintChunkProperties(); 1445 paintChunk2.properties = defaultPaintChunkProperties();
1443 paintChunk2.bounds = FloatRect(0, 0, 100, 100); 1446 paintChunk2.bounds = FloatRect(0, 0, 100, 100);
1444 1447
1448 std::unique_ptr<GeometryMapper> geometryMapper = GeometryMapper::create();
1449
1445 { 1450 {
1446 PaintArtifactCompositor::PendingLayer pendingLayer2(paintChunk2, false); 1451 PaintArtifactCompositor::PendingLayer pendingLayer2(paintChunk2, false);
1447 EXPECT_TRUE( 1452 EXPECT_TRUE(PaintArtifactCompositor::mightOverlap(
1448 PaintArtifactCompositor::mightOverlap(pendingLayer, pendingLayer2)); 1453 pendingLayer, pendingLayer2, *geometryMapper));
1449 } 1454 }
1450 1455
1451 RefPtr<TransformPaintPropertyNode> transform = 1456 RefPtr<TransformPaintPropertyNode> transform =
1452 TransformPaintPropertyNode::create( 1457 TransformPaintPropertyNode::create(
1453 TransformPaintPropertyNode::root(), 1458 TransformPaintPropertyNode::root(),
1454 TransformationMatrix().translate(99, 0), FloatPoint3D(100, 100, 0), 1459 TransformationMatrix().translate(99, 0), FloatPoint3D(100, 100, 0),
1455 false); 1460 false);
1456 { 1461 {
1457 paintChunk2.properties.propertyTreeState.setTransform(transform.get()); 1462 paintChunk2.properties.propertyTreeState.setTransform(transform.get());
1458 PaintArtifactCompositor::PendingLayer pendingLayer2(paintChunk2, false); 1463 PaintArtifactCompositor::PendingLayer pendingLayer2(paintChunk2, false);
1459 EXPECT_TRUE( 1464 EXPECT_TRUE(PaintArtifactCompositor::mightOverlap(
1460 PaintArtifactCompositor::mightOverlap(pendingLayer, pendingLayer2)); 1465 pendingLayer, pendingLayer2, *geometryMapper));
1461 } 1466 }
1462 1467
1463 RefPtr<TransformPaintPropertyNode> transform2 = 1468 RefPtr<TransformPaintPropertyNode> transform2 =
1464 TransformPaintPropertyNode::create( 1469 TransformPaintPropertyNode::create(
1465 TransformPaintPropertyNode::root(), 1470 TransformPaintPropertyNode::root(),
1466 TransformationMatrix().translate(100, 0), FloatPoint3D(100, 100, 0), 1471 TransformationMatrix().translate(100, 0), FloatPoint3D(100, 100, 0),
1467 false); 1472 false);
1468 { 1473 {
1469 paintChunk2.properties.propertyTreeState.setTransform(transform2.get()); 1474 paintChunk2.properties.propertyTreeState.setTransform(transform2.get());
1470 PaintArtifactCompositor::PendingLayer pendingLayer2(paintChunk2, false); 1475 PaintArtifactCompositor::PendingLayer pendingLayer2(paintChunk2, false);
1471 EXPECT_FALSE( 1476 EXPECT_FALSE(PaintArtifactCompositor::mightOverlap(
1472 PaintArtifactCompositor::mightOverlap(pendingLayer, pendingLayer2)); 1477 pendingLayer, pendingLayer2, *geometryMapper));
1473 } 1478 }
1474 } 1479 }
1475 1480
1476 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, PendingLayer) { 1481 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, PendingLayer) {
1482 std::unique_ptr<GeometryMapper> geometryMapper = GeometryMapper::create();
1483
1477 PaintChunk chunk1; 1484 PaintChunk chunk1;
1478 chunk1.properties.propertyTreeState = PropertyTreeState( 1485 chunk1.properties.propertyTreeState = PropertyTreeState(
1479 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), 1486 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
1480 EffectPaintPropertyNode::root()); 1487 EffectPaintPropertyNode::root());
1481 chunk1.properties.backfaceHidden = true; 1488 chunk1.properties.backfaceHidden = true;
1482 chunk1.knownToBeOpaque = true; 1489 chunk1.knownToBeOpaque = true;
1483 chunk1.bounds = FloatRect(0, 0, 30, 40); 1490 chunk1.bounds = FloatRect(0, 0, 30, 40);
1484 1491
1485 PaintArtifactCompositor::PendingLayer pendingLayer(chunk1, false); 1492 PaintArtifactCompositor::PendingLayer pendingLayer(chunk1, false);
1486 1493
1487 EXPECT_TRUE(pendingLayer.backfaceHidden); 1494 EXPECT_TRUE(pendingLayer.backfaceHidden);
1488 EXPECT_TRUE(pendingLayer.knownToBeOpaque); 1495 EXPECT_TRUE(pendingLayer.knownToBeOpaque);
1489 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 30, 40), pendingLayer.bounds); 1496 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 30, 40), pendingLayer.bounds);
1490 1497
1491 PaintChunk chunk2; 1498 PaintChunk chunk2;
1492 chunk2.properties.propertyTreeState = chunk1.properties.propertyTreeState; 1499 chunk2.properties.propertyTreeState = chunk1.properties.propertyTreeState;
1493 chunk2.properties.backfaceHidden = true; 1500 chunk2.properties.backfaceHidden = true;
1494 chunk2.knownToBeOpaque = true; 1501 chunk2.knownToBeOpaque = true;
1495 chunk2.bounds = FloatRect(10, 20, 30, 40); 1502 chunk2.bounds = FloatRect(10, 20, 30, 40);
1496 pendingLayer.merge(PaintArtifactCompositor::PendingLayer(chunk2, false)); 1503 pendingLayer.merge(PaintArtifactCompositor::PendingLayer(chunk2, false),
1504 *geometryMapper);
1497 1505
1498 EXPECT_TRUE(pendingLayer.backfaceHidden); 1506 EXPECT_TRUE(pendingLayer.backfaceHidden);
1499 // Bounds not equal to one PaintChunk. 1507 // Bounds not equal to one PaintChunk.
1500 EXPECT_FALSE(pendingLayer.knownToBeOpaque); 1508 EXPECT_FALSE(pendingLayer.knownToBeOpaque);
1501 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 40, 60), pendingLayer.bounds); 1509 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 40, 60), pendingLayer.bounds);
1502 1510
1503 PaintChunk chunk3; 1511 PaintChunk chunk3;
1504 chunk3.properties.propertyTreeState = chunk1.properties.propertyTreeState; 1512 chunk3.properties.propertyTreeState = chunk1.properties.propertyTreeState;
1505 chunk3.properties.backfaceHidden = true; 1513 chunk3.properties.backfaceHidden = true;
1506 chunk3.knownToBeOpaque = true; 1514 chunk3.knownToBeOpaque = true;
1507 chunk3.bounds = FloatRect(-5, -25, 20, 20); 1515 chunk3.bounds = FloatRect(-5, -25, 20, 20);
1508 pendingLayer.merge(PaintArtifactCompositor::PendingLayer(chunk3, false)); 1516 pendingLayer.merge(PaintArtifactCompositor::PendingLayer(chunk3, false),
1517 *geometryMapper);
1509 1518
1510 EXPECT_TRUE(pendingLayer.backfaceHidden); 1519 EXPECT_TRUE(pendingLayer.backfaceHidden);
1511 EXPECT_FALSE(pendingLayer.knownToBeOpaque); 1520 EXPECT_FALSE(pendingLayer.knownToBeOpaque);
1512 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(-5, -25, 45, 85), pendingLayer.bounds); 1521 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(-5, -25, 45, 85), pendingLayer.bounds);
1513 } 1522 }
1514 1523
1515 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, PendingLayerWithGeometry) { 1524 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, PendingLayerWithGeometry) {
1516 RefPtr<TransformPaintPropertyNode> transform = 1525 RefPtr<TransformPaintPropertyNode> transform =
1517 TransformPaintPropertyNode::create( 1526 TransformPaintPropertyNode::create(
1518 TransformPaintPropertyNode::root(), 1527 TransformPaintPropertyNode::root(),
1519 TransformationMatrix().translate(20, 25), FloatPoint3D(100, 100, 0), 1528 TransformationMatrix().translate(20, 25), FloatPoint3D(100, 100, 0),
1520 false, 0); 1529 false, 0);
1521 1530
1522 PaintChunk chunk1; 1531 PaintChunk chunk1;
1523 chunk1.properties.propertyTreeState = PropertyTreeState( 1532 chunk1.properties.propertyTreeState = PropertyTreeState(
1524 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), 1533 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
1525 EffectPaintPropertyNode::root()); 1534 EffectPaintPropertyNode::root());
1526 chunk1.bounds = FloatRect(0, 0, 30, 40); 1535 chunk1.bounds = FloatRect(0, 0, 30, 40);
1527 1536
1528 PaintArtifactCompositor::PendingLayer pendingLayer(chunk1, false); 1537 PaintArtifactCompositor::PendingLayer pendingLayer(chunk1, false);
1529 1538
1530 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 30, 40), pendingLayer.bounds); 1539 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 30, 40), pendingLayer.bounds);
1531 1540
1532 PaintChunk chunk2; 1541 PaintChunk chunk2;
1533 chunk2.properties.propertyTreeState = chunk1.properties.propertyTreeState; 1542 chunk2.properties.propertyTreeState = chunk1.properties.propertyTreeState;
1534 chunk2.properties.propertyTreeState.setTransform(transform); 1543 chunk2.properties.propertyTreeState.setTransform(transform);
1535 chunk2.bounds = FloatRect(0, 0, 50, 60); 1544 chunk2.bounds = FloatRect(0, 0, 50, 60);
1536 pendingLayer.merge(PaintArtifactCompositor::PendingLayer(chunk2, false)); 1545 std::unique_ptr<GeometryMapper> geometryMapper = GeometryMapper::create();
1546 pendingLayer.merge(PaintArtifactCompositor::PendingLayer(chunk2, false),
1547 *geometryMapper);
1537 1548
1538 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 70, 85), pendingLayer.bounds); 1549 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 70, 85), pendingLayer.bounds);
1539 } 1550 }
1540 1551
1541 // TODO(crbug.com/701991): 1552 // TODO(crbug.com/701991):
1542 // The test is disabled because opaque rect mapping is not implemented yet. 1553 // The test is disabled because opaque rect mapping is not implemented yet.
1543 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, 1554 TEST_F(PaintArtifactCompositorTestWithPropertyTrees,
1544 PendingLayerKnownOpaque_DISABLED) { 1555 PendingLayerKnownOpaque_DISABLED) {
1556 std::unique_ptr<GeometryMapper> geometryMapper = GeometryMapper::create();
1557
1545 PaintChunk chunk1; 1558 PaintChunk chunk1;
1546 chunk1.properties.propertyTreeState = PropertyTreeState( 1559 chunk1.properties.propertyTreeState = PropertyTreeState(
1547 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), 1560 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
1548 EffectPaintPropertyNode::root()); 1561 EffectPaintPropertyNode::root());
1549 chunk1.bounds = FloatRect(0, 0, 30, 40); 1562 chunk1.bounds = FloatRect(0, 0, 30, 40);
1550 chunk1.knownToBeOpaque = false; 1563 chunk1.knownToBeOpaque = false;
1551 PaintArtifactCompositor::PendingLayer pendingLayer(chunk1, false); 1564 PaintArtifactCompositor::PendingLayer pendingLayer(chunk1, false);
1552 1565
1553 EXPECT_FALSE(pendingLayer.knownToBeOpaque); 1566 EXPECT_FALSE(pendingLayer.knownToBeOpaque);
1554 1567
1555 PaintChunk chunk2; 1568 PaintChunk chunk2;
1556 chunk2.properties.propertyTreeState = chunk1.properties.propertyTreeState; 1569 chunk2.properties.propertyTreeState = chunk1.properties.propertyTreeState;
1557 chunk2.bounds = FloatRect(0, 0, 25, 35); 1570 chunk2.bounds = FloatRect(0, 0, 25, 35);
1558 chunk2.knownToBeOpaque = true; 1571 chunk2.knownToBeOpaque = true;
1559 pendingLayer.merge(PaintArtifactCompositor::PendingLayer(chunk2, false)); 1572 pendingLayer.merge(PaintArtifactCompositor::PendingLayer(chunk2, false),
1573 *geometryMapper);
1560 1574
1561 // Chunk 2 doesn't cover the entire layer, so not opaque. 1575 // Chunk 2 doesn't cover the entire layer, so not opaque.
1562 EXPECT_FALSE(pendingLayer.knownToBeOpaque); 1576 EXPECT_FALSE(pendingLayer.knownToBeOpaque);
1563 1577
1564 PaintChunk chunk3; 1578 PaintChunk chunk3;
1565 chunk3.properties.propertyTreeState = chunk1.properties.propertyTreeState; 1579 chunk3.properties.propertyTreeState = chunk1.properties.propertyTreeState;
1566 chunk3.bounds = FloatRect(0, 0, 50, 60); 1580 chunk3.bounds = FloatRect(0, 0, 50, 60);
1567 chunk3.knownToBeOpaque = true; 1581 chunk3.knownToBeOpaque = true;
1568 pendingLayer.merge(PaintArtifactCompositor::PendingLayer(chunk3, false)); 1582 pendingLayer.merge(PaintArtifactCompositor::PendingLayer(chunk3, false),
1583 *geometryMapper);
1569 1584
1570 // Chunk 3 covers the entire layer, so now it's opaque. 1585 // Chunk 3 covers the entire layer, so now it's opaque.
1571 EXPECT_TRUE(pendingLayer.knownToBeOpaque); 1586 EXPECT_TRUE(pendingLayer.knownToBeOpaque);
1572 } 1587 }
1573 1588
1574 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformWithElementId) { 1589 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformWithElementId) {
1575 CompositorElementId expectedCompositorElementId(2, 0); 1590 CompositorElementId expectedCompositorElementId(2, 0);
1576 RefPtr<TransformPaintPropertyNode> transform = 1591 RefPtr<TransformPaintPropertyNode> transform =
1577 TransformPaintPropertyNode::create( 1592 TransformPaintPropertyNode::create(
1578 TransformPaintPropertyNode::root(), TransformationMatrix().rotate(90), 1593 TransformPaintPropertyNode::root(), TransformationMatrix().rotate(90),
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
1957 EXPECT_EQ(gfx::Size(50, 50), layer3->bounds()); 1972 EXPECT_EQ(gfx::Size(50, 50), layer3->bounds());
1958 EXPECT_EQ(effectNode->id, layer3->effect_tree_index()); 1973 EXPECT_EQ(effectNode->id, layer3->effect_tree_index());
1959 1974
1960 const cc::Layer* layer4 = contentLayerAt(3); 1975 const cc::Layer* layer4 = contentLayerAt(3);
1961 EXPECT_EQ(gfx::Vector2dF(100.f, 0.f), layer4->offset_to_transform_parent()); 1976 EXPECT_EQ(gfx::Vector2dF(100.f, 0.f), layer4->offset_to_transform_parent());
1962 EXPECT_EQ(gfx::Size(150, 150), layer4->bounds()); 1977 EXPECT_EQ(gfx::Size(150, 150), layer4->bounds());
1963 EXPECT_EQ(1, layer4->effect_tree_index()); 1978 EXPECT_EQ(1, layer4->effect_tree_index());
1964 } 1979 }
1965 1980
1966 } // namespace blink 1981 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698