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

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 27710005: cc: Use HighResNow as timebase if it is fast and reliable (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add missing include Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "cc/test/fake_rendering_stats_instrumentation.h" 46 #include "cc/test/fake_rendering_stats_instrumentation.h"
47 #include "cc/test/fake_video_frame_provider.h" 47 #include "cc/test/fake_video_frame_provider.h"
48 #include "cc/test/geometry_test_utils.h" 48 #include "cc/test/geometry_test_utils.h"
49 #include "cc/test/layer_test_common.h" 49 #include "cc/test/layer_test_common.h"
50 #include "cc/test/render_pass_test_common.h" 50 #include "cc/test/render_pass_test_common.h"
51 #include "cc/trees/layer_tree_impl.h" 51 #include "cc/trees/layer_tree_impl.h"
52 #include "cc/trees/single_thread_proxy.h" 52 #include "cc/trees/single_thread_proxy.h"
53 #include "media/base/media.h" 53 #include "media/base/media.h"
54 #include "testing/gmock/include/gmock/gmock.h" 54 #include "testing/gmock/include/gmock/gmock.h"
55 #include "testing/gtest/include/gtest/gtest.h" 55 #include "testing/gtest/include/gtest/gtest.h"
56 #include "ui/gfx/frame_time.h"
56 #include "ui/gfx/rect_conversions.h" 57 #include "ui/gfx/rect_conversions.h"
57 #include "ui/gfx/size_conversions.h" 58 #include "ui/gfx/size_conversions.h"
58 #include "ui/gfx/vector2d_conversions.h" 59 #include "ui/gfx/vector2d_conversions.h"
59 60
60 using ::testing::Mock; 61 using ::testing::Mock;
61 using ::testing::Return; 62 using ::testing::Return;
62 using ::testing::AnyNumber; 63 using ::testing::AnyNumber;
63 using ::testing::AtLeast; 64 using ::testing::AtLeast;
64 using ::testing::_; 65 using ::testing::_;
65 using media::VideoFrame; 66 using media::VideoFrame;
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 } 266 }
266 267
267 void InitializeRendererAndDrawFrame() { 268 void InitializeRendererAndDrawFrame() {
268 host_impl_->InitializeRenderer(CreateOutputSurface()); 269 host_impl_->InitializeRenderer(CreateOutputSurface());
269 DrawFrame(); 270 DrawFrame();
270 } 271 }
271 272
272 void DrawFrame() { 273 void DrawFrame() {
273 LayerTreeHostImpl::FrameData frame; 274 LayerTreeHostImpl::FrameData frame;
274 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 275 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
275 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 276 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
276 host_impl_->DidDrawAllLayers(frame); 277 host_impl_->DidDrawAllLayers(frame);
277 } 278 }
278 279
279 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor); 280 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor);
280 void pinch_zoom_pan_viewport_test(float device_scale_factor); 281 void pinch_zoom_pan_viewport_test(float device_scale_factor);
281 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); 282 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor);
282 void pinch_zoom_pan_viewport_and_scroll_boundary_test( 283 void pinch_zoom_pan_viewport_and_scroll_boundary_test(
283 float device_scale_factor); 284 float device_scale_factor);
284 285
285 void CheckNotifyCalledIfCanDrawChanged(bool always_draw) { 286 void CheckNotifyCalledIfCanDrawChanged(bool always_draw) {
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 scroll->SetVerticalScrollbarLayer(scrollbar.get()); 1208 scroll->SetVerticalScrollbarLayer(scrollbar.get());
1208 1209
1209 scroll->AddChild(contents.Pass()); 1210 scroll->AddChild(contents.Pass());
1210 root->AddChild(scroll.Pass()); 1211 root->AddChild(scroll.Pass());
1211 root->AddChild(scrollbar.PassAs<LayerImpl>()); 1212 root->AddChild(scrollbar.PassAs<LayerImpl>());
1212 1213
1213 host_impl_->active_tree()->SetRootLayer(root.Pass()); 1214 host_impl_->active_tree()->SetRootLayer(root.Pass());
1214 host_impl_->active_tree()->DidBecomeActive(); 1215 host_impl_->active_tree()->DidBecomeActive();
1215 InitializeRendererAndDrawFrame(); 1216 InitializeRendererAndDrawFrame();
1216 1217
1217 base::TimeTicks fake_now = base::TimeTicks::Now(); 1218 base::TimeTicks fake_now = gfx::FrameTime::Now();
1218 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); 1219 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now);
1219 1220
1220 // If no scroll happened recently, StartScrollbarAnimation should have no 1221 // If no scroll happened recently, StartScrollbarAnimation should have no
1221 // effect. 1222 // effect.
1222 host_impl_->StartScrollbarAnimation(); 1223 host_impl_->StartScrollbarAnimation();
1223 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); 1224 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_);
1224 EXPECT_FALSE(did_request_redraw_); 1225 EXPECT_FALSE(did_request_redraw_);
1225 1226
1226 // If no scroll happened during a scroll gesture, StartScrollbarAnimation 1227 // If no scroll happened during a scroll gesture, StartScrollbarAnimation
1227 // should have no effect. 1228 // should have no effect.
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1506 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( 1507 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(
1507 host_impl_->active_tree()->root_layer()); 1508 host_impl_->active_tree()->root_layer());
1508 1509
1509 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); 1510 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
1510 DidDrawCheckLayer* layer = 1511 DidDrawCheckLayer* layer =
1511 static_cast<DidDrawCheckLayer*>(root->children()[0]); 1512 static_cast<DidDrawCheckLayer*>(root->children()[0]);
1512 1513
1513 { 1514 {
1514 LayerTreeHostImpl::FrameData frame; 1515 LayerTreeHostImpl::FrameData frame;
1515 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10))); 1516 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10)));
1516 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1517 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1517 host_impl_->DidDrawAllLayers(frame); 1518 host_impl_->DidDrawAllLayers(frame);
1518 1519
1519 EXPECT_TRUE(layer->will_draw_called()); 1520 EXPECT_TRUE(layer->will_draw_called());
1520 EXPECT_TRUE(layer->append_quads_called()); 1521 EXPECT_TRUE(layer->append_quads_called());
1521 EXPECT_TRUE(layer->did_draw_called()); 1522 EXPECT_TRUE(layer->did_draw_called());
1522 } 1523 }
1523 1524
1524 { 1525 {
1525 LayerTreeHostImpl::FrameData frame; 1526 LayerTreeHostImpl::FrameData frame;
1526 1527
1527 layer->set_will_draw_returns_false(); 1528 layer->set_will_draw_returns_false();
1528 layer->ClearDidDrawCheck(); 1529 layer->ClearDidDrawCheck();
1529 1530
1530 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10))); 1531 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10)));
1531 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1532 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1532 host_impl_->DidDrawAllLayers(frame); 1533 host_impl_->DidDrawAllLayers(frame);
1533 1534
1534 EXPECT_TRUE(layer->will_draw_called()); 1535 EXPECT_TRUE(layer->will_draw_called());
1535 EXPECT_FALSE(layer->append_quads_called()); 1536 EXPECT_FALSE(layer->append_quads_called());
1536 EXPECT_FALSE(layer->did_draw_called()); 1537 EXPECT_FALSE(layer->did_draw_called());
1537 } 1538 }
1538 } 1539 }
1539 1540
1540 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { 1541 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) {
1541 // The root layer is always drawn, so run this test on a child layer that 1542 // The root layer is always drawn, so run this test on a child layer that
(...skipping 11 matching lines...) Expand all
1553 layer->SetPosition(gfx::PointF(100.f, 100.f)); 1554 layer->SetPosition(gfx::PointF(100.f, 100.f));
1554 layer->SetBounds(gfx::Size(10, 10)); 1555 layer->SetBounds(gfx::Size(10, 10));
1555 layer->SetContentBounds(gfx::Size(10, 10)); 1556 layer->SetContentBounds(gfx::Size(10, 10));
1556 1557
1557 LayerTreeHostImpl::FrameData frame; 1558 LayerTreeHostImpl::FrameData frame;
1558 1559
1559 EXPECT_FALSE(layer->will_draw_called()); 1560 EXPECT_FALSE(layer->will_draw_called());
1560 EXPECT_FALSE(layer->did_draw_called()); 1561 EXPECT_FALSE(layer->did_draw_called());
1561 1562
1562 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1563 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1563 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1564 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1564 host_impl_->DidDrawAllLayers(frame); 1565 host_impl_->DidDrawAllLayers(frame);
1565 1566
1566 EXPECT_FALSE(layer->will_draw_called()); 1567 EXPECT_FALSE(layer->will_draw_called());
1567 EXPECT_FALSE(layer->did_draw_called()); 1568 EXPECT_FALSE(layer->did_draw_called());
1568 1569
1569 EXPECT_TRUE(layer->visible_content_rect().IsEmpty()); 1570 EXPECT_TRUE(layer->visible_content_rect().IsEmpty());
1570 1571
1571 // Ensure visible_content_rect for layer is not empty 1572 // Ensure visible_content_rect for layer is not empty
1572 layer->SetPosition(gfx::PointF()); 1573 layer->SetPosition(gfx::PointF());
1573 1574
1574 EXPECT_FALSE(layer->will_draw_called()); 1575 EXPECT_FALSE(layer->will_draw_called());
1575 EXPECT_FALSE(layer->did_draw_called()); 1576 EXPECT_FALSE(layer->did_draw_called());
1576 1577
1577 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1578 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1578 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1579 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1579 host_impl_->DidDrawAllLayers(frame); 1580 host_impl_->DidDrawAllLayers(frame);
1580 1581
1581 EXPECT_TRUE(layer->will_draw_called()); 1582 EXPECT_TRUE(layer->will_draw_called());
1582 EXPECT_TRUE(layer->did_draw_called()); 1583 EXPECT_TRUE(layer->did_draw_called());
1583 1584
1584 EXPECT_FALSE(layer->visible_content_rect().IsEmpty()); 1585 EXPECT_FALSE(layer->visible_content_rect().IsEmpty());
1585 } 1586 }
1586 1587
1587 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { 1588 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) {
1588 gfx::Size big_size(1000, 1000); 1589 gfx::Size big_size(1000, 1000);
(...skipping 18 matching lines...) Expand all
1607 top_layer->SetContentsOpaque(true); 1608 top_layer->SetContentsOpaque(true);
1608 1609
1609 LayerTreeHostImpl::FrameData frame; 1610 LayerTreeHostImpl::FrameData frame;
1610 1611
1611 EXPECT_FALSE(occluded_layer->will_draw_called()); 1612 EXPECT_FALSE(occluded_layer->will_draw_called());
1612 EXPECT_FALSE(occluded_layer->did_draw_called()); 1613 EXPECT_FALSE(occluded_layer->did_draw_called());
1613 EXPECT_FALSE(top_layer->will_draw_called()); 1614 EXPECT_FALSE(top_layer->will_draw_called());
1614 EXPECT_FALSE(top_layer->did_draw_called()); 1615 EXPECT_FALSE(top_layer->did_draw_called());
1615 1616
1616 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1617 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1617 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1618 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1618 host_impl_->DidDrawAllLayers(frame); 1619 host_impl_->DidDrawAllLayers(frame);
1619 1620
1620 EXPECT_FALSE(occluded_layer->will_draw_called()); 1621 EXPECT_FALSE(occluded_layer->will_draw_called());
1621 EXPECT_FALSE(occluded_layer->did_draw_called()); 1622 EXPECT_FALSE(occluded_layer->did_draw_called());
1622 EXPECT_TRUE(top_layer->will_draw_called()); 1623 EXPECT_TRUE(top_layer->will_draw_called());
1623 EXPECT_TRUE(top_layer->did_draw_called()); 1624 EXPECT_TRUE(top_layer->did_draw_called());
1624 } 1625 }
1625 1626
1626 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { 1627 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) {
1627 host_impl_->active_tree()->SetRootLayer( 1628 host_impl_->active_tree()->SetRootLayer(
(...skipping 11 matching lines...) Expand all
1639 1640
1640 layer1->SetOpacity(0.3f); 1641 layer1->SetOpacity(0.3f);
1641 layer1->SetPreserves3d(false); 1642 layer1->SetPreserves3d(false);
1642 1643
1643 EXPECT_FALSE(root->did_draw_called()); 1644 EXPECT_FALSE(root->did_draw_called());
1644 EXPECT_FALSE(layer1->did_draw_called()); 1645 EXPECT_FALSE(layer1->did_draw_called());
1645 EXPECT_FALSE(layer2->did_draw_called()); 1646 EXPECT_FALSE(layer2->did_draw_called());
1646 1647
1647 LayerTreeHostImpl::FrameData frame; 1648 LayerTreeHostImpl::FrameData frame;
1648 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1649 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1649 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1650 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1650 host_impl_->DidDrawAllLayers(frame); 1651 host_impl_->DidDrawAllLayers(frame);
1651 1652
1652 EXPECT_TRUE(root->did_draw_called()); 1653 EXPECT_TRUE(root->did_draw_called());
1653 EXPECT_TRUE(layer1->did_draw_called()); 1654 EXPECT_TRUE(layer1->did_draw_called());
1654 EXPECT_TRUE(layer2->did_draw_called()); 1655 EXPECT_TRUE(layer2->did_draw_called());
1655 1656
1656 EXPECT_NE(root->render_surface(), layer1->render_surface()); 1657 EXPECT_NE(root->render_surface(), layer1->render_surface());
1657 EXPECT_TRUE(!!layer1->render_surface()); 1658 EXPECT_TRUE(!!layer1->render_surface());
1658 } 1659 }
1659 1660
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1713 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1713 2, 1714 2,
1714 false, 1715 false,
1715 false, 1716 false,
1716 true, 1717 true,
1717 host_impl_->resource_provider())); 1718 host_impl_->resource_provider()));
1718 1719
1719 LayerTreeHostImpl::FrameData frame; 1720 LayerTreeHostImpl::FrameData frame;
1720 1721
1721 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1722 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1722 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1723 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1723 host_impl_->DidDrawAllLayers(frame); 1724 host_impl_->DidDrawAllLayers(frame);
1724 1725
1725 // When a texture is missing and we're not animating, we draw as usual with 1726 // When a texture is missing and we're not animating, we draw as usual with
1726 // checkerboarding. 1727 // checkerboarding.
1727 host_impl_->active_tree()->SetRootLayer( 1728 host_impl_->active_tree()->SetRootLayer(
1728 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); 1729 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3));
1729 root = 1730 root =
1730 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1731 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1731 root->AddChild( 1732 root->AddChild(
1732 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1733 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1733 4, 1734 4,
1734 true, 1735 true,
1735 false, 1736 false,
1736 false, 1737 false,
1737 host_impl_->resource_provider())); 1738 host_impl_->resource_provider()));
1738 1739
1739 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1740 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1740 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1741 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1741 host_impl_->DidDrawAllLayers(frame); 1742 host_impl_->DidDrawAllLayers(frame);
1742 1743
1743 // When a texture is missing and we're animating, we don't want to draw 1744 // When a texture is missing and we're animating, we don't want to draw
1744 // anything. 1745 // anything.
1745 host_impl_->active_tree()->SetRootLayer( 1746 host_impl_->active_tree()->SetRootLayer(
1746 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); 1747 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5));
1747 root = 1748 root =
1748 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1749 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1749 root->AddChild( 1750 root->AddChild(
1750 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1751 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1751 6, 1752 6,
1752 true, 1753 true,
1753 false, 1754 false,
1754 true, 1755 true,
1755 host_impl_->resource_provider())); 1756 host_impl_->resource_provider()));
1756 1757
1757 EXPECT_FALSE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1758 EXPECT_FALSE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1758 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1759 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1759 host_impl_->DidDrawAllLayers(frame); 1760 host_impl_->DidDrawAllLayers(frame);
1760 1761
1761 // When the layer skips draw and we're animating, we still draw the frame. 1762 // When the layer skips draw and we're animating, we still draw the frame.
1762 host_impl_->active_tree()->SetRootLayer( 1763 host_impl_->active_tree()->SetRootLayer(
1763 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 1764 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
1764 root = 1765 root =
1765 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1766 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1766 root->AddChild( 1767 root->AddChild(
1767 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1768 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1768 8, 1769 8,
1769 false, 1770 false,
1770 true, 1771 true,
1771 true, 1772 true,
1772 host_impl_->resource_provider())); 1773 host_impl_->resource_provider()));
1773 1774
1774 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1775 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1775 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1776 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1776 host_impl_->DidDrawAllLayers(frame); 1777 host_impl_->DidDrawAllLayers(frame);
1777 } 1778 }
1778 1779
1779 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { 1780 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) {
1780 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 1781 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
1781 root->SetScrollable(false); 1782 root->SetScrollable(false);
1782 host_impl_->active_tree()->SetRootLayer(root.Pass()); 1783 host_impl_->active_tree()->SetRootLayer(root.Pass());
1783 InitializeRendererAndDrawFrame(); 1784 InitializeRendererAndDrawFrame();
1784 1785
1785 // Scroll event is ignored because layer is not scrollable. 1786 // Scroll event is ignored because layer is not scrollable.
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
2061 EXPECT_EQ(1.f, scroll->contents_scale_y()); 2062 EXPECT_EQ(1.f, scroll->contents_scale_y());
2062 EXPECT_EQ(1.f, child->contents_scale_x()); 2063 EXPECT_EQ(1.f, child->contents_scale_x());
2063 EXPECT_EQ(1.f, child->contents_scale_y()); 2064 EXPECT_EQ(1.f, child->contents_scale_y());
2064 EXPECT_EQ(1.f, grand_child->contents_scale_x()); 2065 EXPECT_EQ(1.f, grand_child->contents_scale_x());
2065 EXPECT_EQ(1.f, grand_child->contents_scale_y()); 2066 EXPECT_EQ(1.f, grand_child->contents_scale_y());
2066 2067
2067 // Make sure all the layers are drawn with the page scale delta applied, i.e., 2068 // Make sure all the layers are drawn with the page scale delta applied, i.e.,
2068 // the page scale delta on the root layer is applied hierarchically. 2069 // the page scale delta on the root layer is applied hierarchically.
2069 LayerTreeHostImpl::FrameData frame; 2070 LayerTreeHostImpl::FrameData frame;
2070 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2071 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2071 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2072 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2072 host_impl_->DidDrawAllLayers(frame); 2073 host_impl_->DidDrawAllLayers(frame);
2073 2074
2074 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(0, 0)); 2075 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(0, 0));
2075 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(1, 1)); 2076 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(1, 1));
2076 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(0, 0)); 2077 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(0, 0));
2077 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(1, 1)); 2078 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(1, 1));
2078 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(0, 0)); 2079 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(0, 0));
2079 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(1, 1)); 2080 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(1, 1));
2080 EXPECT_EQ(new_page_scale, 2081 EXPECT_EQ(new_page_scale,
2081 grand_child->draw_transform().matrix().getDouble(0, 0)); 2082 grand_child->draw_transform().matrix().getDouble(0, 0));
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
2896 static_cast<BlendStateCheckLayer*>(root->children()[0]); 2897 static_cast<BlendStateCheckLayer*>(root->children()[0]);
2897 layer1->SetPosition(gfx::PointF(2.f, 2.f)); 2898 layer1->SetPosition(gfx::PointF(2.f, 2.f));
2898 2899
2899 LayerTreeHostImpl::FrameData frame; 2900 LayerTreeHostImpl::FrameData frame;
2900 2901
2901 // Opaque layer, drawn without blending. 2902 // Opaque layer, drawn without blending.
2902 layer1->SetContentsOpaque(true); 2903 layer1->SetContentsOpaque(true);
2903 layer1->SetExpectation(false, false); 2904 layer1->SetExpectation(false, false);
2904 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2905 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2905 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2906 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2906 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2907 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2907 EXPECT_TRUE(layer1->quads_appended()); 2908 EXPECT_TRUE(layer1->quads_appended());
2908 host_impl_->DidDrawAllLayers(frame); 2909 host_impl_->DidDrawAllLayers(frame);
2909 2910
2910 // Layer with translucent content and painting, so drawn with blending. 2911 // Layer with translucent content and painting, so drawn with blending.
2911 layer1->SetContentsOpaque(false); 2912 layer1->SetContentsOpaque(false);
2912 layer1->SetExpectation(true, false); 2913 layer1->SetExpectation(true, false);
2913 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2914 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2914 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2915 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2915 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2916 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2916 EXPECT_TRUE(layer1->quads_appended()); 2917 EXPECT_TRUE(layer1->quads_appended());
2917 host_impl_->DidDrawAllLayers(frame); 2918 host_impl_->DidDrawAllLayers(frame);
2918 2919
2919 // Layer with translucent opacity, drawn with blending. 2920 // Layer with translucent opacity, drawn with blending.
2920 layer1->SetContentsOpaque(true); 2921 layer1->SetContentsOpaque(true);
2921 layer1->SetOpacity(0.5f); 2922 layer1->SetOpacity(0.5f);
2922 layer1->SetExpectation(true, false); 2923 layer1->SetExpectation(true, false);
2923 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2924 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2924 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2925 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2925 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2926 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2926 EXPECT_TRUE(layer1->quads_appended()); 2927 EXPECT_TRUE(layer1->quads_appended());
2927 host_impl_->DidDrawAllLayers(frame); 2928 host_impl_->DidDrawAllLayers(frame);
2928 2929
2929 // Layer with translucent opacity and painting, drawn with blending. 2930 // Layer with translucent opacity and painting, drawn with blending.
2930 layer1->SetContentsOpaque(true); 2931 layer1->SetContentsOpaque(true);
2931 layer1->SetOpacity(0.5f); 2932 layer1->SetOpacity(0.5f);
2932 layer1->SetExpectation(true, false); 2933 layer1->SetExpectation(true, false);
2933 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2934 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2934 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2935 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2935 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2936 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2936 EXPECT_TRUE(layer1->quads_appended()); 2937 EXPECT_TRUE(layer1->quads_appended());
2937 host_impl_->DidDrawAllLayers(frame); 2938 host_impl_->DidDrawAllLayers(frame);
2938 2939
2939 layer1->AddChild( 2940 layer1->AddChild(
2940 BlendStateCheckLayer::Create(host_impl_->active_tree(), 2941 BlendStateCheckLayer::Create(host_impl_->active_tree(),
2941 3, 2942 3,
2942 host_impl_->resource_provider())); 2943 host_impl_->resource_provider()));
2943 BlendStateCheckLayer* layer2 = 2944 BlendStateCheckLayer* layer2 =
2944 static_cast<BlendStateCheckLayer*>(layer1->children()[0]); 2945 static_cast<BlendStateCheckLayer*>(layer1->children()[0]);
2945 layer2->SetPosition(gfx::PointF(4.f, 4.f)); 2946 layer2->SetPosition(gfx::PointF(4.f, 4.f));
2946 2947
2947 // 2 opaque layers, drawn without blending. 2948 // 2 opaque layers, drawn without blending.
2948 layer1->SetContentsOpaque(true); 2949 layer1->SetContentsOpaque(true);
2949 layer1->SetOpacity(1.f); 2950 layer1->SetOpacity(1.f);
2950 layer1->SetExpectation(false, false); 2951 layer1->SetExpectation(false, false);
2951 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2952 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2952 layer2->SetContentsOpaque(true); 2953 layer2->SetContentsOpaque(true);
2953 layer2->SetOpacity(1.f); 2954 layer2->SetOpacity(1.f);
2954 layer2->SetExpectation(false, false); 2955 layer2->SetExpectation(false, false);
2955 layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); 2956 layer2->set_update_rect(gfx::RectF(layer1->content_bounds()));
2956 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2957 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2957 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2958 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2958 EXPECT_TRUE(layer1->quads_appended()); 2959 EXPECT_TRUE(layer1->quads_appended());
2959 EXPECT_TRUE(layer2->quads_appended()); 2960 EXPECT_TRUE(layer2->quads_appended());
2960 host_impl_->DidDrawAllLayers(frame); 2961 host_impl_->DidDrawAllLayers(frame);
2961 2962
2962 // Parent layer with translucent content, drawn with blending. 2963 // Parent layer with translucent content, drawn with blending.
2963 // Child layer with opaque content, drawn without blending. 2964 // Child layer with opaque content, drawn without blending.
2964 layer1->SetContentsOpaque(false); 2965 layer1->SetContentsOpaque(false);
2965 layer1->SetExpectation(true, false); 2966 layer1->SetExpectation(true, false);
2966 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2967 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2967 layer2->SetExpectation(false, false); 2968 layer2->SetExpectation(false, false);
2968 layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); 2969 layer2->set_update_rect(gfx::RectF(layer1->content_bounds()));
2969 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2970 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2970 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2971 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2971 EXPECT_TRUE(layer1->quads_appended()); 2972 EXPECT_TRUE(layer1->quads_appended());
2972 EXPECT_TRUE(layer2->quads_appended()); 2973 EXPECT_TRUE(layer2->quads_appended());
2973 host_impl_->DidDrawAllLayers(frame); 2974 host_impl_->DidDrawAllLayers(frame);
2974 2975
2975 // Parent layer with translucent content but opaque painting, drawn without 2976 // Parent layer with translucent content but opaque painting, drawn without
2976 // blending. 2977 // blending.
2977 // Child layer with opaque content, drawn without blending. 2978 // Child layer with opaque content, drawn without blending.
2978 layer1->SetContentsOpaque(true); 2979 layer1->SetContentsOpaque(true);
2979 layer1->SetExpectation(false, false); 2980 layer1->SetExpectation(false, false);
2980 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2981 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2981 layer2->SetExpectation(false, false); 2982 layer2->SetExpectation(false, false);
2982 layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); 2983 layer2->set_update_rect(gfx::RectF(layer1->content_bounds()));
2983 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2984 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2984 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2985 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2985 EXPECT_TRUE(layer1->quads_appended()); 2986 EXPECT_TRUE(layer1->quads_appended());
2986 EXPECT_TRUE(layer2->quads_appended()); 2987 EXPECT_TRUE(layer2->quads_appended());
2987 host_impl_->DidDrawAllLayers(frame); 2988 host_impl_->DidDrawAllLayers(frame);
2988 2989
2989 // Parent layer with translucent opacity and opaque content. Since it has a 2990 // Parent layer with translucent opacity and opaque content. Since it has a
2990 // drawing child, it's drawn to a render surface which carries the opacity, 2991 // drawing child, it's drawn to a render surface which carries the opacity,
2991 // so it's itself drawn without blending. 2992 // so it's itself drawn without blending.
2992 // Child layer with opaque content, drawn without blending (parent surface 2993 // Child layer with opaque content, drawn without blending (parent surface
2993 // carries the inherited opacity). 2994 // carries the inherited opacity).
2994 layer1->SetContentsOpaque(true); 2995 layer1->SetContentsOpaque(true);
2995 layer1->SetOpacity(0.5f); 2996 layer1->SetOpacity(0.5f);
2996 layer1->SetExpectation(false, true); 2997 layer1->SetExpectation(false, true);
2997 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2998 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2998 layer2->SetExpectation(false, false); 2999 layer2->SetExpectation(false, false);
2999 layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); 3000 layer2->set_update_rect(gfx::RectF(layer1->content_bounds()));
3000 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3001 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3001 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3002 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3002 EXPECT_TRUE(layer1->quads_appended()); 3003 EXPECT_TRUE(layer1->quads_appended());
3003 EXPECT_TRUE(layer2->quads_appended()); 3004 EXPECT_TRUE(layer2->quads_appended());
3004 host_impl_->DidDrawAllLayers(frame); 3005 host_impl_->DidDrawAllLayers(frame);
3005 3006
3006 // Draw again, but with child non-opaque, to make sure 3007 // Draw again, but with child non-opaque, to make sure
3007 // layer1 not culled. 3008 // layer1 not culled.
3008 layer1->SetContentsOpaque(true); 3009 layer1->SetContentsOpaque(true);
3009 layer1->SetOpacity(1.f); 3010 layer1->SetOpacity(1.f);
3010 layer1->SetExpectation(false, false); 3011 layer1->SetExpectation(false, false);
3011 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 3012 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
3012 layer2->SetContentsOpaque(true); 3013 layer2->SetContentsOpaque(true);
3013 layer2->SetOpacity(0.5f); 3014 layer2->SetOpacity(0.5f);
3014 layer2->SetExpectation(true, false); 3015 layer2->SetExpectation(true, false);
3015 layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); 3016 layer2->set_update_rect(gfx::RectF(layer1->content_bounds()));
3016 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3017 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3017 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3018 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3018 EXPECT_TRUE(layer1->quads_appended()); 3019 EXPECT_TRUE(layer1->quads_appended());
3019 EXPECT_TRUE(layer2->quads_appended()); 3020 EXPECT_TRUE(layer2->quads_appended());
3020 host_impl_->DidDrawAllLayers(frame); 3021 host_impl_->DidDrawAllLayers(frame);
3021 3022
3022 // A second way of making the child non-opaque. 3023 // A second way of making the child non-opaque.
3023 layer1->SetContentsOpaque(true); 3024 layer1->SetContentsOpaque(true);
3024 layer1->SetOpacity(1.f); 3025 layer1->SetOpacity(1.f);
3025 layer1->SetExpectation(false, false); 3026 layer1->SetExpectation(false, false);
3026 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 3027 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
3027 layer2->SetContentsOpaque(false); 3028 layer2->SetContentsOpaque(false);
3028 layer2->SetOpacity(1.f); 3029 layer2->SetOpacity(1.f);
3029 layer2->SetExpectation(true, false); 3030 layer2->SetExpectation(true, false);
3030 layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); 3031 layer2->set_update_rect(gfx::RectF(layer1->content_bounds()));
3031 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3032 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3032 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3033 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3033 EXPECT_TRUE(layer1->quads_appended()); 3034 EXPECT_TRUE(layer1->quads_appended());
3034 EXPECT_TRUE(layer2->quads_appended()); 3035 EXPECT_TRUE(layer2->quads_appended());
3035 host_impl_->DidDrawAllLayers(frame); 3036 host_impl_->DidDrawAllLayers(frame);
3036 3037
3037 // And when the layer says its not opaque but is painted opaque, it is not 3038 // And when the layer says its not opaque but is painted opaque, it is not
3038 // blended. 3039 // blended.
3039 layer1->SetContentsOpaque(true); 3040 layer1->SetContentsOpaque(true);
3040 layer1->SetOpacity(1.f); 3041 layer1->SetOpacity(1.f);
3041 layer1->SetExpectation(false, false); 3042 layer1->SetExpectation(false, false);
3042 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 3043 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
3043 layer2->SetContentsOpaque(true); 3044 layer2->SetContentsOpaque(true);
3044 layer2->SetOpacity(1.f); 3045 layer2->SetOpacity(1.f);
3045 layer2->SetExpectation(false, false); 3046 layer2->SetExpectation(false, false);
3046 layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); 3047 layer2->set_update_rect(gfx::RectF(layer1->content_bounds()));
3047 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3048 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3048 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3049 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3049 EXPECT_TRUE(layer1->quads_appended()); 3050 EXPECT_TRUE(layer1->quads_appended());
3050 EXPECT_TRUE(layer2->quads_appended()); 3051 EXPECT_TRUE(layer2->quads_appended());
3051 host_impl_->DidDrawAllLayers(frame); 3052 host_impl_->DidDrawAllLayers(frame);
3052 3053
3053 // Layer with partially opaque contents, drawn with blending. 3054 // Layer with partially opaque contents, drawn with blending.
3054 layer1->SetContentsOpaque(false); 3055 layer1->SetContentsOpaque(false);
3055 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3056 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3056 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); 3057 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5));
3057 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3058 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3058 layer1->SetExpectation(true, false); 3059 layer1->SetExpectation(true, false);
3059 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 3060 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
3060 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3061 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3061 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3062 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3062 EXPECT_TRUE(layer1->quads_appended()); 3063 EXPECT_TRUE(layer1->quads_appended());
3063 host_impl_->DidDrawAllLayers(frame); 3064 host_impl_->DidDrawAllLayers(frame);
3064 3065
3065 // Layer with partially opaque contents partially culled, drawn with blending. 3066 // Layer with partially opaque contents partially culled, drawn with blending.
3066 layer1->SetContentsOpaque(false); 3067 layer1->SetContentsOpaque(false);
3067 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3068 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3068 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); 3069 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2));
3069 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3070 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3070 layer1->SetExpectation(true, false); 3071 layer1->SetExpectation(true, false);
3071 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 3072 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
3072 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3073 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3073 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3074 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3074 EXPECT_TRUE(layer1->quads_appended()); 3075 EXPECT_TRUE(layer1->quads_appended());
3075 host_impl_->DidDrawAllLayers(frame); 3076 host_impl_->DidDrawAllLayers(frame);
3076 3077
3077 // Layer with partially opaque contents culled, drawn with blending. 3078 // Layer with partially opaque contents culled, drawn with blending.
3078 layer1->SetContentsOpaque(false); 3079 layer1->SetContentsOpaque(false);
3079 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3080 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3080 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); 3081 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5));
3081 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3082 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3082 layer1->SetExpectation(true, false); 3083 layer1->SetExpectation(true, false);
3083 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 3084 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
3084 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3085 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3085 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3086 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3086 EXPECT_TRUE(layer1->quads_appended()); 3087 EXPECT_TRUE(layer1->quads_appended());
3087 host_impl_->DidDrawAllLayers(frame); 3088 host_impl_->DidDrawAllLayers(frame);
3088 3089
3089 // Layer with partially opaque contents and translucent contents culled, drawn 3090 // Layer with partially opaque contents and translucent contents culled, drawn
3090 // without blending. 3091 // without blending.
3091 layer1->SetContentsOpaque(false); 3092 layer1->SetContentsOpaque(false);
3092 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3093 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3093 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); 3094 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5));
3094 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3095 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3095 layer1->SetExpectation(false, false); 3096 layer1->SetExpectation(false, false);
3096 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 3097 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
3097 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3098 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3098 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3099 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3099 EXPECT_TRUE(layer1->quads_appended()); 3100 EXPECT_TRUE(layer1->quads_appended());
3100 host_impl_->DidDrawAllLayers(frame); 3101 host_impl_->DidDrawAllLayers(frame);
3101 } 3102 }
3102 3103
3103 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { 3104 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest {
3104 public: 3105 public:
3105 LayerTreeHostImplViewportCoveredTest() : 3106 LayerTreeHostImplViewportCoveredTest() :
3106 gutter_quad_material_(DrawQuad::SOLID_COLOR), 3107 gutter_quad_material_(DrawQuad::SOLID_COLOR),
3107 child_(NULL), 3108 child_(NULL),
3108 did_activate_pending_tree_(false) {} 3109 did_activate_pending_tree_(false) {}
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
3446 root->SetContentBounds(gfx::Size(10, 10)); 3447 root->SetContentBounds(gfx::Size(10, 10));
3447 root->SetDrawsContent(true); 3448 root->SetDrawsContent(true);
3448 host_impl_->active_tree()->SetRootLayer(root.Pass()); 3449 host_impl_->active_tree()->SetRootLayer(root.Pass());
3449 EXPECT_FALSE(reshape_tracker->reshape_called()); 3450 EXPECT_FALSE(reshape_tracker->reshape_called());
3450 reshape_tracker->clear_reshape_called(); 3451 reshape_tracker->clear_reshape_called();
3451 3452
3452 LayerTreeHostImpl::FrameData frame; 3453 LayerTreeHostImpl::FrameData frame;
3453 host_impl_->SetViewportSize(gfx::Size(10, 10)); 3454 host_impl_->SetViewportSize(gfx::Size(10, 10));
3454 host_impl_->SetDeviceScaleFactor(1.f); 3455 host_impl_->SetDeviceScaleFactor(1.f);
3455 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3456 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3456 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3457 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3457 EXPECT_TRUE(reshape_tracker->reshape_called()); 3458 EXPECT_TRUE(reshape_tracker->reshape_called());
3458 EXPECT_EQ(reshape_tracker->last_reshape_width(), 10); 3459 EXPECT_EQ(reshape_tracker->last_reshape_width(), 10);
3459 EXPECT_EQ(reshape_tracker->last_reshape_height(), 10); 3460 EXPECT_EQ(reshape_tracker->last_reshape_height(), 10);
3460 EXPECT_EQ(reshape_tracker->last_reshape_scale_factor(), 1.f); 3461 EXPECT_EQ(reshape_tracker->last_reshape_scale_factor(), 1.f);
3461 host_impl_->DidDrawAllLayers(frame); 3462 host_impl_->DidDrawAllLayers(frame);
3462 reshape_tracker->clear_reshape_called(); 3463 reshape_tracker->clear_reshape_called();
3463 3464
3464 host_impl_->SetViewportSize(gfx::Size(20, 30)); 3465 host_impl_->SetViewportSize(gfx::Size(20, 30));
3465 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3466 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3466 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3467 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3467 EXPECT_TRUE(reshape_tracker->reshape_called()); 3468 EXPECT_TRUE(reshape_tracker->reshape_called());
3468 EXPECT_EQ(reshape_tracker->last_reshape_width(), 20); 3469 EXPECT_EQ(reshape_tracker->last_reshape_width(), 20);
3469 EXPECT_EQ(reshape_tracker->last_reshape_height(), 30); 3470 EXPECT_EQ(reshape_tracker->last_reshape_height(), 30);
3470 EXPECT_EQ(reshape_tracker->last_reshape_scale_factor(), 1.f); 3471 EXPECT_EQ(reshape_tracker->last_reshape_scale_factor(), 1.f);
3471 host_impl_->DidDrawAllLayers(frame); 3472 host_impl_->DidDrawAllLayers(frame);
3472 reshape_tracker->clear_reshape_called(); 3473 reshape_tracker->clear_reshape_called();
3473 3474
3474 host_impl_->SetDeviceScaleFactor(2.f); 3475 host_impl_->SetDeviceScaleFactor(2.f);
3475 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3476 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3476 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3477 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3477 EXPECT_TRUE(reshape_tracker->reshape_called()); 3478 EXPECT_TRUE(reshape_tracker->reshape_called());
3478 EXPECT_EQ(reshape_tracker->last_reshape_width(), 20); 3479 EXPECT_EQ(reshape_tracker->last_reshape_width(), 20);
3479 EXPECT_EQ(reshape_tracker->last_reshape_height(), 30); 3480 EXPECT_EQ(reshape_tracker->last_reshape_height(), 30);
3480 EXPECT_EQ(reshape_tracker->last_reshape_scale_factor(), 2.f); 3481 EXPECT_EQ(reshape_tracker->last_reshape_scale_factor(), 2.f);
3481 host_impl_->DidDrawAllLayers(frame); 3482 host_impl_->DidDrawAllLayers(frame);
3482 reshape_tracker->clear_reshape_called(); 3483 reshape_tracker->clear_reshape_called();
3483 } 3484 }
3484 3485
3485 class SwapTrackerContext : public TestWebGraphicsContext3D { 3486 class SwapTrackerContext : public TestWebGraphicsContext3D {
3486 public: 3487 public:
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
3552 root->SetBounds(gfx::Size(500, 500)); 3553 root->SetBounds(gfx::Size(500, 500));
3553 root->SetContentBounds(gfx::Size(500, 500)); 3554 root->SetContentBounds(gfx::Size(500, 500));
3554 root->SetDrawsContent(true); 3555 root->SetDrawsContent(true);
3555 root->AddChild(child.Pass()); 3556 root->AddChild(child.Pass());
3556 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass()); 3557 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass());
3557 3558
3558 LayerTreeHostImpl::FrameData frame; 3559 LayerTreeHostImpl::FrameData frame;
3559 3560
3560 // First frame, the entire screen should get swapped. 3561 // First frame, the entire screen should get swapped.
3561 EXPECT_TRUE(layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect())); 3562 EXPECT_TRUE(layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect()));
3562 layer_tree_host_impl->DrawLayers(&frame, base::TimeTicks::Now()); 3563 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
3563 layer_tree_host_impl->DidDrawAllLayers(frame); 3564 layer_tree_host_impl->DidDrawAllLayers(frame);
3564 layer_tree_host_impl->SwapBuffers(frame); 3565 layer_tree_host_impl->SwapBuffers(frame);
3565 gfx::Rect actual_swap_rect = swap_tracker->update_rect(); 3566 gfx::Rect actual_swap_rect = swap_tracker->update_rect();
3566 gfx::Rect expected_swap_rect = gfx::Rect(0, 0, 500, 500); 3567 gfx::Rect expected_swap_rect = gfx::Rect(0, 0, 500, 500);
3567 EXPECT_EQ(expected_swap_rect.x(), actual_swap_rect.x()); 3568 EXPECT_EQ(expected_swap_rect.x(), actual_swap_rect.x());
3568 EXPECT_EQ(expected_swap_rect.y(), actual_swap_rect.y()); 3569 EXPECT_EQ(expected_swap_rect.y(), actual_swap_rect.y());
3569 EXPECT_EQ(expected_swap_rect.width(), actual_swap_rect.width()); 3570 EXPECT_EQ(expected_swap_rect.width(), actual_swap_rect.width());
3570 EXPECT_EQ(expected_swap_rect.height(), actual_swap_rect.height()); 3571 EXPECT_EQ(expected_swap_rect.height(), actual_swap_rect.height());
3571 EXPECT_EQ(swap_tracker->last_update_type(), 3572 EXPECT_EQ(swap_tracker->last_update_type(),
3572 SwapTrackerContext::PrepareTexture); 3573 SwapTrackerContext::PrepareTexture);
3573 // Second frame, only the damaged area should get swapped. Damage should be 3574 // Second frame, only the damaged area should get swapped. Damage should be
3574 // the union of old and new child rects. 3575 // the union of old and new child rects.
3575 // expected damage rect: gfx::Rect(26, 28); 3576 // expected damage rect: gfx::Rect(26, 28);
3576 // expected swap rect: vertically flipped, with origin at bottom left corner. 3577 // expected swap rect: vertically flipped, with origin at bottom left corner.
3577 layer_tree_host_impl->active_tree()->root_layer()->children()[0]->SetPosition( 3578 layer_tree_host_impl->active_tree()->root_layer()->children()[0]->SetPosition(
3578 gfx::PointF()); 3579 gfx::PointF());
3579 EXPECT_TRUE(layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect())); 3580 EXPECT_TRUE(layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect()));
3580 layer_tree_host_impl->DrawLayers(&frame, base::TimeTicks::Now()); 3581 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
3581 host_impl_->DidDrawAllLayers(frame); 3582 host_impl_->DidDrawAllLayers(frame);
3582 layer_tree_host_impl->SwapBuffers(frame); 3583 layer_tree_host_impl->SwapBuffers(frame);
3583 actual_swap_rect = swap_tracker->update_rect(); 3584 actual_swap_rect = swap_tracker->update_rect();
3584 expected_swap_rect = gfx::Rect(0, 500-28, 26, 28); 3585 expected_swap_rect = gfx::Rect(0, 500-28, 26, 28);
3585 EXPECT_EQ(expected_swap_rect.x(), actual_swap_rect.x()); 3586 EXPECT_EQ(expected_swap_rect.x(), actual_swap_rect.x());
3586 EXPECT_EQ(expected_swap_rect.y(), actual_swap_rect.y()); 3587 EXPECT_EQ(expected_swap_rect.y(), actual_swap_rect.y());
3587 EXPECT_EQ(expected_swap_rect.width(), actual_swap_rect.width()); 3588 EXPECT_EQ(expected_swap_rect.width(), actual_swap_rect.width());
3588 EXPECT_EQ(expected_swap_rect.height(), actual_swap_rect.height()); 3589 EXPECT_EQ(expected_swap_rect.height(), actual_swap_rect.height());
3589 EXPECT_EQ(swap_tracker->last_update_type(), 3590 EXPECT_EQ(swap_tracker->last_update_type(),
3590 SwapTrackerContext::PostSubBuffer); 3591 SwapTrackerContext::PostSubBuffer);
3591 3592
3592 // Make sure that partial swap is constrained to the viewport dimensions 3593 // Make sure that partial swap is constrained to the viewport dimensions
3593 // expected damage rect: gfx::Rect(500, 500); 3594 // expected damage rect: gfx::Rect(500, 500);
3594 // expected swap rect: flipped damage rect, but also clamped to viewport 3595 // expected swap rect: flipped damage rect, but also clamped to viewport
3595 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10)); 3596 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10));
3596 // This will damage everything. 3597 // This will damage everything.
3597 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor( 3598 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor(
3598 SK_ColorBLACK); 3599 SK_ColorBLACK);
3599 EXPECT_TRUE(layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect())); 3600 EXPECT_TRUE(layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect()));
3600 layer_tree_host_impl->DrawLayers(&frame, base::TimeTicks::Now()); 3601 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
3601 host_impl_->DidDrawAllLayers(frame); 3602 host_impl_->DidDrawAllLayers(frame);
3602 layer_tree_host_impl->SwapBuffers(frame); 3603 layer_tree_host_impl->SwapBuffers(frame);
3603 actual_swap_rect = swap_tracker->update_rect(); 3604 actual_swap_rect = swap_tracker->update_rect();
3604 expected_swap_rect = gfx::Rect(10, 10); 3605 expected_swap_rect = gfx::Rect(10, 10);
3605 EXPECT_EQ(expected_swap_rect.x(), actual_swap_rect.x()); 3606 EXPECT_EQ(expected_swap_rect.x(), actual_swap_rect.x());
3606 EXPECT_EQ(expected_swap_rect.y(), actual_swap_rect.y()); 3607 EXPECT_EQ(expected_swap_rect.y(), actual_swap_rect.y());
3607 EXPECT_EQ(expected_swap_rect.width(), actual_swap_rect.width()); 3608 EXPECT_EQ(expected_swap_rect.width(), actual_swap_rect.width());
3608 EXPECT_EQ(expected_swap_rect.height(), actual_swap_rect.height()); 3609 EXPECT_EQ(expected_swap_rect.height(), actual_swap_rect.height());
3609 EXPECT_EQ(swap_tracker->last_update_type(), 3610 EXPECT_EQ(swap_tracker->last_update_type(),
3610 SwapTrackerContext::PrepareTexture); 3611 SwapTrackerContext::PrepareTexture);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
3758 // Run test case 3759 // Run test case
3759 CreateLayerTreeHost(false, output_surface.Pass()); 3760 CreateLayerTreeHost(false, output_surface.Pass());
3760 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); 3761 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
3761 3762
3762 // Without partial swap, and no clipping, no scissor is set. 3763 // Without partial swap, and no clipping, no scissor is set.
3763 harness.MustDrawSolidQuad(); 3764 harness.MustDrawSolidQuad();
3764 harness.MustSetNoScissor(); 3765 harness.MustSetNoScissor();
3765 { 3766 {
3766 LayerTreeHostImpl::FrameData frame; 3767 LayerTreeHostImpl::FrameData frame;
3767 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3768 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3768 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3769 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3769 host_impl_->DidDrawAllLayers(frame); 3770 host_impl_->DidDrawAllLayers(frame);
3770 } 3771 }
3771 Mock::VerifyAndClearExpectations(&mock_context); 3772 Mock::VerifyAndClearExpectations(&mock_context);
3772 3773
3773 // Without partial swap, but a layer does clip its subtree, one scissor is 3774 // Without partial swap, but a layer does clip its subtree, one scissor is
3774 // set. 3775 // set.
3775 host_impl_->active_tree()->root_layer()->SetMasksToBounds(true); 3776 host_impl_->active_tree()->root_layer()->SetMasksToBounds(true);
3776 harness.MustDrawSolidQuad(); 3777 harness.MustDrawSolidQuad();
3777 harness.MustSetScissor(0, 0, 10, 10); 3778 harness.MustSetScissor(0, 0, 10, 10);
3778 { 3779 {
3779 LayerTreeHostImpl::FrameData frame; 3780 LayerTreeHostImpl::FrameData frame;
3780 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3781 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3781 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3782 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3782 host_impl_->DidDrawAllLayers(frame); 3783 host_impl_->DidDrawAllLayers(frame);
3783 } 3784 }
3784 Mock::VerifyAndClearExpectations(&mock_context); 3785 Mock::VerifyAndClearExpectations(&mock_context);
3785 } 3786 }
3786 3787
3787 TEST_F(LayerTreeHostImplTest, PartialSwap) { 3788 TEST_F(LayerTreeHostImplTest, PartialSwap) {
3788 scoped_ptr<MockContext> context_owned(new MockContext); 3789 scoped_ptr<MockContext> context_owned(new MockContext);
3789 MockContext* mock_context = context_owned.get(); 3790 MockContext* mock_context = context_owned.get();
3790 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 3791 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
3791 context_owned.PassAs<TestWebGraphicsContext3D>())); 3792 context_owned.PassAs<TestWebGraphicsContext3D>()));
3792 MockContextHarness harness(mock_context); 3793 MockContextHarness harness(mock_context);
3793 3794
3794 CreateLayerTreeHost(true, output_surface.Pass()); 3795 CreateLayerTreeHost(true, output_surface.Pass());
3795 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); 3796 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
3796 3797
3797 // The first frame is not a partially-swapped one. 3798 // The first frame is not a partially-swapped one.
3798 harness.MustSetScissor(0, 0, 10, 10); 3799 harness.MustSetScissor(0, 0, 10, 10);
3799 harness.MustDrawSolidQuad(); 3800 harness.MustDrawSolidQuad();
3800 { 3801 {
3801 LayerTreeHostImpl::FrameData frame; 3802 LayerTreeHostImpl::FrameData frame;
3802 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3803 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3803 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3804 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3804 host_impl_->DidDrawAllLayers(frame); 3805 host_impl_->DidDrawAllLayers(frame);
3805 } 3806 }
3806 Mock::VerifyAndClearExpectations(&mock_context); 3807 Mock::VerifyAndClearExpectations(&mock_context);
3807 3808
3808 // Damage a portion of the frame. 3809 // Damage a portion of the frame.
3809 host_impl_->active_tree()->root_layer()->set_update_rect( 3810 host_impl_->active_tree()->root_layer()->set_update_rect(
3810 gfx::Rect(0, 0, 2, 3)); 3811 gfx::Rect(0, 0, 2, 3));
3811 3812
3812 // The second frame will be partially-swapped (the y coordinates are flipped). 3813 // The second frame will be partially-swapped (the y coordinates are flipped).
3813 harness.MustSetScissor(0, 7, 2, 3); 3814 harness.MustSetScissor(0, 7, 2, 3);
3814 harness.MustDrawSolidQuad(); 3815 harness.MustDrawSolidQuad();
3815 { 3816 {
3816 LayerTreeHostImpl::FrameData frame; 3817 LayerTreeHostImpl::FrameData frame;
3817 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3818 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3818 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3819 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3819 host_impl_->DidDrawAllLayers(frame); 3820 host_impl_->DidDrawAllLayers(frame);
3820 } 3821 }
3821 Mock::VerifyAndClearExpectations(&mock_context); 3822 Mock::VerifyAndClearExpectations(&mock_context);
3822 } 3823 }
3823 3824
3824 class PartialSwapContext : public TestWebGraphicsContext3D { 3825 class PartialSwapContext : public TestWebGraphicsContext3D {
3825 public: 3826 public:
3826 PartialSwapContext() { 3827 PartialSwapContext() {
3827 test_capabilities_.post_sub_buffer = true; 3828 test_capabilities_.post_sub_buffer = true;
3828 } 3829 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
3922 3923
3923 // Verify all quads have been computed 3924 // Verify all quads have been computed
3924 ASSERT_EQ(2U, frame.render_passes.size()); 3925 ASSERT_EQ(2U, frame.render_passes.size());
3925 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 3926 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
3926 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 3927 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
3927 EXPECT_EQ(DrawQuad::SOLID_COLOR, 3928 EXPECT_EQ(DrawQuad::SOLID_COLOR,
3928 frame.render_passes[0]->quad_list[0]->material); 3929 frame.render_passes[0]->quad_list[0]->material);
3929 EXPECT_EQ(DrawQuad::RENDER_PASS, 3930 EXPECT_EQ(DrawQuad::RENDER_PASS,
3930 frame.render_passes[1]->quad_list[0]->material); 3931 frame.render_passes[1]->quad_list[0]->material);
3931 3932
3932 my_host_impl->DrawLayers(&frame, base::TimeTicks::Now()); 3933 my_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
3933 my_host_impl->DidDrawAllLayers(frame); 3934 my_host_impl->DidDrawAllLayers(frame);
3934 } 3935 }
3935 } 3936 }
3936 3937
3937 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { 3938 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) {
3938 scoped_ptr<LayerTreeHostImpl> my_host_impl = 3939 scoped_ptr<LayerTreeHostImpl> my_host_impl =
3939 SetupLayersForOpacity(false, this, &proxy_, &stats_instrumentation_); 3940 SetupLayersForOpacity(false, this, &proxy_, &stats_instrumentation_);
3940 { 3941 {
3941 LayerTreeHostImpl::FrameData frame; 3942 LayerTreeHostImpl::FrameData frame;
3942 EXPECT_TRUE(my_host_impl->PrepareToDraw(&frame, gfx::Rect())); 3943 EXPECT_TRUE(my_host_impl->PrepareToDraw(&frame, gfx::Rect()));
3943 3944
3944 // Verify all quads have been computed 3945 // Verify all quads have been computed
3945 ASSERT_EQ(2U, frame.render_passes.size()); 3946 ASSERT_EQ(2U, frame.render_passes.size());
3946 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 3947 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
3947 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 3948 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
3948 EXPECT_EQ(DrawQuad::SOLID_COLOR, 3949 EXPECT_EQ(DrawQuad::SOLID_COLOR,
3949 frame.render_passes[0]->quad_list[0]->material); 3950 frame.render_passes[0]->quad_list[0]->material);
3950 EXPECT_EQ(DrawQuad::RENDER_PASS, 3951 EXPECT_EQ(DrawQuad::RENDER_PASS,
3951 frame.render_passes[1]->quad_list[0]->material); 3952 frame.render_passes[1]->quad_list[0]->material);
3952 3953
3953 my_host_impl->DrawLayers(&frame, base::TimeTicks::Now()); 3954 my_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
3954 my_host_impl->DidDrawAllLayers(frame); 3955 my_host_impl->DidDrawAllLayers(frame);
3955 } 3956 }
3956 } 3957 }
3957 3958
3958 // Fake WebKit::WebGraphicsContext3D that tracks the number of textures in use. 3959 // Fake WebKit::WebGraphicsContext3D that tracks the number of textures in use.
3959 class TrackingWebGraphicsContext3D : public TestWebGraphicsContext3D { 3960 class TrackingWebGraphicsContext3D : public TestWebGraphicsContext3D {
3960 public: 3961 public:
3961 TrackingWebGraphicsContext3D() 3962 TrackingWebGraphicsContext3D()
3962 : TestWebGraphicsContext3D(), 3963 : TestWebGraphicsContext3D(),
3963 num_textures_(0) { 3964 num_textures_(0) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
4022 io_surface_layer->SetDrawsContent(true); 4023 io_surface_layer->SetDrawsContent(true);
4023 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10)); 4024 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10));
4024 root_layer->AddChild(io_surface_layer.PassAs<LayerImpl>()); 4025 root_layer->AddChild(io_surface_layer.PassAs<LayerImpl>());
4025 4026
4026 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); 4027 host_impl_->active_tree()->SetRootLayer(root_layer.Pass());
4027 4028
4028 EXPECT_EQ(0u, context3d->NumTextures()); 4029 EXPECT_EQ(0u, context3d->NumTextures());
4029 4030
4030 LayerTreeHostImpl::FrameData frame; 4031 LayerTreeHostImpl::FrameData frame;
4031 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4032 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4032 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4033 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4033 host_impl_->DidDrawAllLayers(frame); 4034 host_impl_->DidDrawAllLayers(frame);
4034 host_impl_->SwapBuffers(frame); 4035 host_impl_->SwapBuffers(frame);
4035 4036
4036 EXPECT_GT(context3d->NumTextures(), 0u); 4037 EXPECT_GT(context3d->NumTextures(), 0u);
4037 4038
4038 // Kill the layer tree. 4039 // Kill the layer tree.
4039 host_impl_->active_tree()->SetRootLayer( 4040 host_impl_->active_tree()->SetRootLayer(
4040 LayerImpl::Create(host_impl_->active_tree(), 100)); 4041 LayerImpl::Create(host_impl_->active_tree(), 100));
4041 // There should be no textures left in use after. 4042 // There should be no textures left in use after.
4042 EXPECT_EQ(0u, context3d->NumTextures()); 4043 EXPECT_EQ(0u, context3d->NumTextures());
(...skipping 22 matching lines...) Expand all
4065 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); 4066 host_impl_->active_tree()->set_background_color(SK_ColorWHITE);
4066 4067
4067 // Verify one quad is drawn when transparent background set is not set. 4068 // Verify one quad is drawn when transparent background set is not set.
4068 host_impl_->active_tree()->set_has_transparent_background(false); 4069 host_impl_->active_tree()->set_has_transparent_background(false);
4069 EXPECT_CALL(*mock_context, useProgram(_)) 4070 EXPECT_CALL(*mock_context, useProgram(_))
4070 .Times(1); 4071 .Times(1);
4071 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) 4072 EXPECT_CALL(*mock_context, drawElements(_, _, _, _))
4072 .Times(1); 4073 .Times(1);
4073 LayerTreeHostImpl::FrameData frame; 4074 LayerTreeHostImpl::FrameData frame;
4074 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4075 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4075 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4076 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4076 host_impl_->DidDrawAllLayers(frame); 4077 host_impl_->DidDrawAllLayers(frame);
4077 Mock::VerifyAndClearExpectations(&mock_context); 4078 Mock::VerifyAndClearExpectations(&mock_context);
4078 4079
4079 // Verify no quads are drawn when transparent background is set. 4080 // Verify no quads are drawn when transparent background is set.
4080 host_impl_->active_tree()->set_has_transparent_background(true); 4081 host_impl_->active_tree()->set_has_transparent_background(true);
4081 host_impl_->SetFullRootLayerDamage(); 4082 host_impl_->SetFullRootLayerDamage();
4082 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4083 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4083 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4084 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4084 host_impl_->DidDrawAllLayers(frame); 4085 host_impl_->DidDrawAllLayers(frame);
4085 Mock::VerifyAndClearExpectations(&mock_context); 4086 Mock::VerifyAndClearExpectations(&mock_context);
4086 } 4087 }
4087 4088
4088 TEST_F(LayerTreeHostImplTest, ReleaseContentsTextureShouldTriggerCommit) { 4089 TEST_F(LayerTreeHostImplTest, ReleaseContentsTextureShouldTriggerCommit) {
4089 set_reduce_memory_result(false); 4090 set_reduce_memory_result(false);
4090 4091
4091 // If changing the memory limit wouldn't result in changing what was 4092 // If changing the memory limit wouldn't result in changing what was
4092 // committed, then no commit should be requested. 4093 // committed, then no commit should be requested.
4093 set_reduce_memory_result(false); 4094 set_reduce_memory_result(false);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
4160 gfx::RectF expected_child_visible_rect(child->content_bounds()); 4161 gfx::RectF expected_child_visible_rect(child->content_bounds());
4161 EXPECT_RECT_EQ(expected_child_visible_rect, 4162 EXPECT_RECT_EQ(expected_child_visible_rect,
4162 root_render_pass->quad_list[0]->visible_rect); 4163 root_render_pass->quad_list[0]->visible_rect);
4163 4164
4164 LayerImpl* root = host_impl_->active_tree()->root_layer(); 4165 LayerImpl* root = host_impl_->active_tree()->root_layer();
4165 gfx::RectF expected_root_visible_rect(root->content_bounds()); 4166 gfx::RectF expected_root_visible_rect(root->content_bounds());
4166 EXPECT_RECT_EQ(expected_root_visible_rect, 4167 EXPECT_RECT_EQ(expected_root_visible_rect,
4167 root_render_pass->quad_list[1]->visible_rect); 4168 root_render_pass->quad_list[1]->visible_rect);
4168 } 4169 }
4169 4170
4170 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4171 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4171 host_impl_->DidDrawAllLayers(frame); 4172 host_impl_->DidDrawAllLayers(frame);
4172 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame)); 4173 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame));
4173 } 4174 }
4174 }; 4175 };
4175 4176
4176 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { 4177 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) {
4177 scoped_ptr<SolidColorLayerImpl> root = 4178 scoped_ptr<SolidColorLayerImpl> root =
4178 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); 4179 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1);
4179 root->SetAnchorPoint(gfx::PointF()); 4180 root->SetAnchorPoint(gfx::PointF());
4180 root->SetPosition(gfx::PointF()); 4181 root->SetPosition(gfx::PointF());
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
4302 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4303 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4303 ASSERT_EQ(DrawQuad::RENDER_PASS, 4304 ASSERT_EQ(DrawQuad::RENDER_PASS,
4304 frame.render_passes[0]->quad_list[0]->material); 4305 frame.render_passes[0]->quad_list[0]->material);
4305 const RenderPassDrawQuad* render_pass_quad = 4306 const RenderPassDrawQuad* render_pass_quad =
4306 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4307 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4307 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4308 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4308 render_pass_quad->rect.ToString()); 4309 render_pass_quad->rect.ToString());
4309 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4310 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4310 render_pass_quad->mask_uv_rect.ToString()); 4311 render_pass_quad->mask_uv_rect.ToString());
4311 4312
4312 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4313 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4313 host_impl_->DidDrawAllLayers(frame); 4314 host_impl_->DidDrawAllLayers(frame);
4314 } 4315 }
4315 4316
4316 4317
4317 // Applying a DSF should change the render surface size, but won't affect 4318 // Applying a DSF should change the render surface size, but won't affect
4318 // which part of the mask is used. 4319 // which part of the mask is used.
4319 device_scale_factor = 2.f; 4320 device_scale_factor = 2.f;
4320 gfx::Size device_viewport = 4321 gfx::Size device_viewport =
4321 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); 4322 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor));
4322 host_impl_->SetViewportSize(device_viewport); 4323 host_impl_->SetViewportSize(device_viewport);
4323 host_impl_->SetDeviceScaleFactor(device_scale_factor); 4324 host_impl_->SetDeviceScaleFactor(device_scale_factor);
4324 host_impl_->active_tree()->set_needs_update_draw_properties(); 4325 host_impl_->active_tree()->set_needs_update_draw_properties();
4325 { 4326 {
4326 LayerTreeHostImpl::FrameData frame; 4327 LayerTreeHostImpl::FrameData frame;
4327 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4328 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4328 4329
4329 ASSERT_EQ(1u, frame.render_passes.size()); 4330 ASSERT_EQ(1u, frame.render_passes.size());
4330 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4331 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4331 ASSERT_EQ(DrawQuad::RENDER_PASS, 4332 ASSERT_EQ(DrawQuad::RENDER_PASS,
4332 frame.render_passes[0]->quad_list[0]->material); 4333 frame.render_passes[0]->quad_list[0]->material);
4333 const RenderPassDrawQuad* render_pass_quad = 4334 const RenderPassDrawQuad* render_pass_quad =
4334 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4335 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4335 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), 4336 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(),
4336 render_pass_quad->rect.ToString()); 4337 render_pass_quad->rect.ToString());
4337 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4338 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4338 render_pass_quad->mask_uv_rect.ToString()); 4339 render_pass_quad->mask_uv_rect.ToString());
4339 4340
4340 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4341 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4341 host_impl_->DidDrawAllLayers(frame); 4342 host_impl_->DidDrawAllLayers(frame);
4342 } 4343 }
4343 4344
4344 4345
4345 // Applying an equivalent content scale on the content layer and the mask 4346 // Applying an equivalent content scale on the content layer and the mask
4346 // should still result in the same part of the mask being used. 4347 // should still result in the same part of the mask being used.
4347 gfx::Size content_bounds = 4348 gfx::Size content_bounds =
4348 gfx::ToRoundedSize(gfx::ScaleSize(scaling_layer_size, 4349 gfx::ToRoundedSize(gfx::ScaleSize(scaling_layer_size,
4349 device_scale_factor)); 4350 device_scale_factor));
4350 content_layer->SetContentBounds(content_bounds); 4351 content_layer->SetContentBounds(content_bounds);
4351 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4352 content_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4352 mask_layer->SetContentBounds(content_bounds); 4353 mask_layer->SetContentBounds(content_bounds);
4353 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4354 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4354 host_impl_->active_tree()->set_needs_update_draw_properties(); 4355 host_impl_->active_tree()->set_needs_update_draw_properties();
4355 { 4356 {
4356 LayerTreeHostImpl::FrameData frame; 4357 LayerTreeHostImpl::FrameData frame;
4357 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4358 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4358 4359
4359 ASSERT_EQ(1u, frame.render_passes.size()); 4360 ASSERT_EQ(1u, frame.render_passes.size());
4360 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4361 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4361 ASSERT_EQ(DrawQuad::RENDER_PASS, 4362 ASSERT_EQ(DrawQuad::RENDER_PASS,
4362 frame.render_passes[0]->quad_list[0]->material); 4363 frame.render_passes[0]->quad_list[0]->material);
4363 const RenderPassDrawQuad* render_pass_quad = 4364 const RenderPassDrawQuad* render_pass_quad =
4364 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4365 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4365 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), 4366 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(),
4366 render_pass_quad->rect.ToString()); 4367 render_pass_quad->rect.ToString());
4367 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4368 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4368 render_pass_quad->mask_uv_rect.ToString()); 4369 render_pass_quad->mask_uv_rect.ToString());
4369 4370
4370 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4371 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4371 host_impl_->DidDrawAllLayers(frame); 4372 host_impl_->DidDrawAllLayers(frame);
4372 } 4373 }
4373 } 4374 }
4374 4375
4375 TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) { 4376 TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) {
4376 // The mask layer has bounds 100x100 but is attached to a layer with bounds 4377 // The mask layer has bounds 100x100 but is attached to a layer with bounds
4377 // 50x50. 4378 // 50x50.
4378 4379
4379 scoped_ptr<LayerImpl> scoped_root = 4380 scoped_ptr<LayerImpl> scoped_root =
4380 LayerImpl::Create(host_impl_->active_tree(), 1); 4381 LayerImpl::Create(host_impl_->active_tree(), 1);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
4423 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4424 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4424 ASSERT_EQ(DrawQuad::RENDER_PASS, 4425 ASSERT_EQ(DrawQuad::RENDER_PASS,
4425 frame.render_passes[0]->quad_list[0]->material); 4426 frame.render_passes[0]->quad_list[0]->material);
4426 const RenderPassDrawQuad* render_pass_quad = 4427 const RenderPassDrawQuad* render_pass_quad =
4427 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4428 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4428 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), 4429 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(),
4429 render_pass_quad->rect.ToString()); 4430 render_pass_quad->rect.ToString());
4430 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4431 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4431 render_pass_quad->mask_uv_rect.ToString()); 4432 render_pass_quad->mask_uv_rect.ToString());
4432 4433
4433 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4434 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4434 host_impl_->DidDrawAllLayers(frame); 4435 host_impl_->DidDrawAllLayers(frame);
4435 } 4436 }
4436 4437
4437 // Applying a DSF should change the render surface size, but won't affect 4438 // Applying a DSF should change the render surface size, but won't affect
4438 // which part of the mask is used. 4439 // which part of the mask is used.
4439 device_scale_factor = 2.f; 4440 device_scale_factor = 2.f;
4440 gfx::Size device_viewport = 4441 gfx::Size device_viewport =
4441 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); 4442 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor));
4442 host_impl_->SetViewportSize(device_viewport); 4443 host_impl_->SetViewportSize(device_viewport);
4443 host_impl_->SetDeviceScaleFactor(device_scale_factor); 4444 host_impl_->SetDeviceScaleFactor(device_scale_factor);
4444 host_impl_->active_tree()->set_needs_update_draw_properties(); 4445 host_impl_->active_tree()->set_needs_update_draw_properties();
4445 { 4446 {
4446 LayerTreeHostImpl::FrameData frame; 4447 LayerTreeHostImpl::FrameData frame;
4447 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4448 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4448 4449
4449 ASSERT_EQ(1u, frame.render_passes.size()); 4450 ASSERT_EQ(1u, frame.render_passes.size());
4450 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4451 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4451 ASSERT_EQ(DrawQuad::RENDER_PASS, 4452 ASSERT_EQ(DrawQuad::RENDER_PASS,
4452 frame.render_passes[0]->quad_list[0]->material); 4453 frame.render_passes[0]->quad_list[0]->material);
4453 const RenderPassDrawQuad* render_pass_quad = 4454 const RenderPassDrawQuad* render_pass_quad =
4454 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4455 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4455 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4456 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4456 render_pass_quad->rect.ToString()); 4457 render_pass_quad->rect.ToString());
4457 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(),
4458 render_pass_quad->mask_uv_rect.ToString()); 4459 render_pass_quad->mask_uv_rect.ToString());
4459 4460
4460 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4461 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4461 host_impl_->DidDrawAllLayers(frame); 4462 host_impl_->DidDrawAllLayers(frame);
4462 } 4463 }
4463 4464
4464 // Applying an equivalent content scale on the content layer and the mask 4465 // Applying an equivalent content scale on the content layer and the mask
4465 // should still result in the same part of the mask being used. 4466 // should still result in the same part of the mask being used.
4466 gfx::Size layer_size_large = 4467 gfx::Size layer_size_large =
4467 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor)); 4468 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor));
4468 content_layer->SetContentBounds(layer_size_large); 4469 content_layer->SetContentBounds(layer_size_large);
4469 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4470 content_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4470 gfx::Size mask_size_large = 4471 gfx::Size mask_size_large =
4471 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor)); 4472 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor));
4472 mask_layer->SetContentBounds(mask_size_large); 4473 mask_layer->SetContentBounds(mask_size_large);
4473 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4474 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4474 host_impl_->active_tree()->set_needs_update_draw_properties(); 4475 host_impl_->active_tree()->set_needs_update_draw_properties();
4475 { 4476 {
4476 LayerTreeHostImpl::FrameData frame; 4477 LayerTreeHostImpl::FrameData frame;
4477 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4478 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4478 4479
4479 ASSERT_EQ(1u, frame.render_passes.size()); 4480 ASSERT_EQ(1u, frame.render_passes.size());
4480 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4481 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4481 ASSERT_EQ(DrawQuad::RENDER_PASS, 4482 ASSERT_EQ(DrawQuad::RENDER_PASS,
4482 frame.render_passes[0]->quad_list[0]->material); 4483 frame.render_passes[0]->quad_list[0]->material);
4483 const RenderPassDrawQuad* render_pass_quad = 4484 const RenderPassDrawQuad* render_pass_quad =
4484 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4485 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4485 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4486 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4486 render_pass_quad->rect.ToString()); 4487 render_pass_quad->rect.ToString());
4487 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4488 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4488 render_pass_quad->mask_uv_rect.ToString()); 4489 render_pass_quad->mask_uv_rect.ToString());
4489 4490
4490 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4491 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4491 host_impl_->DidDrawAllLayers(frame); 4492 host_impl_->DidDrawAllLayers(frame);
4492 } 4493 }
4493 4494
4494 // Applying a different contents scale to the mask layer means it will have 4495 // Applying a different contents scale to the mask layer means it will have
4495 // a larger texture, but it should use the same tex coords to cover the 4496 // a larger texture, but it should use the same tex coords to cover the
4496 // layer it masks. 4497 // layer it masks.
4497 mask_layer->SetContentBounds(mask_size); 4498 mask_layer->SetContentBounds(mask_size);
4498 mask_layer->SetContentsScale(1.f, 1.f); 4499 mask_layer->SetContentsScale(1.f, 1.f);
4499 host_impl_->active_tree()->set_needs_update_draw_properties(); 4500 host_impl_->active_tree()->set_needs_update_draw_properties();
4500 { 4501 {
4501 LayerTreeHostImpl::FrameData frame; 4502 LayerTreeHostImpl::FrameData frame;
4502 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4503 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4503 4504
4504 ASSERT_EQ(1u, frame.render_passes.size()); 4505 ASSERT_EQ(1u, frame.render_passes.size());
4505 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4506 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4506 ASSERT_EQ(DrawQuad::RENDER_PASS, 4507 ASSERT_EQ(DrawQuad::RENDER_PASS,
4507 frame.render_passes[0]->quad_list[0]->material); 4508 frame.render_passes[0]->quad_list[0]->material);
4508 const RenderPassDrawQuad* render_pass_quad = 4509 const RenderPassDrawQuad* render_pass_quad =
4509 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4510 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4510 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4511 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4511 render_pass_quad->rect.ToString()); 4512 render_pass_quad->rect.ToString());
4512 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4513 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4513 render_pass_quad->mask_uv_rect.ToString()); 4514 render_pass_quad->mask_uv_rect.ToString());
4514 4515
4515 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4516 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4516 host_impl_->DidDrawAllLayers(frame); 4517 host_impl_->DidDrawAllLayers(frame);
4517 } 4518 }
4518 } 4519 }
4519 4520
4520 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) { 4521 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) {
4521 // The replica's mask layer has bounds 100x100 but the replica is of a 4522 // The replica's mask layer has bounds 100x100 but the replica is of a
4522 // layer with bounds 50x50. 4523 // layer with bounds 50x50.
4523 4524
4524 scoped_ptr<LayerImpl> scoped_root = 4525 scoped_ptr<LayerImpl> scoped_root =
4525 LayerImpl::Create(host_impl_->active_tree(), 1); 4526 LayerImpl::Create(host_impl_->active_tree(), 1);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
4574 ASSERT_EQ(DrawQuad::RENDER_PASS, 4575 ASSERT_EQ(DrawQuad::RENDER_PASS,
4575 frame.render_passes[0]->quad_list[1]->material); 4576 frame.render_passes[0]->quad_list[1]->material);
4576 const RenderPassDrawQuad* replica_quad = 4577 const RenderPassDrawQuad* replica_quad =
4577 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 4578 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
4578 EXPECT_TRUE(replica_quad->is_replica); 4579 EXPECT_TRUE(replica_quad->is_replica);
4579 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), 4580 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(),
4580 replica_quad->rect.ToString()); 4581 replica_quad->rect.ToString());
4581 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4582 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4582 replica_quad->mask_uv_rect.ToString()); 4583 replica_quad->mask_uv_rect.ToString());
4583 4584
4584 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4585 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4585 host_impl_->DidDrawAllLayers(frame); 4586 host_impl_->DidDrawAllLayers(frame);
4586 } 4587 }
4587 4588
4588 // Applying a DSF should change the render surface size, but won't affect 4589 // Applying a DSF should change the render surface size, but won't affect
4589 // which part of the mask is used. 4590 // which part of the mask is used.
4590 device_scale_factor = 2.f; 4591 device_scale_factor = 2.f;
4591 gfx::Size device_viewport = 4592 gfx::Size device_viewport =
4592 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); 4593 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor));
4593 host_impl_->SetViewportSize(device_viewport); 4594 host_impl_->SetViewportSize(device_viewport);
4594 host_impl_->SetDeviceScaleFactor(device_scale_factor); 4595 host_impl_->SetDeviceScaleFactor(device_scale_factor);
4595 host_impl_->active_tree()->set_needs_update_draw_properties(); 4596 host_impl_->active_tree()->set_needs_update_draw_properties();
4596 { 4597 {
4597 LayerTreeHostImpl::FrameData frame; 4598 LayerTreeHostImpl::FrameData frame;
4598 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4599 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4599 4600
4600 ASSERT_EQ(1u, frame.render_passes.size()); 4601 ASSERT_EQ(1u, frame.render_passes.size());
4601 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 4602 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
4602 ASSERT_EQ(DrawQuad::RENDER_PASS, 4603 ASSERT_EQ(DrawQuad::RENDER_PASS,
4603 frame.render_passes[0]->quad_list[1]->material); 4604 frame.render_passes[0]->quad_list[1]->material);
4604 const RenderPassDrawQuad* replica_quad = 4605 const RenderPassDrawQuad* replica_quad =
4605 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 4606 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
4606 EXPECT_TRUE(replica_quad->is_replica); 4607 EXPECT_TRUE(replica_quad->is_replica);
4607 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4608 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4608 replica_quad->rect.ToString()); 4609 replica_quad->rect.ToString());
4609 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4610 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4610 replica_quad->mask_uv_rect.ToString()); 4611 replica_quad->mask_uv_rect.ToString());
4611 4612
4612 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4613 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4613 host_impl_->DidDrawAllLayers(frame); 4614 host_impl_->DidDrawAllLayers(frame);
4614 } 4615 }
4615 4616
4616 // Applying an equivalent content scale on the content layer and the mask 4617 // Applying an equivalent content scale on the content layer and the mask
4617 // should still result in the same part of the mask being used. 4618 // should still result in the same part of the mask being used.
4618 gfx::Size layer_size_large = 4619 gfx::Size layer_size_large =
4619 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor)); 4620 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor));
4620 content_layer->SetContentBounds(layer_size_large); 4621 content_layer->SetContentBounds(layer_size_large);
4621 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4622 content_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4622 gfx::Size mask_size_large = 4623 gfx::Size mask_size_large =
(...skipping 10 matching lines...) Expand all
4633 ASSERT_EQ(DrawQuad::RENDER_PASS, 4634 ASSERT_EQ(DrawQuad::RENDER_PASS,
4634 frame.render_passes[0]->quad_list[1]->material); 4635 frame.render_passes[0]->quad_list[1]->material);
4635 const RenderPassDrawQuad* replica_quad = 4636 const RenderPassDrawQuad* replica_quad =
4636 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 4637 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
4637 EXPECT_TRUE(replica_quad->is_replica); 4638 EXPECT_TRUE(replica_quad->is_replica);
4638 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4639 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4639 replica_quad->rect.ToString()); 4640 replica_quad->rect.ToString());
4640 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4641 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4641 replica_quad->mask_uv_rect.ToString()); 4642 replica_quad->mask_uv_rect.ToString());
4642 4643
4643 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4644 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4644 host_impl_->DidDrawAllLayers(frame); 4645 host_impl_->DidDrawAllLayers(frame);
4645 } 4646 }
4646 4647
4647 // Applying a different contents scale to the mask layer means it will have 4648 // Applying a different contents scale to the mask layer means it will have
4648 // a larger texture, but it should use the same tex coords to cover the 4649 // a larger texture, but it should use the same tex coords to cover the
4649 // layer it masks. 4650 // layer it masks.
4650 mask_layer->SetContentBounds(mask_size); 4651 mask_layer->SetContentBounds(mask_size);
4651 mask_layer->SetContentsScale(1.f, 1.f); 4652 mask_layer->SetContentsScale(1.f, 1.f);
4652 host_impl_->active_tree()->set_needs_update_draw_properties(); 4653 host_impl_->active_tree()->set_needs_update_draw_properties();
4653 { 4654 {
4654 LayerTreeHostImpl::FrameData frame; 4655 LayerTreeHostImpl::FrameData frame;
4655 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4656 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4656 4657
4657 ASSERT_EQ(1u, frame.render_passes.size()); 4658 ASSERT_EQ(1u, frame.render_passes.size());
4658 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 4659 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
4659 ASSERT_EQ(DrawQuad::RENDER_PASS, 4660 ASSERT_EQ(DrawQuad::RENDER_PASS,
4660 frame.render_passes[0]->quad_list[1]->material); 4661 frame.render_passes[0]->quad_list[1]->material);
4661 const RenderPassDrawQuad* replica_quad = 4662 const RenderPassDrawQuad* replica_quad =
4662 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 4663 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
4663 EXPECT_TRUE(replica_quad->is_replica); 4664 EXPECT_TRUE(replica_quad->is_replica);
4664 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4665 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4665 replica_quad->rect.ToString()); 4666 replica_quad->rect.ToString());
4666 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4667 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4667 replica_quad->mask_uv_rect.ToString()); 4668 replica_quad->mask_uv_rect.ToString());
4668 4669
4669 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4670 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4670 host_impl_->DidDrawAllLayers(frame); 4671 host_impl_->DidDrawAllLayers(frame);
4671 } 4672 }
4672 } 4673 }
4673 4674
4674 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) { 4675 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) {
4675 // The replica is of a layer with bounds 50x50, but it has a child that causes 4676 // The replica is of a layer with bounds 50x50, but it has a child that causes
4676 // the surface bounds to be larger. 4677 // the surface bounds to be larger.
4677 4678
4678 scoped_ptr<LayerImpl> scoped_root = 4679 scoped_ptr<LayerImpl> scoped_root =
4679 LayerImpl::Create(host_impl_->active_tree(), 1); 4680 LayerImpl::Create(host_impl_->active_tree(), 1);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
4750 ASSERT_EQ(DrawQuad::RENDER_PASS, 4751 ASSERT_EQ(DrawQuad::RENDER_PASS,
4751 frame.render_passes[0]->quad_list[1]->material); 4752 frame.render_passes[0]->quad_list[1]->material);
4752 const RenderPassDrawQuad* replica_quad = 4753 const RenderPassDrawQuad* replica_quad =
4753 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 4754 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
4754 EXPECT_TRUE(replica_quad->is_replica); 4755 EXPECT_TRUE(replica_quad->is_replica);
4755 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), 4756 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(),
4756 replica_quad->rect.ToString()); 4757 replica_quad->rect.ToString());
4757 EXPECT_EQ(gfx::RectF(0.f, 0.f, 2.f, 1.f).ToString(), 4758 EXPECT_EQ(gfx::RectF(0.f, 0.f, 2.f, 1.f).ToString(),
4758 replica_quad->mask_uv_rect.ToString()); 4759 replica_quad->mask_uv_rect.ToString());
4759 4760
4760 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4761 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4761 host_impl_->DidDrawAllLayers(frame); 4762 host_impl_->DidDrawAllLayers(frame);
4762 } 4763 }
4763 4764
4764 // Move the child to (-50, 0) instead. Now the mask should be moved to still 4765 // Move the child to (-50, 0) instead. Now the mask should be moved to still
4765 // cover the layer being replicated. 4766 // cover the layer being replicated.
4766 content_child_layer->SetPosition(gfx::Point(-50, 0)); 4767 content_child_layer->SetPosition(gfx::Point(-50, 0));
4767 { 4768 {
4768 LayerTreeHostImpl::FrameData frame; 4769 LayerTreeHostImpl::FrameData frame;
4769 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4770 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4770 4771
(...skipping 13 matching lines...) Expand all
4784 ASSERT_EQ(DrawQuad::RENDER_PASS, 4785 ASSERT_EQ(DrawQuad::RENDER_PASS,
4785 frame.render_passes[0]->quad_list[1]->material); 4786 frame.render_passes[0]->quad_list[1]->material);
4786 const RenderPassDrawQuad* replica_quad = 4787 const RenderPassDrawQuad* replica_quad =
4787 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 4788 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
4788 EXPECT_TRUE(replica_quad->is_replica); 4789 EXPECT_TRUE(replica_quad->is_replica);
4789 EXPECT_EQ(gfx::Rect(-50, 0, 100, 50).ToString(), 4790 EXPECT_EQ(gfx::Rect(-50, 0, 100, 50).ToString(),
4790 replica_quad->rect.ToString()); 4791 replica_quad->rect.ToString());
4791 EXPECT_EQ(gfx::RectF(-1.f, 0.f, 2.f, 1.f).ToString(), 4792 EXPECT_EQ(gfx::RectF(-1.f, 0.f, 2.f, 1.f).ToString(),
4792 replica_quad->mask_uv_rect.ToString()); 4793 replica_quad->mask_uv_rect.ToString());
4793 4794
4794 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4795 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4795 host_impl_->DidDrawAllLayers(frame); 4796 host_impl_->DidDrawAllLayers(frame);
4796 } 4797 }
4797 } 4798 }
4798 4799
4799 TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) { 4800 TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) {
4800 // The masked layer has bounds 50x50, but it has a child that causes 4801 // The masked layer has bounds 50x50, but it has a child that causes
4801 // the surface bounds to be larger. It also has a parent that clips the 4802 // the surface bounds to be larger. It also has a parent that clips the
4802 // masked layer and its surface. 4803 // masked layer and its surface.
4803 4804
4804 scoped_ptr<LayerImpl> scoped_root = 4805 scoped_ptr<LayerImpl> scoped_root =
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
4880 render_pass_quad->rect.ToString()); 4881 render_pass_quad->rect.ToString());
4881 4882
4882 // The masked layer is 50x50, but the surface size is 10x20. So the texture 4883 // The masked layer is 50x50, but the surface size is 10x20. So the texture
4883 // coords in the mask are scaled by 10/50 and 20/50. 4884 // coords in the mask are scaled by 10/50 and 20/50.
4884 // The surface is clipped to (20,10) so the mask texture coords are offset 4885 // The surface is clipped to (20,10) so the mask texture coords are offset
4885 // by 20/50 and 10/50 4886 // by 20/50 and 10/50
4886 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f), 4887 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f),
4887 1.f / 50.f).ToString(), 4888 1.f / 50.f).ToString(),
4888 render_pass_quad->mask_uv_rect.ToString()); 4889 render_pass_quad->mask_uv_rect.ToString());
4889 4890
4890 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4891 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4891 host_impl_->DidDrawAllLayers(frame); 4892 host_impl_->DidDrawAllLayers(frame);
4892 } 4893 }
4893 } 4894 }
4894 4895
4895 class GLRendererWithSetupQuadForAntialiasing : public GLRenderer { 4896 class GLRendererWithSetupQuadForAntialiasing : public GLRenderer {
4896 public: 4897 public:
4897 using GLRenderer::SetupQuadForAntialiasing; 4898 using GLRenderer::SetupQuadForAntialiasing;
4898 }; 4899 };
4899 4900
4900 TEST_F(LayerTreeHostImplTest, FarAwayQuadsDontNeedAA) { 4901 TEST_F(LayerTreeHostImplTest, FarAwayQuadsDontNeedAA) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
4953 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); 4954 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size());
4954 const DrawQuad* quad = frame.render_passes[0]->quad_list[0]; 4955 const DrawQuad* quad = frame.render_passes[0]->quad_list[0];
4955 4956
4956 float edge[24]; 4957 float edge[24];
4957 gfx::QuadF device_layer_quad; 4958 gfx::QuadF device_layer_quad;
4958 bool antialiased = 4959 bool antialiased =
4959 GLRendererWithSetupQuadForAntialiasing::SetupQuadForAntialiasing( 4960 GLRendererWithSetupQuadForAntialiasing::SetupQuadForAntialiasing(
4960 quad->quadTransform(), quad, &device_layer_quad, edge); 4961 quad->quadTransform(), quad, &device_layer_quad, edge);
4961 EXPECT_FALSE(antialiased); 4962 EXPECT_FALSE(antialiased);
4962 4963
4963 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4964 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4964 host_impl_->DidDrawAllLayers(frame); 4965 host_impl_->DidDrawAllLayers(frame);
4965 } 4966 }
4966 4967
4967 4968
4968 class CompositorFrameMetadataTest : public LayerTreeHostImplTest { 4969 class CompositorFrameMetadataTest : public LayerTreeHostImplTest {
4969 public: 4970 public:
4970 CompositorFrameMetadataTest() 4971 CompositorFrameMetadataTest()
4971 : swap_buffers_complete_(0) {} 4972 : swap_buffers_complete_(0) {}
4972 4973
4973 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE { 4974 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
5054 scoped_ptr<VideoLayerImpl> video_layer = 5055 scoped_ptr<VideoLayerImpl> video_layer =
5055 VideoLayerImpl::Create(host_impl_->active_tree(), 2, &provider); 5056 VideoLayerImpl::Create(host_impl_->active_tree(), 2, &provider);
5056 video_layer->SetBounds(gfx::Size(10, 10)); 5057 video_layer->SetBounds(gfx::Size(10, 10));
5057 video_layer->SetContentBounds(gfx::Size(10, 10)); 5058 video_layer->SetContentBounds(gfx::Size(10, 10));
5058 video_layer->SetDrawsContent(true); 5059 video_layer->SetDrawsContent(true);
5059 root_layer->AddChild(video_layer.PassAs<LayerImpl>()); 5060 root_layer->AddChild(video_layer.PassAs<LayerImpl>());
5060 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>()); 5061 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>());
5061 5062
5062 LayerTreeHostImpl::FrameData frame; 5063 LayerTreeHostImpl::FrameData frame;
5063 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 5064 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5064 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 5065 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5065 host_impl_->DidDrawAllLayers(frame); 5066 host_impl_->DidDrawAllLayers(frame);
5066 5067
5067 EXPECT_EQ(1u, frame.will_draw_layers.size()); 5068 EXPECT_EQ(1u, frame.will_draw_layers.size());
5068 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]); 5069 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]);
5069 } 5070 }
5070 5071
5071 class LayerTreeHostImplTestDeferredInitialize : public LayerTreeHostImplTest { 5072 class LayerTreeHostImplTestDeferredInitialize : public LayerTreeHostImplTest {
5072 protected: 5073 protected:
5073 virtual void SetUp() OVERRIDE { 5074 virtual void SetUp() OVERRIDE {
5074 LayerTreeHostImplTest::SetUp(); 5075 LayerTreeHostImplTest::SetUp();
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
5342 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); 5343 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1));
5343 5344
5344 ScopedPtrVector<CopyOutputRequest> requests; 5345 ScopedPtrVector<CopyOutputRequest> requests;
5345 requests.push_back(CopyOutputRequest::CreateRequest( 5346 requests.push_back(CopyOutputRequest::CreateRequest(
5346 base::Bind(&ShutdownReleasesContext_Callback))); 5347 base::Bind(&ShutdownReleasesContext_Callback)));
5347 5348
5348 host_impl_->active_tree()->root_layer()->PassCopyRequests(&requests); 5349 host_impl_->active_tree()->root_layer()->PassCopyRequests(&requests);
5349 5350
5350 LayerTreeHostImpl::FrameData frame; 5351 LayerTreeHostImpl::FrameData frame;
5351 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 5352 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5352 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 5353 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5353 host_impl_->DidDrawAllLayers(frame); 5354 host_impl_->DidDrawAllLayers(frame);
5354 5355
5355 // The CopyOutputResult's callback has a ref on the ContextProvider and a 5356 // The CopyOutputResult's callback has a ref on the ContextProvider and a
5356 // texture in a texture mailbox. 5357 // texture in a texture mailbox.
5357 EXPECT_FALSE(context_provider->HasOneRef()); 5358 EXPECT_FALSE(context_provider->HasOneRef());
5358 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); 5359 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures());
5359 5360
5360 host_impl_.reset(); 5361 host_impl_.reset();
5361 5362
5362 // The CopyOutputResult's callback was cancelled, the CopyOutputResult 5363 // The CopyOutputResult's callback was cancelled, the CopyOutputResult
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
5484 // The root should have scrolled. 5485 // The root should have scrolled.
5485 ASSERT_EQ(2u, scroll_info->scrolls.size()); 5486 ASSERT_EQ(2u, scroll_info->scrolls.size());
5486 ExpectContains(*scroll_info.get(), 5487 ExpectContains(*scroll_info.get(),
5487 host_impl_->active_tree()->root_layer()->id(), 5488 host_impl_->active_tree()->root_layer()->id(),
5488 gfx::Vector2d(0, 10)); 5489 gfx::Vector2d(0, 10));
5489 } 5490 }
5490 } 5491 }
5491 5492
5492 } // namespace 5493 } // namespace
5493 } // namespace cc 5494 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698