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

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: Fix DCHECK Created 7 years, 1 month 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } 261 }
261 262
262 void InitializeRendererAndDrawFrame() { 263 void InitializeRendererAndDrawFrame() {
263 host_impl_->InitializeRenderer(CreateOutputSurface()); 264 host_impl_->InitializeRenderer(CreateOutputSurface());
264 DrawFrame(); 265 DrawFrame();
265 } 266 }
266 267
267 void DrawFrame() { 268 void DrawFrame() {
268 LayerTreeHostImpl::FrameData frame; 269 LayerTreeHostImpl::FrameData frame;
269 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 270 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
270 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 271 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
271 host_impl_->DidDrawAllLayers(frame); 272 host_impl_->DidDrawAllLayers(frame);
272 } 273 }
273 274
274 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor); 275 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor);
275 void pinch_zoom_pan_viewport_test(float device_scale_factor); 276 void pinch_zoom_pan_viewport_test(float device_scale_factor);
276 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); 277 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor);
277 void pinch_zoom_pan_viewport_and_scroll_boundary_test( 278 void pinch_zoom_pan_viewport_and_scroll_boundary_test(
278 float device_scale_factor); 279 float device_scale_factor);
279 280
280 void CheckNotifyCalledIfCanDrawChanged(bool always_draw) { 281 void CheckNotifyCalledIfCanDrawChanged(bool always_draw) {
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 scroll->SetVerticalScrollbarLayer(scrollbar.get()); 1201 scroll->SetVerticalScrollbarLayer(scrollbar.get());
1201 1202
1202 scroll->AddChild(contents.Pass()); 1203 scroll->AddChild(contents.Pass());
1203 root->AddChild(scroll.Pass()); 1204 root->AddChild(scroll.Pass());
1204 root->AddChild(scrollbar.PassAs<LayerImpl>()); 1205 root->AddChild(scrollbar.PassAs<LayerImpl>());
1205 1206
1206 host_impl_->active_tree()->SetRootLayer(root.Pass()); 1207 host_impl_->active_tree()->SetRootLayer(root.Pass());
1207 host_impl_->active_tree()->DidBecomeActive(); 1208 host_impl_->active_tree()->DidBecomeActive();
1208 InitializeRendererAndDrawFrame(); 1209 InitializeRendererAndDrawFrame();
1209 1210
1210 base::TimeTicks fake_now = base::TimeTicks::Now(); 1211 base::TimeTicks fake_now = gfx::FrameTime::Now();
1211 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); 1212 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now);
1212 1213
1213 // If no scroll happened recently, StartScrollbarAnimation should have no 1214 // If no scroll happened recently, StartScrollbarAnimation should have no
1214 // effect. 1215 // effect.
1215 host_impl_->StartScrollbarAnimation(); 1216 host_impl_->StartScrollbarAnimation();
1216 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); 1217 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_);
1217 EXPECT_FALSE(did_request_redraw_); 1218 EXPECT_FALSE(did_request_redraw_);
1218 1219
1219 // If no scroll happened during a scroll gesture, StartScrollbarAnimation 1220 // If no scroll happened during a scroll gesture, StartScrollbarAnimation
1220 // should have no effect. 1221 // should have no effect.
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( 1500 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(
1500 host_impl_->active_tree()->root_layer()); 1501 host_impl_->active_tree()->root_layer());
1501 1502
1502 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); 1503 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
1503 DidDrawCheckLayer* layer = 1504 DidDrawCheckLayer* layer =
1504 static_cast<DidDrawCheckLayer*>(root->children()[0]); 1505 static_cast<DidDrawCheckLayer*>(root->children()[0]);
1505 1506
1506 { 1507 {
1507 LayerTreeHostImpl::FrameData frame; 1508 LayerTreeHostImpl::FrameData frame;
1508 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10))); 1509 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10)));
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_TRUE(layer->will_draw_called()); 1513 EXPECT_TRUE(layer->will_draw_called());
1513 EXPECT_TRUE(layer->append_quads_called()); 1514 EXPECT_TRUE(layer->append_quads_called());
1514 EXPECT_TRUE(layer->did_draw_called()); 1515 EXPECT_TRUE(layer->did_draw_called());
1515 } 1516 }
1516 1517
1517 { 1518 {
1518 LayerTreeHostImpl::FrameData frame; 1519 LayerTreeHostImpl::FrameData frame;
1519 1520
1520 layer->set_will_draw_returns_false(); 1521 layer->set_will_draw_returns_false();
1521 layer->ClearDidDrawCheck(); 1522 layer->ClearDidDrawCheck();
1522 1523
1523 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10))); 1524 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10)));
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_FALSE(layer->append_quads_called()); 1529 EXPECT_FALSE(layer->append_quads_called());
1529 EXPECT_FALSE(layer->did_draw_called()); 1530 EXPECT_FALSE(layer->did_draw_called());
1530 } 1531 }
1531 } 1532 }
1532 1533
1533 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { 1534 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) {
1534 // The root layer is always drawn, so run this test on a child layer that 1535 // The root layer is always drawn, so run this test on a child layer that
(...skipping 11 matching lines...) Expand all
1546 layer->SetPosition(gfx::PointF(100.f, 100.f)); 1547 layer->SetPosition(gfx::PointF(100.f, 100.f));
1547 layer->SetBounds(gfx::Size(10, 10)); 1548 layer->SetBounds(gfx::Size(10, 10));
1548 layer->SetContentBounds(gfx::Size(10, 10)); 1549 layer->SetContentBounds(gfx::Size(10, 10));
1549 1550
1550 LayerTreeHostImpl::FrameData frame; 1551 LayerTreeHostImpl::FrameData frame;
1551 1552
1552 EXPECT_FALSE(layer->will_draw_called()); 1553 EXPECT_FALSE(layer->will_draw_called());
1553 EXPECT_FALSE(layer->did_draw_called()); 1554 EXPECT_FALSE(layer->did_draw_called());
1554 1555
1555 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1556 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1556 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1557 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1557 host_impl_->DidDrawAllLayers(frame); 1558 host_impl_->DidDrawAllLayers(frame);
1558 1559
1559 EXPECT_FALSE(layer->will_draw_called()); 1560 EXPECT_FALSE(layer->will_draw_called());
1560 EXPECT_FALSE(layer->did_draw_called()); 1561 EXPECT_FALSE(layer->did_draw_called());
1561 1562
1562 EXPECT_TRUE(layer->visible_content_rect().IsEmpty()); 1563 EXPECT_TRUE(layer->visible_content_rect().IsEmpty());
1563 1564
1564 // Ensure visible_content_rect for layer is not empty 1565 // Ensure visible_content_rect for layer is not empty
1565 layer->SetPosition(gfx::PointF()); 1566 layer->SetPosition(gfx::PointF());
1566 1567
1567 EXPECT_FALSE(layer->will_draw_called()); 1568 EXPECT_FALSE(layer->will_draw_called());
1568 EXPECT_FALSE(layer->did_draw_called()); 1569 EXPECT_FALSE(layer->did_draw_called());
1569 1570
1570 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1571 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1571 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1572 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1572 host_impl_->DidDrawAllLayers(frame); 1573 host_impl_->DidDrawAllLayers(frame);
1573 1574
1574 EXPECT_TRUE(layer->will_draw_called()); 1575 EXPECT_TRUE(layer->will_draw_called());
1575 EXPECT_TRUE(layer->did_draw_called()); 1576 EXPECT_TRUE(layer->did_draw_called());
1576 1577
1577 EXPECT_FALSE(layer->visible_content_rect().IsEmpty()); 1578 EXPECT_FALSE(layer->visible_content_rect().IsEmpty());
1578 } 1579 }
1579 1580
1580 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { 1581 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) {
1581 gfx::Size big_size(1000, 1000); 1582 gfx::Size big_size(1000, 1000);
(...skipping 18 matching lines...) Expand all
1600 top_layer->SetContentsOpaque(true); 1601 top_layer->SetContentsOpaque(true);
1601 1602
1602 LayerTreeHostImpl::FrameData frame; 1603 LayerTreeHostImpl::FrameData frame;
1603 1604
1604 EXPECT_FALSE(occluded_layer->will_draw_called()); 1605 EXPECT_FALSE(occluded_layer->will_draw_called());
1605 EXPECT_FALSE(occluded_layer->did_draw_called()); 1606 EXPECT_FALSE(occluded_layer->did_draw_called());
1606 EXPECT_FALSE(top_layer->will_draw_called()); 1607 EXPECT_FALSE(top_layer->will_draw_called());
1607 EXPECT_FALSE(top_layer->did_draw_called()); 1608 EXPECT_FALSE(top_layer->did_draw_called());
1608 1609
1609 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1610 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1610 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1611 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1611 host_impl_->DidDrawAllLayers(frame); 1612 host_impl_->DidDrawAllLayers(frame);
1612 1613
1613 EXPECT_FALSE(occluded_layer->will_draw_called()); 1614 EXPECT_FALSE(occluded_layer->will_draw_called());
1614 EXPECT_FALSE(occluded_layer->did_draw_called()); 1615 EXPECT_FALSE(occluded_layer->did_draw_called());
1615 EXPECT_TRUE(top_layer->will_draw_called()); 1616 EXPECT_TRUE(top_layer->will_draw_called());
1616 EXPECT_TRUE(top_layer->did_draw_called()); 1617 EXPECT_TRUE(top_layer->did_draw_called());
1617 } 1618 }
1618 1619
1619 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { 1620 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) {
1620 host_impl_->active_tree()->SetRootLayer( 1621 host_impl_->active_tree()->SetRootLayer(
(...skipping 11 matching lines...) Expand all
1632 1633
1633 layer1->SetOpacity(0.3f); 1634 layer1->SetOpacity(0.3f);
1634 layer1->SetPreserves3d(false); 1635 layer1->SetPreserves3d(false);
1635 1636
1636 EXPECT_FALSE(root->did_draw_called()); 1637 EXPECT_FALSE(root->did_draw_called());
1637 EXPECT_FALSE(layer1->did_draw_called()); 1638 EXPECT_FALSE(layer1->did_draw_called());
1638 EXPECT_FALSE(layer2->did_draw_called()); 1639 EXPECT_FALSE(layer2->did_draw_called());
1639 1640
1640 LayerTreeHostImpl::FrameData frame; 1641 LayerTreeHostImpl::FrameData frame;
1641 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1642 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1642 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1643 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1643 host_impl_->DidDrawAllLayers(frame); 1644 host_impl_->DidDrawAllLayers(frame);
1644 1645
1645 EXPECT_TRUE(root->did_draw_called()); 1646 EXPECT_TRUE(root->did_draw_called());
1646 EXPECT_TRUE(layer1->did_draw_called()); 1647 EXPECT_TRUE(layer1->did_draw_called());
1647 EXPECT_TRUE(layer2->did_draw_called()); 1648 EXPECT_TRUE(layer2->did_draw_called());
1648 1649
1649 EXPECT_NE(root->render_surface(), layer1->render_surface()); 1650 EXPECT_NE(root->render_surface(), layer1->render_surface());
1650 EXPECT_TRUE(!!layer1->render_surface()); 1651 EXPECT_TRUE(!!layer1->render_surface());
1651 } 1652 }
1652 1653
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1705 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1706 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1706 2, 1707 2,
1707 false, 1708 false,
1708 false, 1709 false,
1709 true, 1710 true,
1710 host_impl_->resource_provider())); 1711 host_impl_->resource_provider()));
1711 1712
1712 LayerTreeHostImpl::FrameData frame; 1713 LayerTreeHostImpl::FrameData frame;
1713 1714
1714 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1715 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1715 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1716 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1716 host_impl_->DidDrawAllLayers(frame); 1717 host_impl_->DidDrawAllLayers(frame);
1717 1718
1718 // When a texture is missing and we're not animating, we draw as usual with 1719 // When a texture is missing and we're not animating, we draw as usual with
1719 // checkerboarding. 1720 // checkerboarding.
1720 host_impl_->active_tree()->SetRootLayer( 1721 host_impl_->active_tree()->SetRootLayer(
1721 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); 1722 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3));
1722 root = 1723 root =
1723 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1724 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1724 root->AddChild( 1725 root->AddChild(
1725 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1726 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1726 4, 1727 4,
1727 true, 1728 true,
1728 false, 1729 false,
1729 false, 1730 false,
1730 host_impl_->resource_provider())); 1731 host_impl_->resource_provider()));
1731 1732
1732 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1733 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1733 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1734 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1734 host_impl_->DidDrawAllLayers(frame); 1735 host_impl_->DidDrawAllLayers(frame);
1735 1736
1736 // When a texture is missing and we're animating, we don't want to draw 1737 // When a texture is missing and we're animating, we don't want to draw
1737 // anything. 1738 // anything.
1738 host_impl_->active_tree()->SetRootLayer( 1739 host_impl_->active_tree()->SetRootLayer(
1739 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); 1740 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5));
1740 root = 1741 root =
1741 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1742 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1742 root->AddChild( 1743 root->AddChild(
1743 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1744 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1744 6, 1745 6,
1745 true, 1746 true,
1746 false, 1747 false,
1747 true, 1748 true,
1748 host_impl_->resource_provider())); 1749 host_impl_->resource_provider()));
1749 1750
1750 EXPECT_FALSE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1751 EXPECT_FALSE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1751 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1752 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1752 host_impl_->DidDrawAllLayers(frame); 1753 host_impl_->DidDrawAllLayers(frame);
1753 1754
1754 // When the layer skips draw and we're animating, we still draw the frame. 1755 // When the layer skips draw and we're animating, we still draw the frame.
1755 host_impl_->active_tree()->SetRootLayer( 1756 host_impl_->active_tree()->SetRootLayer(
1756 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 1757 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
1757 root = 1758 root =
1758 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1759 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1759 root->AddChild( 1760 root->AddChild(
1760 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1761 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1761 8, 1762 8,
1762 false, 1763 false,
1763 true, 1764 true,
1764 true, 1765 true,
1765 host_impl_->resource_provider())); 1766 host_impl_->resource_provider()));
1766 1767
1767 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1768 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1768 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 1769 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1769 host_impl_->DidDrawAllLayers(frame); 1770 host_impl_->DidDrawAllLayers(frame);
1770 } 1771 }
1771 1772
1772 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { 1773 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) {
1773 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 1774 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
1774 root->SetScrollable(false); 1775 root->SetScrollable(false);
1775 host_impl_->active_tree()->SetRootLayer(root.Pass()); 1776 host_impl_->active_tree()->SetRootLayer(root.Pass());
1776 InitializeRendererAndDrawFrame(); 1777 InitializeRendererAndDrawFrame();
1777 1778
1778 // Scroll event is ignored because layer is not scrollable. 1779 // Scroll event is ignored because layer is not scrollable.
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 EXPECT_EQ(1.f, scroll->contents_scale_y()); 2053 EXPECT_EQ(1.f, scroll->contents_scale_y());
2053 EXPECT_EQ(1.f, child->contents_scale_x()); 2054 EXPECT_EQ(1.f, child->contents_scale_x());
2054 EXPECT_EQ(1.f, child->contents_scale_y()); 2055 EXPECT_EQ(1.f, child->contents_scale_y());
2055 EXPECT_EQ(1.f, grand_child->contents_scale_x()); 2056 EXPECT_EQ(1.f, grand_child->contents_scale_x());
2056 EXPECT_EQ(1.f, grand_child->contents_scale_y()); 2057 EXPECT_EQ(1.f, grand_child->contents_scale_y());
2057 2058
2058 // Make sure all the layers are drawn with the page scale delta applied, i.e., 2059 // Make sure all the layers are drawn with the page scale delta applied, i.e.,
2059 // the page scale delta on the root layer is applied hierarchically. 2060 // the page scale delta on the root layer is applied hierarchically.
2060 LayerTreeHostImpl::FrameData frame; 2061 LayerTreeHostImpl::FrameData frame;
2061 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2062 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2062 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2063 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2063 host_impl_->DidDrawAllLayers(frame); 2064 host_impl_->DidDrawAllLayers(frame);
2064 2065
2065 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(0, 0)); 2066 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(0, 0));
2066 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(1, 1)); 2067 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(1, 1));
2067 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(0, 0)); 2068 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(0, 0));
2068 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(1, 1)); 2069 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(1, 1));
2069 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(0, 0)); 2070 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(0, 0));
2070 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(1, 1)); 2071 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(1, 1));
2071 EXPECT_EQ(new_page_scale, 2072 EXPECT_EQ(new_page_scale,
2072 grand_child->draw_transform().matrix().getDouble(0, 0)); 2073 grand_child->draw_transform().matrix().getDouble(0, 0));
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
2887 static_cast<BlendStateCheckLayer*>(root->children()[0]); 2888 static_cast<BlendStateCheckLayer*>(root->children()[0]);
2888 layer1->SetPosition(gfx::PointF(2.f, 2.f)); 2889 layer1->SetPosition(gfx::PointF(2.f, 2.f));
2889 2890
2890 LayerTreeHostImpl::FrameData frame; 2891 LayerTreeHostImpl::FrameData frame;
2891 2892
2892 // Opaque layer, drawn without blending. 2893 // Opaque layer, drawn without blending.
2893 layer1->SetContentsOpaque(true); 2894 layer1->SetContentsOpaque(true);
2894 layer1->SetExpectation(false, false); 2895 layer1->SetExpectation(false, false);
2895 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2896 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2896 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2897 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2897 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2898 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2898 EXPECT_TRUE(layer1->quads_appended()); 2899 EXPECT_TRUE(layer1->quads_appended());
2899 host_impl_->DidDrawAllLayers(frame); 2900 host_impl_->DidDrawAllLayers(frame);
2900 2901
2901 // Layer with translucent content and painting, so drawn with blending. 2902 // Layer with translucent content and painting, so drawn with blending.
2902 layer1->SetContentsOpaque(false); 2903 layer1->SetContentsOpaque(false);
2903 layer1->SetExpectation(true, false); 2904 layer1->SetExpectation(true, false);
2904 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2905 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2905 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2906 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2906 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2907 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2907 EXPECT_TRUE(layer1->quads_appended()); 2908 EXPECT_TRUE(layer1->quads_appended());
2908 host_impl_->DidDrawAllLayers(frame); 2909 host_impl_->DidDrawAllLayers(frame);
2909 2910
2910 // Layer with translucent opacity, drawn with blending. 2911 // Layer with translucent opacity, drawn with blending.
2911 layer1->SetContentsOpaque(true); 2912 layer1->SetContentsOpaque(true);
2912 layer1->SetOpacity(0.5f); 2913 layer1->SetOpacity(0.5f);
2913 layer1->SetExpectation(true, false); 2914 layer1->SetExpectation(true, false);
2914 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2915 layer1->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 host_impl_->DidDrawAllLayers(frame); 2919 host_impl_->DidDrawAllLayers(frame);
2919 2920
2920 // Layer with translucent opacity and painting, drawn with blending. 2921 // Layer with translucent opacity and painting, drawn with blending.
2921 layer1->SetContentsOpaque(true); 2922 layer1->SetContentsOpaque(true);
2922 layer1->SetOpacity(0.5f); 2923 layer1->SetOpacity(0.5f);
2923 layer1->SetExpectation(true, false); 2924 layer1->SetExpectation(true, false);
2924 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2925 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2925 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2926 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2926 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2927 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2927 EXPECT_TRUE(layer1->quads_appended()); 2928 EXPECT_TRUE(layer1->quads_appended());
2928 host_impl_->DidDrawAllLayers(frame); 2929 host_impl_->DidDrawAllLayers(frame);
2929 2930
2930 layer1->AddChild( 2931 layer1->AddChild(
2931 BlendStateCheckLayer::Create(host_impl_->active_tree(), 2932 BlendStateCheckLayer::Create(host_impl_->active_tree(),
2932 3, 2933 3,
2933 host_impl_->resource_provider())); 2934 host_impl_->resource_provider()));
2934 BlendStateCheckLayer* layer2 = 2935 BlendStateCheckLayer* layer2 =
2935 static_cast<BlendStateCheckLayer*>(layer1->children()[0]); 2936 static_cast<BlendStateCheckLayer*>(layer1->children()[0]);
2936 layer2->SetPosition(gfx::PointF(4.f, 4.f)); 2937 layer2->SetPosition(gfx::PointF(4.f, 4.f));
2937 2938
2938 // 2 opaque layers, drawn without blending. 2939 // 2 opaque layers, drawn without blending.
2939 layer1->SetContentsOpaque(true); 2940 layer1->SetContentsOpaque(true);
2940 layer1->SetOpacity(1.f); 2941 layer1->SetOpacity(1.f);
2941 layer1->SetExpectation(false, false); 2942 layer1->SetExpectation(false, false);
2942 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2943 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2943 layer2->SetContentsOpaque(true); 2944 layer2->SetContentsOpaque(true);
2944 layer2->SetOpacity(1.f); 2945 layer2->SetOpacity(1.f);
2945 layer2->SetExpectation(false, false); 2946 layer2->SetExpectation(false, false);
2946 layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); 2947 layer2->set_update_rect(gfx::RectF(layer1->content_bounds()));
2947 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2948 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2948 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2949 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2949 EXPECT_TRUE(layer1->quads_appended()); 2950 EXPECT_TRUE(layer1->quads_appended());
2950 EXPECT_TRUE(layer2->quads_appended()); 2951 EXPECT_TRUE(layer2->quads_appended());
2951 host_impl_->DidDrawAllLayers(frame); 2952 host_impl_->DidDrawAllLayers(frame);
2952 2953
2953 // Parent layer with translucent content, drawn with blending. 2954 // Parent layer with translucent content, drawn with blending.
2954 // Child layer with opaque content, drawn without blending. 2955 // Child layer with opaque content, drawn without blending.
2955 layer1->SetContentsOpaque(false); 2956 layer1->SetContentsOpaque(false);
2956 layer1->SetExpectation(true, false); 2957 layer1->SetExpectation(true, false);
2957 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2958 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2958 layer2->SetExpectation(false, false); 2959 layer2->SetExpectation(false, false);
2959 layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); 2960 layer2->set_update_rect(gfx::RectF(layer1->content_bounds()));
2960 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2961 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2961 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2962 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2962 EXPECT_TRUE(layer1->quads_appended()); 2963 EXPECT_TRUE(layer1->quads_appended());
2963 EXPECT_TRUE(layer2->quads_appended()); 2964 EXPECT_TRUE(layer2->quads_appended());
2964 host_impl_->DidDrawAllLayers(frame); 2965 host_impl_->DidDrawAllLayers(frame);
2965 2966
2966 // Parent layer with translucent content but opaque painting, drawn without 2967 // Parent layer with translucent content but opaque painting, drawn without
2967 // blending. 2968 // blending.
2968 // Child layer with opaque content, drawn without blending. 2969 // Child layer with opaque content, drawn without blending.
2969 layer1->SetContentsOpaque(true); 2970 layer1->SetContentsOpaque(true);
2970 layer1->SetExpectation(false, false); 2971 layer1->SetExpectation(false, false);
2971 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2972 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2972 layer2->SetExpectation(false, false); 2973 layer2->SetExpectation(false, false);
2973 layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); 2974 layer2->set_update_rect(gfx::RectF(layer1->content_bounds()));
2974 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2975 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2975 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2976 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2976 EXPECT_TRUE(layer1->quads_appended()); 2977 EXPECT_TRUE(layer1->quads_appended());
2977 EXPECT_TRUE(layer2->quads_appended()); 2978 EXPECT_TRUE(layer2->quads_appended());
2978 host_impl_->DidDrawAllLayers(frame); 2979 host_impl_->DidDrawAllLayers(frame);
2979 2980
2980 // Parent layer with translucent opacity and opaque content. Since it has a 2981 // Parent layer with translucent opacity and opaque content. Since it has a
2981 // drawing child, it's drawn to a render surface which carries the opacity, 2982 // drawing child, it's drawn to a render surface which carries the opacity,
2982 // so it's itself drawn without blending. 2983 // so it's itself drawn without blending.
2983 // Child layer with opaque content, drawn without blending (parent surface 2984 // Child layer with opaque content, drawn without blending (parent surface
2984 // carries the inherited opacity). 2985 // carries the inherited opacity).
2985 layer1->SetContentsOpaque(true); 2986 layer1->SetContentsOpaque(true);
2986 layer1->SetOpacity(0.5f); 2987 layer1->SetOpacity(0.5f);
2987 layer1->SetExpectation(false, true); 2988 layer1->SetExpectation(false, true);
2988 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 2989 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
2989 layer2->SetExpectation(false, false); 2990 layer2->SetExpectation(false, false);
2990 layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); 2991 layer2->set_update_rect(gfx::RectF(layer1->content_bounds()));
2991 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2992 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2992 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 2993 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2993 EXPECT_TRUE(layer1->quads_appended()); 2994 EXPECT_TRUE(layer1->quads_appended());
2994 EXPECT_TRUE(layer2->quads_appended()); 2995 EXPECT_TRUE(layer2->quads_appended());
2995 host_impl_->DidDrawAllLayers(frame); 2996 host_impl_->DidDrawAllLayers(frame);
2996 2997
2997 // Draw again, but with child non-opaque, to make sure 2998 // Draw again, but with child non-opaque, to make sure
2998 // layer1 not culled. 2999 // layer1 not culled.
2999 layer1->SetContentsOpaque(true); 3000 layer1->SetContentsOpaque(true);
3000 layer1->SetOpacity(1.f); 3001 layer1->SetOpacity(1.f);
3001 layer1->SetExpectation(false, false); 3002 layer1->SetExpectation(false, false);
3002 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 3003 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
3003 layer2->SetContentsOpaque(true); 3004 layer2->SetContentsOpaque(true);
3004 layer2->SetOpacity(0.5f); 3005 layer2->SetOpacity(0.5f);
3005 layer2->SetExpectation(true, false); 3006 layer2->SetExpectation(true, false);
3006 layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); 3007 layer2->set_update_rect(gfx::RectF(layer1->content_bounds()));
3007 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3008 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3008 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3009 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3009 EXPECT_TRUE(layer1->quads_appended()); 3010 EXPECT_TRUE(layer1->quads_appended());
3010 EXPECT_TRUE(layer2->quads_appended()); 3011 EXPECT_TRUE(layer2->quads_appended());
3011 host_impl_->DidDrawAllLayers(frame); 3012 host_impl_->DidDrawAllLayers(frame);
3012 3013
3013 // A second way of making the child non-opaque. 3014 // A second way of making the child non-opaque.
3014 layer1->SetContentsOpaque(true); 3015 layer1->SetContentsOpaque(true);
3015 layer1->SetOpacity(1.f); 3016 layer1->SetOpacity(1.f);
3016 layer1->SetExpectation(false, false); 3017 layer1->SetExpectation(false, false);
3017 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 3018 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
3018 layer2->SetContentsOpaque(false); 3019 layer2->SetContentsOpaque(false);
3019 layer2->SetOpacity(1.f); 3020 layer2->SetOpacity(1.f);
3020 layer2->SetExpectation(true, false); 3021 layer2->SetExpectation(true, false);
3021 layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); 3022 layer2->set_update_rect(gfx::RectF(layer1->content_bounds()));
3022 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3023 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3023 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3024 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3024 EXPECT_TRUE(layer1->quads_appended()); 3025 EXPECT_TRUE(layer1->quads_appended());
3025 EXPECT_TRUE(layer2->quads_appended()); 3026 EXPECT_TRUE(layer2->quads_appended());
3026 host_impl_->DidDrawAllLayers(frame); 3027 host_impl_->DidDrawAllLayers(frame);
3027 3028
3028 // And when the layer says its not opaque but is painted opaque, it is not 3029 // And when the layer says its not opaque but is painted opaque, it is not
3029 // blended. 3030 // blended.
3030 layer1->SetContentsOpaque(true); 3031 layer1->SetContentsOpaque(true);
3031 layer1->SetOpacity(1.f); 3032 layer1->SetOpacity(1.f);
3032 layer1->SetExpectation(false, false); 3033 layer1->SetExpectation(false, false);
3033 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 3034 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
3034 layer2->SetContentsOpaque(true); 3035 layer2->SetContentsOpaque(true);
3035 layer2->SetOpacity(1.f); 3036 layer2->SetOpacity(1.f);
3036 layer2->SetExpectation(false, false); 3037 layer2->SetExpectation(false, false);
3037 layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); 3038 layer2->set_update_rect(gfx::RectF(layer1->content_bounds()));
3038 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3039 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3039 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3040 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3040 EXPECT_TRUE(layer1->quads_appended()); 3041 EXPECT_TRUE(layer1->quads_appended());
3041 EXPECT_TRUE(layer2->quads_appended()); 3042 EXPECT_TRUE(layer2->quads_appended());
3042 host_impl_->DidDrawAllLayers(frame); 3043 host_impl_->DidDrawAllLayers(frame);
3043 3044
3044 // Layer with partially opaque contents, drawn with blending. 3045 // Layer with partially opaque contents, drawn with blending.
3045 layer1->SetContentsOpaque(false); 3046 layer1->SetContentsOpaque(false);
3046 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3047 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3047 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); 3048 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5));
3048 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3049 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3049 layer1->SetExpectation(true, false); 3050 layer1->SetExpectation(true, false);
3050 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 3051 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
3051 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3052 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3052 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3053 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3053 EXPECT_TRUE(layer1->quads_appended()); 3054 EXPECT_TRUE(layer1->quads_appended());
3054 host_impl_->DidDrawAllLayers(frame); 3055 host_impl_->DidDrawAllLayers(frame);
3055 3056
3056 // Layer with partially opaque contents partially culled, drawn with blending. 3057 // Layer with partially opaque contents partially culled, drawn with blending.
3057 layer1->SetContentsOpaque(false); 3058 layer1->SetContentsOpaque(false);
3058 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3059 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3059 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); 3060 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2));
3060 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3061 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3061 layer1->SetExpectation(true, false); 3062 layer1->SetExpectation(true, false);
3062 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 3063 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
3063 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3064 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3064 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3065 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3065 EXPECT_TRUE(layer1->quads_appended()); 3066 EXPECT_TRUE(layer1->quads_appended());
3066 host_impl_->DidDrawAllLayers(frame); 3067 host_impl_->DidDrawAllLayers(frame);
3067 3068
3068 // Layer with partially opaque contents culled, drawn with blending. 3069 // Layer with partially opaque contents culled, drawn with blending.
3069 layer1->SetContentsOpaque(false); 3070 layer1->SetContentsOpaque(false);
3070 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3071 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3071 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); 3072 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5));
3072 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3073 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3073 layer1->SetExpectation(true, false); 3074 layer1->SetExpectation(true, false);
3074 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 3075 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
3075 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3076 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3076 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3077 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3077 EXPECT_TRUE(layer1->quads_appended()); 3078 EXPECT_TRUE(layer1->quads_appended());
3078 host_impl_->DidDrawAllLayers(frame); 3079 host_impl_->DidDrawAllLayers(frame);
3079 3080
3080 // Layer with partially opaque contents and translucent contents culled, drawn 3081 // Layer with partially opaque contents and translucent contents culled, drawn
3081 // without blending. 3082 // without blending.
3082 layer1->SetContentsOpaque(false); 3083 layer1->SetContentsOpaque(false);
3083 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3084 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3084 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); 3085 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5));
3085 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3086 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3086 layer1->SetExpectation(false, false); 3087 layer1->SetExpectation(false, false);
3087 layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); 3088 layer1->set_update_rect(gfx::RectF(layer1->content_bounds()));
3088 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3089 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3089 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3090 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3090 EXPECT_TRUE(layer1->quads_appended()); 3091 EXPECT_TRUE(layer1->quads_appended());
3091 host_impl_->DidDrawAllLayers(frame); 3092 host_impl_->DidDrawAllLayers(frame);
3092 } 3093 }
3093 3094
3094 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { 3095 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest {
3095 public: 3096 public:
3096 LayerTreeHostImplViewportCoveredTest() : 3097 LayerTreeHostImplViewportCoveredTest() :
3097 gutter_quad_material_(DrawQuad::SOLID_COLOR), 3098 gutter_quad_material_(DrawQuad::SOLID_COLOR),
3098 child_(NULL), 3099 child_(NULL),
3099 did_activate_pending_tree_(false) {} 3100 did_activate_pending_tree_(false) {}
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
3438 root->SetContentBounds(gfx::Size(10, 10)); 3439 root->SetContentBounds(gfx::Size(10, 10));
3439 root->SetDrawsContent(true); 3440 root->SetDrawsContent(true);
3440 host_impl_->active_tree()->SetRootLayer(root.Pass()); 3441 host_impl_->active_tree()->SetRootLayer(root.Pass());
3441 EXPECT_FALSE(reshape_tracker->reshape_called()); 3442 EXPECT_FALSE(reshape_tracker->reshape_called());
3442 reshape_tracker->clear_reshape_called(); 3443 reshape_tracker->clear_reshape_called();
3443 3444
3444 LayerTreeHostImpl::FrameData frame; 3445 LayerTreeHostImpl::FrameData frame;
3445 host_impl_->SetViewportSize(gfx::Size(10, 10)); 3446 host_impl_->SetViewportSize(gfx::Size(10, 10));
3446 host_impl_->SetDeviceScaleFactor(1.f); 3447 host_impl_->SetDeviceScaleFactor(1.f);
3447 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3448 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3448 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3449 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3449 EXPECT_TRUE(reshape_tracker->reshape_called()); 3450 EXPECT_TRUE(reshape_tracker->reshape_called());
3450 EXPECT_EQ(reshape_tracker->last_reshape_width(), 10); 3451 EXPECT_EQ(reshape_tracker->last_reshape_width(), 10);
3451 EXPECT_EQ(reshape_tracker->last_reshape_height(), 10); 3452 EXPECT_EQ(reshape_tracker->last_reshape_height(), 10);
3452 EXPECT_EQ(reshape_tracker->last_reshape_scale_factor(), 1.f); 3453 EXPECT_EQ(reshape_tracker->last_reshape_scale_factor(), 1.f);
3453 host_impl_->DidDrawAllLayers(frame); 3454 host_impl_->DidDrawAllLayers(frame);
3454 reshape_tracker->clear_reshape_called(); 3455 reshape_tracker->clear_reshape_called();
3455 3456
3456 host_impl_->SetViewportSize(gfx::Size(20, 30)); 3457 host_impl_->SetViewportSize(gfx::Size(20, 30));
3457 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3458 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3458 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3459 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3459 EXPECT_TRUE(reshape_tracker->reshape_called()); 3460 EXPECT_TRUE(reshape_tracker->reshape_called());
3460 EXPECT_EQ(reshape_tracker->last_reshape_width(), 20); 3461 EXPECT_EQ(reshape_tracker->last_reshape_width(), 20);
3461 EXPECT_EQ(reshape_tracker->last_reshape_height(), 30); 3462 EXPECT_EQ(reshape_tracker->last_reshape_height(), 30);
3462 EXPECT_EQ(reshape_tracker->last_reshape_scale_factor(), 1.f); 3463 EXPECT_EQ(reshape_tracker->last_reshape_scale_factor(), 1.f);
3463 host_impl_->DidDrawAllLayers(frame); 3464 host_impl_->DidDrawAllLayers(frame);
3464 reshape_tracker->clear_reshape_called(); 3465 reshape_tracker->clear_reshape_called();
3465 3466
3466 host_impl_->SetDeviceScaleFactor(2.f); 3467 host_impl_->SetDeviceScaleFactor(2.f);
3467 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3468 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3468 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3469 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3469 EXPECT_TRUE(reshape_tracker->reshape_called()); 3470 EXPECT_TRUE(reshape_tracker->reshape_called());
3470 EXPECT_EQ(reshape_tracker->last_reshape_width(), 20); 3471 EXPECT_EQ(reshape_tracker->last_reshape_width(), 20);
3471 EXPECT_EQ(reshape_tracker->last_reshape_height(), 30); 3472 EXPECT_EQ(reshape_tracker->last_reshape_height(), 30);
3472 EXPECT_EQ(reshape_tracker->last_reshape_scale_factor(), 2.f); 3473 EXPECT_EQ(reshape_tracker->last_reshape_scale_factor(), 2.f);
3473 host_impl_->DidDrawAllLayers(frame); 3474 host_impl_->DidDrawAllLayers(frame);
3474 reshape_tracker->clear_reshape_called(); 3475 reshape_tracker->clear_reshape_called();
3475 } 3476 }
3476 3477
3477 class SwapTrackerContext : public TestWebGraphicsContext3D { 3478 class SwapTrackerContext : public TestWebGraphicsContext3D {
3478 public: 3479 public:
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
3542 root->SetBounds(gfx::Size(500, 500)); 3543 root->SetBounds(gfx::Size(500, 500));
3543 root->SetContentBounds(gfx::Size(500, 500)); 3544 root->SetContentBounds(gfx::Size(500, 500));
3544 root->SetDrawsContent(true); 3545 root->SetDrawsContent(true);
3545 root->AddChild(child.Pass()); 3546 root->AddChild(child.Pass());
3546 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass()); 3547 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass());
3547 3548
3548 LayerTreeHostImpl::FrameData frame; 3549 LayerTreeHostImpl::FrameData frame;
3549 3550
3550 // First frame, the entire screen should get swapped. 3551 // First frame, the entire screen should get swapped.
3551 EXPECT_TRUE(layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect())); 3552 EXPECT_TRUE(layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect()));
3552 layer_tree_host_impl->DrawLayers(&frame, base::TimeTicks::Now()); 3553 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
3553 layer_tree_host_impl->DidDrawAllLayers(frame); 3554 layer_tree_host_impl->DidDrawAllLayers(frame);
3554 layer_tree_host_impl->SwapBuffers(frame); 3555 layer_tree_host_impl->SwapBuffers(frame);
3555 gfx::Rect actual_swap_rect = swap_tracker->update_rect(); 3556 gfx::Rect actual_swap_rect = swap_tracker->update_rect();
3556 gfx::Rect expected_swap_rect = gfx::Rect(0, 0, 500, 500); 3557 gfx::Rect expected_swap_rect = gfx::Rect(0, 0, 500, 500);
3557 EXPECT_EQ(expected_swap_rect.x(), actual_swap_rect.x()); 3558 EXPECT_EQ(expected_swap_rect.x(), actual_swap_rect.x());
3558 EXPECT_EQ(expected_swap_rect.y(), actual_swap_rect.y()); 3559 EXPECT_EQ(expected_swap_rect.y(), actual_swap_rect.y());
3559 EXPECT_EQ(expected_swap_rect.width(), actual_swap_rect.width()); 3560 EXPECT_EQ(expected_swap_rect.width(), actual_swap_rect.width());
3560 EXPECT_EQ(expected_swap_rect.height(), actual_swap_rect.height()); 3561 EXPECT_EQ(expected_swap_rect.height(), actual_swap_rect.height());
3561 EXPECT_EQ(swap_tracker->last_update_type(), 3562 EXPECT_EQ(swap_tracker->last_update_type(),
3562 SwapTrackerContext::PrepareTexture); 3563 SwapTrackerContext::PrepareTexture);
3563 // Second frame, only the damaged area should get swapped. Damage should be 3564 // Second frame, only the damaged area should get swapped. Damage should be
3564 // the union of old and new child rects. 3565 // the union of old and new child rects.
3565 // expected damage rect: gfx::Rect(26, 28); 3566 // expected damage rect: gfx::Rect(26, 28);
3566 // expected swap rect: vertically flipped, with origin at bottom left corner. 3567 // expected swap rect: vertically flipped, with origin at bottom left corner.
3567 layer_tree_host_impl->active_tree()->root_layer()->children()[0]->SetPosition( 3568 layer_tree_host_impl->active_tree()->root_layer()->children()[0]->SetPosition(
3568 gfx::PointF()); 3569 gfx::PointF());
3569 EXPECT_TRUE(layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect())); 3570 EXPECT_TRUE(layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect()));
3570 layer_tree_host_impl->DrawLayers(&frame, base::TimeTicks::Now()); 3571 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
3571 host_impl_->DidDrawAllLayers(frame); 3572 host_impl_->DidDrawAllLayers(frame);
3572 layer_tree_host_impl->SwapBuffers(frame); 3573 layer_tree_host_impl->SwapBuffers(frame);
3573 actual_swap_rect = swap_tracker->update_rect(); 3574 actual_swap_rect = swap_tracker->update_rect();
3574 expected_swap_rect = gfx::Rect(0, 500-28, 26, 28); 3575 expected_swap_rect = gfx::Rect(0, 500-28, 26, 28);
3575 EXPECT_EQ(expected_swap_rect.x(), actual_swap_rect.x()); 3576 EXPECT_EQ(expected_swap_rect.x(), actual_swap_rect.x());
3576 EXPECT_EQ(expected_swap_rect.y(), actual_swap_rect.y()); 3577 EXPECT_EQ(expected_swap_rect.y(), actual_swap_rect.y());
3577 EXPECT_EQ(expected_swap_rect.width(), actual_swap_rect.width()); 3578 EXPECT_EQ(expected_swap_rect.width(), actual_swap_rect.width());
3578 EXPECT_EQ(expected_swap_rect.height(), actual_swap_rect.height()); 3579 EXPECT_EQ(expected_swap_rect.height(), actual_swap_rect.height());
3579 EXPECT_EQ(swap_tracker->last_update_type(), 3580 EXPECT_EQ(swap_tracker->last_update_type(),
3580 SwapTrackerContext::PostSubBuffer); 3581 SwapTrackerContext::PostSubBuffer);
3581 3582
3582 // Make sure that partial swap is constrained to the viewport dimensions 3583 // Make sure that partial swap is constrained to the viewport dimensions
3583 // expected damage rect: gfx::Rect(500, 500); 3584 // expected damage rect: gfx::Rect(500, 500);
3584 // expected swap rect: flipped damage rect, but also clamped to viewport 3585 // expected swap rect: flipped damage rect, but also clamped to viewport
3585 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10)); 3586 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10));
3586 // This will damage everything. 3587 // This will damage everything.
3587 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor( 3588 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor(
3588 SK_ColorBLACK); 3589 SK_ColorBLACK);
3589 EXPECT_TRUE(layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect())); 3590 EXPECT_TRUE(layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect()));
3590 layer_tree_host_impl->DrawLayers(&frame, base::TimeTicks::Now()); 3591 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
3591 host_impl_->DidDrawAllLayers(frame); 3592 host_impl_->DidDrawAllLayers(frame);
3592 layer_tree_host_impl->SwapBuffers(frame); 3593 layer_tree_host_impl->SwapBuffers(frame);
3593 actual_swap_rect = swap_tracker->update_rect(); 3594 actual_swap_rect = swap_tracker->update_rect();
3594 expected_swap_rect = gfx::Rect(10, 10); 3595 expected_swap_rect = gfx::Rect(10, 10);
3595 EXPECT_EQ(expected_swap_rect.x(), actual_swap_rect.x()); 3596 EXPECT_EQ(expected_swap_rect.x(), actual_swap_rect.x());
3596 EXPECT_EQ(expected_swap_rect.y(), actual_swap_rect.y()); 3597 EXPECT_EQ(expected_swap_rect.y(), actual_swap_rect.y());
3597 EXPECT_EQ(expected_swap_rect.width(), actual_swap_rect.width()); 3598 EXPECT_EQ(expected_swap_rect.width(), actual_swap_rect.width());
3598 EXPECT_EQ(expected_swap_rect.height(), actual_swap_rect.height()); 3599 EXPECT_EQ(expected_swap_rect.height(), actual_swap_rect.height());
3599 EXPECT_EQ(swap_tracker->last_update_type(), 3600 EXPECT_EQ(swap_tracker->last_update_type(),
3600 SwapTrackerContext::PrepareTexture); 3601 SwapTrackerContext::PrepareTexture);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
3748 // Run test case 3749 // Run test case
3749 CreateLayerTreeHost(false, output_surface.Pass()); 3750 CreateLayerTreeHost(false, output_surface.Pass());
3750 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); 3751 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
3751 3752
3752 // Without partial swap, and no clipping, no scissor is set. 3753 // Without partial swap, and no clipping, no scissor is set.
3753 harness.MustDrawSolidQuad(); 3754 harness.MustDrawSolidQuad();
3754 harness.MustSetNoScissor(); 3755 harness.MustSetNoScissor();
3755 { 3756 {
3756 LayerTreeHostImpl::FrameData frame; 3757 LayerTreeHostImpl::FrameData frame;
3757 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3758 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3758 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3759 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3759 host_impl_->DidDrawAllLayers(frame); 3760 host_impl_->DidDrawAllLayers(frame);
3760 } 3761 }
3761 Mock::VerifyAndClearExpectations(&mock_context); 3762 Mock::VerifyAndClearExpectations(&mock_context);
3762 3763
3763 // Without partial swap, but a layer does clip its subtree, one scissor is 3764 // Without partial swap, but a layer does clip its subtree, one scissor is
3764 // set. 3765 // set.
3765 host_impl_->active_tree()->root_layer()->SetMasksToBounds(true); 3766 host_impl_->active_tree()->root_layer()->SetMasksToBounds(true);
3766 harness.MustDrawSolidQuad(); 3767 harness.MustDrawSolidQuad();
3767 harness.MustSetScissor(0, 0, 10, 10); 3768 harness.MustSetScissor(0, 0, 10, 10);
3768 { 3769 {
3769 LayerTreeHostImpl::FrameData frame; 3770 LayerTreeHostImpl::FrameData frame;
3770 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3771 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3771 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3772 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3772 host_impl_->DidDrawAllLayers(frame); 3773 host_impl_->DidDrawAllLayers(frame);
3773 } 3774 }
3774 Mock::VerifyAndClearExpectations(&mock_context); 3775 Mock::VerifyAndClearExpectations(&mock_context);
3775 } 3776 }
3776 3777
3777 TEST_F(LayerTreeHostImplTest, PartialSwap) { 3778 TEST_F(LayerTreeHostImplTest, PartialSwap) {
3778 scoped_ptr<MockContext> context_owned(new MockContext); 3779 scoped_ptr<MockContext> context_owned(new MockContext);
3779 MockContext* mock_context = context_owned.get(); 3780 MockContext* mock_context = context_owned.get();
3780 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 3781 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
3781 context_owned.PassAs<TestWebGraphicsContext3D>())); 3782 context_owned.PassAs<TestWebGraphicsContext3D>()));
3782 MockContextHarness harness(mock_context); 3783 MockContextHarness harness(mock_context);
3783 3784
3784 CreateLayerTreeHost(true, output_surface.Pass()); 3785 CreateLayerTreeHost(true, output_surface.Pass());
3785 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); 3786 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
3786 3787
3787 // The first frame is not a partially-swapped one. 3788 // The first frame is not a partially-swapped one.
3788 harness.MustSetScissor(0, 0, 10, 10); 3789 harness.MustSetScissor(0, 0, 10, 10);
3789 harness.MustDrawSolidQuad(); 3790 harness.MustDrawSolidQuad();
3790 { 3791 {
3791 LayerTreeHostImpl::FrameData frame; 3792 LayerTreeHostImpl::FrameData frame;
3792 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3793 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3793 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3794 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3794 host_impl_->DidDrawAllLayers(frame); 3795 host_impl_->DidDrawAllLayers(frame);
3795 } 3796 }
3796 Mock::VerifyAndClearExpectations(&mock_context); 3797 Mock::VerifyAndClearExpectations(&mock_context);
3797 3798
3798 // Damage a portion of the frame. 3799 // Damage a portion of the frame.
3799 host_impl_->active_tree()->root_layer()->set_update_rect( 3800 host_impl_->active_tree()->root_layer()->set_update_rect(
3800 gfx::Rect(0, 0, 2, 3)); 3801 gfx::Rect(0, 0, 2, 3));
3801 3802
3802 // The second frame will be partially-swapped (the y coordinates are flipped). 3803 // The second frame will be partially-swapped (the y coordinates are flipped).
3803 harness.MustSetScissor(0, 7, 2, 3); 3804 harness.MustSetScissor(0, 7, 2, 3);
3804 harness.MustDrawSolidQuad(); 3805 harness.MustDrawSolidQuad();
3805 { 3806 {
3806 LayerTreeHostImpl::FrameData frame; 3807 LayerTreeHostImpl::FrameData frame;
3807 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3808 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3808 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 3809 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3809 host_impl_->DidDrawAllLayers(frame); 3810 host_impl_->DidDrawAllLayers(frame);
3810 } 3811 }
3811 Mock::VerifyAndClearExpectations(&mock_context); 3812 Mock::VerifyAndClearExpectations(&mock_context);
3812 } 3813 }
3813 3814
3814 class PartialSwapContext : public TestWebGraphicsContext3D { 3815 class PartialSwapContext : public TestWebGraphicsContext3D {
3815 public: 3816 public:
3816 PartialSwapContext() { 3817 PartialSwapContext() {
3817 test_capabilities_.post_sub_buffer = true; 3818 test_capabilities_.post_sub_buffer = true;
3818 } 3819 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
3912 3913
3913 // Verify all quads have been computed 3914 // Verify all quads have been computed
3914 ASSERT_EQ(2U, frame.render_passes.size()); 3915 ASSERT_EQ(2U, frame.render_passes.size());
3915 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 3916 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
3916 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 3917 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
3917 EXPECT_EQ(DrawQuad::SOLID_COLOR, 3918 EXPECT_EQ(DrawQuad::SOLID_COLOR,
3918 frame.render_passes[0]->quad_list[0]->material); 3919 frame.render_passes[0]->quad_list[0]->material);
3919 EXPECT_EQ(DrawQuad::RENDER_PASS, 3920 EXPECT_EQ(DrawQuad::RENDER_PASS,
3920 frame.render_passes[1]->quad_list[0]->material); 3921 frame.render_passes[1]->quad_list[0]->material);
3921 3922
3922 my_host_impl->DrawLayers(&frame, base::TimeTicks::Now()); 3923 my_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
3923 my_host_impl->DidDrawAllLayers(frame); 3924 my_host_impl->DidDrawAllLayers(frame);
3924 } 3925 }
3925 } 3926 }
3926 3927
3927 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { 3928 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) {
3928 scoped_ptr<LayerTreeHostImpl> my_host_impl = 3929 scoped_ptr<LayerTreeHostImpl> my_host_impl =
3929 SetupLayersForOpacity(false, this, &proxy_, &stats_instrumentation_); 3930 SetupLayersForOpacity(false, this, &proxy_, &stats_instrumentation_);
3930 { 3931 {
3931 LayerTreeHostImpl::FrameData frame; 3932 LayerTreeHostImpl::FrameData frame;
3932 EXPECT_TRUE(my_host_impl->PrepareToDraw(&frame, gfx::Rect())); 3933 EXPECT_TRUE(my_host_impl->PrepareToDraw(&frame, gfx::Rect()));
3933 3934
3934 // Verify all quads have been computed 3935 // Verify all quads have been computed
3935 ASSERT_EQ(2U, frame.render_passes.size()); 3936 ASSERT_EQ(2U, frame.render_passes.size());
3936 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 3937 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
3937 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 3938 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
3938 EXPECT_EQ(DrawQuad::SOLID_COLOR, 3939 EXPECT_EQ(DrawQuad::SOLID_COLOR,
3939 frame.render_passes[0]->quad_list[0]->material); 3940 frame.render_passes[0]->quad_list[0]->material);
3940 EXPECT_EQ(DrawQuad::RENDER_PASS, 3941 EXPECT_EQ(DrawQuad::RENDER_PASS,
3941 frame.render_passes[1]->quad_list[0]->material); 3942 frame.render_passes[1]->quad_list[0]->material);
3942 3943
3943 my_host_impl->DrawLayers(&frame, base::TimeTicks::Now()); 3944 my_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
3944 my_host_impl->DidDrawAllLayers(frame); 3945 my_host_impl->DidDrawAllLayers(frame);
3945 } 3946 }
3946 } 3947 }
3947 3948
3948 // Fake WebKit::WebGraphicsContext3D that tracks the number of textures in use. 3949 // Fake WebKit::WebGraphicsContext3D that tracks the number of textures in use.
3949 class TrackingWebGraphicsContext3D : public TestWebGraphicsContext3D { 3950 class TrackingWebGraphicsContext3D : public TestWebGraphicsContext3D {
3950 public: 3951 public:
3951 TrackingWebGraphicsContext3D() 3952 TrackingWebGraphicsContext3D()
3952 : TestWebGraphicsContext3D(), 3953 : TestWebGraphicsContext3D(),
3953 num_textures_(0) { 3954 num_textures_(0) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
4012 io_surface_layer->SetDrawsContent(true); 4013 io_surface_layer->SetDrawsContent(true);
4013 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10)); 4014 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10));
4014 root_layer->AddChild(io_surface_layer.PassAs<LayerImpl>()); 4015 root_layer->AddChild(io_surface_layer.PassAs<LayerImpl>());
4015 4016
4016 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); 4017 host_impl_->active_tree()->SetRootLayer(root_layer.Pass());
4017 4018
4018 EXPECT_EQ(0u, context3d->NumTextures()); 4019 EXPECT_EQ(0u, context3d->NumTextures());
4019 4020
4020 LayerTreeHostImpl::FrameData frame; 4021 LayerTreeHostImpl::FrameData frame;
4021 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4022 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4022 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4023 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4023 host_impl_->DidDrawAllLayers(frame); 4024 host_impl_->DidDrawAllLayers(frame);
4024 host_impl_->SwapBuffers(frame); 4025 host_impl_->SwapBuffers(frame);
4025 4026
4026 EXPECT_GT(context3d->NumTextures(), 0u); 4027 EXPECT_GT(context3d->NumTextures(), 0u);
4027 4028
4028 // Kill the layer tree. 4029 // Kill the layer tree.
4029 host_impl_->active_tree()->SetRootLayer( 4030 host_impl_->active_tree()->SetRootLayer(
4030 LayerImpl::Create(host_impl_->active_tree(), 100)); 4031 LayerImpl::Create(host_impl_->active_tree(), 100));
4031 // There should be no textures left in use after. 4032 // There should be no textures left in use after.
4032 EXPECT_EQ(0u, context3d->NumTextures()); 4033 EXPECT_EQ(0u, context3d->NumTextures());
(...skipping 22 matching lines...) Expand all
4055 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); 4056 host_impl_->active_tree()->set_background_color(SK_ColorWHITE);
4056 4057
4057 // Verify one quad is drawn when transparent background set is not set. 4058 // Verify one quad is drawn when transparent background set is not set.
4058 host_impl_->active_tree()->set_has_transparent_background(false); 4059 host_impl_->active_tree()->set_has_transparent_background(false);
4059 EXPECT_CALL(*mock_context, useProgram(_)) 4060 EXPECT_CALL(*mock_context, useProgram(_))
4060 .Times(1); 4061 .Times(1);
4061 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) 4062 EXPECT_CALL(*mock_context, drawElements(_, _, _, _))
4062 .Times(1); 4063 .Times(1);
4063 LayerTreeHostImpl::FrameData frame; 4064 LayerTreeHostImpl::FrameData frame;
4064 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4065 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4065 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4066 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4066 host_impl_->DidDrawAllLayers(frame); 4067 host_impl_->DidDrawAllLayers(frame);
4067 Mock::VerifyAndClearExpectations(&mock_context); 4068 Mock::VerifyAndClearExpectations(&mock_context);
4068 4069
4069 // Verify no quads are drawn when transparent background is set. 4070 // Verify no quads are drawn when transparent background is set.
4070 host_impl_->active_tree()->set_has_transparent_background(true); 4071 host_impl_->active_tree()->set_has_transparent_background(true);
4071 host_impl_->SetFullRootLayerDamage(); 4072 host_impl_->SetFullRootLayerDamage();
4072 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4073 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4073 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4074 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4074 host_impl_->DidDrawAllLayers(frame); 4075 host_impl_->DidDrawAllLayers(frame);
4075 Mock::VerifyAndClearExpectations(&mock_context); 4076 Mock::VerifyAndClearExpectations(&mock_context);
4076 } 4077 }
4077 4078
4078 TEST_F(LayerTreeHostImplTest, ReleaseContentsTextureShouldTriggerCommit) { 4079 TEST_F(LayerTreeHostImplTest, ReleaseContentsTextureShouldTriggerCommit) {
4079 set_reduce_memory_result(false); 4080 set_reduce_memory_result(false);
4080 4081
4081 // If changing the memory limit wouldn't result in changing what was 4082 // If changing the memory limit wouldn't result in changing what was
4082 // committed, then no commit should be requested. 4083 // committed, then no commit should be requested.
4083 set_reduce_memory_result(false); 4084 set_reduce_memory_result(false);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
4150 gfx::RectF expected_child_visible_rect(child->content_bounds()); 4151 gfx::RectF expected_child_visible_rect(child->content_bounds());
4151 EXPECT_RECT_EQ(expected_child_visible_rect, 4152 EXPECT_RECT_EQ(expected_child_visible_rect,
4152 root_render_pass->quad_list[0]->visible_rect); 4153 root_render_pass->quad_list[0]->visible_rect);
4153 4154
4154 LayerImpl* root = host_impl_->active_tree()->root_layer(); 4155 LayerImpl* root = host_impl_->active_tree()->root_layer();
4155 gfx::RectF expected_root_visible_rect(root->content_bounds()); 4156 gfx::RectF expected_root_visible_rect(root->content_bounds());
4156 EXPECT_RECT_EQ(expected_root_visible_rect, 4157 EXPECT_RECT_EQ(expected_root_visible_rect,
4157 root_render_pass->quad_list[1]->visible_rect); 4158 root_render_pass->quad_list[1]->visible_rect);
4158 } 4159 }
4159 4160
4160 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4161 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4161 host_impl_->DidDrawAllLayers(frame); 4162 host_impl_->DidDrawAllLayers(frame);
4162 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame)); 4163 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame));
4163 } 4164 }
4164 }; 4165 };
4165 4166
4166 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { 4167 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) {
4167 scoped_ptr<SolidColorLayerImpl> root = 4168 scoped_ptr<SolidColorLayerImpl> root =
4168 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); 4169 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1);
4169 root->SetAnchorPoint(gfx::PointF()); 4170 root->SetAnchorPoint(gfx::PointF());
4170 root->SetPosition(gfx::PointF()); 4171 root->SetPosition(gfx::PointF());
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
4290 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4291 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4291 ASSERT_EQ(DrawQuad::RENDER_PASS, 4292 ASSERT_EQ(DrawQuad::RENDER_PASS,
4292 frame.render_passes[0]->quad_list[0]->material); 4293 frame.render_passes[0]->quad_list[0]->material);
4293 const RenderPassDrawQuad* render_pass_quad = 4294 const RenderPassDrawQuad* render_pass_quad =
4294 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4295 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4295 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4296 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4296 render_pass_quad->rect.ToString()); 4297 render_pass_quad->rect.ToString());
4297 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4298 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4298 render_pass_quad->mask_uv_rect.ToString()); 4299 render_pass_quad->mask_uv_rect.ToString());
4299 4300
4300 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4301 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4301 host_impl_->DidDrawAllLayers(frame); 4302 host_impl_->DidDrawAllLayers(frame);
4302 } 4303 }
4303 4304
4304 4305
4305 // Applying a DSF should change the render surface size, but won't affect 4306 // Applying a DSF should change the render surface size, but won't affect
4306 // which part of the mask is used. 4307 // which part of the mask is used.
4307 device_scale_factor = 2.f; 4308 device_scale_factor = 2.f;
4308 gfx::Size device_viewport = 4309 gfx::Size device_viewport =
4309 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); 4310 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor));
4310 host_impl_->SetViewportSize(device_viewport); 4311 host_impl_->SetViewportSize(device_viewport);
4311 host_impl_->SetDeviceScaleFactor(device_scale_factor); 4312 host_impl_->SetDeviceScaleFactor(device_scale_factor);
4312 host_impl_->active_tree()->set_needs_update_draw_properties(); 4313 host_impl_->active_tree()->set_needs_update_draw_properties();
4313 { 4314 {
4314 LayerTreeHostImpl::FrameData frame; 4315 LayerTreeHostImpl::FrameData frame;
4315 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4316 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4316 4317
4317 ASSERT_EQ(1u, frame.render_passes.size()); 4318 ASSERT_EQ(1u, frame.render_passes.size());
4318 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4319 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4319 ASSERT_EQ(DrawQuad::RENDER_PASS, 4320 ASSERT_EQ(DrawQuad::RENDER_PASS,
4320 frame.render_passes[0]->quad_list[0]->material); 4321 frame.render_passes[0]->quad_list[0]->material);
4321 const RenderPassDrawQuad* render_pass_quad = 4322 const RenderPassDrawQuad* render_pass_quad =
4322 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4323 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4323 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), 4324 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(),
4324 render_pass_quad->rect.ToString()); 4325 render_pass_quad->rect.ToString());
4325 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4326 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4326 render_pass_quad->mask_uv_rect.ToString()); 4327 render_pass_quad->mask_uv_rect.ToString());
4327 4328
4328 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4329 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4329 host_impl_->DidDrawAllLayers(frame); 4330 host_impl_->DidDrawAllLayers(frame);
4330 } 4331 }
4331 4332
4332 4333
4333 // Applying an equivalent content scale on the content layer and the mask 4334 // Applying an equivalent content scale on the content layer and the mask
4334 // should still result in the same part of the mask being used. 4335 // should still result in the same part of the mask being used.
4335 gfx::Size content_bounds = 4336 gfx::Size content_bounds =
4336 gfx::ToRoundedSize(gfx::ScaleSize(scaling_layer_size, 4337 gfx::ToRoundedSize(gfx::ScaleSize(scaling_layer_size,
4337 device_scale_factor)); 4338 device_scale_factor));
4338 content_layer->SetContentBounds(content_bounds); 4339 content_layer->SetContentBounds(content_bounds);
4339 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4340 content_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4340 mask_layer->SetContentBounds(content_bounds); 4341 mask_layer->SetContentBounds(content_bounds);
4341 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4342 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4342 host_impl_->active_tree()->set_needs_update_draw_properties(); 4343 host_impl_->active_tree()->set_needs_update_draw_properties();
4343 { 4344 {
4344 LayerTreeHostImpl::FrameData frame; 4345 LayerTreeHostImpl::FrameData frame;
4345 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4346 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4346 4347
4347 ASSERT_EQ(1u, frame.render_passes.size()); 4348 ASSERT_EQ(1u, frame.render_passes.size());
4348 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4349 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4349 ASSERT_EQ(DrawQuad::RENDER_PASS, 4350 ASSERT_EQ(DrawQuad::RENDER_PASS,
4350 frame.render_passes[0]->quad_list[0]->material); 4351 frame.render_passes[0]->quad_list[0]->material);
4351 const RenderPassDrawQuad* render_pass_quad = 4352 const RenderPassDrawQuad* render_pass_quad =
4352 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4353 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4353 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), 4354 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(),
4354 render_pass_quad->rect.ToString()); 4355 render_pass_quad->rect.ToString());
4355 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4356 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4356 render_pass_quad->mask_uv_rect.ToString()); 4357 render_pass_quad->mask_uv_rect.ToString());
4357 4358
4358 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4359 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4359 host_impl_->DidDrawAllLayers(frame); 4360 host_impl_->DidDrawAllLayers(frame);
4360 } 4361 }
4361 } 4362 }
4362 4363
4363 TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) { 4364 TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) {
4364 // The mask layer has bounds 100x100 but is attached to a layer with bounds 4365 // The mask layer has bounds 100x100 but is attached to a layer with bounds
4365 // 50x50. 4366 // 50x50.
4366 4367
4367 scoped_ptr<LayerImpl> scoped_root = 4368 scoped_ptr<LayerImpl> scoped_root =
4368 LayerImpl::Create(host_impl_->active_tree(), 1); 4369 LayerImpl::Create(host_impl_->active_tree(), 1);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
4411 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4412 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4412 ASSERT_EQ(DrawQuad::RENDER_PASS, 4413 ASSERT_EQ(DrawQuad::RENDER_PASS,
4413 frame.render_passes[0]->quad_list[0]->material); 4414 frame.render_passes[0]->quad_list[0]->material);
4414 const RenderPassDrawQuad* render_pass_quad = 4415 const RenderPassDrawQuad* render_pass_quad =
4415 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4416 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4416 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), 4417 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(),
4417 render_pass_quad->rect.ToString()); 4418 render_pass_quad->rect.ToString());
4418 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4419 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4419 render_pass_quad->mask_uv_rect.ToString()); 4420 render_pass_quad->mask_uv_rect.ToString());
4420 4421
4421 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4422 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4422 host_impl_->DidDrawAllLayers(frame); 4423 host_impl_->DidDrawAllLayers(frame);
4423 } 4424 }
4424 4425
4425 // Applying a DSF should change the render surface size, but won't affect 4426 // Applying a DSF should change the render surface size, but won't affect
4426 // which part of the mask is used. 4427 // which part of the mask is used.
4427 device_scale_factor = 2.f; 4428 device_scale_factor = 2.f;
4428 gfx::Size device_viewport = 4429 gfx::Size device_viewport =
4429 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); 4430 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor));
4430 host_impl_->SetViewportSize(device_viewport); 4431 host_impl_->SetViewportSize(device_viewport);
4431 host_impl_->SetDeviceScaleFactor(device_scale_factor); 4432 host_impl_->SetDeviceScaleFactor(device_scale_factor);
4432 host_impl_->active_tree()->set_needs_update_draw_properties(); 4433 host_impl_->active_tree()->set_needs_update_draw_properties();
4433 { 4434 {
4434 LayerTreeHostImpl::FrameData frame; 4435 LayerTreeHostImpl::FrameData frame;
4435 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4436 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4436 4437
4437 ASSERT_EQ(1u, frame.render_passes.size()); 4438 ASSERT_EQ(1u, frame.render_passes.size());
4438 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4439 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4439 ASSERT_EQ(DrawQuad::RENDER_PASS, 4440 ASSERT_EQ(DrawQuad::RENDER_PASS,
4440 frame.render_passes[0]->quad_list[0]->material); 4441 frame.render_passes[0]->quad_list[0]->material);
4441 const RenderPassDrawQuad* render_pass_quad = 4442 const RenderPassDrawQuad* render_pass_quad =
4442 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4443 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4443 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4444 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4444 render_pass_quad->rect.ToString()); 4445 render_pass_quad->rect.ToString());
4445 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4446 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4446 render_pass_quad->mask_uv_rect.ToString()); 4447 render_pass_quad->mask_uv_rect.ToString());
4447 4448
4448 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4449 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4449 host_impl_->DidDrawAllLayers(frame); 4450 host_impl_->DidDrawAllLayers(frame);
4450 } 4451 }
4451 4452
4452 // Applying an equivalent content scale on the content layer and the mask 4453 // Applying an equivalent content scale on the content layer and the mask
4453 // should still result in the same part of the mask being used. 4454 // should still result in the same part of the mask being used.
4454 gfx::Size layer_size_large = 4455 gfx::Size layer_size_large =
4455 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor)); 4456 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor));
4456 content_layer->SetContentBounds(layer_size_large); 4457 content_layer->SetContentBounds(layer_size_large);
4457 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4458 content_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4458 gfx::Size mask_size_large = 4459 gfx::Size mask_size_large =
4459 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor)); 4460 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor));
4460 mask_layer->SetContentBounds(mask_size_large); 4461 mask_layer->SetContentBounds(mask_size_large);
4461 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4462 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4462 host_impl_->active_tree()->set_needs_update_draw_properties(); 4463 host_impl_->active_tree()->set_needs_update_draw_properties();
4463 { 4464 {
4464 LayerTreeHostImpl::FrameData frame; 4465 LayerTreeHostImpl::FrameData frame;
4465 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4466 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4466 4467
4467 ASSERT_EQ(1u, frame.render_passes.size()); 4468 ASSERT_EQ(1u, frame.render_passes.size());
4468 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4469 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4469 ASSERT_EQ(DrawQuad::RENDER_PASS, 4470 ASSERT_EQ(DrawQuad::RENDER_PASS,
4470 frame.render_passes[0]->quad_list[0]->material); 4471 frame.render_passes[0]->quad_list[0]->material);
4471 const RenderPassDrawQuad* render_pass_quad = 4472 const RenderPassDrawQuad* render_pass_quad =
4472 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4473 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4473 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4474 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4474 render_pass_quad->rect.ToString()); 4475 render_pass_quad->rect.ToString());
4475 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4476 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4476 render_pass_quad->mask_uv_rect.ToString()); 4477 render_pass_quad->mask_uv_rect.ToString());
4477 4478
4478 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4479 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4479 host_impl_->DidDrawAllLayers(frame); 4480 host_impl_->DidDrawAllLayers(frame);
4480 } 4481 }
4481 4482
4482 // Applying a different contents scale to the mask layer means it will have 4483 // Applying a different contents scale to the mask layer means it will have
4483 // a larger texture, but it should use the same tex coords to cover the 4484 // a larger texture, but it should use the same tex coords to cover the
4484 // layer it masks. 4485 // layer it masks.
4485 mask_layer->SetContentBounds(mask_size); 4486 mask_layer->SetContentBounds(mask_size);
4486 mask_layer->SetContentsScale(1.f, 1.f); 4487 mask_layer->SetContentsScale(1.f, 1.f);
4487 host_impl_->active_tree()->set_needs_update_draw_properties(); 4488 host_impl_->active_tree()->set_needs_update_draw_properties();
4488 { 4489 {
4489 LayerTreeHostImpl::FrameData frame; 4490 LayerTreeHostImpl::FrameData frame;
4490 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4491 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4491 4492
4492 ASSERT_EQ(1u, frame.render_passes.size()); 4493 ASSERT_EQ(1u, frame.render_passes.size());
4493 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4494 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4494 ASSERT_EQ(DrawQuad::RENDER_PASS, 4495 ASSERT_EQ(DrawQuad::RENDER_PASS,
4495 frame.render_passes[0]->quad_list[0]->material); 4496 frame.render_passes[0]->quad_list[0]->material);
4496 const RenderPassDrawQuad* render_pass_quad = 4497 const RenderPassDrawQuad* render_pass_quad =
4497 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4498 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4498 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4499 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4499 render_pass_quad->rect.ToString()); 4500 render_pass_quad->rect.ToString());
4500 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4501 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4501 render_pass_quad->mask_uv_rect.ToString()); 4502 render_pass_quad->mask_uv_rect.ToString());
4502 4503
4503 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4504 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4504 host_impl_->DidDrawAllLayers(frame); 4505 host_impl_->DidDrawAllLayers(frame);
4505 } 4506 }
4506 } 4507 }
4507 4508
4508 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) { 4509 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) {
4509 // The replica's mask layer has bounds 100x100 but the replica is of a 4510 // The replica's mask layer has bounds 100x100 but the replica is of a
4510 // layer with bounds 50x50. 4511 // layer with bounds 50x50.
4511 4512
4512 scoped_ptr<LayerImpl> scoped_root = 4513 scoped_ptr<LayerImpl> scoped_root =
4513 LayerImpl::Create(host_impl_->active_tree(), 1); 4514 LayerImpl::Create(host_impl_->active_tree(), 1);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
4562 ASSERT_EQ(DrawQuad::RENDER_PASS, 4563 ASSERT_EQ(DrawQuad::RENDER_PASS,
4563 frame.render_passes[0]->quad_list[1]->material); 4564 frame.render_passes[0]->quad_list[1]->material);
4564 const RenderPassDrawQuad* replica_quad = 4565 const RenderPassDrawQuad* replica_quad =
4565 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 4566 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
4566 EXPECT_TRUE(replica_quad->is_replica); 4567 EXPECT_TRUE(replica_quad->is_replica);
4567 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), 4568 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(),
4568 replica_quad->rect.ToString()); 4569 replica_quad->rect.ToString());
4569 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4570 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4570 replica_quad->mask_uv_rect.ToString()); 4571 replica_quad->mask_uv_rect.ToString());
4571 4572
4572 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4573 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4573 host_impl_->DidDrawAllLayers(frame); 4574 host_impl_->DidDrawAllLayers(frame);
4574 } 4575 }
4575 4576
4576 // Applying a DSF should change the render surface size, but won't affect 4577 // Applying a DSF should change the render surface size, but won't affect
4577 // which part of the mask is used. 4578 // which part of the mask is used.
4578 device_scale_factor = 2.f; 4579 device_scale_factor = 2.f;
4579 gfx::Size device_viewport = 4580 gfx::Size device_viewport =
4580 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); 4581 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor));
4581 host_impl_->SetViewportSize(device_viewport); 4582 host_impl_->SetViewportSize(device_viewport);
4582 host_impl_->SetDeviceScaleFactor(device_scale_factor); 4583 host_impl_->SetDeviceScaleFactor(device_scale_factor);
4583 host_impl_->active_tree()->set_needs_update_draw_properties(); 4584 host_impl_->active_tree()->set_needs_update_draw_properties();
4584 { 4585 {
4585 LayerTreeHostImpl::FrameData frame; 4586 LayerTreeHostImpl::FrameData frame;
4586 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4587 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4587 4588
4588 ASSERT_EQ(1u, frame.render_passes.size()); 4589 ASSERT_EQ(1u, frame.render_passes.size());
4589 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 4590 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
4590 ASSERT_EQ(DrawQuad::RENDER_PASS, 4591 ASSERT_EQ(DrawQuad::RENDER_PASS,
4591 frame.render_passes[0]->quad_list[1]->material); 4592 frame.render_passes[0]->quad_list[1]->material);
4592 const RenderPassDrawQuad* replica_quad = 4593 const RenderPassDrawQuad* replica_quad =
4593 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 4594 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
4594 EXPECT_TRUE(replica_quad->is_replica); 4595 EXPECT_TRUE(replica_quad->is_replica);
4595 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4596 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4596 replica_quad->rect.ToString()); 4597 replica_quad->rect.ToString());
4597 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4598 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4598 replica_quad->mask_uv_rect.ToString()); 4599 replica_quad->mask_uv_rect.ToString());
4599 4600
4600 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4601 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4601 host_impl_->DidDrawAllLayers(frame); 4602 host_impl_->DidDrawAllLayers(frame);
4602 } 4603 }
4603 4604
4604 // Applying an equivalent content scale on the content layer and the mask 4605 // Applying an equivalent content scale on the content layer and the mask
4605 // should still result in the same part of the mask being used. 4606 // should still result in the same part of the mask being used.
4606 gfx::Size layer_size_large = 4607 gfx::Size layer_size_large =
4607 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor)); 4608 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor));
4608 content_layer->SetContentBounds(layer_size_large); 4609 content_layer->SetContentBounds(layer_size_large);
4609 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4610 content_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4610 gfx::Size mask_size_large = 4611 gfx::Size mask_size_large =
(...skipping 10 matching lines...) Expand all
4621 ASSERT_EQ(DrawQuad::RENDER_PASS, 4622 ASSERT_EQ(DrawQuad::RENDER_PASS,
4622 frame.render_passes[0]->quad_list[1]->material); 4623 frame.render_passes[0]->quad_list[1]->material);
4623 const RenderPassDrawQuad* replica_quad = 4624 const RenderPassDrawQuad* replica_quad =
4624 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 4625 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
4625 EXPECT_TRUE(replica_quad->is_replica); 4626 EXPECT_TRUE(replica_quad->is_replica);
4626 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4627 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4627 replica_quad->rect.ToString()); 4628 replica_quad->rect.ToString());
4628 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4629 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4629 replica_quad->mask_uv_rect.ToString()); 4630 replica_quad->mask_uv_rect.ToString());
4630 4631
4631 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4632 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4632 host_impl_->DidDrawAllLayers(frame); 4633 host_impl_->DidDrawAllLayers(frame);
4633 } 4634 }
4634 4635
4635 // Applying a different contents scale to the mask layer means it will have 4636 // Applying a different contents scale to the mask layer means it will have
4636 // a larger texture, but it should use the same tex coords to cover the 4637 // a larger texture, but it should use the same tex coords to cover the
4637 // layer it masks. 4638 // layer it masks.
4638 mask_layer->SetContentBounds(mask_size); 4639 mask_layer->SetContentBounds(mask_size);
4639 mask_layer->SetContentsScale(1.f, 1.f); 4640 mask_layer->SetContentsScale(1.f, 1.f);
4640 host_impl_->active_tree()->set_needs_update_draw_properties(); 4641 host_impl_->active_tree()->set_needs_update_draw_properties();
4641 { 4642 {
4642 LayerTreeHostImpl::FrameData frame; 4643 LayerTreeHostImpl::FrameData frame;
4643 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4644 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4644 4645
4645 ASSERT_EQ(1u, frame.render_passes.size()); 4646 ASSERT_EQ(1u, frame.render_passes.size());
4646 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 4647 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
4647 ASSERT_EQ(DrawQuad::RENDER_PASS, 4648 ASSERT_EQ(DrawQuad::RENDER_PASS,
4648 frame.render_passes[0]->quad_list[1]->material); 4649 frame.render_passes[0]->quad_list[1]->material);
4649 const RenderPassDrawQuad* replica_quad = 4650 const RenderPassDrawQuad* replica_quad =
4650 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 4651 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
4651 EXPECT_TRUE(replica_quad->is_replica); 4652 EXPECT_TRUE(replica_quad->is_replica);
4652 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4653 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4653 replica_quad->rect.ToString()); 4654 replica_quad->rect.ToString());
4654 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4655 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4655 replica_quad->mask_uv_rect.ToString()); 4656 replica_quad->mask_uv_rect.ToString());
4656 4657
4657 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4658 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4658 host_impl_->DidDrawAllLayers(frame); 4659 host_impl_->DidDrawAllLayers(frame);
4659 } 4660 }
4660 } 4661 }
4661 4662
4662 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) { 4663 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) {
4663 // The replica is of a layer with bounds 50x50, but it has a child that causes 4664 // The replica is of a layer with bounds 50x50, but it has a child that causes
4664 // the surface bounds to be larger. 4665 // the surface bounds to be larger.
4665 4666
4666 scoped_ptr<LayerImpl> scoped_root = 4667 scoped_ptr<LayerImpl> scoped_root =
4667 LayerImpl::Create(host_impl_->active_tree(), 1); 4668 LayerImpl::Create(host_impl_->active_tree(), 1);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
4738 ASSERT_EQ(DrawQuad::RENDER_PASS, 4739 ASSERT_EQ(DrawQuad::RENDER_PASS,
4739 frame.render_passes[0]->quad_list[1]->material); 4740 frame.render_passes[0]->quad_list[1]->material);
4740 const RenderPassDrawQuad* replica_quad = 4741 const RenderPassDrawQuad* replica_quad =
4741 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 4742 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
4742 EXPECT_TRUE(replica_quad->is_replica); 4743 EXPECT_TRUE(replica_quad->is_replica);
4743 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), 4744 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(),
4744 replica_quad->rect.ToString()); 4745 replica_quad->rect.ToString());
4745 EXPECT_EQ(gfx::RectF(0.f, 0.f, 2.f, 1.f).ToString(), 4746 EXPECT_EQ(gfx::RectF(0.f, 0.f, 2.f, 1.f).ToString(),
4746 replica_quad->mask_uv_rect.ToString()); 4747 replica_quad->mask_uv_rect.ToString());
4747 4748
4748 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4749 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4749 host_impl_->DidDrawAllLayers(frame); 4750 host_impl_->DidDrawAllLayers(frame);
4750 } 4751 }
4751 4752
4752 // Move the child to (-50, 0) instead. Now the mask should be moved to still 4753 // Move the child to (-50, 0) instead. Now the mask should be moved to still
4753 // cover the layer being replicated. 4754 // cover the layer being replicated.
4754 content_child_layer->SetPosition(gfx::Point(-50, 0)); 4755 content_child_layer->SetPosition(gfx::Point(-50, 0));
4755 { 4756 {
4756 LayerTreeHostImpl::FrameData frame; 4757 LayerTreeHostImpl::FrameData frame;
4757 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4758 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4758 4759
(...skipping 13 matching lines...) Expand all
4772 ASSERT_EQ(DrawQuad::RENDER_PASS, 4773 ASSERT_EQ(DrawQuad::RENDER_PASS,
4773 frame.render_passes[0]->quad_list[1]->material); 4774 frame.render_passes[0]->quad_list[1]->material);
4774 const RenderPassDrawQuad* replica_quad = 4775 const RenderPassDrawQuad* replica_quad =
4775 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 4776 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
4776 EXPECT_TRUE(replica_quad->is_replica); 4777 EXPECT_TRUE(replica_quad->is_replica);
4777 EXPECT_EQ(gfx::Rect(-50, 0, 100, 50).ToString(), 4778 EXPECT_EQ(gfx::Rect(-50, 0, 100, 50).ToString(),
4778 replica_quad->rect.ToString()); 4779 replica_quad->rect.ToString());
4779 EXPECT_EQ(gfx::RectF(-1.f, 0.f, 2.f, 1.f).ToString(), 4780 EXPECT_EQ(gfx::RectF(-1.f, 0.f, 2.f, 1.f).ToString(),
4780 replica_quad->mask_uv_rect.ToString()); 4781 replica_quad->mask_uv_rect.ToString());
4781 4782
4782 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4783 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4783 host_impl_->DidDrawAllLayers(frame); 4784 host_impl_->DidDrawAllLayers(frame);
4784 } 4785 }
4785 } 4786 }
4786 4787
4787 TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) { 4788 TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) {
4788 // The masked layer has bounds 50x50, but it has a child that causes 4789 // The masked layer has bounds 50x50, but it has a child that causes
4789 // the surface bounds to be larger. It also has a parent that clips the 4790 // the surface bounds to be larger. It also has a parent that clips the
4790 // masked layer and its surface. 4791 // masked layer and its surface.
4791 4792
4792 scoped_ptr<LayerImpl> scoped_root = 4793 scoped_ptr<LayerImpl> scoped_root =
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
4868 render_pass_quad->rect.ToString()); 4869 render_pass_quad->rect.ToString());
4869 4870
4870 // The masked layer is 50x50, but the surface size is 10x20. So the texture 4871 // The masked layer is 50x50, but the surface size is 10x20. So the texture
4871 // coords in the mask are scaled by 10/50 and 20/50. 4872 // coords in the mask are scaled by 10/50 and 20/50.
4872 // The surface is clipped to (20,10) so the mask texture coords are offset 4873 // The surface is clipped to (20,10) so the mask texture coords are offset
4873 // by 20/50 and 10/50 4874 // by 20/50 and 10/50
4874 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f), 4875 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f),
4875 1.f / 50.f).ToString(), 4876 1.f / 50.f).ToString(),
4876 render_pass_quad->mask_uv_rect.ToString()); 4877 render_pass_quad->mask_uv_rect.ToString());
4877 4878
4878 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4879 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4879 host_impl_->DidDrawAllLayers(frame); 4880 host_impl_->DidDrawAllLayers(frame);
4880 } 4881 }
4881 } 4882 }
4882 4883
4883 class GLRendererWithSetupQuadForAntialiasing : public GLRenderer { 4884 class GLRendererWithSetupQuadForAntialiasing : public GLRenderer {
4884 public: 4885 public:
4885 using GLRenderer::SetupQuadForAntialiasing; 4886 using GLRenderer::SetupQuadForAntialiasing;
4886 }; 4887 };
4887 4888
4888 TEST_F(LayerTreeHostImplTest, FarAwayQuadsDontNeedAA) { 4889 TEST_F(LayerTreeHostImplTest, FarAwayQuadsDontNeedAA) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
4941 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); 4942 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size());
4942 const DrawQuad* quad = frame.render_passes[0]->quad_list[0]; 4943 const DrawQuad* quad = frame.render_passes[0]->quad_list[0];
4943 4944
4944 float edge[24]; 4945 float edge[24];
4945 gfx::QuadF device_layer_quad; 4946 gfx::QuadF device_layer_quad;
4946 bool antialiased = 4947 bool antialiased =
4947 GLRendererWithSetupQuadForAntialiasing::SetupQuadForAntialiasing( 4948 GLRendererWithSetupQuadForAntialiasing::SetupQuadForAntialiasing(
4948 quad->quadTransform(), quad, &device_layer_quad, edge); 4949 quad->quadTransform(), quad, &device_layer_quad, edge);
4949 EXPECT_FALSE(antialiased); 4950 EXPECT_FALSE(antialiased);
4950 4951
4951 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 4952 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4952 host_impl_->DidDrawAllLayers(frame); 4953 host_impl_->DidDrawAllLayers(frame);
4953 } 4954 }
4954 4955
4955 4956
4956 class CompositorFrameMetadataTest : public LayerTreeHostImplTest { 4957 class CompositorFrameMetadataTest : public LayerTreeHostImplTest {
4957 public: 4958 public:
4958 CompositorFrameMetadataTest() 4959 CompositorFrameMetadataTest()
4959 : swap_buffers_complete_(0) {} 4960 : swap_buffers_complete_(0) {}
4960 4961
4961 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE { 4962 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
5042 scoped_ptr<VideoLayerImpl> video_layer = 5043 scoped_ptr<VideoLayerImpl> video_layer =
5043 VideoLayerImpl::Create(host_impl_->active_tree(), 2, &provider); 5044 VideoLayerImpl::Create(host_impl_->active_tree(), 2, &provider);
5044 video_layer->SetBounds(gfx::Size(10, 10)); 5045 video_layer->SetBounds(gfx::Size(10, 10));
5045 video_layer->SetContentBounds(gfx::Size(10, 10)); 5046 video_layer->SetContentBounds(gfx::Size(10, 10));
5046 video_layer->SetDrawsContent(true); 5047 video_layer->SetDrawsContent(true);
5047 root_layer->AddChild(video_layer.PassAs<LayerImpl>()); 5048 root_layer->AddChild(video_layer.PassAs<LayerImpl>());
5048 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>()); 5049 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>());
5049 5050
5050 LayerTreeHostImpl::FrameData frame; 5051 LayerTreeHostImpl::FrameData frame;
5051 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 5052 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5052 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 5053 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5053 host_impl_->DidDrawAllLayers(frame); 5054 host_impl_->DidDrawAllLayers(frame);
5054 5055
5055 EXPECT_EQ(1u, frame.will_draw_layers.size()); 5056 EXPECT_EQ(1u, frame.will_draw_layers.size());
5056 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]); 5057 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]);
5057 } 5058 }
5058 5059
5059 class LayerTreeHostImplTestDeferredInitialize : public LayerTreeHostImplTest { 5060 class LayerTreeHostImplTestDeferredInitialize : public LayerTreeHostImplTest {
5060 protected: 5061 protected:
5061 virtual void SetUp() OVERRIDE { 5062 virtual void SetUp() OVERRIDE {
5062 LayerTreeHostImplTest::SetUp(); 5063 LayerTreeHostImplTest::SetUp();
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
5326 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); 5327 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1));
5327 5328
5328 ScopedPtrVector<CopyOutputRequest> requests; 5329 ScopedPtrVector<CopyOutputRequest> requests;
5329 requests.push_back(CopyOutputRequest::CreateRequest( 5330 requests.push_back(CopyOutputRequest::CreateRequest(
5330 base::Bind(&ShutdownReleasesContext_Callback))); 5331 base::Bind(&ShutdownReleasesContext_Callback)));
5331 5332
5332 host_impl_->active_tree()->root_layer()->PassCopyRequests(&requests); 5333 host_impl_->active_tree()->root_layer()->PassCopyRequests(&requests);
5333 5334
5334 LayerTreeHostImpl::FrameData frame; 5335 LayerTreeHostImpl::FrameData frame;
5335 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); 5336 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5336 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 5337 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5337 host_impl_->DidDrawAllLayers(frame); 5338 host_impl_->DidDrawAllLayers(frame);
5338 5339
5339 // The CopyOutputResult's callback has a ref on the ContextProvider and a 5340 // The CopyOutputResult's callback has a ref on the ContextProvider and a
5340 // texture in a texture mailbox. 5341 // texture in a texture mailbox.
5341 EXPECT_FALSE(context_provider->HasOneRef()); 5342 EXPECT_FALSE(context_provider->HasOneRef());
5342 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); 5343 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures());
5343 5344
5344 host_impl_.reset(); 5345 host_impl_.reset();
5345 5346
5346 // The CopyOutputResult's callback was cancelled, the CopyOutputResult 5347 // The CopyOutputResult's callback was cancelled, the CopyOutputResult
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
5468 // The root should have scrolled. 5469 // The root should have scrolled.
5469 ASSERT_EQ(2u, scroll_info->scrolls.size()); 5470 ASSERT_EQ(2u, scroll_info->scrolls.size());
5470 ExpectContains(*scroll_info.get(), 5471 ExpectContains(*scroll_info.get(),
5471 host_impl_->active_tree()->root_layer()->id(), 5472 host_impl_->active_tree()->root_layer()->id(),
5472 gfx::Vector2d(0, 10)); 5473 gfx::Vector2d(0, 10));
5473 } 5474 }
5474 } 5475 }
5475 5476
5476 } // namespace 5477 } // namespace
5477 } // namespace cc 5478 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698