| 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/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 layer->SetDrawsContent(true); | 253 layer->SetDrawsContent(true); |
| 254 layer->SetBounds(size); | 254 layer->SetBounds(size); |
| 255 layer->SetContentBounds(size); | 255 layer->SetContentBounds(size); |
| 256 layer->SetMaxScrollOffset(gfx::Vector2d(size.width() * 2, | 256 layer->SetMaxScrollOffset(gfx::Vector2d(size.width() * 2, |
| 257 size.height() * 2)); | 257 size.height() * 2)); |
| 258 return layer.Pass(); | 258 return layer.Pass(); |
| 259 } | 259 } |
| 260 | 260 |
| 261 void DrawFrame() { | 261 void DrawFrame() { |
| 262 LayerTreeHostImpl::FrameData frame; | 262 LayerTreeHostImpl::FrameData frame; |
| 263 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 263 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 264 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 264 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 265 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 265 host_impl_->DidDrawAllLayers(frame); | 266 host_impl_->DidDrawAllLayers(frame); |
| 266 } | 267 } |
| 267 | 268 |
| 268 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor); | 269 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor); |
| 269 void pinch_zoom_pan_viewport_test(float device_scale_factor); | 270 void pinch_zoom_pan_viewport_test(float device_scale_factor); |
| 270 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); | 271 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); |
| 271 void pinch_zoom_pan_viewport_and_scroll_boundary_test( | 272 void pinch_zoom_pan_viewport_and_scroll_boundary_test( |
| 272 float device_scale_factor); | 273 float device_scale_factor); |
| 273 | 274 |
| (...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1476 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1477 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 1477 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 1478 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
| 1478 host_impl_->active_tree()->root_layer()); | 1479 host_impl_->active_tree()->root_layer()); |
| 1479 | 1480 |
| 1480 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 1481 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 1481 DidDrawCheckLayer* layer = | 1482 DidDrawCheckLayer* layer = |
| 1482 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 1483 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
| 1483 | 1484 |
| 1484 { | 1485 { |
| 1485 LayerTreeHostImpl::FrameData frame; | 1486 LayerTreeHostImpl::FrameData frame; |
| 1486 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10))); | 1487 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 1488 host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10))); |
| 1487 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1489 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1488 host_impl_->DidDrawAllLayers(frame); | 1490 host_impl_->DidDrawAllLayers(frame); |
| 1489 | 1491 |
| 1490 EXPECT_TRUE(layer->will_draw_called()); | 1492 EXPECT_TRUE(layer->will_draw_called()); |
| 1491 EXPECT_TRUE(layer->append_quads_called()); | 1493 EXPECT_TRUE(layer->append_quads_called()); |
| 1492 EXPECT_TRUE(layer->did_draw_called()); | 1494 EXPECT_TRUE(layer->did_draw_called()); |
| 1493 } | 1495 } |
| 1494 | 1496 |
| 1495 { | 1497 { |
| 1496 LayerTreeHostImpl::FrameData frame; | 1498 LayerTreeHostImpl::FrameData frame; |
| 1497 | 1499 |
| 1498 layer->set_will_draw_returns_false(); | 1500 layer->set_will_draw_returns_false(); |
| 1499 layer->ClearDidDrawCheck(); | 1501 layer->ClearDidDrawCheck(); |
| 1500 | 1502 |
| 1501 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10))); | 1503 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 1504 host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10))); |
| 1502 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1505 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1503 host_impl_->DidDrawAllLayers(frame); | 1506 host_impl_->DidDrawAllLayers(frame); |
| 1504 | 1507 |
| 1505 EXPECT_TRUE(layer->will_draw_called()); | 1508 EXPECT_TRUE(layer->will_draw_called()); |
| 1506 EXPECT_FALSE(layer->append_quads_called()); | 1509 EXPECT_FALSE(layer->append_quads_called()); |
| 1507 EXPECT_FALSE(layer->did_draw_called()); | 1510 EXPECT_FALSE(layer->did_draw_called()); |
| 1508 } | 1511 } |
| 1509 } | 1512 } |
| 1510 | 1513 |
| 1511 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { | 1514 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1523 // Ensure visible_content_rect for layer is empty. | 1526 // Ensure visible_content_rect for layer is empty. |
| 1524 layer->SetPosition(gfx::PointF(100.f, 100.f)); | 1527 layer->SetPosition(gfx::PointF(100.f, 100.f)); |
| 1525 layer->SetBounds(gfx::Size(10, 10)); | 1528 layer->SetBounds(gfx::Size(10, 10)); |
| 1526 layer->SetContentBounds(gfx::Size(10, 10)); | 1529 layer->SetContentBounds(gfx::Size(10, 10)); |
| 1527 | 1530 |
| 1528 LayerTreeHostImpl::FrameData frame; | 1531 LayerTreeHostImpl::FrameData frame; |
| 1529 | 1532 |
| 1530 EXPECT_FALSE(layer->will_draw_called()); | 1533 EXPECT_FALSE(layer->will_draw_called()); |
| 1531 EXPECT_FALSE(layer->did_draw_called()); | 1534 EXPECT_FALSE(layer->did_draw_called()); |
| 1532 | 1535 |
| 1533 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 1536 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 1537 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 1534 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1538 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1535 host_impl_->DidDrawAllLayers(frame); | 1539 host_impl_->DidDrawAllLayers(frame); |
| 1536 | 1540 |
| 1537 EXPECT_FALSE(layer->will_draw_called()); | 1541 EXPECT_FALSE(layer->will_draw_called()); |
| 1538 EXPECT_FALSE(layer->did_draw_called()); | 1542 EXPECT_FALSE(layer->did_draw_called()); |
| 1539 | 1543 |
| 1540 EXPECT_TRUE(layer->visible_content_rect().IsEmpty()); | 1544 EXPECT_TRUE(layer->visible_content_rect().IsEmpty()); |
| 1541 | 1545 |
| 1542 // Ensure visible_content_rect for layer is not empty | 1546 // Ensure visible_content_rect for layer is not empty |
| 1543 layer->SetPosition(gfx::PointF()); | 1547 layer->SetPosition(gfx::PointF()); |
| 1544 | 1548 |
| 1545 EXPECT_FALSE(layer->will_draw_called()); | 1549 EXPECT_FALSE(layer->will_draw_called()); |
| 1546 EXPECT_FALSE(layer->did_draw_called()); | 1550 EXPECT_FALSE(layer->did_draw_called()); |
| 1547 | 1551 |
| 1548 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 1552 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 1553 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 1549 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1554 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1550 host_impl_->DidDrawAllLayers(frame); | 1555 host_impl_->DidDrawAllLayers(frame); |
| 1551 | 1556 |
| 1552 EXPECT_TRUE(layer->will_draw_called()); | 1557 EXPECT_TRUE(layer->will_draw_called()); |
| 1553 EXPECT_TRUE(layer->did_draw_called()); | 1558 EXPECT_TRUE(layer->did_draw_called()); |
| 1554 | 1559 |
| 1555 EXPECT_FALSE(layer->visible_content_rect().IsEmpty()); | 1560 EXPECT_FALSE(layer->visible_content_rect().IsEmpty()); |
| 1556 } | 1561 } |
| 1557 | 1562 |
| 1558 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { | 1563 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1577 top_layer->SetContentBounds(big_size); | 1582 top_layer->SetContentBounds(big_size); |
| 1578 top_layer->SetContentsOpaque(true); | 1583 top_layer->SetContentsOpaque(true); |
| 1579 | 1584 |
| 1580 LayerTreeHostImpl::FrameData frame; | 1585 LayerTreeHostImpl::FrameData frame; |
| 1581 | 1586 |
| 1582 EXPECT_FALSE(occluded_layer->will_draw_called()); | 1587 EXPECT_FALSE(occluded_layer->will_draw_called()); |
| 1583 EXPECT_FALSE(occluded_layer->did_draw_called()); | 1588 EXPECT_FALSE(occluded_layer->did_draw_called()); |
| 1584 EXPECT_FALSE(top_layer->will_draw_called()); | 1589 EXPECT_FALSE(top_layer->will_draw_called()); |
| 1585 EXPECT_FALSE(top_layer->did_draw_called()); | 1590 EXPECT_FALSE(top_layer->did_draw_called()); |
| 1586 | 1591 |
| 1587 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 1592 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 1593 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 1588 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1594 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1589 host_impl_->DidDrawAllLayers(frame); | 1595 host_impl_->DidDrawAllLayers(frame); |
| 1590 | 1596 |
| 1591 EXPECT_FALSE(occluded_layer->will_draw_called()); | 1597 EXPECT_FALSE(occluded_layer->will_draw_called()); |
| 1592 EXPECT_FALSE(occluded_layer->did_draw_called()); | 1598 EXPECT_FALSE(occluded_layer->did_draw_called()); |
| 1593 EXPECT_TRUE(top_layer->will_draw_called()); | 1599 EXPECT_TRUE(top_layer->will_draw_called()); |
| 1594 EXPECT_TRUE(top_layer->did_draw_called()); | 1600 EXPECT_TRUE(top_layer->did_draw_called()); |
| 1595 } | 1601 } |
| 1596 | 1602 |
| 1597 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { | 1603 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1609 static_cast<DidDrawCheckLayer*>(layer1->children()[0]); | 1615 static_cast<DidDrawCheckLayer*>(layer1->children()[0]); |
| 1610 | 1616 |
| 1611 layer1->SetOpacity(0.3f); | 1617 layer1->SetOpacity(0.3f); |
| 1612 layer1->SetPreserves3d(false); | 1618 layer1->SetPreserves3d(false); |
| 1613 | 1619 |
| 1614 EXPECT_FALSE(root->did_draw_called()); | 1620 EXPECT_FALSE(root->did_draw_called()); |
| 1615 EXPECT_FALSE(layer1->did_draw_called()); | 1621 EXPECT_FALSE(layer1->did_draw_called()); |
| 1616 EXPECT_FALSE(layer2->did_draw_called()); | 1622 EXPECT_FALSE(layer2->did_draw_called()); |
| 1617 | 1623 |
| 1618 LayerTreeHostImpl::FrameData frame; | 1624 LayerTreeHostImpl::FrameData frame; |
| 1619 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 1625 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 1626 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 1620 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1627 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1621 host_impl_->DidDrawAllLayers(frame); | 1628 host_impl_->DidDrawAllLayers(frame); |
| 1622 | 1629 |
| 1623 EXPECT_TRUE(root->did_draw_called()); | 1630 EXPECT_TRUE(root->did_draw_called()); |
| 1624 EXPECT_TRUE(layer1->did_draw_called()); | 1631 EXPECT_TRUE(layer1->did_draw_called()); |
| 1625 EXPECT_TRUE(layer2->did_draw_called()); | 1632 EXPECT_TRUE(layer2->did_draw_called()); |
| 1626 | 1633 |
| 1627 EXPECT_NE(root->render_surface(), layer1->render_surface()); | 1634 EXPECT_NE(root->render_surface(), layer1->render_surface()); |
| 1628 EXPECT_TRUE(!!layer1->render_surface()); | 1635 EXPECT_TRUE(!!layer1->render_surface()); |
| 1629 } | 1636 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1682 root->AddChild( | 1689 root->AddChild( |
| 1683 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1690 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 1684 2, | 1691 2, |
| 1685 false, | 1692 false, |
| 1686 false, | 1693 false, |
| 1687 true, | 1694 true, |
| 1688 host_impl_->resource_provider())); | 1695 host_impl_->resource_provider())); |
| 1689 | 1696 |
| 1690 LayerTreeHostImpl::FrameData frame; | 1697 LayerTreeHostImpl::FrameData frame; |
| 1691 | 1698 |
| 1692 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 1699 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 1700 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 1693 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1701 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1694 host_impl_->DidDrawAllLayers(frame); | 1702 host_impl_->DidDrawAllLayers(frame); |
| 1695 | 1703 |
| 1696 // When a texture is missing and we're not animating, we draw as usual with | 1704 // When a texture is missing and we're not animating, we draw as usual with |
| 1697 // checkerboarding. | 1705 // checkerboarding. |
| 1698 host_impl_->active_tree()->SetRootLayer( | 1706 host_impl_->active_tree()->SetRootLayer( |
| 1699 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 1707 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 1700 root = | 1708 root = |
| 1701 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1709 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 1702 root->AddChild( | 1710 root->AddChild( |
| 1703 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1711 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 1704 4, | 1712 4, |
| 1705 true, | 1713 true, |
| 1706 false, | 1714 false, |
| 1707 false, | 1715 false, |
| 1708 host_impl_->resource_provider())); | 1716 host_impl_->resource_provider())); |
| 1709 | 1717 |
| 1710 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 1718 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 1719 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 1711 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1720 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1712 host_impl_->DidDrawAllLayers(frame); | 1721 host_impl_->DidDrawAllLayers(frame); |
| 1713 | 1722 |
| 1714 // When a texture is missing and we're animating, we don't want to draw | 1723 // When a texture is missing and we're animating, we don't want to draw |
| 1715 // anything. | 1724 // anything. |
| 1716 host_impl_->active_tree()->SetRootLayer( | 1725 host_impl_->active_tree()->SetRootLayer( |
| 1717 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); | 1726 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); |
| 1718 root = | 1727 root = |
| 1719 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1728 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 1720 root->AddChild( | 1729 root->AddChild( |
| 1721 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1730 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 1722 6, | 1731 6, |
| 1723 true, | 1732 true, |
| 1724 false, | 1733 false, |
| 1725 true, | 1734 true, |
| 1726 host_impl_->resource_provider())); | 1735 host_impl_->resource_provider())); |
| 1727 | 1736 |
| 1728 EXPECT_FALSE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 1737 EXPECT_EQ(DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, |
| 1738 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 1729 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1739 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1730 host_impl_->DidDrawAllLayers(frame); | 1740 host_impl_->DidDrawAllLayers(frame); |
| 1731 | 1741 |
| 1732 // When the layer skips draw and we're animating, we still draw the frame. | 1742 // When the layer skips draw and we're animating, we still draw the frame. |
| 1733 host_impl_->active_tree()->SetRootLayer( | 1743 host_impl_->active_tree()->SetRootLayer( |
| 1734 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 1744 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
| 1735 root = | 1745 root = |
| 1736 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1746 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 1737 root->AddChild( | 1747 root->AddChild( |
| 1738 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1748 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2028 EXPECT_EQ(1.f, scroll->contents_scale_x()); | 2038 EXPECT_EQ(1.f, scroll->contents_scale_x()); |
| 2029 EXPECT_EQ(1.f, scroll->contents_scale_y()); | 2039 EXPECT_EQ(1.f, scroll->contents_scale_y()); |
| 2030 EXPECT_EQ(1.f, child->contents_scale_x()); | 2040 EXPECT_EQ(1.f, child->contents_scale_x()); |
| 2031 EXPECT_EQ(1.f, child->contents_scale_y()); | 2041 EXPECT_EQ(1.f, child->contents_scale_y()); |
| 2032 EXPECT_EQ(1.f, grand_child->contents_scale_x()); | 2042 EXPECT_EQ(1.f, grand_child->contents_scale_x()); |
| 2033 EXPECT_EQ(1.f, grand_child->contents_scale_y()); | 2043 EXPECT_EQ(1.f, grand_child->contents_scale_y()); |
| 2034 | 2044 |
| 2035 // Make sure all the layers are drawn with the page scale delta applied, i.e., | 2045 // Make sure all the layers are drawn with the page scale delta applied, i.e., |
| 2036 // the page scale delta on the root layer is applied hierarchically. | 2046 // the page scale delta on the root layer is applied hierarchically. |
| 2037 LayerTreeHostImpl::FrameData frame; | 2047 LayerTreeHostImpl::FrameData frame; |
| 2038 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 2048 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 2049 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 2039 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2050 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2040 host_impl_->DidDrawAllLayers(frame); | 2051 host_impl_->DidDrawAllLayers(frame); |
| 2041 | 2052 |
| 2042 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(0, 0)); | 2053 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(0, 0)); |
| 2043 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(1, 1)); | 2054 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(1, 1)); |
| 2044 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(0, 0)); | 2055 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(0, 0)); |
| 2045 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(1, 1)); | 2056 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(1, 1)); |
| 2046 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(0, 0)); | 2057 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(0, 0)); |
| 2047 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(1, 1)); | 2058 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(1, 1)); |
| 2048 EXPECT_EQ(new_page_scale, | 2059 EXPECT_EQ(new_page_scale, |
| (...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2844 BlendStateCheckLayer* layer1 = | 2855 BlendStateCheckLayer* layer1 = |
| 2845 static_cast<BlendStateCheckLayer*>(root->children()[0]); | 2856 static_cast<BlendStateCheckLayer*>(root->children()[0]); |
| 2846 layer1->SetPosition(gfx::PointF(2.f, 2.f)); | 2857 layer1->SetPosition(gfx::PointF(2.f, 2.f)); |
| 2847 | 2858 |
| 2848 LayerTreeHostImpl::FrameData frame; | 2859 LayerTreeHostImpl::FrameData frame; |
| 2849 | 2860 |
| 2850 // Opaque layer, drawn without blending. | 2861 // Opaque layer, drawn without blending. |
| 2851 layer1->SetContentsOpaque(true); | 2862 layer1->SetContentsOpaque(true); |
| 2852 layer1->SetExpectation(false, false); | 2863 layer1->SetExpectation(false, false); |
| 2853 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 2864 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 2854 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 2865 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 2866 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 2855 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2867 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2856 EXPECT_TRUE(layer1->quads_appended()); | 2868 EXPECT_TRUE(layer1->quads_appended()); |
| 2857 host_impl_->DidDrawAllLayers(frame); | 2869 host_impl_->DidDrawAllLayers(frame); |
| 2858 | 2870 |
| 2859 // Layer with translucent content and painting, so drawn with blending. | 2871 // Layer with translucent content and painting, so drawn with blending. |
| 2860 layer1->SetContentsOpaque(false); | 2872 layer1->SetContentsOpaque(false); |
| 2861 layer1->SetExpectation(true, false); | 2873 layer1->SetExpectation(true, false); |
| 2862 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 2874 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 2863 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 2875 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 2876 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 2864 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2877 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2865 EXPECT_TRUE(layer1->quads_appended()); | 2878 EXPECT_TRUE(layer1->quads_appended()); |
| 2866 host_impl_->DidDrawAllLayers(frame); | 2879 host_impl_->DidDrawAllLayers(frame); |
| 2867 | 2880 |
| 2868 // Layer with translucent opacity, drawn with blending. | 2881 // Layer with translucent opacity, drawn with blending. |
| 2869 layer1->SetContentsOpaque(true); | 2882 layer1->SetContentsOpaque(true); |
| 2870 layer1->SetOpacity(0.5f); | 2883 layer1->SetOpacity(0.5f); |
| 2871 layer1->SetExpectation(true, false); | 2884 layer1->SetExpectation(true, false); |
| 2872 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 2885 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 2873 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 2886 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 2887 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 2874 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2888 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2875 EXPECT_TRUE(layer1->quads_appended()); | 2889 EXPECT_TRUE(layer1->quads_appended()); |
| 2876 host_impl_->DidDrawAllLayers(frame); | 2890 host_impl_->DidDrawAllLayers(frame); |
| 2877 | 2891 |
| 2878 // Layer with translucent opacity and painting, drawn with blending. | 2892 // Layer with translucent opacity and painting, drawn with blending. |
| 2879 layer1->SetContentsOpaque(true); | 2893 layer1->SetContentsOpaque(true); |
| 2880 layer1->SetOpacity(0.5f); | 2894 layer1->SetOpacity(0.5f); |
| 2881 layer1->SetExpectation(true, false); | 2895 layer1->SetExpectation(true, false); |
| 2882 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 2896 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 2883 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 2897 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 2898 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 2884 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2899 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2885 EXPECT_TRUE(layer1->quads_appended()); | 2900 EXPECT_TRUE(layer1->quads_appended()); |
| 2886 host_impl_->DidDrawAllLayers(frame); | 2901 host_impl_->DidDrawAllLayers(frame); |
| 2887 | 2902 |
| 2888 layer1->AddChild( | 2903 layer1->AddChild( |
| 2889 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 2904 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
| 2890 3, | 2905 3, |
| 2891 host_impl_->resource_provider())); | 2906 host_impl_->resource_provider())); |
| 2892 BlendStateCheckLayer* layer2 = | 2907 BlendStateCheckLayer* layer2 = |
| 2893 static_cast<BlendStateCheckLayer*>(layer1->children()[0]); | 2908 static_cast<BlendStateCheckLayer*>(layer1->children()[0]); |
| 2894 layer2->SetPosition(gfx::PointF(4.f, 4.f)); | 2909 layer2->SetPosition(gfx::PointF(4.f, 4.f)); |
| 2895 | 2910 |
| 2896 // 2 opaque layers, drawn without blending. | 2911 // 2 opaque layers, drawn without blending. |
| 2897 layer1->SetContentsOpaque(true); | 2912 layer1->SetContentsOpaque(true); |
| 2898 layer1->SetOpacity(1.f); | 2913 layer1->SetOpacity(1.f); |
| 2899 layer1->SetExpectation(false, false); | 2914 layer1->SetExpectation(false, false); |
| 2900 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 2915 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 2901 layer2->SetContentsOpaque(true); | 2916 layer2->SetContentsOpaque(true); |
| 2902 layer2->SetOpacity(1.f); | 2917 layer2->SetOpacity(1.f); |
| 2903 layer2->SetExpectation(false, false); | 2918 layer2->SetExpectation(false, false); |
| 2904 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 2919 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 2905 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 2920 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 2921 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 2906 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2922 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2907 EXPECT_TRUE(layer1->quads_appended()); | 2923 EXPECT_TRUE(layer1->quads_appended()); |
| 2908 EXPECT_TRUE(layer2->quads_appended()); | 2924 EXPECT_TRUE(layer2->quads_appended()); |
| 2909 host_impl_->DidDrawAllLayers(frame); | 2925 host_impl_->DidDrawAllLayers(frame); |
| 2910 | 2926 |
| 2911 // Parent layer with translucent content, drawn with blending. | 2927 // Parent layer with translucent content, drawn with blending. |
| 2912 // Child layer with opaque content, drawn without blending. | 2928 // Child layer with opaque content, drawn without blending. |
| 2913 layer1->SetContentsOpaque(false); | 2929 layer1->SetContentsOpaque(false); |
| 2914 layer1->SetExpectation(true, false); | 2930 layer1->SetExpectation(true, false); |
| 2915 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 2931 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 2916 layer2->SetExpectation(false, false); | 2932 layer2->SetExpectation(false, false); |
| 2917 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 2933 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 2918 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 2934 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 2935 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 2919 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2936 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2920 EXPECT_TRUE(layer1->quads_appended()); | 2937 EXPECT_TRUE(layer1->quads_appended()); |
| 2921 EXPECT_TRUE(layer2->quads_appended()); | 2938 EXPECT_TRUE(layer2->quads_appended()); |
| 2922 host_impl_->DidDrawAllLayers(frame); | 2939 host_impl_->DidDrawAllLayers(frame); |
| 2923 | 2940 |
| 2924 // Parent layer with translucent content but opaque painting, drawn without | 2941 // Parent layer with translucent content but opaque painting, drawn without |
| 2925 // blending. | 2942 // blending. |
| 2926 // Child layer with opaque content, drawn without blending. | 2943 // Child layer with opaque content, drawn without blending. |
| 2927 layer1->SetContentsOpaque(true); | 2944 layer1->SetContentsOpaque(true); |
| 2928 layer1->SetExpectation(false, false); | 2945 layer1->SetExpectation(false, false); |
| 2929 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 2946 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 2930 layer2->SetExpectation(false, false); | 2947 layer2->SetExpectation(false, false); |
| 2931 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 2948 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 2932 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 2949 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 2950 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 2933 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2951 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2934 EXPECT_TRUE(layer1->quads_appended()); | 2952 EXPECT_TRUE(layer1->quads_appended()); |
| 2935 EXPECT_TRUE(layer2->quads_appended()); | 2953 EXPECT_TRUE(layer2->quads_appended()); |
| 2936 host_impl_->DidDrawAllLayers(frame); | 2954 host_impl_->DidDrawAllLayers(frame); |
| 2937 | 2955 |
| 2938 // Parent layer with translucent opacity and opaque content. Since it has a | 2956 // Parent layer with translucent opacity and opaque content. Since it has a |
| 2939 // drawing child, it's drawn to a render surface which carries the opacity, | 2957 // drawing child, it's drawn to a render surface which carries the opacity, |
| 2940 // so it's itself drawn without blending. | 2958 // so it's itself drawn without blending. |
| 2941 // Child layer with opaque content, drawn without blending (parent surface | 2959 // Child layer with opaque content, drawn without blending (parent surface |
| 2942 // carries the inherited opacity). | 2960 // carries the inherited opacity). |
| 2943 layer1->SetContentsOpaque(true); | 2961 layer1->SetContentsOpaque(true); |
| 2944 layer1->SetOpacity(0.5f); | 2962 layer1->SetOpacity(0.5f); |
| 2945 layer1->SetExpectation(false, true); | 2963 layer1->SetExpectation(false, true); |
| 2946 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 2964 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 2947 layer2->SetExpectation(false, false); | 2965 layer2->SetExpectation(false, false); |
| 2948 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 2966 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 2949 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 2967 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 2968 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 2950 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2969 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2951 EXPECT_TRUE(layer1->quads_appended()); | 2970 EXPECT_TRUE(layer1->quads_appended()); |
| 2952 EXPECT_TRUE(layer2->quads_appended()); | 2971 EXPECT_TRUE(layer2->quads_appended()); |
| 2953 host_impl_->DidDrawAllLayers(frame); | 2972 host_impl_->DidDrawAllLayers(frame); |
| 2954 | 2973 |
| 2955 // Draw again, but with child non-opaque, to make sure | 2974 // Draw again, but with child non-opaque, to make sure |
| 2956 // layer1 not culled. | 2975 // layer1 not culled. |
| 2957 layer1->SetContentsOpaque(true); | 2976 layer1->SetContentsOpaque(true); |
| 2958 layer1->SetOpacity(1.f); | 2977 layer1->SetOpacity(1.f); |
| 2959 layer1->SetExpectation(false, false); | 2978 layer1->SetExpectation(false, false); |
| 2960 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 2979 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 2961 layer2->SetContentsOpaque(true); | 2980 layer2->SetContentsOpaque(true); |
| 2962 layer2->SetOpacity(0.5f); | 2981 layer2->SetOpacity(0.5f); |
| 2963 layer2->SetExpectation(true, false); | 2982 layer2->SetExpectation(true, false); |
| 2964 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 2983 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 2965 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 2984 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 2985 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 2966 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2986 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2967 EXPECT_TRUE(layer1->quads_appended()); | 2987 EXPECT_TRUE(layer1->quads_appended()); |
| 2968 EXPECT_TRUE(layer2->quads_appended()); | 2988 EXPECT_TRUE(layer2->quads_appended()); |
| 2969 host_impl_->DidDrawAllLayers(frame); | 2989 host_impl_->DidDrawAllLayers(frame); |
| 2970 | 2990 |
| 2971 // A second way of making the child non-opaque. | 2991 // A second way of making the child non-opaque. |
| 2972 layer1->SetContentsOpaque(true); | 2992 layer1->SetContentsOpaque(true); |
| 2973 layer1->SetOpacity(1.f); | 2993 layer1->SetOpacity(1.f); |
| 2974 layer1->SetExpectation(false, false); | 2994 layer1->SetExpectation(false, false); |
| 2975 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 2995 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 2976 layer2->SetContentsOpaque(false); | 2996 layer2->SetContentsOpaque(false); |
| 2977 layer2->SetOpacity(1.f); | 2997 layer2->SetOpacity(1.f); |
| 2978 layer2->SetExpectation(true, false); | 2998 layer2->SetExpectation(true, false); |
| 2979 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 2999 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 2980 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 3000 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3001 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 2981 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 3002 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2982 EXPECT_TRUE(layer1->quads_appended()); | 3003 EXPECT_TRUE(layer1->quads_appended()); |
| 2983 EXPECT_TRUE(layer2->quads_appended()); | 3004 EXPECT_TRUE(layer2->quads_appended()); |
| 2984 host_impl_->DidDrawAllLayers(frame); | 3005 host_impl_->DidDrawAllLayers(frame); |
| 2985 | 3006 |
| 2986 // And when the layer says its not opaque but is painted opaque, it is not | 3007 // And when the layer says its not opaque but is painted opaque, it is not |
| 2987 // blended. | 3008 // blended. |
| 2988 layer1->SetContentsOpaque(true); | 3009 layer1->SetContentsOpaque(true); |
| 2989 layer1->SetOpacity(1.f); | 3010 layer1->SetOpacity(1.f); |
| 2990 layer1->SetExpectation(false, false); | 3011 layer1->SetExpectation(false, false); |
| 2991 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3012 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 2992 layer2->SetContentsOpaque(true); | 3013 layer2->SetContentsOpaque(true); |
| 2993 layer2->SetOpacity(1.f); | 3014 layer2->SetOpacity(1.f); |
| 2994 layer2->SetExpectation(false, false); | 3015 layer2->SetExpectation(false, false); |
| 2995 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3016 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 2996 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 3017 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3018 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 2997 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 3019 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2998 EXPECT_TRUE(layer1->quads_appended()); | 3020 EXPECT_TRUE(layer1->quads_appended()); |
| 2999 EXPECT_TRUE(layer2->quads_appended()); | 3021 EXPECT_TRUE(layer2->quads_appended()); |
| 3000 host_impl_->DidDrawAllLayers(frame); | 3022 host_impl_->DidDrawAllLayers(frame); |
| 3001 | 3023 |
| 3002 // Layer with partially opaque contents, drawn with blending. | 3024 // Layer with partially opaque contents, drawn with blending. |
| 3003 layer1->SetContentsOpaque(false); | 3025 layer1->SetContentsOpaque(false); |
| 3004 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 3026 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
| 3005 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); | 3027 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); |
| 3006 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 3028 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
| 3007 layer1->SetExpectation(true, false); | 3029 layer1->SetExpectation(true, false); |
| 3008 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3030 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3009 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 3031 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3032 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 3010 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 3033 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3011 EXPECT_TRUE(layer1->quads_appended()); | 3034 EXPECT_TRUE(layer1->quads_appended()); |
| 3012 host_impl_->DidDrawAllLayers(frame); | 3035 host_impl_->DidDrawAllLayers(frame); |
| 3013 | 3036 |
| 3014 // Layer with partially opaque contents partially culled, drawn with blending. | 3037 // Layer with partially opaque contents partially culled, drawn with blending. |
| 3015 layer1->SetContentsOpaque(false); | 3038 layer1->SetContentsOpaque(false); |
| 3016 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 3039 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
| 3017 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); | 3040 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); |
| 3018 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 3041 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
| 3019 layer1->SetExpectation(true, false); | 3042 layer1->SetExpectation(true, false); |
| 3020 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3043 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3021 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 3044 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3045 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 3022 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 3046 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3023 EXPECT_TRUE(layer1->quads_appended()); | 3047 EXPECT_TRUE(layer1->quads_appended()); |
| 3024 host_impl_->DidDrawAllLayers(frame); | 3048 host_impl_->DidDrawAllLayers(frame); |
| 3025 | 3049 |
| 3026 // Layer with partially opaque contents culled, drawn with blending. | 3050 // Layer with partially opaque contents culled, drawn with blending. |
| 3027 layer1->SetContentsOpaque(false); | 3051 layer1->SetContentsOpaque(false); |
| 3028 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 3052 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
| 3029 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); | 3053 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); |
| 3030 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 3054 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
| 3031 layer1->SetExpectation(true, false); | 3055 layer1->SetExpectation(true, false); |
| 3032 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3056 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3033 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 3057 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3058 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 3034 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 3059 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3035 EXPECT_TRUE(layer1->quads_appended()); | 3060 EXPECT_TRUE(layer1->quads_appended()); |
| 3036 host_impl_->DidDrawAllLayers(frame); | 3061 host_impl_->DidDrawAllLayers(frame); |
| 3037 | 3062 |
| 3038 // Layer with partially opaque contents and translucent contents culled, drawn | 3063 // Layer with partially opaque contents and translucent contents culled, drawn |
| 3039 // without blending. | 3064 // without blending. |
| 3040 layer1->SetContentsOpaque(false); | 3065 layer1->SetContentsOpaque(false); |
| 3041 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 3066 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
| 3042 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); | 3067 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); |
| 3043 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 3068 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
| 3044 layer1->SetExpectation(false, false); | 3069 layer1->SetExpectation(false, false); |
| 3045 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3070 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3046 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 3071 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3072 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 3047 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 3073 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3048 EXPECT_TRUE(layer1->quads_appended()); | 3074 EXPECT_TRUE(layer1->quads_appended()); |
| 3049 host_impl_->DidDrawAllLayers(frame); | 3075 host_impl_->DidDrawAllLayers(frame); |
| 3050 } | 3076 } |
| 3051 | 3077 |
| 3052 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { | 3078 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { |
| 3053 protected: | 3079 protected: |
| 3054 LayerTreeHostImplViewportCoveredTest() : | 3080 LayerTreeHostImplViewportCoveredTest() : |
| 3055 gutter_quad_material_(DrawQuad::SOLID_COLOR), | 3081 gutter_quad_material_(DrawQuad::SOLID_COLOR), |
| 3056 child_(NULL), | 3082 child_(NULL), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3081 // Expect no gutter rects. | 3107 // Expect no gutter rects. |
| 3082 void TestLayerCoversFullViewport() { | 3108 void TestLayerCoversFullViewport() { |
| 3083 gfx::Rect layer_rect(viewport_size_); | 3109 gfx::Rect layer_rect(viewport_size_); |
| 3084 child_->SetPosition(layer_rect.origin()); | 3110 child_->SetPosition(layer_rect.origin()); |
| 3085 child_->SetBounds(layer_rect.size()); | 3111 child_->SetBounds(layer_rect.size()); |
| 3086 child_->SetContentBounds(layer_rect.size()); | 3112 child_->SetContentBounds(layer_rect.size()); |
| 3087 child_->SetQuadRect(gfx::Rect(layer_rect.size())); | 3113 child_->SetQuadRect(gfx::Rect(layer_rect.size())); |
| 3088 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); | 3114 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); |
| 3089 | 3115 |
| 3090 LayerTreeHostImpl::FrameData frame; | 3116 LayerTreeHostImpl::FrameData frame; |
| 3091 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 3117 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3118 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 3092 ASSERT_EQ(1u, frame.render_passes.size()); | 3119 ASSERT_EQ(1u, frame.render_passes.size()); |
| 3093 | 3120 |
| 3094 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list)); | 3121 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list)); |
| 3095 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); | 3122 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); |
| 3096 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); | 3123 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); |
| 3097 | 3124 |
| 3098 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); | 3125 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); |
| 3099 host_impl_->DidDrawAllLayers(frame); | 3126 host_impl_->DidDrawAllLayers(frame); |
| 3100 } | 3127 } |
| 3101 | 3128 |
| 3102 // Expect fullscreen gutter rect. | 3129 // Expect fullscreen gutter rect. |
| 3103 void TestEmptyLayer() { | 3130 void TestEmptyLayer() { |
| 3104 gfx::Rect layer_rect(0, 0, 0, 0); | 3131 gfx::Rect layer_rect(0, 0, 0, 0); |
| 3105 child_->SetPosition(layer_rect.origin()); | 3132 child_->SetPosition(layer_rect.origin()); |
| 3106 child_->SetBounds(layer_rect.size()); | 3133 child_->SetBounds(layer_rect.size()); |
| 3107 child_->SetContentBounds(layer_rect.size()); | 3134 child_->SetContentBounds(layer_rect.size()); |
| 3108 child_->SetQuadRect(gfx::Rect(layer_rect.size())); | 3135 child_->SetQuadRect(gfx::Rect(layer_rect.size())); |
| 3109 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); | 3136 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); |
| 3110 | 3137 |
| 3111 LayerTreeHostImpl::FrameData frame; | 3138 LayerTreeHostImpl::FrameData frame; |
| 3112 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 3139 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3140 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 3113 ASSERT_EQ(1u, frame.render_passes.size()); | 3141 ASSERT_EQ(1u, frame.render_passes.size()); |
| 3114 | 3142 |
| 3115 EXPECT_EQ(1u, CountGutterQuads(frame.render_passes[0]->quad_list)); | 3143 EXPECT_EQ(1u, CountGutterQuads(frame.render_passes[0]->quad_list)); |
| 3116 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); | 3144 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); |
| 3117 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); | 3145 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); |
| 3118 | 3146 |
| 3119 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); | 3147 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); |
| 3120 host_impl_->DidDrawAllLayers(frame); | 3148 host_impl_->DidDrawAllLayers(frame); |
| 3121 } | 3149 } |
| 3122 | 3150 |
| 3123 // Expect four surrounding gutter rects. | 3151 // Expect four surrounding gutter rects. |
| 3124 void TestLayerInMiddleOfViewport() { | 3152 void TestLayerInMiddleOfViewport() { |
| 3125 gfx::Rect layer_rect(500, 500, 200, 200); | 3153 gfx::Rect layer_rect(500, 500, 200, 200); |
| 3126 child_->SetPosition(layer_rect.origin()); | 3154 child_->SetPosition(layer_rect.origin()); |
| 3127 child_->SetBounds(layer_rect.size()); | 3155 child_->SetBounds(layer_rect.size()); |
| 3128 child_->SetContentBounds(layer_rect.size()); | 3156 child_->SetContentBounds(layer_rect.size()); |
| 3129 child_->SetQuadRect(gfx::Rect(layer_rect.size())); | 3157 child_->SetQuadRect(gfx::Rect(layer_rect.size())); |
| 3130 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); | 3158 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); |
| 3131 | 3159 |
| 3132 LayerTreeHostImpl::FrameData frame; | 3160 LayerTreeHostImpl::FrameData frame; |
| 3133 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 3161 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3162 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 3134 ASSERT_EQ(1u, frame.render_passes.size()); | 3163 ASSERT_EQ(1u, frame.render_passes.size()); |
| 3135 | 3164 |
| 3136 EXPECT_EQ(4u, CountGutterQuads(frame.render_passes[0]->quad_list)); | 3165 EXPECT_EQ(4u, CountGutterQuads(frame.render_passes[0]->quad_list)); |
| 3137 EXPECT_EQ(5u, frame.render_passes[0]->quad_list.size()); | 3166 EXPECT_EQ(5u, frame.render_passes[0]->quad_list.size()); |
| 3138 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); | 3167 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); |
| 3139 | 3168 |
| 3140 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); | 3169 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); |
| 3141 host_impl_->DidDrawAllLayers(frame); | 3170 host_impl_->DidDrawAllLayers(frame); |
| 3142 } | 3171 } |
| 3143 | 3172 |
| 3144 // Expect no gutter rects. | 3173 // Expect no gutter rects. |
| 3145 void TestLayerIsLargerThanViewport() { | 3174 void TestLayerIsLargerThanViewport() { |
| 3146 gfx::Rect layer_rect(viewport_size_.width() + 10, | 3175 gfx::Rect layer_rect(viewport_size_.width() + 10, |
| 3147 viewport_size_.height() + 10); | 3176 viewport_size_.height() + 10); |
| 3148 child_->SetPosition(layer_rect.origin()); | 3177 child_->SetPosition(layer_rect.origin()); |
| 3149 child_->SetBounds(layer_rect.size()); | 3178 child_->SetBounds(layer_rect.size()); |
| 3150 child_->SetContentBounds(layer_rect.size()); | 3179 child_->SetContentBounds(layer_rect.size()); |
| 3151 child_->SetQuadRect(gfx::Rect(layer_rect.size())); | 3180 child_->SetQuadRect(gfx::Rect(layer_rect.size())); |
| 3152 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); | 3181 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); |
| 3153 | 3182 |
| 3154 LayerTreeHostImpl::FrameData frame; | 3183 LayerTreeHostImpl::FrameData frame; |
| 3155 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 3184 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3185 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 3156 ASSERT_EQ(1u, frame.render_passes.size()); | 3186 ASSERT_EQ(1u, frame.render_passes.size()); |
| 3157 | 3187 |
| 3158 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list)); | 3188 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list)); |
| 3159 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); | 3189 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); |
| 3160 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); | 3190 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); |
| 3161 | 3191 |
| 3162 host_impl_->DidDrawAllLayers(frame); | 3192 host_impl_->DidDrawAllLayers(frame); |
| 3163 } | 3193 } |
| 3164 | 3194 |
| 3165 virtual void DidActivatePendingTree() OVERRIDE { | 3195 virtual void DidActivatePendingTree() OVERRIDE { |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3364 root->SetBounds(gfx::Size(10, 10)); | 3394 root->SetBounds(gfx::Size(10, 10)); |
| 3365 root->SetContentBounds(gfx::Size(10, 10)); | 3395 root->SetContentBounds(gfx::Size(10, 10)); |
| 3366 root->SetDrawsContent(true); | 3396 root->SetDrawsContent(true); |
| 3367 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 3397 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 3368 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); | 3398 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); |
| 3369 provider->TestContext3d()->clear_reshape_called(); | 3399 provider->TestContext3d()->clear_reshape_called(); |
| 3370 | 3400 |
| 3371 LayerTreeHostImpl::FrameData frame; | 3401 LayerTreeHostImpl::FrameData frame; |
| 3372 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 3402 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 3373 host_impl_->SetDeviceScaleFactor(1.f); | 3403 host_impl_->SetDeviceScaleFactor(1.f); |
| 3374 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 3404 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3405 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 3375 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 3406 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3376 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | 3407 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); |
| 3377 EXPECT_EQ(provider->TestContext3d()->width(), 10); | 3408 EXPECT_EQ(provider->TestContext3d()->width(), 10); |
| 3378 EXPECT_EQ(provider->TestContext3d()->height(), 10); | 3409 EXPECT_EQ(provider->TestContext3d()->height(), 10); |
| 3379 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); | 3410 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); |
| 3380 host_impl_->DidDrawAllLayers(frame); | 3411 host_impl_->DidDrawAllLayers(frame); |
| 3381 provider->TestContext3d()->clear_reshape_called(); | 3412 provider->TestContext3d()->clear_reshape_called(); |
| 3382 | 3413 |
| 3383 host_impl_->SetViewportSize(gfx::Size(20, 30)); | 3414 host_impl_->SetViewportSize(gfx::Size(20, 30)); |
| 3384 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 3415 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3416 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 3385 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 3417 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3386 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | 3418 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); |
| 3387 EXPECT_EQ(provider->TestContext3d()->width(), 20); | 3419 EXPECT_EQ(provider->TestContext3d()->width(), 20); |
| 3388 EXPECT_EQ(provider->TestContext3d()->height(), 30); | 3420 EXPECT_EQ(provider->TestContext3d()->height(), 30); |
| 3389 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); | 3421 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); |
| 3390 host_impl_->DidDrawAllLayers(frame); | 3422 host_impl_->DidDrawAllLayers(frame); |
| 3391 provider->TestContext3d()->clear_reshape_called(); | 3423 provider->TestContext3d()->clear_reshape_called(); |
| 3392 | 3424 |
| 3393 host_impl_->SetDeviceScaleFactor(2.f); | 3425 host_impl_->SetDeviceScaleFactor(2.f); |
| 3394 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 3426 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3427 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 3395 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 3428 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3396 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | 3429 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); |
| 3397 EXPECT_EQ(provider->TestContext3d()->width(), 20); | 3430 EXPECT_EQ(provider->TestContext3d()->width(), 20); |
| 3398 EXPECT_EQ(provider->TestContext3d()->height(), 30); | 3431 EXPECT_EQ(provider->TestContext3d()->height(), 30); |
| 3399 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 2.f); | 3432 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 2.f); |
| 3400 host_impl_->DidDrawAllLayers(frame); | 3433 host_impl_->DidDrawAllLayers(frame); |
| 3401 provider->TestContext3d()->clear_reshape_called(); | 3434 provider->TestContext3d()->clear_reshape_called(); |
| 3402 } | 3435 } |
| 3403 | 3436 |
| 3404 // Make sure damage tracking propagates all the way to the graphics context, | 3437 // Make sure damage tracking propagates all the way to the graphics context, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 3434 root->SetAnchorPoint(gfx::PointF()); | 3467 root->SetAnchorPoint(gfx::PointF()); |
| 3435 root->SetBounds(gfx::Size(500, 500)); | 3468 root->SetBounds(gfx::Size(500, 500)); |
| 3436 root->SetContentBounds(gfx::Size(500, 500)); | 3469 root->SetContentBounds(gfx::Size(500, 500)); |
| 3437 root->SetDrawsContent(true); | 3470 root->SetDrawsContent(true); |
| 3438 root->AddChild(child.Pass()); | 3471 root->AddChild(child.Pass()); |
| 3439 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass()); | 3472 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass()); |
| 3440 | 3473 |
| 3441 LayerTreeHostImpl::FrameData frame; | 3474 LayerTreeHostImpl::FrameData frame; |
| 3442 | 3475 |
| 3443 // First frame, the entire screen should get swapped. | 3476 // First frame, the entire screen should get swapped. |
| 3444 EXPECT_TRUE(layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect())); | 3477 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3478 layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect())); |
| 3445 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); | 3479 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3446 layer_tree_host_impl->DidDrawAllLayers(frame); | 3480 layer_tree_host_impl->DidDrawAllLayers(frame); |
| 3447 layer_tree_host_impl->SwapBuffers(frame); | 3481 layer_tree_host_impl->SwapBuffers(frame); |
| 3448 EXPECT_EQ(TestContextSupport::SWAP, | 3482 EXPECT_EQ(TestContextSupport::SWAP, |
| 3449 context_provider->support()->last_swap_type()); | 3483 context_provider->support()->last_swap_type()); |
| 3450 | 3484 |
| 3451 // Second frame, only the damaged area should get swapped. Damage should be | 3485 // Second frame, only the damaged area should get swapped. Damage should be |
| 3452 // the union of old and new child rects. | 3486 // the union of old and new child rects. |
| 3453 // expected damage rect: gfx::Rect(26, 28); | 3487 // expected damage rect: gfx::Rect(26, 28); |
| 3454 // expected swap rect: vertically flipped, with origin at bottom left corner. | 3488 // expected swap rect: vertically flipped, with origin at bottom left corner. |
| 3455 layer_tree_host_impl->active_tree()->root_layer()->children()[0]->SetPosition( | 3489 layer_tree_host_impl->active_tree()->root_layer()->children()[0]->SetPosition( |
| 3456 gfx::PointF()); | 3490 gfx::PointF()); |
| 3457 EXPECT_TRUE(layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect())); | 3491 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3492 layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect())); |
| 3458 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); | 3493 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3459 host_impl_->DidDrawAllLayers(frame); | 3494 host_impl_->DidDrawAllLayers(frame); |
| 3460 layer_tree_host_impl->SwapBuffers(frame); | 3495 layer_tree_host_impl->SwapBuffers(frame); |
| 3461 | 3496 |
| 3462 // Make sure that partial swap is constrained to the viewport dimensions | 3497 // Make sure that partial swap is constrained to the viewport dimensions |
| 3463 // expected damage rect: gfx::Rect(500, 500); | 3498 // expected damage rect: gfx::Rect(500, 500); |
| 3464 // expected swap rect: flipped damage rect, but also clamped to viewport | 3499 // expected swap rect: flipped damage rect, but also clamped to viewport |
| 3465 EXPECT_EQ(TestContextSupport::PARTIAL_SWAP, | 3500 EXPECT_EQ(TestContextSupport::PARTIAL_SWAP, |
| 3466 context_provider->support()->last_swap_type()); | 3501 context_provider->support()->last_swap_type()); |
| 3467 gfx::Rect expected_swap_rect(0, 500-28, 26, 28); | 3502 gfx::Rect expected_swap_rect(0, 500-28, 26, 28); |
| 3468 EXPECT_EQ(expected_swap_rect.ToString(), | 3503 EXPECT_EQ(expected_swap_rect.ToString(), |
| 3469 context_provider->support()-> | 3504 context_provider->support()-> |
| 3470 last_partial_swap_rect().ToString()); | 3505 last_partial_swap_rect().ToString()); |
| 3471 | 3506 |
| 3472 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10)); | 3507 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10)); |
| 3473 // This will damage everything. | 3508 // This will damage everything. |
| 3474 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor( | 3509 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor( |
| 3475 SK_ColorBLACK); | 3510 SK_ColorBLACK); |
| 3476 EXPECT_TRUE(layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect())); | 3511 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3512 layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect())); |
| 3477 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); | 3513 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3478 host_impl_->DidDrawAllLayers(frame); | 3514 host_impl_->DidDrawAllLayers(frame); |
| 3479 layer_tree_host_impl->SwapBuffers(frame); | 3515 layer_tree_host_impl->SwapBuffers(frame); |
| 3480 | 3516 |
| 3481 EXPECT_EQ(TestContextSupport::SWAP, | 3517 EXPECT_EQ(TestContextSupport::SWAP, |
| 3482 context_provider->support()->last_swap_type()); | 3518 context_provider->support()->last_swap_type()); |
| 3483 } | 3519 } |
| 3484 | 3520 |
| 3485 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { | 3521 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { |
| 3486 scoped_ptr<LayerImpl> root = | 3522 scoped_ptr<LayerImpl> root = |
| 3487 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 3523 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
| 3488 scoped_ptr<LayerImpl> child = | 3524 scoped_ptr<LayerImpl> child = |
| 3489 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); | 3525 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); |
| 3490 child->SetAnchorPoint(gfx::PointF()); | 3526 child->SetAnchorPoint(gfx::PointF()); |
| 3491 child->SetBounds(gfx::Size(10, 10)); | 3527 child->SetBounds(gfx::Size(10, 10)); |
| 3492 child->SetContentBounds(gfx::Size(10, 10)); | 3528 child->SetContentBounds(gfx::Size(10, 10)); |
| 3493 child->SetDrawsContent(true); | 3529 child->SetDrawsContent(true); |
| 3494 root->SetAnchorPoint(gfx::PointF()); | 3530 root->SetAnchorPoint(gfx::PointF()); |
| 3495 root->SetBounds(gfx::Size(10, 10)); | 3531 root->SetBounds(gfx::Size(10, 10)); |
| 3496 root->SetContentBounds(gfx::Size(10, 10)); | 3532 root->SetContentBounds(gfx::Size(10, 10)); |
| 3497 root->SetDrawsContent(true); | 3533 root->SetDrawsContent(true); |
| 3498 root->SetForceRenderSurface(true); | 3534 root->SetForceRenderSurface(true); |
| 3499 root->AddChild(child.Pass()); | 3535 root->AddChild(child.Pass()); |
| 3500 | 3536 |
| 3501 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 3537 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 3502 | 3538 |
| 3503 LayerTreeHostImpl::FrameData frame; | 3539 LayerTreeHostImpl::FrameData frame; |
| 3504 | 3540 |
| 3505 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 3541 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3542 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 3506 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); | 3543 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); |
| 3507 EXPECT_EQ(1u, frame.render_passes.size()); | 3544 EXPECT_EQ(1u, frame.render_passes.size()); |
| 3508 host_impl_->DidDrawAllLayers(frame); | 3545 host_impl_->DidDrawAllLayers(frame); |
| 3509 } | 3546 } |
| 3510 | 3547 |
| 3511 class FakeLayerWithQuads : public LayerImpl { | 3548 class FakeLayerWithQuads : public LayerImpl { |
| 3512 public: | 3549 public: |
| 3513 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { | 3550 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
| 3514 return scoped_ptr<LayerImpl>(new FakeLayerWithQuads(tree_impl, id)); | 3551 return scoped_ptr<LayerImpl>(new FakeLayerWithQuads(tree_impl, id)); |
| 3515 } | 3552 } |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3630 LayerTreeSettings settings = DefaultSettings(); | 3667 LayerTreeSettings settings = DefaultSettings(); |
| 3631 settings.partial_swap_enabled = false; | 3668 settings.partial_swap_enabled = false; |
| 3632 CreateHostImpl(settings, output_surface.Pass()); | 3669 CreateHostImpl(settings, output_surface.Pass()); |
| 3633 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 3670 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
| 3634 | 3671 |
| 3635 // Without partial swap, and no clipping, no scissor is set. | 3672 // Without partial swap, and no clipping, no scissor is set. |
| 3636 harness.MustDrawSolidQuad(); | 3673 harness.MustDrawSolidQuad(); |
| 3637 harness.MustSetNoScissor(); | 3674 harness.MustSetNoScissor(); |
| 3638 { | 3675 { |
| 3639 LayerTreeHostImpl::FrameData frame; | 3676 LayerTreeHostImpl::FrameData frame; |
| 3640 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 3677 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3678 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 3641 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 3679 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3642 host_impl_->DidDrawAllLayers(frame); | 3680 host_impl_->DidDrawAllLayers(frame); |
| 3643 } | 3681 } |
| 3644 Mock::VerifyAndClearExpectations(&mock_context); | 3682 Mock::VerifyAndClearExpectations(&mock_context); |
| 3645 | 3683 |
| 3646 // Without partial swap, but a layer does clip its subtree, one scissor is | 3684 // Without partial swap, but a layer does clip its subtree, one scissor is |
| 3647 // set. | 3685 // set. |
| 3648 host_impl_->active_tree()->root_layer()->SetMasksToBounds(true); | 3686 host_impl_->active_tree()->root_layer()->SetMasksToBounds(true); |
| 3649 harness.MustDrawSolidQuad(); | 3687 harness.MustDrawSolidQuad(); |
| 3650 harness.MustSetScissor(0, 0, 10, 10); | 3688 harness.MustSetScissor(0, 0, 10, 10); |
| 3651 { | 3689 { |
| 3652 LayerTreeHostImpl::FrameData frame; | 3690 LayerTreeHostImpl::FrameData frame; |
| 3653 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 3691 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3692 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 3654 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 3693 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3655 host_impl_->DidDrawAllLayers(frame); | 3694 host_impl_->DidDrawAllLayers(frame); |
| 3656 } | 3695 } |
| 3657 Mock::VerifyAndClearExpectations(&mock_context); | 3696 Mock::VerifyAndClearExpectations(&mock_context); |
| 3658 } | 3697 } |
| 3659 | 3698 |
| 3660 TEST_F(LayerTreeHostImplTest, PartialSwap) { | 3699 TEST_F(LayerTreeHostImplTest, PartialSwap) { |
| 3661 scoped_ptr<MockContext> context_owned(new MockContext); | 3700 scoped_ptr<MockContext> context_owned(new MockContext); |
| 3662 MockContext* mock_context = context_owned.get(); | 3701 MockContext* mock_context = context_owned.get(); |
| 3663 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 3702 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 3664 context_owned.PassAs<TestWebGraphicsContext3D>())); | 3703 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 3665 MockContextHarness harness(mock_context); | 3704 MockContextHarness harness(mock_context); |
| 3666 | 3705 |
| 3667 LayerTreeSettings settings = DefaultSettings(); | 3706 LayerTreeSettings settings = DefaultSettings(); |
| 3668 settings.partial_swap_enabled = true; | 3707 settings.partial_swap_enabled = true; |
| 3669 CreateHostImpl(settings, output_surface.Pass()); | 3708 CreateHostImpl(settings, output_surface.Pass()); |
| 3670 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 3709 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
| 3671 | 3710 |
| 3672 // The first frame is not a partially-swapped one. | 3711 // The first frame is not a partially-swapped one. |
| 3673 harness.MustSetScissor(0, 0, 10, 10); | 3712 harness.MustSetScissor(0, 0, 10, 10); |
| 3674 harness.MustDrawSolidQuad(); | 3713 harness.MustDrawSolidQuad(); |
| 3675 { | 3714 { |
| 3676 LayerTreeHostImpl::FrameData frame; | 3715 LayerTreeHostImpl::FrameData frame; |
| 3677 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 3716 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3717 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 3678 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 3718 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3679 host_impl_->DidDrawAllLayers(frame); | 3719 host_impl_->DidDrawAllLayers(frame); |
| 3680 } | 3720 } |
| 3681 Mock::VerifyAndClearExpectations(&mock_context); | 3721 Mock::VerifyAndClearExpectations(&mock_context); |
| 3682 | 3722 |
| 3683 // Damage a portion of the frame. | 3723 // Damage a portion of the frame. |
| 3684 host_impl_->active_tree()->root_layer()->SetUpdateRect( | 3724 host_impl_->active_tree()->root_layer()->SetUpdateRect( |
| 3685 gfx::Rect(0, 0, 2, 3)); | 3725 gfx::Rect(0, 0, 2, 3)); |
| 3686 | 3726 |
| 3687 // The second frame will be partially-swapped (the y coordinates are flipped). | 3727 // The second frame will be partially-swapped (the y coordinates are flipped). |
| 3688 harness.MustSetScissor(0, 7, 2, 3); | 3728 harness.MustSetScissor(0, 7, 2, 3); |
| 3689 harness.MustDrawSolidQuad(); | 3729 harness.MustDrawSolidQuad(); |
| 3690 { | 3730 { |
| 3691 LayerTreeHostImpl::FrameData frame; | 3731 LayerTreeHostImpl::FrameData frame; |
| 3692 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 3732 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3733 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 3693 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 3734 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3694 host_impl_->DidDrawAllLayers(frame); | 3735 host_impl_->DidDrawAllLayers(frame); |
| 3695 } | 3736 } |
| 3696 Mock::VerifyAndClearExpectations(&mock_context); | 3737 Mock::VerifyAndClearExpectations(&mock_context); |
| 3697 } | 3738 } |
| 3698 | 3739 |
| 3699 static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity( | 3740 static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity( |
| 3700 bool partial_swap, | 3741 bool partial_swap, |
| 3701 LayerTreeHostImplClient* client, | 3742 LayerTreeHostImplClient* client, |
| 3702 Proxy* proxy, | 3743 Proxy* proxy, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3773 | 3814 |
| 3774 my_host_impl->active_tree()->SetRootLayer(root.Pass()); | 3815 my_host_impl->active_tree()->SetRootLayer(root.Pass()); |
| 3775 return my_host_impl.Pass(); | 3816 return my_host_impl.Pass(); |
| 3776 } | 3817 } |
| 3777 | 3818 |
| 3778 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { | 3819 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { |
| 3779 scoped_ptr<LayerTreeHostImpl> my_host_impl = | 3820 scoped_ptr<LayerTreeHostImpl> my_host_impl = |
| 3780 SetupLayersForOpacity(true, this, &proxy_, &stats_instrumentation_); | 3821 SetupLayersForOpacity(true, this, &proxy_, &stats_instrumentation_); |
| 3781 { | 3822 { |
| 3782 LayerTreeHostImpl::FrameData frame; | 3823 LayerTreeHostImpl::FrameData frame; |
| 3783 EXPECT_TRUE(my_host_impl->PrepareToDraw(&frame, gfx::Rect())); | 3824 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3825 my_host_impl->PrepareToDraw(&frame, gfx::Rect())); |
| 3784 | 3826 |
| 3785 // Verify all quads have been computed | 3827 // Verify all quads have been computed |
| 3786 ASSERT_EQ(2U, frame.render_passes.size()); | 3828 ASSERT_EQ(2U, frame.render_passes.size()); |
| 3787 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); | 3829 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); |
| 3788 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); | 3830 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); |
| 3789 EXPECT_EQ(DrawQuad::SOLID_COLOR, | 3831 EXPECT_EQ(DrawQuad::SOLID_COLOR, |
| 3790 frame.render_passes[0]->quad_list[0]->material); | 3832 frame.render_passes[0]->quad_list[0]->material); |
| 3791 EXPECT_EQ(DrawQuad::RENDER_PASS, | 3833 EXPECT_EQ(DrawQuad::RENDER_PASS, |
| 3792 frame.render_passes[1]->quad_list[0]->material); | 3834 frame.render_passes[1]->quad_list[0]->material); |
| 3793 | 3835 |
| 3794 my_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); | 3836 my_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3795 my_host_impl->DidDrawAllLayers(frame); | 3837 my_host_impl->DidDrawAllLayers(frame); |
| 3796 } | 3838 } |
| 3797 } | 3839 } |
| 3798 | 3840 |
| 3799 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { | 3841 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { |
| 3800 scoped_ptr<LayerTreeHostImpl> my_host_impl = | 3842 scoped_ptr<LayerTreeHostImpl> my_host_impl = |
| 3801 SetupLayersForOpacity(false, this, &proxy_, &stats_instrumentation_); | 3843 SetupLayersForOpacity(false, this, &proxy_, &stats_instrumentation_); |
| 3802 { | 3844 { |
| 3803 LayerTreeHostImpl::FrameData frame; | 3845 LayerTreeHostImpl::FrameData frame; |
| 3804 EXPECT_TRUE(my_host_impl->PrepareToDraw(&frame, gfx::Rect())); | 3846 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3847 my_host_impl->PrepareToDraw(&frame, gfx::Rect())); |
| 3805 | 3848 |
| 3806 // Verify all quads have been computed | 3849 // Verify all quads have been computed |
| 3807 ASSERT_EQ(2U, frame.render_passes.size()); | 3850 ASSERT_EQ(2U, frame.render_passes.size()); |
| 3808 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); | 3851 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); |
| 3809 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); | 3852 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); |
| 3810 EXPECT_EQ(DrawQuad::SOLID_COLOR, | 3853 EXPECT_EQ(DrawQuad::SOLID_COLOR, |
| 3811 frame.render_passes[0]->quad_list[0]->material); | 3854 frame.render_passes[0]->quad_list[0]->material); |
| 3812 EXPECT_EQ(DrawQuad::RENDER_PASS, | 3855 EXPECT_EQ(DrawQuad::RENDER_PASS, |
| 3813 frame.render_passes[1]->quad_list[0]->material); | 3856 frame.render_passes[1]->quad_list[0]->material); |
| 3814 | 3857 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3850 io_surface_layer->SetContentBounds(gfx::Size(10, 10)); | 3893 io_surface_layer->SetContentBounds(gfx::Size(10, 10)); |
| 3851 io_surface_layer->SetDrawsContent(true); | 3894 io_surface_layer->SetDrawsContent(true); |
| 3852 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10)); | 3895 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10)); |
| 3853 root_layer->AddChild(io_surface_layer.PassAs<LayerImpl>()); | 3896 root_layer->AddChild(io_surface_layer.PassAs<LayerImpl>()); |
| 3854 | 3897 |
| 3855 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); | 3898 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); |
| 3856 | 3899 |
| 3857 EXPECT_EQ(0u, context3d->NumTextures()); | 3900 EXPECT_EQ(0u, context3d->NumTextures()); |
| 3858 | 3901 |
| 3859 LayerTreeHostImpl::FrameData frame; | 3902 LayerTreeHostImpl::FrameData frame; |
| 3860 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 3903 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3904 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 3861 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 3905 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3862 host_impl_->DidDrawAllLayers(frame); | 3906 host_impl_->DidDrawAllLayers(frame); |
| 3863 host_impl_->SwapBuffers(frame); | 3907 host_impl_->SwapBuffers(frame); |
| 3864 | 3908 |
| 3865 EXPECT_GT(context3d->NumTextures(), 0u); | 3909 EXPECT_GT(context3d->NumTextures(), 0u); |
| 3866 | 3910 |
| 3867 // Kill the layer tree. | 3911 // Kill the layer tree. |
| 3868 host_impl_->active_tree()->SetRootLayer( | 3912 host_impl_->active_tree()->SetRootLayer( |
| 3869 LayerImpl::Create(host_impl_->active_tree(), 100)); | 3913 LayerImpl::Create(host_impl_->active_tree(), 100)); |
| 3870 // There should be no textures left in use after. | 3914 // There should be no textures left in use after. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3895 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 3939 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 3896 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); | 3940 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); |
| 3897 | 3941 |
| 3898 // Verify one quad is drawn when transparent background set is not set. | 3942 // Verify one quad is drawn when transparent background set is not set. |
| 3899 host_impl_->active_tree()->set_has_transparent_background(false); | 3943 host_impl_->active_tree()->set_has_transparent_background(false); |
| 3900 EXPECT_CALL(*mock_context, useProgram(_)) | 3944 EXPECT_CALL(*mock_context, useProgram(_)) |
| 3901 .Times(1); | 3945 .Times(1); |
| 3902 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) | 3946 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) |
| 3903 .Times(1); | 3947 .Times(1); |
| 3904 LayerTreeHostImpl::FrameData frame; | 3948 LayerTreeHostImpl::FrameData frame; |
| 3905 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 3949 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3950 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 3906 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 3951 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3907 host_impl_->DidDrawAllLayers(frame); | 3952 host_impl_->DidDrawAllLayers(frame); |
| 3908 Mock::VerifyAndClearExpectations(&mock_context); | 3953 Mock::VerifyAndClearExpectations(&mock_context); |
| 3909 | 3954 |
| 3910 // Verify no quads are drawn when transparent background is set. | 3955 // Verify no quads are drawn when transparent background is set. |
| 3911 host_impl_->active_tree()->set_has_transparent_background(true); | 3956 host_impl_->active_tree()->set_has_transparent_background(true); |
| 3912 host_impl_->SetFullRootLayerDamage(); | 3957 host_impl_->SetFullRootLayerDamage(); |
| 3913 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 3958 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 3959 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 3914 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 3960 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3915 host_impl_->DidDrawAllLayers(frame); | 3961 host_impl_->DidDrawAllLayers(frame); |
| 3916 Mock::VerifyAndClearExpectations(&mock_context); | 3962 Mock::VerifyAndClearExpectations(&mock_context); |
| 3917 } | 3963 } |
| 3918 | 3964 |
| 3919 TEST_F(LayerTreeHostImplTest, ReleaseContentsTextureShouldTriggerCommit) { | 3965 TEST_F(LayerTreeHostImplTest, ReleaseContentsTextureShouldTriggerCommit) { |
| 3920 set_reduce_memory_result(false); | 3966 set_reduce_memory_result(false); |
| 3921 | 3967 |
| 3922 // If changing the memory limit wouldn't result in changing what was | 3968 // If changing the memory limit wouldn't result in changing what was |
| 3923 // committed, then no commit should be requested. | 3969 // committed, then no commit should be requested. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3960 : public LayerTreeHostImplTest { | 4006 : public LayerTreeHostImplTest { |
| 3961 protected: | 4007 protected: |
| 3962 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE { | 4008 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE { |
| 3963 return FakeOutputSurface::CreateDelegating3d().PassAs<OutputSurface>(); | 4009 return FakeOutputSurface::CreateDelegating3d().PassAs<OutputSurface>(); |
| 3964 } | 4010 } |
| 3965 | 4011 |
| 3966 void DrawFrameAndTestDamage(const gfx::RectF& expected_damage) { | 4012 void DrawFrameAndTestDamage(const gfx::RectF& expected_damage) { |
| 3967 bool expect_to_draw = !expected_damage.IsEmpty(); | 4013 bool expect_to_draw = !expected_damage.IsEmpty(); |
| 3968 | 4014 |
| 3969 LayerTreeHostImpl::FrameData frame; | 4015 LayerTreeHostImpl::FrameData frame; |
| 3970 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 4016 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 4017 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 3971 | 4018 |
| 3972 if (!expect_to_draw) { | 4019 if (!expect_to_draw) { |
| 3973 // With no damage, we don't draw, and no quads are created. | 4020 // With no damage, we don't draw, and no quads are created. |
| 3974 ASSERT_EQ(0u, frame.render_passes.size()); | 4021 ASSERT_EQ(0u, frame.render_passes.size()); |
| 3975 } else { | 4022 } else { |
| 3976 ASSERT_EQ(1u, frame.render_passes.size()); | 4023 ASSERT_EQ(1u, frame.render_passes.size()); |
| 3977 | 4024 |
| 3978 // Verify the damage rect for the root render pass. | 4025 // Verify the damage rect for the root render pass. |
| 3979 const RenderPass* root_render_pass = frame.render_passes.back(); | 4026 const RenderPass* root_render_pass = frame.render_passes.back(); |
| 3980 EXPECT_RECT_EQ(expected_damage, root_render_pass->damage_rect); | 4027 EXPECT_RECT_EQ(expected_damage, root_render_pass->damage_rect); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4111 mask_layer->SetDrawsContent(true); | 4158 mask_layer->SetDrawsContent(true); |
| 4112 | 4159 |
| 4113 | 4160 |
| 4114 // Check that the tree scaling is correctly taken into account for the mask, | 4161 // Check that the tree scaling is correctly taken into account for the mask, |
| 4115 // that should fully map onto the quad. | 4162 // that should fully map onto the quad. |
| 4116 float device_scale_factor = 1.f; | 4163 float device_scale_factor = 1.f; |
| 4117 host_impl_->SetViewportSize(root_size); | 4164 host_impl_->SetViewportSize(root_size); |
| 4118 host_impl_->SetDeviceScaleFactor(device_scale_factor); | 4165 host_impl_->SetDeviceScaleFactor(device_scale_factor); |
| 4119 { | 4166 { |
| 4120 LayerTreeHostImpl::FrameData frame; | 4167 LayerTreeHostImpl::FrameData frame; |
| 4121 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 4168 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 4169 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 4122 | 4170 |
| 4123 ASSERT_EQ(1u, frame.render_passes.size()); | 4171 ASSERT_EQ(1u, frame.render_passes.size()); |
| 4124 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); | 4172 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); |
| 4125 ASSERT_EQ(DrawQuad::RENDER_PASS, | 4173 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 4126 frame.render_passes[0]->quad_list[0]->material); | 4174 frame.render_passes[0]->quad_list[0]->material); |
| 4127 const RenderPassDrawQuad* render_pass_quad = | 4175 const RenderPassDrawQuad* render_pass_quad = |
| 4128 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); | 4176 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); |
| 4129 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 4177 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 4130 render_pass_quad->rect.ToString()); | 4178 render_pass_quad->rect.ToString()); |
| 4131 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 4179 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 4132 render_pass_quad->mask_uv_rect.ToString()); | 4180 render_pass_quad->mask_uv_rect.ToString()); |
| 4133 | 4181 |
| 4134 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4182 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4135 host_impl_->DidDrawAllLayers(frame); | 4183 host_impl_->DidDrawAllLayers(frame); |
| 4136 } | 4184 } |
| 4137 | 4185 |
| 4138 | 4186 |
| 4139 // Applying a DSF should change the render surface size, but won't affect | 4187 // Applying a DSF should change the render surface size, but won't affect |
| 4140 // which part of the mask is used. | 4188 // which part of the mask is used. |
| 4141 device_scale_factor = 2.f; | 4189 device_scale_factor = 2.f; |
| 4142 gfx::Size device_viewport = | 4190 gfx::Size device_viewport = |
| 4143 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); | 4191 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); |
| 4144 host_impl_->SetViewportSize(device_viewport); | 4192 host_impl_->SetViewportSize(device_viewport); |
| 4145 host_impl_->SetDeviceScaleFactor(device_scale_factor); | 4193 host_impl_->SetDeviceScaleFactor(device_scale_factor); |
| 4146 host_impl_->active_tree()->set_needs_update_draw_properties(); | 4194 host_impl_->active_tree()->set_needs_update_draw_properties(); |
| 4147 { | 4195 { |
| 4148 LayerTreeHostImpl::FrameData frame; | 4196 LayerTreeHostImpl::FrameData frame; |
| 4149 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 4197 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 4198 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 4150 | 4199 |
| 4151 ASSERT_EQ(1u, frame.render_passes.size()); | 4200 ASSERT_EQ(1u, frame.render_passes.size()); |
| 4152 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); | 4201 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); |
| 4153 ASSERT_EQ(DrawQuad::RENDER_PASS, | 4202 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 4154 frame.render_passes[0]->quad_list[0]->material); | 4203 frame.render_passes[0]->quad_list[0]->material); |
| 4155 const RenderPassDrawQuad* render_pass_quad = | 4204 const RenderPassDrawQuad* render_pass_quad = |
| 4156 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); | 4205 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); |
| 4157 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), | 4206 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), |
| 4158 render_pass_quad->rect.ToString()); | 4207 render_pass_quad->rect.ToString()); |
| 4159 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 4208 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 4160 render_pass_quad->mask_uv_rect.ToString()); | 4209 render_pass_quad->mask_uv_rect.ToString()); |
| 4161 | 4210 |
| 4162 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4211 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4163 host_impl_->DidDrawAllLayers(frame); | 4212 host_impl_->DidDrawAllLayers(frame); |
| 4164 } | 4213 } |
| 4165 | 4214 |
| 4166 | 4215 |
| 4167 // Applying an equivalent content scale on the content layer and the mask | 4216 // Applying an equivalent content scale on the content layer and the mask |
| 4168 // should still result in the same part of the mask being used. | 4217 // should still result in the same part of the mask being used. |
| 4169 gfx::Size content_bounds = | 4218 gfx::Size content_bounds = |
| 4170 gfx::ToRoundedSize(gfx::ScaleSize(scaling_layer_size, | 4219 gfx::ToRoundedSize(gfx::ScaleSize(scaling_layer_size, |
| 4171 device_scale_factor)); | 4220 device_scale_factor)); |
| 4172 content_layer->SetContentBounds(content_bounds); | 4221 content_layer->SetContentBounds(content_bounds); |
| 4173 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); | 4222 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); |
| 4174 mask_layer->SetContentBounds(content_bounds); | 4223 mask_layer->SetContentBounds(content_bounds); |
| 4175 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); | 4224 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); |
| 4176 host_impl_->active_tree()->set_needs_update_draw_properties(); | 4225 host_impl_->active_tree()->set_needs_update_draw_properties(); |
| 4177 { | 4226 { |
| 4178 LayerTreeHostImpl::FrameData frame; | 4227 LayerTreeHostImpl::FrameData frame; |
| 4179 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 4228 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 4229 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 4180 | 4230 |
| 4181 ASSERT_EQ(1u, frame.render_passes.size()); | 4231 ASSERT_EQ(1u, frame.render_passes.size()); |
| 4182 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); | 4232 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); |
| 4183 ASSERT_EQ(DrawQuad::RENDER_PASS, | 4233 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 4184 frame.render_passes[0]->quad_list[0]->material); | 4234 frame.render_passes[0]->quad_list[0]->material); |
| 4185 const RenderPassDrawQuad* render_pass_quad = | 4235 const RenderPassDrawQuad* render_pass_quad = |
| 4186 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); | 4236 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); |
| 4187 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), | 4237 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), |
| 4188 render_pass_quad->rect.ToString()); | 4238 render_pass_quad->rect.ToString()); |
| 4189 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 4239 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4232 mask_layer->SetPosition(gfx::PointF()); | 4282 mask_layer->SetPosition(gfx::PointF()); |
| 4233 mask_layer->SetAnchorPoint(gfx::PointF()); | 4283 mask_layer->SetAnchorPoint(gfx::PointF()); |
| 4234 mask_layer->SetDrawsContent(true); | 4284 mask_layer->SetDrawsContent(true); |
| 4235 | 4285 |
| 4236 // Check that the mask fills the surface. | 4286 // Check that the mask fills the surface. |
| 4237 float device_scale_factor = 1.f; | 4287 float device_scale_factor = 1.f; |
| 4238 host_impl_->SetViewportSize(root_size); | 4288 host_impl_->SetViewportSize(root_size); |
| 4239 host_impl_->SetDeviceScaleFactor(device_scale_factor); | 4289 host_impl_->SetDeviceScaleFactor(device_scale_factor); |
| 4240 { | 4290 { |
| 4241 LayerTreeHostImpl::FrameData frame; | 4291 LayerTreeHostImpl::FrameData frame; |
| 4242 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 4292 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 4293 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 4243 | 4294 |
| 4244 ASSERT_EQ(1u, frame.render_passes.size()); | 4295 ASSERT_EQ(1u, frame.render_passes.size()); |
| 4245 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); | 4296 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); |
| 4246 ASSERT_EQ(DrawQuad::RENDER_PASS, | 4297 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 4247 frame.render_passes[0]->quad_list[0]->material); | 4298 frame.render_passes[0]->quad_list[0]->material); |
| 4248 const RenderPassDrawQuad* render_pass_quad = | 4299 const RenderPassDrawQuad* render_pass_quad = |
| 4249 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); | 4300 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); |
| 4250 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), | 4301 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), |
| 4251 render_pass_quad->rect.ToString()); | 4302 render_pass_quad->rect.ToString()); |
| 4252 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 4303 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 4253 render_pass_quad->mask_uv_rect.ToString()); | 4304 render_pass_quad->mask_uv_rect.ToString()); |
| 4254 | 4305 |
| 4255 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4306 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4256 host_impl_->DidDrawAllLayers(frame); | 4307 host_impl_->DidDrawAllLayers(frame); |
| 4257 } | 4308 } |
| 4258 | 4309 |
| 4259 // Applying a DSF should change the render surface size, but won't affect | 4310 // Applying a DSF should change the render surface size, but won't affect |
| 4260 // which part of the mask is used. | 4311 // which part of the mask is used. |
| 4261 device_scale_factor = 2.f; | 4312 device_scale_factor = 2.f; |
| 4262 gfx::Size device_viewport = | 4313 gfx::Size device_viewport = |
| 4263 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); | 4314 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); |
| 4264 host_impl_->SetViewportSize(device_viewport); | 4315 host_impl_->SetViewportSize(device_viewport); |
| 4265 host_impl_->SetDeviceScaleFactor(device_scale_factor); | 4316 host_impl_->SetDeviceScaleFactor(device_scale_factor); |
| 4266 host_impl_->active_tree()->set_needs_update_draw_properties(); | 4317 host_impl_->active_tree()->set_needs_update_draw_properties(); |
| 4267 { | 4318 { |
| 4268 LayerTreeHostImpl::FrameData frame; | 4319 LayerTreeHostImpl::FrameData frame; |
| 4269 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 4320 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 4321 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 4270 | 4322 |
| 4271 ASSERT_EQ(1u, frame.render_passes.size()); | 4323 ASSERT_EQ(1u, frame.render_passes.size()); |
| 4272 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); | 4324 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); |
| 4273 ASSERT_EQ(DrawQuad::RENDER_PASS, | 4325 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 4274 frame.render_passes[0]->quad_list[0]->material); | 4326 frame.render_passes[0]->quad_list[0]->material); |
| 4275 const RenderPassDrawQuad* render_pass_quad = | 4327 const RenderPassDrawQuad* render_pass_quad = |
| 4276 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); | 4328 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); |
| 4277 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 4329 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 4278 render_pass_quad->rect.ToString()); | 4330 render_pass_quad->rect.ToString()); |
| 4279 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 4331 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 4280 render_pass_quad->mask_uv_rect.ToString()); | 4332 render_pass_quad->mask_uv_rect.ToString()); |
| 4281 | 4333 |
| 4282 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4334 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4283 host_impl_->DidDrawAllLayers(frame); | 4335 host_impl_->DidDrawAllLayers(frame); |
| 4284 } | 4336 } |
| 4285 | 4337 |
| 4286 // Applying an equivalent content scale on the content layer and the mask | 4338 // Applying an equivalent content scale on the content layer and the mask |
| 4287 // should still result in the same part of the mask being used. | 4339 // should still result in the same part of the mask being used. |
| 4288 gfx::Size layer_size_large = | 4340 gfx::Size layer_size_large = |
| 4289 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor)); | 4341 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor)); |
| 4290 content_layer->SetContentBounds(layer_size_large); | 4342 content_layer->SetContentBounds(layer_size_large); |
| 4291 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); | 4343 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); |
| 4292 gfx::Size mask_size_large = | 4344 gfx::Size mask_size_large = |
| 4293 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor)); | 4345 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor)); |
| 4294 mask_layer->SetContentBounds(mask_size_large); | 4346 mask_layer->SetContentBounds(mask_size_large); |
| 4295 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); | 4347 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); |
| 4296 host_impl_->active_tree()->set_needs_update_draw_properties(); | 4348 host_impl_->active_tree()->set_needs_update_draw_properties(); |
| 4297 { | 4349 { |
| 4298 LayerTreeHostImpl::FrameData frame; | 4350 LayerTreeHostImpl::FrameData frame; |
| 4299 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 4351 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 4352 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 4300 | 4353 |
| 4301 ASSERT_EQ(1u, frame.render_passes.size()); | 4354 ASSERT_EQ(1u, frame.render_passes.size()); |
| 4302 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); | 4355 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); |
| 4303 ASSERT_EQ(DrawQuad::RENDER_PASS, | 4356 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 4304 frame.render_passes[0]->quad_list[0]->material); | 4357 frame.render_passes[0]->quad_list[0]->material); |
| 4305 const RenderPassDrawQuad* render_pass_quad = | 4358 const RenderPassDrawQuad* render_pass_quad = |
| 4306 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); | 4359 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); |
| 4307 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 4360 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 4308 render_pass_quad->rect.ToString()); | 4361 render_pass_quad->rect.ToString()); |
| 4309 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 4362 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 4310 render_pass_quad->mask_uv_rect.ToString()); | 4363 render_pass_quad->mask_uv_rect.ToString()); |
| 4311 | 4364 |
| 4312 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4365 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4313 host_impl_->DidDrawAllLayers(frame); | 4366 host_impl_->DidDrawAllLayers(frame); |
| 4314 } | 4367 } |
| 4315 | 4368 |
| 4316 // Applying a different contents scale to the mask layer means it will have | 4369 // Applying a different contents scale to the mask layer means it will have |
| 4317 // a larger texture, but it should use the same tex coords to cover the | 4370 // a larger texture, but it should use the same tex coords to cover the |
| 4318 // layer it masks. | 4371 // layer it masks. |
| 4319 mask_layer->SetContentBounds(mask_size); | 4372 mask_layer->SetContentBounds(mask_size); |
| 4320 mask_layer->SetContentsScale(1.f, 1.f); | 4373 mask_layer->SetContentsScale(1.f, 1.f); |
| 4321 host_impl_->active_tree()->set_needs_update_draw_properties(); | 4374 host_impl_->active_tree()->set_needs_update_draw_properties(); |
| 4322 { | 4375 { |
| 4323 LayerTreeHostImpl::FrameData frame; | 4376 LayerTreeHostImpl::FrameData frame; |
| 4324 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 4377 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 4378 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 4325 | 4379 |
| 4326 ASSERT_EQ(1u, frame.render_passes.size()); | 4380 ASSERT_EQ(1u, frame.render_passes.size()); |
| 4327 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); | 4381 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); |
| 4328 ASSERT_EQ(DrawQuad::RENDER_PASS, | 4382 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 4329 frame.render_passes[0]->quad_list[0]->material); | 4383 frame.render_passes[0]->quad_list[0]->material); |
| 4330 const RenderPassDrawQuad* render_pass_quad = | 4384 const RenderPassDrawQuad* render_pass_quad = |
| 4331 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); | 4385 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); |
| 4332 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 4386 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 4333 render_pass_quad->rect.ToString()); | 4387 render_pass_quad->rect.ToString()); |
| 4334 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 4388 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4382 mask_layer->SetPosition(gfx::PointF()); | 4436 mask_layer->SetPosition(gfx::PointF()); |
| 4383 mask_layer->SetAnchorPoint(gfx::PointF()); | 4437 mask_layer->SetAnchorPoint(gfx::PointF()); |
| 4384 mask_layer->SetDrawsContent(true); | 4438 mask_layer->SetDrawsContent(true); |
| 4385 | 4439 |
| 4386 // Check that the mask fills the surface. | 4440 // Check that the mask fills the surface. |
| 4387 float device_scale_factor = 1.f; | 4441 float device_scale_factor = 1.f; |
| 4388 host_impl_->SetViewportSize(root_size); | 4442 host_impl_->SetViewportSize(root_size); |
| 4389 host_impl_->SetDeviceScaleFactor(device_scale_factor); | 4443 host_impl_->SetDeviceScaleFactor(device_scale_factor); |
| 4390 { | 4444 { |
| 4391 LayerTreeHostImpl::FrameData frame; | 4445 LayerTreeHostImpl::FrameData frame; |
| 4392 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 4446 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 4447 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 4393 | 4448 |
| 4394 ASSERT_EQ(1u, frame.render_passes.size()); | 4449 ASSERT_EQ(1u, frame.render_passes.size()); |
| 4395 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); | 4450 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); |
| 4396 ASSERT_EQ(DrawQuad::RENDER_PASS, | 4451 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 4397 frame.render_passes[0]->quad_list[1]->material); | 4452 frame.render_passes[0]->quad_list[1]->material); |
| 4398 const RenderPassDrawQuad* replica_quad = | 4453 const RenderPassDrawQuad* replica_quad = |
| 4399 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); | 4454 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); |
| 4400 EXPECT_TRUE(replica_quad->is_replica); | 4455 EXPECT_TRUE(replica_quad->is_replica); |
| 4401 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), | 4456 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), |
| 4402 replica_quad->rect.ToString()); | 4457 replica_quad->rect.ToString()); |
| 4403 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 4458 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 4404 replica_quad->mask_uv_rect.ToString()); | 4459 replica_quad->mask_uv_rect.ToString()); |
| 4405 | 4460 |
| 4406 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4461 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4407 host_impl_->DidDrawAllLayers(frame); | 4462 host_impl_->DidDrawAllLayers(frame); |
| 4408 } | 4463 } |
| 4409 | 4464 |
| 4410 // Applying a DSF should change the render surface size, but won't affect | 4465 // Applying a DSF should change the render surface size, but won't affect |
| 4411 // which part of the mask is used. | 4466 // which part of the mask is used. |
| 4412 device_scale_factor = 2.f; | 4467 device_scale_factor = 2.f; |
| 4413 gfx::Size device_viewport = | 4468 gfx::Size device_viewport = |
| 4414 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); | 4469 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); |
| 4415 host_impl_->SetViewportSize(device_viewport); | 4470 host_impl_->SetViewportSize(device_viewport); |
| 4416 host_impl_->SetDeviceScaleFactor(device_scale_factor); | 4471 host_impl_->SetDeviceScaleFactor(device_scale_factor); |
| 4417 host_impl_->active_tree()->set_needs_update_draw_properties(); | 4472 host_impl_->active_tree()->set_needs_update_draw_properties(); |
| 4418 { | 4473 { |
| 4419 LayerTreeHostImpl::FrameData frame; | 4474 LayerTreeHostImpl::FrameData frame; |
| 4420 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 4475 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 4476 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 4421 | 4477 |
| 4422 ASSERT_EQ(1u, frame.render_passes.size()); | 4478 ASSERT_EQ(1u, frame.render_passes.size()); |
| 4423 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); | 4479 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); |
| 4424 ASSERT_EQ(DrawQuad::RENDER_PASS, | 4480 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 4425 frame.render_passes[0]->quad_list[1]->material); | 4481 frame.render_passes[0]->quad_list[1]->material); |
| 4426 const RenderPassDrawQuad* replica_quad = | 4482 const RenderPassDrawQuad* replica_quad = |
| 4427 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); | 4483 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); |
| 4428 EXPECT_TRUE(replica_quad->is_replica); | 4484 EXPECT_TRUE(replica_quad->is_replica); |
| 4429 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 4485 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 4430 replica_quad->rect.ToString()); | 4486 replica_quad->rect.ToString()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4441 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor)); | 4497 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor)); |
| 4442 content_layer->SetContentBounds(layer_size_large); | 4498 content_layer->SetContentBounds(layer_size_large); |
| 4443 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); | 4499 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); |
| 4444 gfx::Size mask_size_large = | 4500 gfx::Size mask_size_large = |
| 4445 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor)); | 4501 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor)); |
| 4446 mask_layer->SetContentBounds(mask_size_large); | 4502 mask_layer->SetContentBounds(mask_size_large); |
| 4447 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); | 4503 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); |
| 4448 host_impl_->active_tree()->set_needs_update_draw_properties(); | 4504 host_impl_->active_tree()->set_needs_update_draw_properties(); |
| 4449 { | 4505 { |
| 4450 LayerTreeHostImpl::FrameData frame; | 4506 LayerTreeHostImpl::FrameData frame; |
| 4451 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 4507 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 4508 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 4452 | 4509 |
| 4453 ASSERT_EQ(1u, frame.render_passes.size()); | 4510 ASSERT_EQ(1u, frame.render_passes.size()); |
| 4454 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); | 4511 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); |
| 4455 ASSERT_EQ(DrawQuad::RENDER_PASS, | 4512 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 4456 frame.render_passes[0]->quad_list[1]->material); | 4513 frame.render_passes[0]->quad_list[1]->material); |
| 4457 const RenderPassDrawQuad* replica_quad = | 4514 const RenderPassDrawQuad* replica_quad = |
| 4458 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); | 4515 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); |
| 4459 EXPECT_TRUE(replica_quad->is_replica); | 4516 EXPECT_TRUE(replica_quad->is_replica); |
| 4460 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 4517 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 4461 replica_quad->rect.ToString()); | 4518 replica_quad->rect.ToString()); |
| 4462 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 4519 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 4463 replica_quad->mask_uv_rect.ToString()); | 4520 replica_quad->mask_uv_rect.ToString()); |
| 4464 | 4521 |
| 4465 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4522 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4466 host_impl_->DidDrawAllLayers(frame); | 4523 host_impl_->DidDrawAllLayers(frame); |
| 4467 } | 4524 } |
| 4468 | 4525 |
| 4469 // Applying a different contents scale to the mask layer means it will have | 4526 // Applying a different contents scale to the mask layer means it will have |
| 4470 // a larger texture, but it should use the same tex coords to cover the | 4527 // a larger texture, but it should use the same tex coords to cover the |
| 4471 // layer it masks. | 4528 // layer it masks. |
| 4472 mask_layer->SetContentBounds(mask_size); | 4529 mask_layer->SetContentBounds(mask_size); |
| 4473 mask_layer->SetContentsScale(1.f, 1.f); | 4530 mask_layer->SetContentsScale(1.f, 1.f); |
| 4474 host_impl_->active_tree()->set_needs_update_draw_properties(); | 4531 host_impl_->active_tree()->set_needs_update_draw_properties(); |
| 4475 { | 4532 { |
| 4476 LayerTreeHostImpl::FrameData frame; | 4533 LayerTreeHostImpl::FrameData frame; |
| 4477 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 4534 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 4535 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 4478 | 4536 |
| 4479 ASSERT_EQ(1u, frame.render_passes.size()); | 4537 ASSERT_EQ(1u, frame.render_passes.size()); |
| 4480 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); | 4538 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); |
| 4481 ASSERT_EQ(DrawQuad::RENDER_PASS, | 4539 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 4482 frame.render_passes[0]->quad_list[1]->material); | 4540 frame.render_passes[0]->quad_list[1]->material); |
| 4483 const RenderPassDrawQuad* replica_quad = | 4541 const RenderPassDrawQuad* replica_quad = |
| 4484 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); | 4542 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); |
| 4485 EXPECT_TRUE(replica_quad->is_replica); | 4543 EXPECT_TRUE(replica_quad->is_replica); |
| 4486 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 4544 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 4487 replica_quad->rect.ToString()); | 4545 replica_quad->rect.ToString()); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4547 mask_layer->SetContentBounds(mask_size); | 4605 mask_layer->SetContentBounds(mask_size); |
| 4548 mask_layer->SetPosition(gfx::PointF()); | 4606 mask_layer->SetPosition(gfx::PointF()); |
| 4549 mask_layer->SetAnchorPoint(gfx::PointF()); | 4607 mask_layer->SetAnchorPoint(gfx::PointF()); |
| 4550 mask_layer->SetDrawsContent(true); | 4608 mask_layer->SetDrawsContent(true); |
| 4551 | 4609 |
| 4552 float device_scale_factor = 1.f; | 4610 float device_scale_factor = 1.f; |
| 4553 host_impl_->SetViewportSize(root_size); | 4611 host_impl_->SetViewportSize(root_size); |
| 4554 host_impl_->SetDeviceScaleFactor(device_scale_factor); | 4612 host_impl_->SetDeviceScaleFactor(device_scale_factor); |
| 4555 { | 4613 { |
| 4556 LayerTreeHostImpl::FrameData frame; | 4614 LayerTreeHostImpl::FrameData frame; |
| 4557 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 4615 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 4616 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 4558 | 4617 |
| 4559 ASSERT_EQ(1u, frame.render_passes.size()); | 4618 ASSERT_EQ(1u, frame.render_passes.size()); |
| 4560 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); | 4619 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); |
| 4561 | 4620 |
| 4562 // The surface is 100x50. | 4621 // The surface is 100x50. |
| 4563 ASSERT_EQ(DrawQuad::RENDER_PASS, | 4622 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 4564 frame.render_passes[0]->quad_list[0]->material); | 4623 frame.render_passes[0]->quad_list[0]->material); |
| 4565 const RenderPassDrawQuad* render_pass_quad = | 4624 const RenderPassDrawQuad* render_pass_quad = |
| 4566 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); | 4625 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); |
| 4567 EXPECT_FALSE(render_pass_quad->is_replica); | 4626 EXPECT_FALSE(render_pass_quad->is_replica); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 4581 | 4640 |
| 4582 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4641 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4583 host_impl_->DidDrawAllLayers(frame); | 4642 host_impl_->DidDrawAllLayers(frame); |
| 4584 } | 4643 } |
| 4585 | 4644 |
| 4586 // Move the child to (-50, 0) instead. Now the mask should be moved to still | 4645 // Move the child to (-50, 0) instead. Now the mask should be moved to still |
| 4587 // cover the layer being replicated. | 4646 // cover the layer being replicated. |
| 4588 content_child_layer->SetPosition(gfx::Point(-50, 0)); | 4647 content_child_layer->SetPosition(gfx::Point(-50, 0)); |
| 4589 { | 4648 { |
| 4590 LayerTreeHostImpl::FrameData frame; | 4649 LayerTreeHostImpl::FrameData frame; |
| 4591 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 4650 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 4651 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 4592 | 4652 |
| 4593 ASSERT_EQ(1u, frame.render_passes.size()); | 4653 ASSERT_EQ(1u, frame.render_passes.size()); |
| 4594 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); | 4654 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); |
| 4595 | 4655 |
| 4596 // The surface is 100x50 with its origin at (-50, 0). | 4656 // The surface is 100x50 with its origin at (-50, 0). |
| 4597 ASSERT_EQ(DrawQuad::RENDER_PASS, | 4657 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 4598 frame.render_passes[0]->quad_list[0]->material); | 4658 frame.render_passes[0]->quad_list[0]->material); |
| 4599 const RenderPassDrawQuad* render_pass_quad = | 4659 const RenderPassDrawQuad* render_pass_quad = |
| 4600 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); | 4660 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); |
| 4601 EXPECT_FALSE(render_pass_quad->is_replica); | 4661 EXPECT_FALSE(render_pass_quad->is_replica); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4680 mask_layer->SetContentBounds(mask_size); | 4740 mask_layer->SetContentBounds(mask_size); |
| 4681 mask_layer->SetPosition(gfx::PointF()); | 4741 mask_layer->SetPosition(gfx::PointF()); |
| 4682 mask_layer->SetAnchorPoint(gfx::PointF()); | 4742 mask_layer->SetAnchorPoint(gfx::PointF()); |
| 4683 mask_layer->SetDrawsContent(true); | 4743 mask_layer->SetDrawsContent(true); |
| 4684 | 4744 |
| 4685 float device_scale_factor = 1.f; | 4745 float device_scale_factor = 1.f; |
| 4686 host_impl_->SetViewportSize(root_size); | 4746 host_impl_->SetViewportSize(root_size); |
| 4687 host_impl_->SetDeviceScaleFactor(device_scale_factor); | 4747 host_impl_->SetDeviceScaleFactor(device_scale_factor); |
| 4688 { | 4748 { |
| 4689 LayerTreeHostImpl::FrameData frame; | 4749 LayerTreeHostImpl::FrameData frame; |
| 4690 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 4750 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 4751 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 4691 | 4752 |
| 4692 ASSERT_EQ(1u, frame.render_passes.size()); | 4753 ASSERT_EQ(1u, frame.render_passes.size()); |
| 4693 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); | 4754 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); |
| 4694 | 4755 |
| 4695 // The surface is clipped to 10x20. | 4756 // The surface is clipped to 10x20. |
| 4696 ASSERT_EQ(DrawQuad::RENDER_PASS, | 4757 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 4697 frame.render_passes[0]->quad_list[0]->material); | 4758 frame.render_passes[0]->quad_list[0]->material); |
| 4698 const RenderPassDrawQuad* render_pass_quad = | 4759 const RenderPassDrawQuad* render_pass_quad = |
| 4699 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); | 4760 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); |
| 4700 EXPECT_FALSE(render_pass_quad->is_replica); | 4761 EXPECT_FALSE(render_pass_quad->is_replica); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4762 scrolling_layer->SetScrollable(true); | 4823 scrolling_layer->SetScrollable(true); |
| 4763 scrolling_layer->SetMaxScrollOffset(scroll_offset); | 4824 scrolling_layer->SetMaxScrollOffset(scroll_offset); |
| 4764 scrolling_layer->SetScrollOffset(scroll_offset); | 4825 scrolling_layer->SetScrollOffset(scroll_offset); |
| 4765 | 4826 |
| 4766 host_impl_->ActivatePendingTree(); | 4827 host_impl_->ActivatePendingTree(); |
| 4767 | 4828 |
| 4768 host_impl_->active_tree()->UpdateDrawProperties(); | 4829 host_impl_->active_tree()->UpdateDrawProperties(); |
| 4769 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); | 4830 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); |
| 4770 | 4831 |
| 4771 LayerTreeHostImpl::FrameData frame; | 4832 LayerTreeHostImpl::FrameData frame; |
| 4772 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 4833 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 4834 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 4773 | 4835 |
| 4774 ASSERT_EQ(1u, frame.render_passes.size()); | 4836 ASSERT_EQ(1u, frame.render_passes.size()); |
| 4775 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); | 4837 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); |
| 4776 const DrawQuad* quad = frame.render_passes[0]->quad_list[0]; | 4838 const DrawQuad* quad = frame.render_passes[0]->quad_list[0]; |
| 4777 | 4839 |
| 4778 float edge[24]; | 4840 float edge[24]; |
| 4779 gfx::QuadF device_layer_quad; | 4841 gfx::QuadF device_layer_quad; |
| 4780 bool antialiased = | 4842 bool antialiased = |
| 4781 GLRendererWithSetupQuadForAntialiasing::SetupQuadForAntialiasing( | 4843 GLRendererWithSetupQuadForAntialiasing::SetupQuadForAntialiasing( |
| 4782 quad->quadTransform(), quad, &device_layer_quad, edge); | 4844 quad->quadTransform(), quad, &device_layer_quad, edge); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 4796 swap_buffers_complete_++; | 4858 swap_buffers_complete_++; |
| 4797 } | 4859 } |
| 4798 | 4860 |
| 4799 int swap_buffers_complete_; | 4861 int swap_buffers_complete_; |
| 4800 }; | 4862 }; |
| 4801 | 4863 |
| 4802 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) { | 4864 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) { |
| 4803 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 4865 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
| 4804 { | 4866 { |
| 4805 LayerTreeHostImpl::FrameData frame; | 4867 LayerTreeHostImpl::FrameData frame; |
| 4806 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 4868 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 4869 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 4807 host_impl_->DrawLayers(&frame, base::TimeTicks()); | 4870 host_impl_->DrawLayers(&frame, base::TimeTicks()); |
| 4808 host_impl_->DidDrawAllLayers(frame); | 4871 host_impl_->DidDrawAllLayers(frame); |
| 4809 } | 4872 } |
| 4810 CompositorFrameAck ack; | 4873 CompositorFrameAck ack; |
| 4811 host_impl_->ReclaimResources(&ack); | 4874 host_impl_->ReclaimResources(&ack); |
| 4812 host_impl_->OnSwapBuffersComplete(); | 4875 host_impl_->OnSwapBuffersComplete(); |
| 4813 EXPECT_EQ(swap_buffers_complete_, 1); | 4876 EXPECT_EQ(swap_buffers_complete_, 1); |
| 4814 } | 4877 } |
| 4815 | 4878 |
| 4816 class CountingSoftwareDevice : public SoftwareOutputDevice { | 4879 class CountingSoftwareDevice : public SoftwareOutputDevice { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4876 FakeVideoFrameProvider provider; | 4939 FakeVideoFrameProvider provider; |
| 4877 scoped_ptr<VideoLayerImpl> video_layer = | 4940 scoped_ptr<VideoLayerImpl> video_layer = |
| 4878 VideoLayerImpl::Create(host_impl_->active_tree(), 2, &provider); | 4941 VideoLayerImpl::Create(host_impl_->active_tree(), 2, &provider); |
| 4879 video_layer->SetBounds(gfx::Size(10, 10)); | 4942 video_layer->SetBounds(gfx::Size(10, 10)); |
| 4880 video_layer->SetContentBounds(gfx::Size(10, 10)); | 4943 video_layer->SetContentBounds(gfx::Size(10, 10)); |
| 4881 video_layer->SetDrawsContent(true); | 4944 video_layer->SetDrawsContent(true); |
| 4882 root_layer->AddChild(video_layer.PassAs<LayerImpl>()); | 4945 root_layer->AddChild(video_layer.PassAs<LayerImpl>()); |
| 4883 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>()); | 4946 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>()); |
| 4884 | 4947 |
| 4885 LayerTreeHostImpl::FrameData frame; | 4948 LayerTreeHostImpl::FrameData frame; |
| 4886 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 4949 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 4950 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 4887 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4951 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4888 host_impl_->DidDrawAllLayers(frame); | 4952 host_impl_->DidDrawAllLayers(frame); |
| 4889 | 4953 |
| 4890 EXPECT_EQ(1u, frame.will_draw_layers.size()); | 4954 EXPECT_EQ(1u, frame.will_draw_layers.size()); |
| 4891 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]); | 4955 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]); |
| 4892 } | 4956 } |
| 4893 | 4957 |
| 4894 class LayerTreeHostImplTestDeferredInitialize : public LayerTreeHostImplTest { | 4958 class LayerTreeHostImplTestDeferredInitialize : public LayerTreeHostImplTest { |
| 4895 protected: | 4959 protected: |
| 4896 virtual void SetUp() OVERRIDE { | 4960 virtual void SetUp() OVERRIDE { |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5181 | 5245 |
| 5182 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 5246 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 5183 | 5247 |
| 5184 ScopedPtrVector<CopyOutputRequest> requests; | 5248 ScopedPtrVector<CopyOutputRequest> requests; |
| 5185 requests.push_back(CopyOutputRequest::CreateRequest( | 5249 requests.push_back(CopyOutputRequest::CreateRequest( |
| 5186 base::Bind(&ShutdownReleasesContext_Callback))); | 5250 base::Bind(&ShutdownReleasesContext_Callback))); |
| 5187 | 5251 |
| 5188 host_impl_->active_tree()->root_layer()->PassCopyRequests(&requests); | 5252 host_impl_->active_tree()->root_layer()->PassCopyRequests(&requests); |
| 5189 | 5253 |
| 5190 LayerTreeHostImpl::FrameData frame; | 5254 LayerTreeHostImpl::FrameData frame; |
| 5191 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 5255 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 5256 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 5192 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 5257 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 5193 host_impl_->DidDrawAllLayers(frame); | 5258 host_impl_->DidDrawAllLayers(frame); |
| 5194 | 5259 |
| 5195 // The CopyOutputResult's callback has a ref on the ContextProvider and a | 5260 // The CopyOutputResult's callback has a ref on the ContextProvider and a |
| 5196 // texture in a texture mailbox. | 5261 // texture in a texture mailbox. |
| 5197 EXPECT_FALSE(context_provider->HasOneRef()); | 5262 EXPECT_FALSE(context_provider->HasOneRef()); |
| 5198 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); | 5263 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); |
| 5199 | 5264 |
| 5200 host_impl_.reset(); | 5265 host_impl_.reset(); |
| 5201 | 5266 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5369 ui::LatencyInfo latency_info; | 5434 ui::LatencyInfo latency_info; |
| 5370 latency_info.AddLatencyNumber( | 5435 latency_info.AddLatencyNumber( |
| 5371 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); | 5436 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); |
| 5372 scoped_ptr<SwapPromise> swap_promise( | 5437 scoped_ptr<SwapPromise> swap_promise( |
| 5373 new LatencyInfoSwapPromise(latency_info)); | 5438 new LatencyInfoSwapPromise(latency_info)); |
| 5374 host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass()); | 5439 host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass()); |
| 5375 host_impl_->SetNeedsRedraw(); | 5440 host_impl_->SetNeedsRedraw(); |
| 5376 | 5441 |
| 5377 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 5442 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
| 5378 LayerTreeHostImpl::FrameData frame; | 5443 LayerTreeHostImpl::FrameData frame; |
| 5379 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 5444 EXPECT_EQ(DrawSwapReadbackResult::DID_DRAW, |
| 5445 host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 5380 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 5446 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 5381 host_impl_->DidDrawAllLayers(frame); | 5447 host_impl_->DidDrawAllLayers(frame); |
| 5382 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); | 5448 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); |
| 5383 | 5449 |
| 5384 const std::vector<ui::LatencyInfo>& metadata_latency_after = | 5450 const std::vector<ui::LatencyInfo>& metadata_latency_after = |
| 5385 fake_output_surface->last_sent_frame().metadata.latency_info; | 5451 fake_output_surface->last_sent_frame().metadata.latency_info; |
| 5386 EXPECT_EQ(1u, metadata_latency_after.size()); | 5452 EXPECT_EQ(1u, metadata_latency_after.size()); |
| 5387 EXPECT_TRUE(metadata_latency_after[0].FindLatency( | 5453 EXPECT_TRUE(metadata_latency_after[0].FindLatency( |
| 5388 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); | 5454 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); |
| 5389 } | 5455 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5453 &set_needs_redraw_count)); | 5519 &set_needs_redraw_count)); |
| 5454 // Empty damage rect won't signal the monitor. | 5520 // Empty damage rect won't signal the monitor. |
| 5455 host_impl_->SetNeedsRedrawRect(gfx::Rect()); | 5521 host_impl_->SetNeedsRedrawRect(gfx::Rect()); |
| 5456 EXPECT_EQ(0, set_needs_commit_count); | 5522 EXPECT_EQ(0, set_needs_commit_count); |
| 5457 EXPECT_EQ(2, set_needs_redraw_count); | 5523 EXPECT_EQ(2, set_needs_redraw_count); |
| 5458 } | 5524 } |
| 5459 } | 5525 } |
| 5460 | 5526 |
| 5461 } // namespace | 5527 } // namespace |
| 5462 } // namespace cc | 5528 } // namespace cc |
| OLD | NEW |