| 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/layer_tree_host.h" | 5 #include "cc/layer_tree_host.h" |
| 6 | 6 |
| 7 #include "base/synchronization/lock.h" | 7 #include "base/synchronization/lock.h" |
| 8 #include "cc/content_layer.h" | 8 #include "cc/content_layer.h" |
| 9 #include "cc/content_layer_client.h" | 9 #include "cc/content_layer_client.h" |
| 10 #include "cc/layer_impl.h" | 10 #include "cc/layer_impl.h" |
| (...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1341 scoped_refptr<ContentLayerWithUpdateTracking> m_parent; | 1341 scoped_refptr<ContentLayerWithUpdateTracking> m_parent; |
| 1342 scoped_refptr<ContentLayerWithUpdateTracking> m_child; | 1342 scoped_refptr<ContentLayerWithUpdateTracking> m_child; |
| 1343 int m_numCommits; | 1343 int m_numCommits; |
| 1344 }; | 1344 }; |
| 1345 | 1345 |
| 1346 TEST_F(LayerTreeHostTestAtomicCommitWithPartialUpdate, runMultiThread) | 1346 TEST_F(LayerTreeHostTestAtomicCommitWithPartialUpdate, runMultiThread) |
| 1347 { | 1347 { |
| 1348 runTest(true); | 1348 runTest(true); |
| 1349 } | 1349 } |
| 1350 | 1350 |
| 1351 class TestLayer : public Layer { | |
| 1352 public: | |
| 1353 static scoped_refptr<TestLayer> create() { return make_scoped_refptr(new Tes
tLayer()); } | |
| 1354 | |
| 1355 virtual void update(ResourceUpdateQueue&, const OcclusionTracker* occlusion,
RenderingStats&) OVERRIDE | |
| 1356 { | |
| 1357 // Gain access to internals of the OcclusionTracker. | |
| 1358 const TestOcclusionTracker* testOcclusion = static_cast<const TestOcclus
ionTracker*>(occlusion); | |
| 1359 if (!testOcclusion) { | |
| 1360 m_occlusion.Clear(); | |
| 1361 return; | |
| 1362 } | |
| 1363 m_occlusion = UnionRegions(testOcclusion->occlusionFromInsideTarget(), t
estOcclusion->occlusionFromOutsideTarget()); | |
| 1364 } | |
| 1365 | |
| 1366 virtual bool drawsContent() const OVERRIDE { return true; } | |
| 1367 | |
| 1368 const Region& occlusion() const { return m_occlusion; } | |
| 1369 void clearOcclusion() { m_occlusion.Clear(); } | |
| 1370 | |
| 1371 private: | |
| 1372 TestLayer() : Layer() { } | |
| 1373 virtual ~TestLayer() { } | |
| 1374 | |
| 1375 Region m_occlusion; | |
| 1376 }; | |
| 1377 | |
| 1378 static void setTestLayerPropertiesForTesting(TestLayer* layer, Layer* parent, co
nst gfx::Transform& transform, const gfx::PointF& anchor, const gfx::PointF& pos
ition, const gfx::Size& bounds, bool opaque) | |
| 1379 { | |
| 1380 setLayerPropertiesForTesting(layer, parent, transform, anchor, position, bou
nds, opaque); | |
| 1381 layer->clearOcclusion(); | |
| 1382 } | |
| 1383 | |
| 1384 class LayerTreeHostTestLayerOcclusion : public LayerTreeHostTest { | |
| 1385 public: | |
| 1386 LayerTreeHostTestLayerOcclusion() { } | |
| 1387 | |
| 1388 virtual void beginTest() OVERRIDE | |
| 1389 { | |
| 1390 scoped_refptr<TestLayer> rootLayer = TestLayer::create(); | |
| 1391 scoped_refptr<TestLayer> child = TestLayer::create(); | |
| 1392 scoped_refptr<TestLayer> child2 = TestLayer::create(); | |
| 1393 scoped_refptr<TestLayer> grandChild = TestLayer::create(); | |
| 1394 scoped_refptr<TestLayer> mask = TestLayer::create(); | |
| 1395 | |
| 1396 gfx::Transform identityMatrix; | |
| 1397 | |
| 1398 child->setMasksToBounds(true); | |
| 1399 child->setForceRenderSurface(true); | |
| 1400 | |
| 1401 // See LayerTreeHostCommonTest.layerAddsSelfToOccludedRegionWithRotatedS
urface for a nice visual of these layers and how they end up | |
| 1402 // positioned on the screen. | |
| 1403 | |
| 1404 // The child layer is a surface and the grandChild is opaque, but clippe
d to the child and rootLayer | |
| 1405 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); | |
| 1406 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), identityM
atrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), false); | |
| 1407 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(20, 500), true); | |
| 1408 | |
| 1409 m_layerTreeHost->setRootLayer(rootLayer); | |
| 1410 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | |
| 1411 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); | |
| 1412 ResourceUpdateQueue queue; | |
| 1413 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | |
| 1414 m_layerTreeHost->commitComplete(); | |
| 1415 | |
| 1416 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occlusion().ToString()); | |
| 1417 EXPECT_EQ(gfx::Rect(0, 0, 10, 190).ToString(), child->occlusion().ToStri
ng()); | |
| 1418 EXPECT_EQ(gfx::Rect(10, 10, 10, 190).ToString(), rootLayer->occlusion().
ToString()); | |
| 1419 | |
| 1420 // If the child layer is opaque, then it adds to the occlusion seen by t
he rootLayer. | |
| 1421 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::Po
intF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); | |
| 1422 setLayerPropertiesForTesting(child.get(), rootLayer.get(), identityMatri
x, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); | |
| 1423 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(20, 500), true); | |
| 1424 | |
| 1425 m_layerTreeHost->setRootLayer(rootLayer); | |
| 1426 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | |
| 1427 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | |
| 1428 m_layerTreeHost->commitComplete(); | |
| 1429 | |
| 1430 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occlusion().ToString()); | |
| 1431 EXPECT_EQ(gfx::Rect(0, 0, 10, 190).ToString(), child->occlusion().ToStri
ng()); | |
| 1432 EXPECT_EQ(gfx::Rect(10, 10, 190, 190).ToString(), rootLayer->occlusion()
.ToString()); | |
| 1433 | |
| 1434 // Add a second child to the root layer and the regions should merge | |
| 1435 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); | |
| 1436 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), identityM
atrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), false); | |
| 1437 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(20, 500), true); | |
| 1438 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(20, 10), gfx::Size(10, 500), true); | |
| 1439 | |
| 1440 m_layerTreeHost->setRootLayer(rootLayer); | |
| 1441 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | |
| 1442 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | |
| 1443 m_layerTreeHost->commitComplete(); | |
| 1444 | |
| 1445 EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString()); | |
| 1446 EXPECT_EQ(gfx::Rect(10, 0, 10, 190).ToString(), grandChild->occlusion().
ToString()); | |
| 1447 EXPECT_EQ(gfx::Rect(0, 0, 20, 190).ToString(), child->occlusion().ToStri
ng()); | |
| 1448 EXPECT_EQ(gfx::Rect(10, 10, 20, 190).ToString(), rootLayer->occlusion().
ToString()); | |
| 1449 | |
| 1450 // If the child layer has a mask on it, then it shouldn't contribute to
occlusion on stuff below it | |
| 1451 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::Po
intF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); | |
| 1452 setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); | |
| 1453 setLayerPropertiesForTesting(child.get(), rootLayer.get(), identityMatri
x, gfx::PointF(0, 0), gfx::PointF(20, 20), gfx::Size(500, 500), true); | |
| 1454 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(500, 500), true); | |
| 1455 | |
| 1456 child->setMaskLayer(mask.get()); | |
| 1457 | |
| 1458 m_layerTreeHost->setRootLayer(rootLayer); | |
| 1459 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | |
| 1460 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | |
| 1461 m_layerTreeHost->commitComplete(); | |
| 1462 | |
| 1463 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occlusion().ToString()); | |
| 1464 EXPECT_EQ(gfx::Rect(0, 0, 180, 180).ToString(), child->occlusion().ToStr
ing()); | |
| 1465 EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString()); | |
| 1466 EXPECT_EQ(gfx::Rect(10, 10, 190, 190).ToString(), rootLayer->occlusion()
.ToString()); | |
| 1467 | |
| 1468 // If the child layer with a mask is below child2, then child2 should co
ntribute to occlusion on everything, and child shouldn't contribute to the rootL
ayer | |
| 1469 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::Po
intF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); | |
| 1470 setLayerPropertiesForTesting(child.get(), rootLayer.get(), identityMatri
x, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); | |
| 1471 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(20, 500), true); | |
| 1472 setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(20, 10), gfx::Size(10, 500), true); | |
| 1473 | |
| 1474 child->setMaskLayer(mask.get()); | |
| 1475 | |
| 1476 m_layerTreeHost->setRootLayer(rootLayer); | |
| 1477 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | |
| 1478 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | |
| 1479 m_layerTreeHost->commitComplete(); | |
| 1480 | |
| 1481 EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString()); | |
| 1482 EXPECT_EQ(gfx::Rect(10, 0, 10, 190).ToString(), grandChild->occlusion().
ToString()); | |
| 1483 EXPECT_EQ(gfx::Rect(0, 0, 20, 190).ToString(), child->occlusion().ToStri
ng()); | |
| 1484 EXPECT_EQ(gfx::Rect(20, 10, 10, 190), rootLayer->occlusion()); | |
| 1485 | |
| 1486 // If the child layer has a non-opaque drawOpacity, then it shouldn't co
ntribute to occlusion on stuff below it | |
| 1487 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); | |
| 1488 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(20, 10), gfx::Size(10, 500), true); | |
| 1489 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), identityM
atrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); | |
| 1490 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(20, 500), true); | |
| 1491 | |
| 1492 child->setMaskLayer(0); | |
| 1493 child->setOpacity(0.5); | |
| 1494 | |
| 1495 m_layerTreeHost->setRootLayer(rootLayer); | |
| 1496 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | |
| 1497 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | |
| 1498 m_layerTreeHost->commitComplete(); | |
| 1499 | |
| 1500 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occlusion().ToString()); | |
| 1501 EXPECT_EQ(gfx::Rect(0, 0, 10, 190).ToString(), child->occlusion().ToStri
ng()); | |
| 1502 EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString()); | |
| 1503 EXPECT_EQ(gfx::Rect(20, 10, 10, 190).ToString(), rootLayer->occlusion().
ToString()); | |
| 1504 | |
| 1505 // If the child layer with non-opaque drawOpacity is below child2, then
child2 should contribute to occlusion on everything, and child shouldn't contrib
ute to the rootLayer | |
| 1506 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); | |
| 1507 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), identityM
atrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); | |
| 1508 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(20, 500), true); | |
| 1509 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(20, 10), gfx::Size(10, 500), true); | |
| 1510 | |
| 1511 child->setMaskLayer(0); | |
| 1512 child->setOpacity(0.5); | |
| 1513 | |
| 1514 m_layerTreeHost->setRootLayer(rootLayer); | |
| 1515 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | |
| 1516 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | |
| 1517 m_layerTreeHost->commitComplete(); | |
| 1518 | |
| 1519 EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString()); | |
| 1520 EXPECT_EQ(gfx::Rect(10, 0, 10, 190).ToString(), grandChild->occlusion().
ToString()); | |
| 1521 EXPECT_EQ(gfx::Rect(0, 0, 20, 190).ToString(), child->occlusion().ToStri
ng()); | |
| 1522 EXPECT_EQ(gfx::Rect(20, 10, 10, 190).ToString(), rootLayer->occlusion().
ToString()); | |
| 1523 | |
| 1524 // Kill the layerTreeHost immediately. | |
| 1525 m_layerTreeHost->setRootLayer(0); | |
| 1526 m_layerTreeHost.reset(); | |
| 1527 | |
| 1528 endTest(); | |
| 1529 } | |
| 1530 | |
| 1531 virtual void afterTest() OVERRIDE | |
| 1532 { | |
| 1533 } | |
| 1534 }; | |
| 1535 | |
| 1536 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLayerOcclusion) | |
| 1537 | |
| 1538 class LayerTreeHostTestLayerOcclusionWithFilters : public LayerTreeHostTest { | |
| 1539 public: | |
| 1540 LayerTreeHostTestLayerOcclusionWithFilters() { } | |
| 1541 | |
| 1542 virtual void beginTest() OVERRIDE | |
| 1543 { | |
| 1544 scoped_refptr<TestLayer> rootLayer = TestLayer::create(); | |
| 1545 scoped_refptr<TestLayer> child = TestLayer::create(); | |
| 1546 scoped_refptr<TestLayer> child2 = TestLayer::create(); | |
| 1547 scoped_refptr<TestLayer> grandChild = TestLayer::create(); | |
| 1548 scoped_refptr<TestLayer> mask = TestLayer::create(); | |
| 1549 | |
| 1550 gfx::Transform identityMatrix; | |
| 1551 gfx::Transform childTransform; | |
| 1552 childTransform.Translate(250, 250); | |
| 1553 childTransform.Rotate(90); | |
| 1554 childTransform.Translate(-250, -250); | |
| 1555 | |
| 1556 child->setMasksToBounds(true); | |
| 1557 | |
| 1558 // If the child layer has a filter that changes alpha values, and is bel
ow child2, then child2 should contribute to occlusion on everything, | |
| 1559 // and child shouldn't contribute to the rootLayer | |
| 1560 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); | |
| 1561 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran
sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); | |
| 1562 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); | |
| 1563 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true); | |
| 1564 | |
| 1565 { | |
| 1566 WebKit::WebFilterOperations filters; | |
| 1567 filters.append(WebKit::WebFilterOperation::createOpacityFilter(0.5))
; | |
| 1568 child->setFilters(filters); | |
| 1569 } | |
| 1570 | |
| 1571 m_layerTreeHost->setRootLayer(rootLayer); | |
| 1572 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | |
| 1573 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); | |
| 1574 ResourceUpdateQueue queue; | |
| 1575 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | |
| 1576 m_layerTreeHost->commitComplete(); | |
| 1577 | |
| 1578 EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString()); | |
| 1579 EXPECT_EQ(gfx::Rect(40, 330, 130, 190).ToString(), grandChild->occlusion
().ToString()); | |
| 1580 EXPECT_EQ(UnionRegions(gfx::Rect(10, 330, 160, 170), gfx::Rect(40, 500,
130, 20)).ToString(), child->occlusion().ToString()); | |
| 1581 EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), rootLayer->occlusion()
.ToString()); | |
| 1582 | |
| 1583 // If the child layer has a filter that moves pixels/changes alpha, and
is below child2, then child should not inherit occlusion from outside its subtre
e, | |
| 1584 // and should not contribute to the rootLayer | |
| 1585 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); | |
| 1586 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran
sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); | |
| 1587 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); | |
| 1588 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true); | |
| 1589 | |
| 1590 { | |
| 1591 WebKit::WebFilterOperations filters; | |
| 1592 filters.append(WebKit::WebFilterOperation::createBlurFilter(10)); | |
| 1593 child->setFilters(filters); | |
| 1594 } | |
| 1595 | |
| 1596 m_layerTreeHost->setRootLayer(rootLayer); | |
| 1597 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | |
| 1598 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | |
| 1599 m_layerTreeHost->commitComplete(); | |
| 1600 | |
| 1601 EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString()); | |
| 1602 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occlusion().ToString()); | |
| 1603 EXPECT_EQ(gfx::Rect(10, 330, 160, 170).ToString(), child->occlusion().To
String()); | |
| 1604 EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), rootLayer->occlusion()
.ToString()); | |
| 1605 | |
| 1606 // Kill the layerTreeHost immediately. | |
| 1607 m_layerTreeHost->setRootLayer(0); | |
| 1608 m_layerTreeHost.reset(); | |
| 1609 | |
| 1610 LayerTreeHost::setNeedsFilterContext(false); | |
| 1611 endTest(); | |
| 1612 } | |
| 1613 | |
| 1614 virtual void afterTest() OVERRIDE | |
| 1615 { | |
| 1616 } | |
| 1617 }; | |
| 1618 | |
| 1619 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLayerOcclusionWithFilters) | |
| 1620 | |
| 1621 class LayerTreeHostTestManySurfaces : public LayerTreeHostTest { | |
| 1622 public: | |
| 1623 LayerTreeHostTestManySurfaces() { } | |
| 1624 | |
| 1625 virtual void beginTest() OVERRIDE | |
| 1626 { | |
| 1627 // We create enough RenderSurfaces that it will trigger Vector reallocat
ion while computing occlusion. | |
| 1628 Region occluded; | |
| 1629 const gfx::Transform identityMatrix; | |
| 1630 std::vector<scoped_refptr<TestLayer> > layers; | |
| 1631 std::vector<scoped_refptr<TestLayer> > children; | |
| 1632 int numSurfaces = 20; | |
| 1633 scoped_refptr<TestLayer> replica = TestLayer::create(); | |
| 1634 | |
| 1635 for (int i = 0; i < numSurfaces; ++i) { | |
| 1636 layers.push_back(TestLayer::create()); | |
| 1637 if (!i) { | |
| 1638 setTestLayerPropertiesForTesting(layers.back().get(), 0, identit
yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); | |
| 1639 layers.back()->createRenderSurface(); | |
| 1640 } else { | |
| 1641 setTestLayerPropertiesForTesting(layers.back().get(), layers[lay
ers.size()-2].get(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(1, 1), gfx::
Size(200-i, 200-i), true); | |
| 1642 layers.back()->setMasksToBounds(true); | |
| 1643 layers.back()->setReplicaLayer(replica.get()); // Make it have a
RenderSurfaceImpl | |
| 1644 } | |
| 1645 } | |
| 1646 | |
| 1647 for (int i = 1; i < numSurfaces; ++i) { | |
| 1648 children.push_back(TestLayer::create()); | |
| 1649 setTestLayerPropertiesForTesting(children.back().get(), layers[i].ge
t(), identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500),
false); | |
| 1650 } | |
| 1651 | |
| 1652 m_layerTreeHost->setRootLayer(layers[0].get()); | |
| 1653 m_layerTreeHost->setViewportSize(layers[0]->bounds(), layers[0]->bounds(
)); | |
| 1654 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); | |
| 1655 ResourceUpdateQueue queue; | |
| 1656 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | |
| 1657 m_layerTreeHost->commitComplete(); | |
| 1658 | |
| 1659 for (int i = 0; i < numSurfaces-1; ++i) { | |
| 1660 gfx::Rect expectedOcclusion(1, 1, 200-i-1, 200-i-1); | |
| 1661 EXPECT_EQ(expectedOcclusion.ToString(), layers[i]->occlusion().ToStr
ing()); | |
| 1662 } | |
| 1663 | |
| 1664 // Kill the layerTreeHost immediately. | |
| 1665 m_layerTreeHost->setRootLayer(0); | |
| 1666 m_layerTreeHost.reset(); | |
| 1667 | |
| 1668 endTest(); | |
| 1669 } | |
| 1670 | |
| 1671 virtual void afterTest() OVERRIDE | |
| 1672 { | |
| 1673 } | |
| 1674 }; | |
| 1675 | |
| 1676 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestManySurfaces) | |
| 1677 | |
| 1678 // A loseOutputSurface(1) should lead to a didRecreateOutputSurface(true) | 1351 // A loseOutputSurface(1) should lead to a didRecreateOutputSurface(true) |
| 1679 class LayerTreeHostTestSetSingleLostContext : public LayerTreeHostTest { | 1352 class LayerTreeHostTestSetSingleLostContext : public LayerTreeHostTest { |
| 1680 public: | 1353 public: |
| 1681 LayerTreeHostTestSetSingleLostContext() | 1354 LayerTreeHostTestSetSingleLostContext() |
| 1682 { | 1355 { |
| 1683 } | 1356 } |
| 1684 | 1357 |
| 1685 virtual void beginTest() OVERRIDE | 1358 virtual void beginTest() OVERRIDE |
| 1686 { | 1359 { |
| 1687 postSetNeedsCommitToMainThread(); | 1360 postSetNeedsCommitToMainThread(); |
| (...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2959 LayerTreeSettings settings; | 2632 LayerTreeSettings settings; |
| 2960 settings.maxPartialTextureUpdates = 4; | 2633 settings.maxPartialTextureUpdates = 4; |
| 2961 | 2634 |
| 2962 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc
oped_ptr<Thread>()); | 2635 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc
oped_ptr<Thread>()); |
| 2963 EXPECT_TRUE(host->initializeRendererIfNeeded()); | 2636 EXPECT_TRUE(host->initializeRendererIfNeeded()); |
| 2964 EXPECT_EQ(0u, host->settings().maxPartialTextureUpdates); | 2637 EXPECT_EQ(0u, host->settings().maxPartialTextureUpdates); |
| 2965 } | 2638 } |
| 2966 | 2639 |
| 2967 } // namespace | 2640 } // namespace |
| 2968 } // namespace cc | 2641 } // namespace cc |
| OLD | NEW |