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

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 frame_time.h 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 } 267 }
267 268
268 void InitializeRendererAndDrawFrame() { 269 void InitializeRendererAndDrawFrame() {
269 host_impl_->InitializeRenderer(CreateOutputSurface()); 270 host_impl_->InitializeRenderer(CreateOutputSurface());
270 DrawFrame(); 271 DrawFrame();
271 } 272 }
272 273
273 void DrawFrame() { 274 void DrawFrame() {
274 LayerTreeHostImpl::FrameData frame; 275 LayerTreeHostImpl::FrameData frame;
275 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 276 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
276 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 277 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
277 host_impl_->DidDrawAllLayers(frame); 278 host_impl_->DidDrawAllLayers(frame);
278 } 279 }
279 280
280 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor); 281 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor);
281 void pinch_zoom_pan_viewport_test(float device_scale_factor); 282 void pinch_zoom_pan_viewport_test(float device_scale_factor);
282 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); 283 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor);
283 void pinch_zoom_pan_viewport_and_scroll_boundary_test( 284 void pinch_zoom_pan_viewport_and_scroll_boundary_test(
284 float device_scale_factor); 285 float device_scale_factor);
285 286
286 void CheckNotifyCalledIfCanDrawChanged(bool always_draw) { 287 void CheckNotifyCalledIfCanDrawChanged(bool always_draw) {
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 scroll->SetVerticalScrollbarLayer(scrollbar.get()); 1154 scroll->SetVerticalScrollbarLayer(scrollbar.get());
1154 1155
1155 scroll->AddChild(contents.Pass()); 1156 scroll->AddChild(contents.Pass());
1156 root->AddChild(scroll.Pass()); 1157 root->AddChild(scroll.Pass());
1157 root->AddChild(scrollbar.PassAs<LayerImpl>()); 1158 root->AddChild(scrollbar.PassAs<LayerImpl>());
1158 1159
1159 host_impl_->active_tree()->SetRootLayer(root.Pass()); 1160 host_impl_->active_tree()->SetRootLayer(root.Pass());
1160 host_impl_->active_tree()->DidBecomeActive(); 1161 host_impl_->active_tree()->DidBecomeActive();
1161 InitializeRendererAndDrawFrame(); 1162 InitializeRendererAndDrawFrame();
1162 1163
1163 base::TimeTicks fake_now = base::TimeTicks::Now(); 1164 base::TimeTicks fake_now = gfx::FrameTime::Now();
1164 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); 1165 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now);
1165 1166
1166 // If no scroll happened recently, StartScrollbarAnimation should have no 1167 // If no scroll happened recently, StartScrollbarAnimation should have no
1167 // effect. 1168 // effect.
1168 host_impl_->StartScrollbarAnimation(); 1169 host_impl_->StartScrollbarAnimation();
1169 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); 1170 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_);
1170 EXPECT_FALSE(did_request_redraw_); 1171 EXPECT_FALSE(did_request_redraw_);
1171 1172
1172 // If no scroll happened during a scroll gesture, StartScrollbarAnimation 1173 // If no scroll happened during a scroll gesture, StartScrollbarAnimation
1173 // should have no effect. 1174 // should have no effect.
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( 1453 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(
1453 host_impl_->active_tree()->root_layer()); 1454 host_impl_->active_tree()->root_layer());
1454 1455
1455 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); 1456 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
1456 DidDrawCheckLayer* layer = 1457 DidDrawCheckLayer* layer =
1457 static_cast<DidDrawCheckLayer*>(root->children()[0]); 1458 static_cast<DidDrawCheckLayer*>(root->children()[0]);
1458 1459
1459 { 1460 {
1460 LayerTreeHostImpl::FrameData frame; 1461 LayerTreeHostImpl::FrameData frame;
1461 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10))); 1462 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10)));
1462 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1463 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1463 host_impl_->DidDrawAllLayers(frame); 1464 host_impl_->DidDrawAllLayers(frame);
1464 1465
1465 EXPECT_TRUE(layer->will_draw_called()); 1466 EXPECT_TRUE(layer->will_draw_called());
1466 EXPECT_TRUE(layer->append_quads_called()); 1467 EXPECT_TRUE(layer->append_quads_called());
1467 EXPECT_TRUE(layer->did_draw_called()); 1468 EXPECT_TRUE(layer->did_draw_called());
1468 } 1469 }
1469 1470
1470 { 1471 {
1471 LayerTreeHostImpl::FrameData frame; 1472 LayerTreeHostImpl::FrameData frame;
1472 1473
1473 layer->set_will_draw_returns_false(); 1474 layer->set_will_draw_returns_false();
1474 layer->ClearDidDrawCheck(); 1475 layer->ClearDidDrawCheck();
1475 1476
1476 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10))); 1477 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10)));
1477 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1478 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1478 host_impl_->DidDrawAllLayers(frame); 1479 host_impl_->DidDrawAllLayers(frame);
1479 1480
1480 EXPECT_TRUE(layer->will_draw_called()); 1481 EXPECT_TRUE(layer->will_draw_called());
1481 EXPECT_FALSE(layer->append_quads_called()); 1482 EXPECT_FALSE(layer->append_quads_called());
1482 EXPECT_FALSE(layer->did_draw_called()); 1483 EXPECT_FALSE(layer->did_draw_called());
1483 } 1484 }
1484 } 1485 }
1485 1486
1486 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { 1487 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) {
1487 // The root layer is always drawn, so run this test on a child layer that 1488 // The root layer is always drawn, so run this test on a child layer that
(...skipping 11 matching lines...) Expand all
1499 layer->SetPosition(gfx::PointF(100.f, 100.f)); 1500 layer->SetPosition(gfx::PointF(100.f, 100.f));
1500 layer->SetBounds(gfx::Size(10, 10)); 1501 layer->SetBounds(gfx::Size(10, 10));
1501 layer->SetContentBounds(gfx::Size(10, 10)); 1502 layer->SetContentBounds(gfx::Size(10, 10));
1502 1503
1503 LayerTreeHostImpl::FrameData frame; 1504 LayerTreeHostImpl::FrameData frame;
1504 1505
1505 EXPECT_FALSE(layer->will_draw_called()); 1506 EXPECT_FALSE(layer->will_draw_called());
1506 EXPECT_FALSE(layer->did_draw_called()); 1507 EXPECT_FALSE(layer->did_draw_called());
1507 1508
1508 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1509 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1509 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1510 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1510 host_impl_->DidDrawAllLayers(frame); 1511 host_impl_->DidDrawAllLayers(frame);
1511 1512
1512 EXPECT_FALSE(layer->will_draw_called()); 1513 EXPECT_FALSE(layer->will_draw_called());
1513 EXPECT_FALSE(layer->did_draw_called()); 1514 EXPECT_FALSE(layer->did_draw_called());
1514 1515
1515 EXPECT_TRUE(layer->visible_content_rect().IsEmpty()); 1516 EXPECT_TRUE(layer->visible_content_rect().IsEmpty());
1516 1517
1517 // Ensure visible_content_rect for layer is not empty 1518 // Ensure visible_content_rect for layer is not empty
1518 layer->SetPosition(gfx::PointF()); 1519 layer->SetPosition(gfx::PointF());
1519 1520
1520 EXPECT_FALSE(layer->will_draw_called()); 1521 EXPECT_FALSE(layer->will_draw_called());
1521 EXPECT_FALSE(layer->did_draw_called()); 1522 EXPECT_FALSE(layer->did_draw_called());
1522 1523
1523 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1524 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1524 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1525 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1525 host_impl_->DidDrawAllLayers(frame); 1526 host_impl_->DidDrawAllLayers(frame);
1526 1527
1527 EXPECT_TRUE(layer->will_draw_called()); 1528 EXPECT_TRUE(layer->will_draw_called());
1528 EXPECT_TRUE(layer->did_draw_called()); 1529 EXPECT_TRUE(layer->did_draw_called());
1529 1530
1530 EXPECT_FALSE(layer->visible_content_rect().IsEmpty()); 1531 EXPECT_FALSE(layer->visible_content_rect().IsEmpty());
1531 } 1532 }
1532 1533
1533 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { 1534 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) {
1534 gfx::Size big_size(1000, 1000); 1535 gfx::Size big_size(1000, 1000);
(...skipping 18 matching lines...) Expand all
1553 top_layer->SetContentsOpaque(true); 1554 top_layer->SetContentsOpaque(true);
1554 1555
1555 LayerTreeHostImpl::FrameData frame; 1556 LayerTreeHostImpl::FrameData frame;
1556 1557
1557 EXPECT_FALSE(occluded_layer->will_draw_called()); 1558 EXPECT_FALSE(occluded_layer->will_draw_called());
1558 EXPECT_FALSE(occluded_layer->did_draw_called()); 1559 EXPECT_FALSE(occluded_layer->did_draw_called());
1559 EXPECT_FALSE(top_layer->will_draw_called()); 1560 EXPECT_FALSE(top_layer->will_draw_called());
1560 EXPECT_FALSE(top_layer->did_draw_called()); 1561 EXPECT_FALSE(top_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(occluded_layer->will_draw_called()); 1567 EXPECT_FALSE(occluded_layer->will_draw_called());
1567 EXPECT_FALSE(occluded_layer->did_draw_called()); 1568 EXPECT_FALSE(occluded_layer->did_draw_called());
1568 EXPECT_TRUE(top_layer->will_draw_called()); 1569 EXPECT_TRUE(top_layer->will_draw_called());
1569 EXPECT_TRUE(top_layer->did_draw_called()); 1570 EXPECT_TRUE(top_layer->did_draw_called());
1570 } 1571 }
1571 1572
1572 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { 1573 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) {
1573 host_impl_->active_tree()->SetRootLayer( 1574 host_impl_->active_tree()->SetRootLayer(
(...skipping 11 matching lines...) Expand all
1585 1586
1586 layer1->SetOpacity(0.3f); 1587 layer1->SetOpacity(0.3f);
1587 layer1->SetPreserves3d(false); 1588 layer1->SetPreserves3d(false);
1588 1589
1589 EXPECT_FALSE(root->did_draw_called()); 1590 EXPECT_FALSE(root->did_draw_called());
1590 EXPECT_FALSE(layer1->did_draw_called()); 1591 EXPECT_FALSE(layer1->did_draw_called());
1591 EXPECT_FALSE(layer2->did_draw_called()); 1592 EXPECT_FALSE(layer2->did_draw_called());
1592 1593
1593 LayerTreeHostImpl::FrameData frame; 1594 LayerTreeHostImpl::FrameData frame;
1594 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1595 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1595 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1596 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1596 host_impl_->DidDrawAllLayers(frame); 1597 host_impl_->DidDrawAllLayers(frame);
1597 1598
1598 EXPECT_TRUE(root->did_draw_called()); 1599 EXPECT_TRUE(root->did_draw_called());
1599 EXPECT_TRUE(layer1->did_draw_called()); 1600 EXPECT_TRUE(layer1->did_draw_called());
1600 EXPECT_TRUE(layer2->did_draw_called()); 1601 EXPECT_TRUE(layer2->did_draw_called());
1601 1602
1602 EXPECT_NE(root->render_surface(), layer1->render_surface()); 1603 EXPECT_NE(root->render_surface(), layer1->render_surface());
1603 EXPECT_TRUE(!!layer1->render_surface()); 1604 EXPECT_TRUE(!!layer1->render_surface());
1604 } 1605 }
1605 1606
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1658 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1659 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1659 2, 1660 2,
1660 false, 1661 false,
1661 false, 1662 false,
1662 true, 1663 true,
1663 host_impl_->resource_provider())); 1664 host_impl_->resource_provider()));
1664 1665
1665 LayerTreeHostImpl::FrameData frame; 1666 LayerTreeHostImpl::FrameData frame;
1666 1667
1667 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1668 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1668 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1669 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1669 host_impl_->DidDrawAllLayers(frame); 1670 host_impl_->DidDrawAllLayers(frame);
1670 1671
1671 // When a texture is missing and we're not animating, we draw as usual with 1672 // When a texture is missing and we're not animating, we draw as usual with
1672 // checkerboarding. 1673 // checkerboarding.
1673 host_impl_->active_tree()->SetRootLayer( 1674 host_impl_->active_tree()->SetRootLayer(
1674 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); 1675 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3));
1675 root = 1676 root =
1676 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1677 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1677 root->AddChild( 1678 root->AddChild(
1678 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1679 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1679 4, 1680 4,
1680 true, 1681 true,
1681 false, 1682 false,
1682 false, 1683 false,
1683 host_impl_->resource_provider())); 1684 host_impl_->resource_provider()));
1684 1685
1685 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1686 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1686 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1687 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1687 host_impl_->DidDrawAllLayers(frame); 1688 host_impl_->DidDrawAllLayers(frame);
1688 1689
1689 // When a texture is missing and we're animating, we don't want to draw 1690 // When a texture is missing and we're animating, we don't want to draw
1690 // anything. 1691 // anything.
1691 host_impl_->active_tree()->SetRootLayer( 1692 host_impl_->active_tree()->SetRootLayer(
1692 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); 1693 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5));
1693 root = 1694 root =
1694 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1695 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1695 root->AddChild( 1696 root->AddChild(
1696 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1697 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1697 6, 1698 6,
1698 true, 1699 true,
1699 false, 1700 false,
1700 true, 1701 true,
1701 host_impl_->resource_provider())); 1702 host_impl_->resource_provider()));
1702 1703
1703 EXPECT_FALSE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1704 EXPECT_FALSE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1704 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1705 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1705 host_impl_->DidDrawAllLayers(frame); 1706 host_impl_->DidDrawAllLayers(frame);
1706 1707
1707 // When the layer skips draw and we're animating, we still draw the frame. 1708 // When the layer skips draw and we're animating, we still draw the frame.
1708 host_impl_->active_tree()->SetRootLayer( 1709 host_impl_->active_tree()->SetRootLayer(
1709 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 1710 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
1710 root = 1711 root =
1711 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1712 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1712 root->AddChild( 1713 root->AddChild(
1713 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1714 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1714 8, 1715 8,
1715 false, 1716 false,
1716 true, 1717 true,
1717 true, 1718 true,
1718 host_impl_->resource_provider())); 1719 host_impl_->resource_provider()));
1719 1720
1720 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1721 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1721 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1722 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1722 host_impl_->DidDrawAllLayers(frame); 1723 host_impl_->DidDrawAllLayers(frame);
1723 } 1724 }
1724 1725
1725 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { 1726 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) {
1726 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 1727 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
1727 root->SetScrollable(false); 1728 root->SetScrollable(false);
1728 host_impl_->active_tree()->SetRootLayer(root.Pass()); 1729 host_impl_->active_tree()->SetRootLayer(root.Pass());
1729 InitializeRendererAndDrawFrame(); 1730 InitializeRendererAndDrawFrame();
1730 1731
1731 // Scroll event is ignored because layer is not scrollable. 1732 // Scroll event is ignored because layer is not scrollable.
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
2007 EXPECT_EQ(1.f, scroll->contents_scale_y()); 2008 EXPECT_EQ(1.f, scroll->contents_scale_y());
2008 EXPECT_EQ(1.f, child->contents_scale_x()); 2009 EXPECT_EQ(1.f, child->contents_scale_x());
2009 EXPECT_EQ(1.f, child->contents_scale_y()); 2010 EXPECT_EQ(1.f, child->contents_scale_y());
2010 EXPECT_EQ(1.f, grand_child->contents_scale_x()); 2011 EXPECT_EQ(1.f, grand_child->contents_scale_x());
2011 EXPECT_EQ(1.f, grand_child->contents_scale_y()); 2012 EXPECT_EQ(1.f, grand_child->contents_scale_y());
2012 2013
2013 // Make sure all the layers are drawn with the page scale delta applied, i.e., 2014 // Make sure all the layers are drawn with the page scale delta applied, i.e.,
2014 // the page scale delta on the root layer is applied hierarchically. 2015 // the page scale delta on the root layer is applied hierarchically.
2015 LayerTreeHostImpl::FrameData frame; 2016 LayerTreeHostImpl::FrameData frame;
2016 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2017 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2017 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2018 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2018 host_impl_->DidDrawAllLayers(frame); 2019 host_impl_->DidDrawAllLayers(frame);
2019 2020
2020 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(0, 0)); 2021 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(0, 0));
2021 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(1, 1)); 2022 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(1, 1));
2022 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(0, 0)); 2023 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(0, 0));
2023 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(1, 1)); 2024 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(1, 1));
2024 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(0, 0)); 2025 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(0, 0));
2025 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(1, 1)); 2026 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(1, 1));
2026 EXPECT_EQ(new_page_scale, 2027 EXPECT_EQ(new_page_scale,
2027 grand_child->draw_transform().matrix().getDouble(0, 0)); 2028 grand_child->draw_transform().matrix().getDouble(0, 0));
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
2842 static_cast<BlendStateCheckLayer*>(root->children()[0]); 2843 static_cast<BlendStateCheckLayer*>(root->children()[0]);
2843 layer1->SetPosition(gfx::PointF(2.f, 2.f)); 2844 layer1->SetPosition(gfx::PointF(2.f, 2.f));
2844 2845
2845 LayerTreeHostImpl::FrameData frame; 2846 LayerTreeHostImpl::FrameData frame;
2846 2847
2847 // Opaque layer, drawn without blending. 2848 // Opaque layer, drawn without blending.
2848 layer1->SetContentsOpaque(true); 2849 layer1->SetContentsOpaque(true);
2849 layer1->SetExpectation(false, false); 2850 layer1->SetExpectation(false, false);
2850 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2851 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2851 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2852 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2852 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2853 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2853 EXPECT_TRUE(layer1->quads_appended()); 2854 EXPECT_TRUE(layer1->quads_appended());
2854 host_impl_->DidDrawAllLayers(frame); 2855 host_impl_->DidDrawAllLayers(frame);
2855 2856
2856 // Layer with translucent content and painting, so drawn with blending. 2857 // Layer with translucent content and painting, so drawn with blending.
2857 layer1->SetContentsOpaque(false); 2858 layer1->SetContentsOpaque(false);
2858 layer1->SetExpectation(true, false); 2859 layer1->SetExpectation(true, false);
2859 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2860 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2860 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2861 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2861 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2862 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2862 EXPECT_TRUE(layer1->quads_appended()); 2863 EXPECT_TRUE(layer1->quads_appended());
2863 host_impl_->DidDrawAllLayers(frame); 2864 host_impl_->DidDrawAllLayers(frame);
2864 2865
2865 // Layer with translucent opacity, drawn with blending. 2866 // Layer with translucent opacity, drawn with blending.
2866 layer1->SetContentsOpaque(true); 2867 layer1->SetContentsOpaque(true);
2867 layer1->SetOpacity(0.5f); 2868 layer1->SetOpacity(0.5f);
2868 layer1->SetExpectation(true, false); 2869 layer1->SetExpectation(true, false);
2869 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2870 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2870 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2871 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2871 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2872 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2872 EXPECT_TRUE(layer1->quads_appended()); 2873 EXPECT_TRUE(layer1->quads_appended());
2873 host_impl_->DidDrawAllLayers(frame); 2874 host_impl_->DidDrawAllLayers(frame);
2874 2875
2875 // Layer with translucent opacity and painting, drawn with blending. 2876 // Layer with translucent opacity and painting, drawn with blending.
2876 layer1->SetContentsOpaque(true); 2877 layer1->SetContentsOpaque(true);
2877 layer1->SetOpacity(0.5f); 2878 layer1->SetOpacity(0.5f);
2878 layer1->SetExpectation(true, false); 2879 layer1->SetExpectation(true, false);
2879 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2880 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2880 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2881 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2881 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2882 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2882 EXPECT_TRUE(layer1->quads_appended()); 2883 EXPECT_TRUE(layer1->quads_appended());
2883 host_impl_->DidDrawAllLayers(frame); 2884 host_impl_->DidDrawAllLayers(frame);
2884 2885
2885 layer1->AddChild( 2886 layer1->AddChild(
2886 BlendStateCheckLayer::Create(host_impl_->active_tree(), 2887 BlendStateCheckLayer::Create(host_impl_->active_tree(),
2887 3, 2888 3,
2888 host_impl_->resource_provider())); 2889 host_impl_->resource_provider()));
2889 BlendStateCheckLayer* layer2 = 2890 BlendStateCheckLayer* layer2 =
2890 static_cast<BlendStateCheckLayer*>(layer1->children()[0]); 2891 static_cast<BlendStateCheckLayer*>(layer1->children()[0]);
2891 layer2->SetPosition(gfx::PointF(4.f, 4.f)); 2892 layer2->SetPosition(gfx::PointF(4.f, 4.f));
2892 2893
2893 // 2 opaque layers, drawn without blending. 2894 // 2 opaque layers, drawn without blending.
2894 layer1->SetContentsOpaque(true); 2895 layer1->SetContentsOpaque(true);
2895 layer1->SetOpacity(1.f); 2896 layer1->SetOpacity(1.f);
2896 layer1->SetExpectation(false, false); 2897 layer1->SetExpectation(false, false);
2897 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2898 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2898 layer2->SetContentsOpaque(true); 2899 layer2->SetContentsOpaque(true);
2899 layer2->SetOpacity(1.f); 2900 layer2->SetOpacity(1.f);
2900 layer2->SetExpectation(false, false); 2901 layer2->SetExpectation(false, false);
2901 layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); 2902 layer2->set_update_rect(gfx::RectF(layer1->content_bounds()));
2902 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2903 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2903 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2904 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2904 EXPECT_TRUE(layer1->quads_appended()); 2905 EXPECT_TRUE(layer1->quads_appended());
2905 EXPECT_TRUE(layer2->quads_appended()); 2906 EXPECT_TRUE(layer2->quads_appended());
2906 host_impl_->DidDrawAllLayers(frame); 2907 host_impl_->DidDrawAllLayers(frame);
2907 2908
2908 // Parent layer with translucent content, drawn with blending. 2909 // Parent layer with translucent content, drawn with blending.
2909 // Child layer with opaque content, drawn without blending. 2910 // Child layer with opaque content, drawn without blending.
2910 layer1->SetContentsOpaque(false); 2911 layer1->SetContentsOpaque(false);
2911 layer1->SetExpectation(true, false); 2912 layer1->SetExpectation(true, false);
2912 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2913 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2913 layer2->SetExpectation(false, false); 2914 layer2->SetExpectation(false, false);
2914 layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); 2915 layer2->set_update_rect(gfx::RectF(layer1->content_bounds()));
2915 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2916 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2916 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2917 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2917 EXPECT_TRUE(layer1->quads_appended()); 2918 EXPECT_TRUE(layer1->quads_appended());
2918 EXPECT_TRUE(layer2->quads_appended()); 2919 EXPECT_TRUE(layer2->quads_appended());
2919 host_impl_->DidDrawAllLayers(frame); 2920 host_impl_->DidDrawAllLayers(frame);
2920 2921
2921 // Parent layer with translucent content but opaque painting, drawn without 2922 // Parent layer with translucent content but opaque painting, drawn without
2922 // blending. 2923 // blending.
2923 // Child layer with opaque content, drawn without blending. 2924 // Child layer with opaque content, drawn without blending.
2924 layer1->SetContentsOpaque(true); 2925 layer1->SetContentsOpaque(true);
2925 layer1->SetExpectation(false, false); 2926 layer1->SetExpectation(false, false);
2926 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2927 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2927 layer2->SetExpectation(false, false); 2928 layer2->SetExpectation(false, false);
2928 layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); 2929 layer2->set_update_rect(gfx::RectF(layer1->content_bounds()));
2929 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2930 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2930 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2931 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2931 EXPECT_TRUE(layer1->quads_appended()); 2932 EXPECT_TRUE(layer1->quads_appended());
2932 EXPECT_TRUE(layer2->quads_appended()); 2933 EXPECT_TRUE(layer2->quads_appended());
2933 host_impl_->DidDrawAllLayers(frame); 2934 host_impl_->DidDrawAllLayers(frame);
2934 2935
2935 // Parent layer with translucent opacity and opaque content. Since it has a 2936 // Parent layer with translucent opacity and opaque content. Since it has a
2936 // drawing child, it's drawn to a render surface which carries the opacity, 2937 // drawing child, it's drawn to a render surface which carries the opacity,
2937 // so it's itself drawn without blending. 2938 // so it's itself drawn without blending.
2938 // Child layer with opaque content, drawn without blending (parent surface 2939 // Child layer with opaque content, drawn without blending (parent surface
2939 // carries the inherited opacity). 2940 // carries the inherited opacity).
2940 layer1->SetContentsOpaque(true); 2941 layer1->SetContentsOpaque(true);
2941 layer1->SetOpacity(0.5f); 2942 layer1->SetOpacity(0.5f);
2942 layer1->SetExpectation(false, true); 2943 layer1->SetExpectation(false, true);
2943 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2944 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2944 layer2->SetExpectation(false, false); 2945 layer2->SetExpectation(false, false);
2945 layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); 2946 layer2->set_update_rect(gfx::RectF(layer1->content_bounds()));
2946 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2947 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2947 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2948 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2948 EXPECT_TRUE(layer1->quads_appended()); 2949 EXPECT_TRUE(layer1->quads_appended());
2949 EXPECT_TRUE(layer2->quads_appended()); 2950 EXPECT_TRUE(layer2->quads_appended());
2950 host_impl_->DidDrawAllLayers(frame); 2951 host_impl_->DidDrawAllLayers(frame);
2951 2952
2952 // Draw again, but with child non-opaque, to make sure 2953 // Draw again, but with child non-opaque, to make sure
2953 // layer1 not culled. 2954 // layer1 not culled.
2954 layer1->SetContentsOpaque(true); 2955 layer1->SetContentsOpaque(true);
2955 layer1->SetOpacity(1.f); 2956 layer1->SetOpacity(1.f);
2956 layer1->SetExpectation(false, false); 2957 layer1->SetExpectation(false, false);
2957 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2958 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2958 layer2->SetContentsOpaque(true); 2959 layer2->SetContentsOpaque(true);
2959 layer2->SetOpacity(0.5f); 2960 layer2->SetOpacity(0.5f);
2960 layer2->SetExpectation(true, false); 2961 layer2->SetExpectation(true, false);
2961 layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); 2962 layer2->set_update_rect(gfx::RectF(layer1->content_bounds()));
2962 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2963 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2963 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2964 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2964 EXPECT_TRUE(layer1->quads_appended()); 2965 EXPECT_TRUE(layer1->quads_appended());
2965 EXPECT_TRUE(layer2->quads_appended()); 2966 EXPECT_TRUE(layer2->quads_appended());
2966 host_impl_->DidDrawAllLayers(frame); 2967 host_impl_->DidDrawAllLayers(frame);
2967 2968
2968 // A second way of making the child non-opaque. 2969 // A second way of making the child non-opaque.
2969 layer1->SetContentsOpaque(true); 2970 layer1->SetContentsOpaque(true);
2970 layer1->SetOpacity(1.f); 2971 layer1->SetOpacity(1.f);
2971 layer1->SetExpectation(false, false); 2972 layer1->SetExpectation(false, false);
2972 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2973 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2973 layer2->SetContentsOpaque(false); 2974 layer2->SetContentsOpaque(false);
2974 layer2->SetOpacity(1.f); 2975 layer2->SetOpacity(1.f);
2975 layer2->SetExpectation(true, false); 2976 layer2->SetExpectation(true, false);
2976 layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); 2977 layer2->set_update_rect(gfx::RectF(layer1->content_bounds()));
2977 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2978 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2978 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2979 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2979 EXPECT_TRUE(layer1->quads_appended()); 2980 EXPECT_TRUE(layer1->quads_appended());
2980 EXPECT_TRUE(layer2->quads_appended()); 2981 EXPECT_TRUE(layer2->quads_appended());
2981 host_impl_->DidDrawAllLayers(frame); 2982 host_impl_->DidDrawAllLayers(frame);
2982 2983
2983 // And when the layer says its not opaque but is painted opaque, it is not 2984 // And when the layer says its not opaque but is painted opaque, it is not
2984 // blended. 2985 // blended.
2985 layer1->SetContentsOpaque(true); 2986 layer1->SetContentsOpaque(true);
2986 layer1->SetOpacity(1.f); 2987 layer1->SetOpacity(1.f);
2987 layer1->SetExpectation(false, false); 2988 layer1->SetExpectation(false, false);
2988 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2989 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2989 layer2->SetContentsOpaque(true); 2990 layer2->SetContentsOpaque(true);
2990 layer2->SetOpacity(1.f); 2991 layer2->SetOpacity(1.f);
2991 layer2->SetExpectation(false, false); 2992 layer2->SetExpectation(false, false);
2992 layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); 2993 layer2->set_update_rect(gfx::RectF(layer1->content_bounds()));
2993 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2994 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2994 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2995 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2995 EXPECT_TRUE(layer1->quads_appended()); 2996 EXPECT_TRUE(layer1->quads_appended());
2996 EXPECT_TRUE(layer2->quads_appended()); 2997 EXPECT_TRUE(layer2->quads_appended());
2997 host_impl_->DidDrawAllLayers(frame); 2998 host_impl_->DidDrawAllLayers(frame);
2998 2999
2999 // Layer with partially opaque contents, drawn with blending. 3000 // Layer with partially opaque contents, drawn with blending.
3000 layer1->SetContentsOpaque(false); 3001 layer1->SetContentsOpaque(false);
3001 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3002 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3002 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); 3003 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5));
3003 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3004 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3004 layer1->SetExpectation(true, false); 3005 layer1->SetExpectation(true, false);
3005 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 3006 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
3006 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3007 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3007 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3008 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3008 EXPECT_TRUE(layer1->quads_appended()); 3009 EXPECT_TRUE(layer1->quads_appended());
3009 host_impl_->DidDrawAllLayers(frame); 3010 host_impl_->DidDrawAllLayers(frame);
3010 3011
3011 // Layer with partially opaque contents partially culled, drawn with blending. 3012 // Layer with partially opaque contents partially culled, drawn with blending.
3012 layer1->SetContentsOpaque(false); 3013 layer1->SetContentsOpaque(false);
3013 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3014 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3014 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); 3015 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2));
3015 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3016 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3016 layer1->SetExpectation(true, false); 3017 layer1->SetExpectation(true, false);
3017 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 3018 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
3018 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3019 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3019 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3020 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3020 EXPECT_TRUE(layer1->quads_appended()); 3021 EXPECT_TRUE(layer1->quads_appended());
3021 host_impl_->DidDrawAllLayers(frame); 3022 host_impl_->DidDrawAllLayers(frame);
3022 3023
3023 // Layer with partially opaque contents culled, drawn with blending. 3024 // Layer with partially opaque contents culled, drawn with blending.
3024 layer1->SetContentsOpaque(false); 3025 layer1->SetContentsOpaque(false);
3025 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3026 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3026 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); 3027 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5));
3027 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3028 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3028 layer1->SetExpectation(true, false); 3029 layer1->SetExpectation(true, false);
3029 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 3030 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
3030 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3031 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3031 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3032 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3032 EXPECT_TRUE(layer1->quads_appended()); 3033 EXPECT_TRUE(layer1->quads_appended());
3033 host_impl_->DidDrawAllLayers(frame); 3034 host_impl_->DidDrawAllLayers(frame);
3034 3035
3035 // Layer with partially opaque contents and translucent contents culled, drawn 3036 // Layer with partially opaque contents and translucent contents culled, drawn
3036 // without blending. 3037 // without blending.
3037 layer1->SetContentsOpaque(false); 3038 layer1->SetContentsOpaque(false);
3038 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3039 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3039 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); 3040 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5));
3040 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3041 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
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 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3044 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3044 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3045 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3045 EXPECT_TRUE(layer1->quads_appended()); 3046 EXPECT_TRUE(layer1->quads_appended());
3046 host_impl_->DidDrawAllLayers(frame); 3047 host_impl_->DidDrawAllLayers(frame);
3047 } 3048 }
3048 3049
3049 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { 3050 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest {
3050 public: 3051 public:
3051 LayerTreeHostImplViewportCoveredTest() : 3052 LayerTreeHostImplViewportCoveredTest() :
3052 gutter_quad_material_(DrawQuad::SOLID_COLOR), 3053 gutter_quad_material_(DrawQuad::SOLID_COLOR),
3053 child_(NULL), 3054 child_(NULL),
3054 did_activate_pending_tree_(false) {} 3055 did_activate_pending_tree_(false) {}
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
3392 root->SetContentBounds(gfx::Size(10, 10)); 3393 root->SetContentBounds(gfx::Size(10, 10));
3393 root->SetDrawsContent(true); 3394 root->SetDrawsContent(true);
3394 host_impl_->active_tree()->SetRootLayer(root.Pass()); 3395 host_impl_->active_tree()->SetRootLayer(root.Pass());
3395 EXPECT_FALSE(reshape_tracker->reshape_called()); 3396 EXPECT_FALSE(reshape_tracker->reshape_called());
3396 reshape_tracker->clear_reshape_called(); 3397 reshape_tracker->clear_reshape_called();
3397 3398
3398 LayerTreeHostImpl::FrameData frame; 3399 LayerTreeHostImpl::FrameData frame;
3399 host_impl_->SetViewportSize(gfx::Size(10, 10)); 3400 host_impl_->SetViewportSize(gfx::Size(10, 10));
3400 host_impl_->SetDeviceScaleFactor(1.f); 3401 host_impl_->SetDeviceScaleFactor(1.f);
3401 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3402 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3402 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3403 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3403 EXPECT_TRUE(reshape_tracker->reshape_called()); 3404 EXPECT_TRUE(reshape_tracker->reshape_called());
3404 EXPECT_EQ(reshape_tracker->last_reshape_width(), 10); 3405 EXPECT_EQ(reshape_tracker->last_reshape_width(), 10);
3405 EXPECT_EQ(reshape_tracker->last_reshape_height(), 10); 3406 EXPECT_EQ(reshape_tracker->last_reshape_height(), 10);
3406 EXPECT_EQ(reshape_tracker->last_reshape_scale_factor(), 1.f); 3407 EXPECT_EQ(reshape_tracker->last_reshape_scale_factor(), 1.f);
3407 host_impl_->DidDrawAllLayers(frame); 3408 host_impl_->DidDrawAllLayers(frame);
3408 reshape_tracker->clear_reshape_called(); 3409 reshape_tracker->clear_reshape_called();
3409 3410
3410 host_impl_->SetViewportSize(gfx::Size(20, 30)); 3411 host_impl_->SetViewportSize(gfx::Size(20, 30));
3411 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3412 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3412 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3413 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3413 EXPECT_TRUE(reshape_tracker->reshape_called()); 3414 EXPECT_TRUE(reshape_tracker->reshape_called());
3414 EXPECT_EQ(reshape_tracker->last_reshape_width(), 20); 3415 EXPECT_EQ(reshape_tracker->last_reshape_width(), 20);
3415 EXPECT_EQ(reshape_tracker->last_reshape_height(), 30); 3416 EXPECT_EQ(reshape_tracker->last_reshape_height(), 30);
3416 EXPECT_EQ(reshape_tracker->last_reshape_scale_factor(), 1.f); 3417 EXPECT_EQ(reshape_tracker->last_reshape_scale_factor(), 1.f);
3417 host_impl_->DidDrawAllLayers(frame); 3418 host_impl_->DidDrawAllLayers(frame);
3418 reshape_tracker->clear_reshape_called(); 3419 reshape_tracker->clear_reshape_called();
3419 3420
3420 host_impl_->SetDeviceScaleFactor(2.f); 3421 host_impl_->SetDeviceScaleFactor(2.f);
3421 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3422 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3422 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3423 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3423 EXPECT_TRUE(reshape_tracker->reshape_called()); 3424 EXPECT_TRUE(reshape_tracker->reshape_called());
3424 EXPECT_EQ(reshape_tracker->last_reshape_width(), 20); 3425 EXPECT_EQ(reshape_tracker->last_reshape_width(), 20);
3425 EXPECT_EQ(reshape_tracker->last_reshape_height(), 30); 3426 EXPECT_EQ(reshape_tracker->last_reshape_height(), 30);
3426 EXPECT_EQ(reshape_tracker->last_reshape_scale_factor(), 2.f); 3427 EXPECT_EQ(reshape_tracker->last_reshape_scale_factor(), 2.f);
3427 host_impl_->DidDrawAllLayers(frame); 3428 host_impl_->DidDrawAllLayers(frame);
3428 reshape_tracker->clear_reshape_called(); 3429 reshape_tracker->clear_reshape_called();
3429 } 3430 }
3430 3431
3431 class SwapTrackerContext : public TestWebGraphicsContext3D { 3432 class SwapTrackerContext : public TestWebGraphicsContext3D {
3432 public: 3433 public:
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
3498 root->SetBounds(gfx::Size(500, 500)); 3499 root->SetBounds(gfx::Size(500, 500));
3499 root->SetContentBounds(gfx::Size(500, 500)); 3500 root->SetContentBounds(gfx::Size(500, 500));
3500 root->SetDrawsContent(true); 3501 root->SetDrawsContent(true);
3501 root->AddChild(child.Pass()); 3502 root->AddChild(child.Pass());
3502 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass()); 3503 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass());
3503 3504
3504 LayerTreeHostImpl::FrameData frame; 3505 LayerTreeHostImpl::FrameData frame;
3505 3506
3506 // First frame, the entire screen should get swapped. 3507 // First frame, the entire screen should get swapped.
3507 EXPECT_TRUE(layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect())); 3508 EXPECT_TRUE(layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect()));
3508 layer_tree_host_impl->DrawLayers(&frame, base::TimeTicks::Now()); 3509 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
3509 layer_tree_host_impl->DidDrawAllLayers(frame); 3510 layer_tree_host_impl->DidDrawAllLayers(frame);
3510 layer_tree_host_impl->SwapBuffers(frame); 3511 layer_tree_host_impl->SwapBuffers(frame);
3511 gfx::Rect actual_swap_rect = swap_tracker->update_rect(); 3512 gfx::Rect actual_swap_rect = swap_tracker->update_rect();
3512 gfx::Rect expected_swap_rect = gfx::Rect(0, 0, 500, 500); 3513 gfx::Rect expected_swap_rect = gfx::Rect(0, 0, 500, 500);
3513 EXPECT_EQ(expected_swap_rect.x(), actual_swap_rect.x()); 3514 EXPECT_EQ(expected_swap_rect.x(), actual_swap_rect.x());
3514 EXPECT_EQ(expected_swap_rect.y(), actual_swap_rect.y()); 3515 EXPECT_EQ(expected_swap_rect.y(), actual_swap_rect.y());
3515 EXPECT_EQ(expected_swap_rect.width(), actual_swap_rect.width()); 3516 EXPECT_EQ(expected_swap_rect.width(), actual_swap_rect.width());
3516 EXPECT_EQ(expected_swap_rect.height(), actual_swap_rect.height()); 3517 EXPECT_EQ(expected_swap_rect.height(), actual_swap_rect.height());
3517 EXPECT_EQ(swap_tracker->last_update_type(), 3518 EXPECT_EQ(swap_tracker->last_update_type(),
3518 SwapTrackerContext::PrepareTexture); 3519 SwapTrackerContext::PrepareTexture);
3519 // Second frame, only the damaged area should get swapped. Damage should be 3520 // Second frame, only the damaged area should get swapped. Damage should be
3520 // the union of old and new child rects. 3521 // the union of old and new child rects.
3521 // expected damage rect: gfx::Rect(26, 28); 3522 // expected damage rect: gfx::Rect(26, 28);
3522 // expected swap rect: vertically flipped, with origin at bottom left corner. 3523 // expected swap rect: vertically flipped, with origin at bottom left corner.
3523 layer_tree_host_impl->active_tree()->root_layer()->children()[0]->SetPosition( 3524 layer_tree_host_impl->active_tree()->root_layer()->children()[0]->SetPosition(
3524 gfx::PointF()); 3525 gfx::PointF());
3525 EXPECT_TRUE(layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect())); 3526 EXPECT_TRUE(layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect()));
3526 layer_tree_host_impl->DrawLayers(&frame, base::TimeTicks::Now()); 3527 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
3527 host_impl_->DidDrawAllLayers(frame); 3528 host_impl_->DidDrawAllLayers(frame);
3528 layer_tree_host_impl->SwapBuffers(frame); 3529 layer_tree_host_impl->SwapBuffers(frame);
3529 actual_swap_rect = swap_tracker->update_rect(); 3530 actual_swap_rect = swap_tracker->update_rect();
3530 expected_swap_rect = gfx::Rect(0, 500-28, 26, 28); 3531 expected_swap_rect = gfx::Rect(0, 500-28, 26, 28);
3531 EXPECT_EQ(expected_swap_rect.x(), actual_swap_rect.x()); 3532 EXPECT_EQ(expected_swap_rect.x(), actual_swap_rect.x());
3532 EXPECT_EQ(expected_swap_rect.y(), actual_swap_rect.y()); 3533 EXPECT_EQ(expected_swap_rect.y(), actual_swap_rect.y());
3533 EXPECT_EQ(expected_swap_rect.width(), actual_swap_rect.width()); 3534 EXPECT_EQ(expected_swap_rect.width(), actual_swap_rect.width());
3534 EXPECT_EQ(expected_swap_rect.height(), actual_swap_rect.height()); 3535 EXPECT_EQ(expected_swap_rect.height(), actual_swap_rect.height());
3535 EXPECT_EQ(swap_tracker->last_update_type(), 3536 EXPECT_EQ(swap_tracker->last_update_type(),
3536 SwapTrackerContext::PostSubBuffer); 3537 SwapTrackerContext::PostSubBuffer);
3537 3538
3538 // Make sure that partial swap is constrained to the viewport dimensions 3539 // Make sure that partial swap is constrained to the viewport dimensions
3539 // expected damage rect: gfx::Rect(500, 500); 3540 // expected damage rect: gfx::Rect(500, 500);
3540 // expected swap rect: flipped damage rect, but also clamped to viewport 3541 // expected swap rect: flipped damage rect, but also clamped to viewport
3541 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10)); 3542 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10));
3542 // This will damage everything. 3543 // This will damage everything.
3543 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor( 3544 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor(
3544 SK_ColorBLACK); 3545 SK_ColorBLACK);
3545 EXPECT_TRUE(layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect())); 3546 EXPECT_TRUE(layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect()));
3546 layer_tree_host_impl->DrawLayers(&frame, base::TimeTicks::Now()); 3547 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
3547 host_impl_->DidDrawAllLayers(frame); 3548 host_impl_->DidDrawAllLayers(frame);
3548 layer_tree_host_impl->SwapBuffers(frame); 3549 layer_tree_host_impl->SwapBuffers(frame);
3549 actual_swap_rect = swap_tracker->update_rect(); 3550 actual_swap_rect = swap_tracker->update_rect();
3550 expected_swap_rect = gfx::Rect(10, 10); 3551 expected_swap_rect = gfx::Rect(10, 10);
3551 EXPECT_EQ(expected_swap_rect.x(), actual_swap_rect.x()); 3552 EXPECT_EQ(expected_swap_rect.x(), actual_swap_rect.x());
3552 EXPECT_EQ(expected_swap_rect.y(), actual_swap_rect.y()); 3553 EXPECT_EQ(expected_swap_rect.y(), actual_swap_rect.y());
3553 EXPECT_EQ(expected_swap_rect.width(), actual_swap_rect.width()); 3554 EXPECT_EQ(expected_swap_rect.width(), actual_swap_rect.width());
3554 EXPECT_EQ(expected_swap_rect.height(), actual_swap_rect.height()); 3555 EXPECT_EQ(expected_swap_rect.height(), actual_swap_rect.height());
3555 EXPECT_EQ(swap_tracker->last_update_type(), 3556 EXPECT_EQ(swap_tracker->last_update_type(),
3556 SwapTrackerContext::PrepareTexture); 3557 SwapTrackerContext::PrepareTexture);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
3704 // Run test case 3705 // Run test case
3705 CreateLayerTreeHost(false, output_surface.Pass()); 3706 CreateLayerTreeHost(false, output_surface.Pass());
3706 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); 3707 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
3707 3708
3708 // Without partial swap, and no clipping, no scissor is set. 3709 // Without partial swap, and no clipping, no scissor is set.
3709 harness.MustDrawSolidQuad(); 3710 harness.MustDrawSolidQuad();
3710 harness.MustSetNoScissor(); 3711 harness.MustSetNoScissor();
3711 { 3712 {
3712 LayerTreeHostImpl::FrameData frame; 3713 LayerTreeHostImpl::FrameData frame;
3713 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3714 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3714 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3715 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3715 host_impl_->DidDrawAllLayers(frame); 3716 host_impl_->DidDrawAllLayers(frame);
3716 } 3717 }
3717 Mock::VerifyAndClearExpectations(&mock_context); 3718 Mock::VerifyAndClearExpectations(&mock_context);
3718 3719
3719 // Without partial swap, but a layer does clip its subtree, one scissor is 3720 // Without partial swap, but a layer does clip its subtree, one scissor is
3720 // set. 3721 // set.
3721 host_impl_->active_tree()->root_layer()->SetMasksToBounds(true); 3722 host_impl_->active_tree()->root_layer()->SetMasksToBounds(true);
3722 harness.MustDrawSolidQuad(); 3723 harness.MustDrawSolidQuad();
3723 harness.MustSetScissor(0, 0, 10, 10); 3724 harness.MustSetScissor(0, 0, 10, 10);
3724 { 3725 {
3725 LayerTreeHostImpl::FrameData frame; 3726 LayerTreeHostImpl::FrameData frame;
3726 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3727 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3727 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3728 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3728 host_impl_->DidDrawAllLayers(frame); 3729 host_impl_->DidDrawAllLayers(frame);
3729 } 3730 }
3730 Mock::VerifyAndClearExpectations(&mock_context); 3731 Mock::VerifyAndClearExpectations(&mock_context);
3731 } 3732 }
3732 3733
3733 TEST_F(LayerTreeHostImplTest, PartialSwap) { 3734 TEST_F(LayerTreeHostImplTest, PartialSwap) {
3734 scoped_ptr<MockContext> context_owned(new MockContext); 3735 scoped_ptr<MockContext> context_owned(new MockContext);
3735 MockContext* mock_context = context_owned.get(); 3736 MockContext* mock_context = context_owned.get();
3736 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 3737 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
3737 context_owned.PassAs<TestWebGraphicsContext3D>())); 3738 context_owned.PassAs<TestWebGraphicsContext3D>()));
3738 MockContextHarness harness(mock_context); 3739 MockContextHarness harness(mock_context);
3739 3740
3740 CreateLayerTreeHost(true, output_surface.Pass()); 3741 CreateLayerTreeHost(true, output_surface.Pass());
3741 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); 3742 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
3742 3743
3743 // The first frame is not a partially-swapped one. 3744 // The first frame is not a partially-swapped one.
3744 harness.MustSetScissor(0, 0, 10, 10); 3745 harness.MustSetScissor(0, 0, 10, 10);
3745 harness.MustDrawSolidQuad(); 3746 harness.MustDrawSolidQuad();
3746 { 3747 {
3747 LayerTreeHostImpl::FrameData frame; 3748 LayerTreeHostImpl::FrameData frame;
3748 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3749 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3749 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3750 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3750 host_impl_->DidDrawAllLayers(frame); 3751 host_impl_->DidDrawAllLayers(frame);
3751 } 3752 }
3752 Mock::VerifyAndClearExpectations(&mock_context); 3753 Mock::VerifyAndClearExpectations(&mock_context);
3753 3754
3754 // Damage a portion of the frame. 3755 // Damage a portion of the frame.
3755 host_impl_->active_tree()->root_layer()->set_update_rect( 3756 host_impl_->active_tree()->root_layer()->set_update_rect(
3756 gfx::Rect(0, 0, 2, 3)); 3757 gfx::Rect(0, 0, 2, 3));
3757 3758
3758 // The second frame will be partially-swapped (the y coordinates are flipped). 3759 // The second frame will be partially-swapped (the y coordinates are flipped).
3759 harness.MustSetScissor(0, 7, 2, 3); 3760 harness.MustSetScissor(0, 7, 2, 3);
3760 harness.MustDrawSolidQuad(); 3761 harness.MustDrawSolidQuad();
3761 { 3762 {
3762 LayerTreeHostImpl::FrameData frame; 3763 LayerTreeHostImpl::FrameData frame;
3763 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3764 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3764 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3765 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3765 host_impl_->DidDrawAllLayers(frame); 3766 host_impl_->DidDrawAllLayers(frame);
3766 } 3767 }
3767 Mock::VerifyAndClearExpectations(&mock_context); 3768 Mock::VerifyAndClearExpectations(&mock_context);
3768 } 3769 }
3769 3770
3770 class PartialSwapContext : public TestWebGraphicsContext3D { 3771 class PartialSwapContext : public TestWebGraphicsContext3D {
3771 public: 3772 public:
3772 PartialSwapContext() { 3773 PartialSwapContext() {
3773 test_capabilities_.post_sub_buffer = true; 3774 test_capabilities_.post_sub_buffer = true;
3774 } 3775 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
3868 3869
3869 // Verify all quads have been computed 3870 // Verify all quads have been computed
3870 ASSERT_EQ(2U, frame.render_passes.size()); 3871 ASSERT_EQ(2U, frame.render_passes.size());
3871 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 3872 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
3872 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 3873 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
3873 EXPECT_EQ(DrawQuad::SOLID_COLOR, 3874 EXPECT_EQ(DrawQuad::SOLID_COLOR,
3874 frame.render_passes[0]->quad_list[0]->material); 3875 frame.render_passes[0]->quad_list[0]->material);
3875 EXPECT_EQ(DrawQuad::RENDER_PASS, 3876 EXPECT_EQ(DrawQuad::RENDER_PASS,
3876 frame.render_passes[1]->quad_list[0]->material); 3877 frame.render_passes[1]->quad_list[0]->material);
3877 3878
3878 my_host_impl->DrawLayers(&frame, base::TimeTicks::Now()); 3879 my_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
3879 my_host_impl->DidDrawAllLayers(frame); 3880 my_host_impl->DidDrawAllLayers(frame);
3880 } 3881 }
3881 } 3882 }
3882 3883
3883 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { 3884 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) {
3884 scoped_ptr<LayerTreeHostImpl> my_host_impl = 3885 scoped_ptr<LayerTreeHostImpl> my_host_impl =
3885 SetupLayersForOpacity(false, this, &proxy_, &stats_instrumentation_); 3886 SetupLayersForOpacity(false, this, &proxy_, &stats_instrumentation_);
3886 { 3887 {
3887 LayerTreeHostImpl::FrameData frame; 3888 LayerTreeHostImpl::FrameData frame;
3888 EXPECT_TRUE(my_host_impl->PrepareToDraw(&frame, gfx::Rect())); 3889 EXPECT_TRUE(my_host_impl->PrepareToDraw(&frame, gfx::Rect()));
3889 3890
3890 // Verify all quads have been computed 3891 // Verify all quads have been computed
3891 ASSERT_EQ(2U, frame.render_passes.size()); 3892 ASSERT_EQ(2U, frame.render_passes.size());
3892 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 3893 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
3893 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 3894 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
3894 EXPECT_EQ(DrawQuad::SOLID_COLOR, 3895 EXPECT_EQ(DrawQuad::SOLID_COLOR,
3895 frame.render_passes[0]->quad_list[0]->material); 3896 frame.render_passes[0]->quad_list[0]->material);
3896 EXPECT_EQ(DrawQuad::RENDER_PASS, 3897 EXPECT_EQ(DrawQuad::RENDER_PASS,
3897 frame.render_passes[1]->quad_list[0]->material); 3898 frame.render_passes[1]->quad_list[0]->material);
3898 3899
3899 my_host_impl->DrawLayers(&frame, base::TimeTicks::Now()); 3900 my_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
3900 my_host_impl->DidDrawAllLayers(frame); 3901 my_host_impl->DidDrawAllLayers(frame);
3901 } 3902 }
3902 } 3903 }
3903 3904
3904 // Fake WebKit::WebGraphicsContext3D that tracks the number of textures in use. 3905 // Fake WebKit::WebGraphicsContext3D that tracks the number of textures in use.
3905 class TrackingWebGraphicsContext3D : public TestWebGraphicsContext3D { 3906 class TrackingWebGraphicsContext3D : public TestWebGraphicsContext3D {
3906 public: 3907 public:
3907 TrackingWebGraphicsContext3D() 3908 TrackingWebGraphicsContext3D()
3908 : TestWebGraphicsContext3D(), 3909 : TestWebGraphicsContext3D(),
3909 num_textures_(0) { 3910 num_textures_(0) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
3968 io_surface_layer->SetDrawsContent(true); 3969 io_surface_layer->SetDrawsContent(true);
3969 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10)); 3970 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10));
3970 root_layer->AddChild(io_surface_layer.PassAs<LayerImpl>()); 3971 root_layer->AddChild(io_surface_layer.PassAs<LayerImpl>());
3971 3972
3972 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); 3973 host_impl_->active_tree()->SetRootLayer(root_layer.Pass());
3973 3974
3974 EXPECT_EQ(0u, context3d->NumTextures()); 3975 EXPECT_EQ(0u, context3d->NumTextures());
3975 3976
3976 LayerTreeHostImpl::FrameData frame; 3977 LayerTreeHostImpl::FrameData frame;
3977 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3978 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3978 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3979 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3979 host_impl_->DidDrawAllLayers(frame); 3980 host_impl_->DidDrawAllLayers(frame);
3980 host_impl_->SwapBuffers(frame); 3981 host_impl_->SwapBuffers(frame);
3981 3982
3982 EXPECT_GT(context3d->NumTextures(), 0u); 3983 EXPECT_GT(context3d->NumTextures(), 0u);
3983 3984
3984 // Kill the layer tree. 3985 // Kill the layer tree.
3985 host_impl_->active_tree()->SetRootLayer( 3986 host_impl_->active_tree()->SetRootLayer(
3986 LayerImpl::Create(host_impl_->active_tree(), 100)); 3987 LayerImpl::Create(host_impl_->active_tree(), 100));
3987 // There should be no textures left in use after. 3988 // There should be no textures left in use after.
3988 EXPECT_EQ(0u, context3d->NumTextures()); 3989 EXPECT_EQ(0u, context3d->NumTextures());
(...skipping 22 matching lines...) Expand all
4011 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); 4012 host_impl_->active_tree()->set_background_color(SK_ColorWHITE);
4012 4013
4013 // Verify one quad is drawn when transparent background set is not set. 4014 // Verify one quad is drawn when transparent background set is not set.
4014 host_impl_->active_tree()->set_has_transparent_background(false); 4015 host_impl_->active_tree()->set_has_transparent_background(false);
4015 EXPECT_CALL(*mock_context, useProgram(_)) 4016 EXPECT_CALL(*mock_context, useProgram(_))
4016 .Times(1); 4017 .Times(1);
4017 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) 4018 EXPECT_CALL(*mock_context, drawElements(_, _, _, _))
4018 .Times(1); 4019 .Times(1);
4019 LayerTreeHostImpl::FrameData frame; 4020 LayerTreeHostImpl::FrameData frame;
4020 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4021 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4021 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4022 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4022 host_impl_->DidDrawAllLayers(frame); 4023 host_impl_->DidDrawAllLayers(frame);
4023 Mock::VerifyAndClearExpectations(&mock_context); 4024 Mock::VerifyAndClearExpectations(&mock_context);
4024 4025
4025 // Verify no quads are drawn when transparent background is set. 4026 // Verify no quads are drawn when transparent background is set.
4026 host_impl_->active_tree()->set_has_transparent_background(true); 4027 host_impl_->active_tree()->set_has_transparent_background(true);
4027 host_impl_->SetFullRootLayerDamage(); 4028 host_impl_->SetFullRootLayerDamage();
4028 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4029 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4029 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4030 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4030 host_impl_->DidDrawAllLayers(frame); 4031 host_impl_->DidDrawAllLayers(frame);
4031 Mock::VerifyAndClearExpectations(&mock_context); 4032 Mock::VerifyAndClearExpectations(&mock_context);
4032 } 4033 }
4033 4034
4034 TEST_F(LayerTreeHostImplTest, ReleaseContentsTextureShouldTriggerCommit) { 4035 TEST_F(LayerTreeHostImplTest, ReleaseContentsTextureShouldTriggerCommit) {
4035 set_reduce_memory_result(false); 4036 set_reduce_memory_result(false);
4036 4037
4037 // If changing the memory limit wouldn't result in changing what was 4038 // If changing the memory limit wouldn't result in changing what was
4038 // committed, then no commit should be requested. 4039 // committed, then no commit should be requested.
4039 set_reduce_memory_result(false); 4040 set_reduce_memory_result(false);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
4106 gfx::RectF expected_child_visible_rect(child->content_bounds()); 4107 gfx::RectF expected_child_visible_rect(child->content_bounds());
4107 EXPECT_RECT_EQ(expected_child_visible_rect, 4108 EXPECT_RECT_EQ(expected_child_visible_rect,
4108 root_render_pass->quad_list[0]->visible_rect); 4109 root_render_pass->quad_list[0]->visible_rect);
4109 4110
4110 LayerImpl* root = host_impl_->active_tree()->root_layer(); 4111 LayerImpl* root = host_impl_->active_tree()->root_layer();
4111 gfx::RectF expected_root_visible_rect(root->content_bounds()); 4112 gfx::RectF expected_root_visible_rect(root->content_bounds());
4112 EXPECT_RECT_EQ(expected_root_visible_rect, 4113 EXPECT_RECT_EQ(expected_root_visible_rect,
4113 root_render_pass->quad_list[1]->visible_rect); 4114 root_render_pass->quad_list[1]->visible_rect);
4114 } 4115 }
4115 4116
4116 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4117 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4117 host_impl_->DidDrawAllLayers(frame); 4118 host_impl_->DidDrawAllLayers(frame);
4118 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame)); 4119 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame));
4119 } 4120 }
4120 }; 4121 };
4121 4122
4122 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { 4123 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) {
4123 scoped_ptr<SolidColorLayerImpl> root = 4124 scoped_ptr<SolidColorLayerImpl> root =
4124 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); 4125 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1);
4125 root->SetAnchorPoint(gfx::PointF()); 4126 root->SetAnchorPoint(gfx::PointF());
4126 root->SetPosition(gfx::PointF()); 4127 root->SetPosition(gfx::PointF());
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
4248 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4249 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4249 ASSERT_EQ(DrawQuad::RENDER_PASS, 4250 ASSERT_EQ(DrawQuad::RENDER_PASS,
4250 frame.render_passes[0]->quad_list[0]->material); 4251 frame.render_passes[0]->quad_list[0]->material);
4251 const RenderPassDrawQuad* render_pass_quad = 4252 const RenderPassDrawQuad* render_pass_quad =
4252 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4253 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4253 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4254 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4254 render_pass_quad->rect.ToString()); 4255 render_pass_quad->rect.ToString());
4255 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4256 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4256 render_pass_quad->mask_uv_rect.ToString()); 4257 render_pass_quad->mask_uv_rect.ToString());
4257 4258
4258 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4259 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4259 host_impl_->DidDrawAllLayers(frame); 4260 host_impl_->DidDrawAllLayers(frame);
4260 } 4261 }
4261 4262
4262 4263
4263 // Applying a DSF should change the render surface size, but won't affect 4264 // Applying a DSF should change the render surface size, but won't affect
4264 // which part of the mask is used. 4265 // which part of the mask is used.
4265 device_scale_factor = 2.f; 4266 device_scale_factor = 2.f;
4266 gfx::Size device_viewport = 4267 gfx::Size device_viewport =
4267 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); 4268 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor));
4268 host_impl_->SetViewportSize(device_viewport); 4269 host_impl_->SetViewportSize(device_viewport);
4269 host_impl_->SetDeviceScaleFactor(device_scale_factor); 4270 host_impl_->SetDeviceScaleFactor(device_scale_factor);
4270 host_impl_->active_tree()->set_needs_update_draw_properties(); 4271 host_impl_->active_tree()->set_needs_update_draw_properties();
4271 { 4272 {
4272 LayerTreeHostImpl::FrameData frame; 4273 LayerTreeHostImpl::FrameData frame;
4273 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4274 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4274 4275
4275 ASSERT_EQ(1u, frame.render_passes.size()); 4276 ASSERT_EQ(1u, frame.render_passes.size());
4276 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4277 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4277 ASSERT_EQ(DrawQuad::RENDER_PASS, 4278 ASSERT_EQ(DrawQuad::RENDER_PASS,
4278 frame.render_passes[0]->quad_list[0]->material); 4279 frame.render_passes[0]->quad_list[0]->material);
4279 const RenderPassDrawQuad* render_pass_quad = 4280 const RenderPassDrawQuad* render_pass_quad =
4280 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4281 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4281 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), 4282 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(),
4282 render_pass_quad->rect.ToString()); 4283 render_pass_quad->rect.ToString());
4283 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4284 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4284 render_pass_quad->mask_uv_rect.ToString()); 4285 render_pass_quad->mask_uv_rect.ToString());
4285 4286
4286 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4287 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4287 host_impl_->DidDrawAllLayers(frame); 4288 host_impl_->DidDrawAllLayers(frame);
4288 } 4289 }
4289 4290
4290 4291
4291 // Applying an equivalent content scale on the content layer and the mask 4292 // Applying an equivalent content scale on the content layer and the mask
4292 // should still result in the same part of the mask being used. 4293 // should still result in the same part of the mask being used.
4293 gfx::Size content_bounds = 4294 gfx::Size content_bounds =
4294 gfx::ToRoundedSize(gfx::ScaleSize(scaling_layer_size, 4295 gfx::ToRoundedSize(gfx::ScaleSize(scaling_layer_size,
4295 device_scale_factor)); 4296 device_scale_factor));
4296 content_layer->SetContentBounds(content_bounds); 4297 content_layer->SetContentBounds(content_bounds);
4297 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4298 content_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4298 mask_layer->SetContentBounds(content_bounds); 4299 mask_layer->SetContentBounds(content_bounds);
4299 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4300 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4300 host_impl_->active_tree()->set_needs_update_draw_properties(); 4301 host_impl_->active_tree()->set_needs_update_draw_properties();
4301 { 4302 {
4302 LayerTreeHostImpl::FrameData frame; 4303 LayerTreeHostImpl::FrameData frame;
4303 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4304 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4304 4305
4305 ASSERT_EQ(1u, frame.render_passes.size()); 4306 ASSERT_EQ(1u, frame.render_passes.size());
4306 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4307 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4307 ASSERT_EQ(DrawQuad::RENDER_PASS, 4308 ASSERT_EQ(DrawQuad::RENDER_PASS,
4308 frame.render_passes[0]->quad_list[0]->material); 4309 frame.render_passes[0]->quad_list[0]->material);
4309 const RenderPassDrawQuad* render_pass_quad = 4310 const RenderPassDrawQuad* render_pass_quad =
4310 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4311 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4311 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), 4312 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(),
4312 render_pass_quad->rect.ToString()); 4313 render_pass_quad->rect.ToString());
4313 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4314 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4314 render_pass_quad->mask_uv_rect.ToString()); 4315 render_pass_quad->mask_uv_rect.ToString());
4315 4316
4316 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4317 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4317 host_impl_->DidDrawAllLayers(frame); 4318 host_impl_->DidDrawAllLayers(frame);
4318 } 4319 }
4319 } 4320 }
4320 4321
4321 TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) { 4322 TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) {
4322 // The mask layer has bounds 100x100 but is attached to a layer with bounds 4323 // The mask layer has bounds 100x100 but is attached to a layer with bounds
4323 // 50x50. 4324 // 50x50.
4324 4325
4325 scoped_ptr<LayerImpl> scoped_root = 4326 scoped_ptr<LayerImpl> scoped_root =
4326 LayerImpl::Create(host_impl_->active_tree(), 1); 4327 LayerImpl::Create(host_impl_->active_tree(), 1);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
4369 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4370 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4370 ASSERT_EQ(DrawQuad::RENDER_PASS, 4371 ASSERT_EQ(DrawQuad::RENDER_PASS,
4371 frame.render_passes[0]->quad_list[0]->material); 4372 frame.render_passes[0]->quad_list[0]->material);
4372 const RenderPassDrawQuad* render_pass_quad = 4373 const RenderPassDrawQuad* render_pass_quad =
4373 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4374 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4374 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), 4375 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(),
4375 render_pass_quad->rect.ToString()); 4376 render_pass_quad->rect.ToString());
4376 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4377 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4377 render_pass_quad->mask_uv_rect.ToString()); 4378 render_pass_quad->mask_uv_rect.ToString());
4378 4379
4379 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4380 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4380 host_impl_->DidDrawAllLayers(frame); 4381 host_impl_->DidDrawAllLayers(frame);
4381 } 4382 }
4382 4383
4383 // Applying a DSF should change the render surface size, but won't affect 4384 // Applying a DSF should change the render surface size, but won't affect
4384 // which part of the mask is used. 4385 // which part of the mask is used.
4385 device_scale_factor = 2.f; 4386 device_scale_factor = 2.f;
4386 gfx::Size device_viewport = 4387 gfx::Size device_viewport =
4387 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); 4388 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor));
4388 host_impl_->SetViewportSize(device_viewport); 4389 host_impl_->SetViewportSize(device_viewport);
4389 host_impl_->SetDeviceScaleFactor(device_scale_factor); 4390 host_impl_->SetDeviceScaleFactor(device_scale_factor);
4390 host_impl_->active_tree()->set_needs_update_draw_properties(); 4391 host_impl_->active_tree()->set_needs_update_draw_properties();
4391 { 4392 {
4392 LayerTreeHostImpl::FrameData frame; 4393 LayerTreeHostImpl::FrameData frame;
4393 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4394 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4394 4395
4395 ASSERT_EQ(1u, frame.render_passes.size()); 4396 ASSERT_EQ(1u, frame.render_passes.size());
4396 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4397 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4397 ASSERT_EQ(DrawQuad::RENDER_PASS, 4398 ASSERT_EQ(DrawQuad::RENDER_PASS,
4398 frame.render_passes[0]->quad_list[0]->material); 4399 frame.render_passes[0]->quad_list[0]->material);
4399 const RenderPassDrawQuad* render_pass_quad = 4400 const RenderPassDrawQuad* render_pass_quad =
4400 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4401 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4401 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4402 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4402 render_pass_quad->rect.ToString()); 4403 render_pass_quad->rect.ToString());
4403 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4404 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4404 render_pass_quad->mask_uv_rect.ToString()); 4405 render_pass_quad->mask_uv_rect.ToString());
4405 4406
4406 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4407 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4407 host_impl_->DidDrawAllLayers(frame); 4408 host_impl_->DidDrawAllLayers(frame);
4408 } 4409 }
4409 4410
4410 // Applying an equivalent content scale on the content layer and the mask 4411 // Applying an equivalent content scale on the content layer and the mask
4411 // should still result in the same part of the mask being used. 4412 // should still result in the same part of the mask being used.
4412 gfx::Size layer_size_large = 4413 gfx::Size layer_size_large =
4413 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor)); 4414 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor));
4414 content_layer->SetContentBounds(layer_size_large); 4415 content_layer->SetContentBounds(layer_size_large);
4415 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4416 content_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4416 gfx::Size mask_size_large = 4417 gfx::Size mask_size_large =
4417 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor)); 4418 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor));
4418 mask_layer->SetContentBounds(mask_size_large); 4419 mask_layer->SetContentBounds(mask_size_large);
4419 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4420 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4420 host_impl_->active_tree()->set_needs_update_draw_properties(); 4421 host_impl_->active_tree()->set_needs_update_draw_properties();
4421 { 4422 {
4422 LayerTreeHostImpl::FrameData frame; 4423 LayerTreeHostImpl::FrameData frame;
4423 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4424 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4424 4425
4425 ASSERT_EQ(1u, frame.render_passes.size()); 4426 ASSERT_EQ(1u, frame.render_passes.size());
4426 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4427 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4427 ASSERT_EQ(DrawQuad::RENDER_PASS, 4428 ASSERT_EQ(DrawQuad::RENDER_PASS,
4428 frame.render_passes[0]->quad_list[0]->material); 4429 frame.render_passes[0]->quad_list[0]->material);
4429 const RenderPassDrawQuad* render_pass_quad = 4430 const RenderPassDrawQuad* render_pass_quad =
4430 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4431 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4431 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4432 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4432 render_pass_quad->rect.ToString()); 4433 render_pass_quad->rect.ToString());
4433 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4434 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4434 render_pass_quad->mask_uv_rect.ToString()); 4435 render_pass_quad->mask_uv_rect.ToString());
4435 4436
4436 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4437 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4437 host_impl_->DidDrawAllLayers(frame); 4438 host_impl_->DidDrawAllLayers(frame);
4438 } 4439 }
4439 4440
4440 // Applying a different contents scale to the mask layer means it will have 4441 // Applying a different contents scale to the mask layer means it will have
4441 // a larger texture, but it should use the same tex coords to cover the 4442 // a larger texture, but it should use the same tex coords to cover the
4442 // layer it masks. 4443 // layer it masks.
4443 mask_layer->SetContentBounds(mask_size); 4444 mask_layer->SetContentBounds(mask_size);
4444 mask_layer->SetContentsScale(1.f, 1.f); 4445 mask_layer->SetContentsScale(1.f, 1.f);
4445 host_impl_->active_tree()->set_needs_update_draw_properties(); 4446 host_impl_->active_tree()->set_needs_update_draw_properties();
4446 { 4447 {
4447 LayerTreeHostImpl::FrameData frame; 4448 LayerTreeHostImpl::FrameData frame;
4448 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4449 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4449 4450
4450 ASSERT_EQ(1u, frame.render_passes.size()); 4451 ASSERT_EQ(1u, frame.render_passes.size());
4451 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4452 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4452 ASSERT_EQ(DrawQuad::RENDER_PASS, 4453 ASSERT_EQ(DrawQuad::RENDER_PASS,
4453 frame.render_passes[0]->quad_list[0]->material); 4454 frame.render_passes[0]->quad_list[0]->material);
4454 const RenderPassDrawQuad* render_pass_quad = 4455 const RenderPassDrawQuad* render_pass_quad =
4455 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4456 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4456 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4457 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4457 render_pass_quad->rect.ToString()); 4458 render_pass_quad->rect.ToString());
4458 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4459 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4459 render_pass_quad->mask_uv_rect.ToString()); 4460 render_pass_quad->mask_uv_rect.ToString());
4460 4461
4461 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4462 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4462 host_impl_->DidDrawAllLayers(frame); 4463 host_impl_->DidDrawAllLayers(frame);
4463 } 4464 }
4464 } 4465 }
4465 4466
4466 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) { 4467 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) {
4467 // The replica's mask layer has bounds 100x100 but the replica is of a 4468 // The replica's mask layer has bounds 100x100 but the replica is of a
4468 // layer with bounds 50x50. 4469 // layer with bounds 50x50.
4469 4470
4470 scoped_ptr<LayerImpl> scoped_root = 4471 scoped_ptr<LayerImpl> scoped_root =
4471 LayerImpl::Create(host_impl_->active_tree(), 1); 4472 LayerImpl::Create(host_impl_->active_tree(), 1);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
4520 ASSERT_EQ(DrawQuad::RENDER_PASS, 4521 ASSERT_EQ(DrawQuad::RENDER_PASS,
4521 frame.render_passes[0]->quad_list[1]->material); 4522 frame.render_passes[0]->quad_list[1]->material);
4522 const RenderPassDrawQuad* replica_quad = 4523 const RenderPassDrawQuad* replica_quad =
4523 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 4524 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
4524 EXPECT_TRUE(replica_quad->is_replica); 4525 EXPECT_TRUE(replica_quad->is_replica);
4525 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), 4526 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(),
4526 replica_quad->rect.ToString()); 4527 replica_quad->rect.ToString());
4527 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4528 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4528 replica_quad->mask_uv_rect.ToString()); 4529 replica_quad->mask_uv_rect.ToString());
4529 4530
4530 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4531 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4531 host_impl_->DidDrawAllLayers(frame); 4532 host_impl_->DidDrawAllLayers(frame);
4532 } 4533 }
4533 4534
4534 // Applying a DSF should change the render surface size, but won't affect 4535 // Applying a DSF should change the render surface size, but won't affect
4535 // which part of the mask is used. 4536 // which part of the mask is used.
4536 device_scale_factor = 2.f; 4537 device_scale_factor = 2.f;
4537 gfx::Size device_viewport = 4538 gfx::Size device_viewport =
4538 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); 4539 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor));
4539 host_impl_->SetViewportSize(device_viewport); 4540 host_impl_->SetViewportSize(device_viewport);
4540 host_impl_->SetDeviceScaleFactor(device_scale_factor); 4541 host_impl_->SetDeviceScaleFactor(device_scale_factor);
4541 host_impl_->active_tree()->set_needs_update_draw_properties(); 4542 host_impl_->active_tree()->set_needs_update_draw_properties();
4542 { 4543 {
4543 LayerTreeHostImpl::FrameData frame; 4544 LayerTreeHostImpl::FrameData frame;
4544 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4545 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4545 4546
4546 ASSERT_EQ(1u, frame.render_passes.size()); 4547 ASSERT_EQ(1u, frame.render_passes.size());
4547 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 4548 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
4548 ASSERT_EQ(DrawQuad::RENDER_PASS, 4549 ASSERT_EQ(DrawQuad::RENDER_PASS,
4549 frame.render_passes[0]->quad_list[1]->material); 4550 frame.render_passes[0]->quad_list[1]->material);
4550 const RenderPassDrawQuad* replica_quad = 4551 const RenderPassDrawQuad* replica_quad =
4551 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 4552 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
4552 EXPECT_TRUE(replica_quad->is_replica); 4553 EXPECT_TRUE(replica_quad->is_replica);
4553 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4554 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4554 replica_quad->rect.ToString()); 4555 replica_quad->rect.ToString());
4555 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4556 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4556 replica_quad->mask_uv_rect.ToString()); 4557 replica_quad->mask_uv_rect.ToString());
4557 4558
4558 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4559 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4559 host_impl_->DidDrawAllLayers(frame); 4560 host_impl_->DidDrawAllLayers(frame);
4560 } 4561 }
4561 4562
4562 // Applying an equivalent content scale on the content layer and the mask 4563 // Applying an equivalent content scale on the content layer and the mask
4563 // should still result in the same part of the mask being used. 4564 // should still result in the same part of the mask being used.
4564 gfx::Size layer_size_large = 4565 gfx::Size layer_size_large =
4565 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor)); 4566 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor));
4566 content_layer->SetContentBounds(layer_size_large); 4567 content_layer->SetContentBounds(layer_size_large);
4567 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4568 content_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4568 gfx::Size mask_size_large = 4569 gfx::Size mask_size_large =
(...skipping 10 matching lines...) Expand all
4579 ASSERT_EQ(DrawQuad::RENDER_PASS, 4580 ASSERT_EQ(DrawQuad::RENDER_PASS,
4580 frame.render_passes[0]->quad_list[1]->material); 4581 frame.render_passes[0]->quad_list[1]->material);
4581 const RenderPassDrawQuad* replica_quad = 4582 const RenderPassDrawQuad* replica_quad =
4582 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 4583 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
4583 EXPECT_TRUE(replica_quad->is_replica); 4584 EXPECT_TRUE(replica_quad->is_replica);
4584 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4585 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4585 replica_quad->rect.ToString()); 4586 replica_quad->rect.ToString());
4586 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4587 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4587 replica_quad->mask_uv_rect.ToString()); 4588 replica_quad->mask_uv_rect.ToString());
4588 4589
4589 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4590 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4590 host_impl_->DidDrawAllLayers(frame); 4591 host_impl_->DidDrawAllLayers(frame);
4591 } 4592 }
4592 4593
4593 // Applying a different contents scale to the mask layer means it will have 4594 // Applying a different contents scale to the mask layer means it will have
4594 // a larger texture, but it should use the same tex coords to cover the 4595 // a larger texture, but it should use the same tex coords to cover the
4595 // layer it masks. 4596 // layer it masks.
4596 mask_layer->SetContentBounds(mask_size); 4597 mask_layer->SetContentBounds(mask_size);
4597 mask_layer->SetContentsScale(1.f, 1.f); 4598 mask_layer->SetContentsScale(1.f, 1.f);
4598 host_impl_->active_tree()->set_needs_update_draw_properties(); 4599 host_impl_->active_tree()->set_needs_update_draw_properties();
4599 { 4600 {
4600 LayerTreeHostImpl::FrameData frame; 4601 LayerTreeHostImpl::FrameData frame;
4601 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4602 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4602 4603
4603 ASSERT_EQ(1u, frame.render_passes.size()); 4604 ASSERT_EQ(1u, frame.render_passes.size());
4604 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 4605 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
4605 ASSERT_EQ(DrawQuad::RENDER_PASS, 4606 ASSERT_EQ(DrawQuad::RENDER_PASS,
4606 frame.render_passes[0]->quad_list[1]->material); 4607 frame.render_passes[0]->quad_list[1]->material);
4607 const RenderPassDrawQuad* replica_quad = 4608 const RenderPassDrawQuad* replica_quad =
4608 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 4609 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
4609 EXPECT_TRUE(replica_quad->is_replica); 4610 EXPECT_TRUE(replica_quad->is_replica);
4610 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4611 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4611 replica_quad->rect.ToString()); 4612 replica_quad->rect.ToString());
4612 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4613 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4613 replica_quad->mask_uv_rect.ToString()); 4614 replica_quad->mask_uv_rect.ToString());
4614 4615
4615 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4616 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4616 host_impl_->DidDrawAllLayers(frame); 4617 host_impl_->DidDrawAllLayers(frame);
4617 } 4618 }
4618 } 4619 }
4619 4620
4620 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) { 4621 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) {
4621 // The replica is of a layer with bounds 50x50, but it has a child that causes 4622 // The replica is of a layer with bounds 50x50, but it has a child that causes
4622 // the surface bounds to be larger. 4623 // the surface bounds to be larger.
4623 4624
4624 scoped_ptr<LayerImpl> scoped_root = 4625 scoped_ptr<LayerImpl> scoped_root =
4625 LayerImpl::Create(host_impl_->active_tree(), 1); 4626 LayerImpl::Create(host_impl_->active_tree(), 1);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
4696 ASSERT_EQ(DrawQuad::RENDER_PASS, 4697 ASSERT_EQ(DrawQuad::RENDER_PASS,
4697 frame.render_passes[0]->quad_list[1]->material); 4698 frame.render_passes[0]->quad_list[1]->material);
4698 const RenderPassDrawQuad* replica_quad = 4699 const RenderPassDrawQuad* replica_quad =
4699 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 4700 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
4700 EXPECT_TRUE(replica_quad->is_replica); 4701 EXPECT_TRUE(replica_quad->is_replica);
4701 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), 4702 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(),
4702 replica_quad->rect.ToString()); 4703 replica_quad->rect.ToString());
4703 EXPECT_EQ(gfx::RectF(0.f, 0.f, 2.f, 1.f).ToString(), 4704 EXPECT_EQ(gfx::RectF(0.f, 0.f, 2.f, 1.f).ToString(),
4704 replica_quad->mask_uv_rect.ToString()); 4705 replica_quad->mask_uv_rect.ToString());
4705 4706
4706 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4707 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4707 host_impl_->DidDrawAllLayers(frame); 4708 host_impl_->DidDrawAllLayers(frame);
4708 } 4709 }
4709 4710
4710 // Move the child to (-50, 0) instead. Now the mask should be moved to still 4711 // Move the child to (-50, 0) instead. Now the mask should be moved to still
4711 // cover the layer being replicated. 4712 // cover the layer being replicated.
4712 content_child_layer->SetPosition(gfx::Point(-50, 0)); 4713 content_child_layer->SetPosition(gfx::Point(-50, 0));
4713 { 4714 {
4714 LayerTreeHostImpl::FrameData frame; 4715 LayerTreeHostImpl::FrameData frame;
4715 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4716 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4716 4717
(...skipping 13 matching lines...) Expand all
4730 ASSERT_EQ(DrawQuad::RENDER_PASS, 4731 ASSERT_EQ(DrawQuad::RENDER_PASS,
4731 frame.render_passes[0]->quad_list[1]->material); 4732 frame.render_passes[0]->quad_list[1]->material);
4732 const RenderPassDrawQuad* replica_quad = 4733 const RenderPassDrawQuad* replica_quad =
4733 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 4734 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
4734 EXPECT_TRUE(replica_quad->is_replica); 4735 EXPECT_TRUE(replica_quad->is_replica);
4735 EXPECT_EQ(gfx::Rect(-50, 0, 100, 50).ToString(), 4736 EXPECT_EQ(gfx::Rect(-50, 0, 100, 50).ToString(),
4736 replica_quad->rect.ToString()); 4737 replica_quad->rect.ToString());
4737 EXPECT_EQ(gfx::RectF(-1.f, 0.f, 2.f, 1.f).ToString(), 4738 EXPECT_EQ(gfx::RectF(-1.f, 0.f, 2.f, 1.f).ToString(),
4738 replica_quad->mask_uv_rect.ToString()); 4739 replica_quad->mask_uv_rect.ToString());
4739 4740
4740 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4741 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4741 host_impl_->DidDrawAllLayers(frame); 4742 host_impl_->DidDrawAllLayers(frame);
4742 } 4743 }
4743 } 4744 }
4744 4745
4745 TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) { 4746 TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) {
4746 // The masked layer has bounds 50x50, but it has a child that causes 4747 // The masked layer has bounds 50x50, but it has a child that causes
4747 // the surface bounds to be larger. It also has a parent that clips the 4748 // the surface bounds to be larger. It also has a parent that clips the
4748 // masked layer and its surface. 4749 // masked layer and its surface.
4749 4750
4750 scoped_ptr<LayerImpl> scoped_root = 4751 scoped_ptr<LayerImpl> scoped_root =
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
4826 render_pass_quad->rect.ToString()); 4827 render_pass_quad->rect.ToString());
4827 4828
4828 // The masked layer is 50x50, but the surface size is 10x20. So the texture 4829 // The masked layer is 50x50, but the surface size is 10x20. So the texture
4829 // coords in the mask are scaled by 10/50 and 20/50. 4830 // coords in the mask are scaled by 10/50 and 20/50.
4830 // The surface is clipped to (20,10) so the mask texture coords are offset 4831 // The surface is clipped to (20,10) so the mask texture coords are offset
4831 // by 20/50 and 10/50 4832 // by 20/50 and 10/50
4832 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f), 4833 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f),
4833 1.f / 50.f).ToString(), 4834 1.f / 50.f).ToString(),
4834 render_pass_quad->mask_uv_rect.ToString()); 4835 render_pass_quad->mask_uv_rect.ToString());
4835 4836
4836 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4837 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4837 host_impl_->DidDrawAllLayers(frame); 4838 host_impl_->DidDrawAllLayers(frame);
4838 } 4839 }
4839 } 4840 }
4840 4841
4841 class GLRendererWithSetupQuadForAntialiasing : public GLRenderer { 4842 class GLRendererWithSetupQuadForAntialiasing : public GLRenderer {
4842 public: 4843 public:
4843 using GLRenderer::SetupQuadForAntialiasing; 4844 using GLRenderer::SetupQuadForAntialiasing;
4844 }; 4845 };
4845 4846
4846 TEST_F(LayerTreeHostImplTest, FarAwayQuadsDontNeedAA) { 4847 TEST_F(LayerTreeHostImplTest, FarAwayQuadsDontNeedAA) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
4899 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); 4900 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size());
4900 const DrawQuad* quad = frame.render_passes[0]->quad_list[0]; 4901 const DrawQuad* quad = frame.render_passes[0]->quad_list[0];
4901 4902
4902 float edge[24]; 4903 float edge[24];
4903 gfx::QuadF device_layer_quad; 4904 gfx::QuadF device_layer_quad;
4904 bool antialiased = 4905 bool antialiased =
4905 GLRendererWithSetupQuadForAntialiasing::SetupQuadForAntialiasing( 4906 GLRendererWithSetupQuadForAntialiasing::SetupQuadForAntialiasing(
4906 quad->quadTransform(), quad, &device_layer_quad, edge); 4907 quad->quadTransform(), quad, &device_layer_quad, edge);
4907 EXPECT_FALSE(antialiased); 4908 EXPECT_FALSE(antialiased);
4908 4909
4909 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4910 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4910 host_impl_->DidDrawAllLayers(frame); 4911 host_impl_->DidDrawAllLayers(frame);
4911 } 4912 }
4912 4913
4913 4914
4914 class CompositorFrameMetadataTest : public LayerTreeHostImplTest { 4915 class CompositorFrameMetadataTest : public LayerTreeHostImplTest {
4915 public: 4916 public:
4916 CompositorFrameMetadataTest() 4917 CompositorFrameMetadataTest()
4917 : swap_buffers_complete_(0) {} 4918 : swap_buffers_complete_(0) {}
4918 4919
4919 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE { 4920 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
5000 scoped_ptr<VideoLayerImpl> video_layer = 5001 scoped_ptr<VideoLayerImpl> video_layer =
5001 VideoLayerImpl::Create(host_impl_->active_tree(), 2, &provider); 5002 VideoLayerImpl::Create(host_impl_->active_tree(), 2, &provider);
5002 video_layer->SetBounds(gfx::Size(10, 10)); 5003 video_layer->SetBounds(gfx::Size(10, 10));
5003 video_layer->SetContentBounds(gfx::Size(10, 10)); 5004 video_layer->SetContentBounds(gfx::Size(10, 10));
5004 video_layer->SetDrawsContent(true); 5005 video_layer->SetDrawsContent(true);
5005 root_layer->AddChild(video_layer.PassAs<LayerImpl>()); 5006 root_layer->AddChild(video_layer.PassAs<LayerImpl>());
5006 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>()); 5007 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>());
5007 5008
5008 LayerTreeHostImpl::FrameData frame; 5009 LayerTreeHostImpl::FrameData frame;
5009 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 5010 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5010 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 5011 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5011 host_impl_->DidDrawAllLayers(frame); 5012 host_impl_->DidDrawAllLayers(frame);
5012 5013
5013 EXPECT_EQ(1u, frame.will_draw_layers.size()); 5014 EXPECT_EQ(1u, frame.will_draw_layers.size());
5014 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]); 5015 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]);
5015 } 5016 }
5016 5017
5017 class LayerTreeHostImplTestDeferredInitialize : public LayerTreeHostImplTest { 5018 class LayerTreeHostImplTestDeferredInitialize : public LayerTreeHostImplTest {
5018 protected: 5019 protected:
5019 virtual void SetUp() OVERRIDE { 5020 virtual void SetUp() OVERRIDE {
5020 LayerTreeHostImplTest::SetUp(); 5021 LayerTreeHostImplTest::SetUp();
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
5288 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); 5289 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1));
5289 5290
5290 ScopedPtrVector<CopyOutputRequest> requests; 5291 ScopedPtrVector<CopyOutputRequest> requests;
5291 requests.push_back(CopyOutputRequest::CreateRequest( 5292 requests.push_back(CopyOutputRequest::CreateRequest(
5292 base::Bind(&ShutdownReleasesContext_Callback))); 5293 base::Bind(&ShutdownReleasesContext_Callback)));
5293 5294
5294 host_impl_->active_tree()->root_layer()->PassCopyRequests(&requests); 5295 host_impl_->active_tree()->root_layer()->PassCopyRequests(&requests);
5295 5296
5296 LayerTreeHostImpl::FrameData frame; 5297 LayerTreeHostImpl::FrameData frame;
5297 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 5298 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5298 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 5299 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5299 host_impl_->DidDrawAllLayers(frame); 5300 host_impl_->DidDrawAllLayers(frame);
5300 5301
5301 // The CopyOutputResult's callback has a ref on the ContextProvider and a 5302 // The CopyOutputResult's callback has a ref on the ContextProvider and a
5302 // texture in a texture mailbox. 5303 // texture in a texture mailbox.
5303 EXPECT_FALSE(context_provider->HasOneRef()); 5304 EXPECT_FALSE(context_provider->HasOneRef());
5304 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); 5305 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures());
5305 5306
5306 host_impl_.reset(); 5307 host_impl_.reset();
5307 5308
5308 // The CopyOutputResult's callback was cancelled, the CopyOutputResult 5309 // The CopyOutputResult's callback was cancelled, the CopyOutputResult
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
5430 // The root should have scrolled. 5431 // The root should have scrolled.
5431 ASSERT_EQ(2u, scroll_info->scrolls.size()); 5432 ASSERT_EQ(2u, scroll_info->scrolls.size());
5432 ExpectContains(*scroll_info.get(), 5433 ExpectContains(*scroll_info.get(),
5433 host_impl_->active_tree()->root_layer()->id(), 5434 host_impl_->active_tree()->root_layer()->id(),
5434 gfx::Vector2d(0, 10)); 5435 gfx::Vector2d(0, 10));
5435 } 5436 }
5436 } 5437 }
5437 5438
5438 } // namespace 5439 } // namespace
5439 } // namespace cc 5440 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698