OLD | NEW |
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 "base/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
8 #include "base/threading/thread_task_runner_handle.h" | 8 #include "base/threading/thread_task_runner_handle.h" |
9 #include "cc/layers/layer.h" | 9 #include "cc/layers/layer.h" |
10 #include "cc/test/fake_compositor_frame_sink.h" | 10 #include "cc/test/fake_compositor_frame_sink.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "platform/testing/PictureMatchers.h" | 23 #include "platform/testing/PictureMatchers.h" |
24 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 24 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
25 #include "platform/testing/TestPaintArtifact.h" | 25 #include "platform/testing/TestPaintArtifact.h" |
26 #include "platform/testing/WebLayerTreeViewImplForTesting.h" | 26 #include "platform/testing/WebLayerTreeViewImplForTesting.h" |
27 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
28 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
29 #include <memory> | 29 #include <memory> |
30 | 30 |
31 namespace blink { | 31 namespace blink { |
32 | 32 |
| 33 #define EXPECT_BLINK_FLOAT_RECT_EQ(expected, actual) \ |
| 34 do { \ |
| 35 EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \ |
| 36 EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \ |
| 37 EXPECT_FLOAT_EQ((expected).width(), (actual).width()); \ |
| 38 EXPECT_FLOAT_EQ((expected).height(), (actual).height()); \ |
| 39 } while (false) |
| 40 |
33 using ::blink::testing::createOpacityOnlyEffect; | 41 using ::blink::testing::createOpacityOnlyEffect; |
34 using ::testing::Pointee; | 42 using ::testing::Pointee; |
35 | 43 |
36 PaintChunkProperties defaultPaintChunkProperties() { | 44 PaintChunkProperties defaultPaintChunkProperties() { |
37 PropertyTreeState propertyTreeState( | 45 PropertyTreeState propertyTreeState( |
38 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 46 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
39 EffectPaintPropertyNode::root(), ScrollPaintPropertyNode::root()); | 47 EffectPaintPropertyNode::root(), ScrollPaintPropertyNode::root()); |
40 return PaintChunkProperties(propertyTreeState); | 48 return PaintChunkProperties(propertyTreeState); |
41 } | 49 } |
42 | 50 |
(...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1459 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1467 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
1460 EffectPaintPropertyNode::root(), ScrollPaintPropertyNode::root()); | 1468 EffectPaintPropertyNode::root(), ScrollPaintPropertyNode::root()); |
1461 chunk1.properties.backfaceHidden = true; | 1469 chunk1.properties.backfaceHidden = true; |
1462 chunk1.knownToBeOpaque = true; | 1470 chunk1.knownToBeOpaque = true; |
1463 chunk1.bounds = FloatRect(0, 0, 30, 40); | 1471 chunk1.bounds = FloatRect(0, 0, 30, 40); |
1464 | 1472 |
1465 PaintArtifactCompositor::PendingLayer pendingLayer(chunk1); | 1473 PaintArtifactCompositor::PendingLayer pendingLayer(chunk1); |
1466 | 1474 |
1467 EXPECT_TRUE(pendingLayer.backfaceHidden); | 1475 EXPECT_TRUE(pendingLayer.backfaceHidden); |
1468 EXPECT_TRUE(pendingLayer.knownToBeOpaque); | 1476 EXPECT_TRUE(pendingLayer.knownToBeOpaque); |
1469 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 30, 40), pendingLayer.bounds); | 1477 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 30, 40), pendingLayer.bounds); |
1470 | 1478 |
1471 PaintChunk chunk2; | 1479 PaintChunk chunk2; |
1472 chunk2.properties.propertyTreeState = chunk1.properties.propertyTreeState; | 1480 chunk2.properties.propertyTreeState = chunk1.properties.propertyTreeState; |
1473 chunk2.properties.backfaceHidden = true; | 1481 chunk2.properties.backfaceHidden = true; |
1474 chunk2.knownToBeOpaque = true; | 1482 chunk2.knownToBeOpaque = true; |
1475 chunk2.bounds = FloatRect(10, 20, 30, 40); | 1483 chunk2.bounds = FloatRect(10, 20, 30, 40); |
1476 pendingLayer.add(chunk2, nullptr); | 1484 pendingLayer.add(chunk2, nullptr); |
1477 | 1485 |
1478 EXPECT_TRUE(pendingLayer.backfaceHidden); | 1486 EXPECT_TRUE(pendingLayer.backfaceHidden); |
1479 // Bounds not equal to one PaintChunk. | 1487 // Bounds not equal to one PaintChunk. |
1480 EXPECT_FALSE(pendingLayer.knownToBeOpaque); | 1488 EXPECT_FALSE(pendingLayer.knownToBeOpaque); |
1481 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 40, 60), pendingLayer.bounds); | 1489 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 40, 60), pendingLayer.bounds); |
1482 | 1490 |
1483 PaintChunk chunk3; | 1491 PaintChunk chunk3; |
1484 chunk3.properties.propertyTreeState = chunk1.properties.propertyTreeState; | 1492 chunk3.properties.propertyTreeState = chunk1.properties.propertyTreeState; |
1485 chunk3.properties.backfaceHidden = true; | 1493 chunk3.properties.backfaceHidden = true; |
1486 chunk3.knownToBeOpaque = true; | 1494 chunk3.knownToBeOpaque = true; |
1487 chunk3.bounds = FloatRect(-5, -25, 20, 20); | 1495 chunk3.bounds = FloatRect(-5, -25, 20, 20); |
1488 pendingLayer.add(chunk3, nullptr); | 1496 pendingLayer.add(chunk3, nullptr); |
1489 | 1497 |
1490 EXPECT_TRUE(pendingLayer.backfaceHidden); | 1498 EXPECT_TRUE(pendingLayer.backfaceHidden); |
1491 EXPECT_FALSE(pendingLayer.knownToBeOpaque); | 1499 EXPECT_FALSE(pendingLayer.knownToBeOpaque); |
1492 EXPECT_FLOAT_RECT_EQ(FloatRect(-5, -25, 45, 85), pendingLayer.bounds); | 1500 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(-5, -25, 45, 85), pendingLayer.bounds); |
1493 } | 1501 } |
1494 | 1502 |
1495 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, PendingLayerWithGeometry) { | 1503 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, PendingLayerWithGeometry) { |
1496 RefPtr<TransformPaintPropertyNode> transform = | 1504 RefPtr<TransformPaintPropertyNode> transform = |
1497 TransformPaintPropertyNode::create( | 1505 TransformPaintPropertyNode::create( |
1498 TransformPaintPropertyNode::root(), | 1506 TransformPaintPropertyNode::root(), |
1499 TransformationMatrix().translate(20, 25), FloatPoint3D(100, 100, 0), | 1507 TransformationMatrix().translate(20, 25), FloatPoint3D(100, 100, 0), |
1500 false, 0); | 1508 false, 0); |
1501 | 1509 |
1502 PaintChunk chunk1; | 1510 PaintChunk chunk1; |
1503 chunk1.properties.propertyTreeState = PropertyTreeState( | 1511 chunk1.properties.propertyTreeState = PropertyTreeState( |
1504 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1512 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
1505 EffectPaintPropertyNode::root(), ScrollPaintPropertyNode::root()); | 1513 EffectPaintPropertyNode::root(), ScrollPaintPropertyNode::root()); |
1506 chunk1.bounds = FloatRect(0, 0, 30, 40); | 1514 chunk1.bounds = FloatRect(0, 0, 30, 40); |
1507 | 1515 |
1508 PaintArtifactCompositor::PendingLayer pendingLayer(chunk1); | 1516 PaintArtifactCompositor::PendingLayer pendingLayer(chunk1); |
1509 | 1517 |
1510 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 30, 40), pendingLayer.bounds); | 1518 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 30, 40), pendingLayer.bounds); |
1511 | 1519 |
1512 PaintChunk chunk2; | 1520 PaintChunk chunk2; |
1513 chunk2.properties.propertyTreeState = chunk1.properties.propertyTreeState; | 1521 chunk2.properties.propertyTreeState = chunk1.properties.propertyTreeState; |
1514 chunk2.properties.propertyTreeState.setTransform(transform); | 1522 chunk2.properties.propertyTreeState.setTransform(transform); |
1515 chunk2.bounds = FloatRect(0, 0, 50, 60); | 1523 chunk2.bounds = FloatRect(0, 0, 50, 60); |
1516 GeometryMapper geometryMapper; | 1524 GeometryMapper geometryMapper; |
1517 pendingLayer.add(chunk2, &geometryMapper); | 1525 pendingLayer.add(chunk2, &geometryMapper); |
1518 | 1526 |
1519 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 70, 85), pendingLayer.bounds); | 1527 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 70, 85), pendingLayer.bounds); |
1520 } | 1528 } |
1521 | 1529 |
1522 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, PendingLayerKnownOpaque) { | 1530 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, PendingLayerKnownOpaque) { |
1523 PaintChunk chunk1; | 1531 PaintChunk chunk1; |
1524 chunk1.properties.propertyTreeState = PropertyTreeState( | 1532 chunk1.properties.propertyTreeState = PropertyTreeState( |
1525 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1533 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
1526 EffectPaintPropertyNode::root(), ScrollPaintPropertyNode::root()); | 1534 EffectPaintPropertyNode::root(), ScrollPaintPropertyNode::root()); |
1527 chunk1.bounds = FloatRect(0, 0, 30, 40); | 1535 chunk1.bounds = FloatRect(0, 0, 30, 40); |
1528 chunk1.knownToBeOpaque = false; | 1536 chunk1.knownToBeOpaque = false; |
1529 PaintArtifactCompositor::PendingLayer pendingLayer(chunk1); | 1537 PaintArtifactCompositor::PendingLayer pendingLayer(chunk1); |
(...skipping 13 matching lines...) Expand all Loading... |
1543 chunk3.properties.propertyTreeState = chunk1.properties.propertyTreeState; | 1551 chunk3.properties.propertyTreeState = chunk1.properties.propertyTreeState; |
1544 chunk3.bounds = FloatRect(0, 0, 50, 60); | 1552 chunk3.bounds = FloatRect(0, 0, 50, 60); |
1545 chunk3.knownToBeOpaque = true; | 1553 chunk3.knownToBeOpaque = true; |
1546 pendingLayer.add(chunk3, nullptr); | 1554 pendingLayer.add(chunk3, nullptr); |
1547 | 1555 |
1548 // Chunk 3 covers the entire layer, so now it's opaque. | 1556 // Chunk 3 covers the entire layer, so now it's opaque. |
1549 EXPECT_TRUE(pendingLayer.knownToBeOpaque); | 1557 EXPECT_TRUE(pendingLayer.knownToBeOpaque); |
1550 } | 1558 } |
1551 | 1559 |
1552 } // namespace blink | 1560 } // namespace blink |
OLD | NEW |