Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

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

Issue 12544032: Initialize cc::Renderer in vsync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: First CreateOutputSurface async, chrome starts up and renders, broke a lot of tests again :( Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
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.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/synchronization/lock.h" 9 #include "base/synchronization/lock.h"
10 #include "cc/animation/timing_function.h" 10 #include "cc/animation/timing_function.h"
(...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1560 EXPECT_EQ(2, num_complete_commits_); 1560 EXPECT_EQ(2, num_complete_commits_);
1561 } 1561 }
1562 1562
1563 private: 1563 private:
1564 int num_commits_deferred_; 1564 int num_commits_deferred_;
1565 int num_complete_commits_; 1565 int num_complete_commits_;
1566 }; 1566 };
1567 1567
1568 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferCommits); 1568 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferCommits);
1569 1569
1570 class LayerTreeHostWithProxy : public LayerTreeHost { 1570 class LayerTreeHostWithProxy : public LayerTreeHost { public:
danakj 2013/04/10 16:40:14 typo here
1571 public:
1572 LayerTreeHostWithProxy(FakeLayerTreeHostClient* client, 1571 LayerTreeHostWithProxy(FakeLayerTreeHostClient* client,
1573 const LayerTreeSettings& settings, 1572 const LayerTreeSettings& settings,
1574 scoped_ptr<Proxy> proxy) 1573 scoped_ptr<FakeProxy> proxy)
1575 : LayerTreeHost(client, settings) { 1574 : LayerTreeHost(client, settings) {
1576 EXPECT_TRUE(InitializeForTesting(proxy.Pass())); 1575 proxy->SetHost(this);
1576 EXPECT_TRUE(InitializeForTesting(proxy.PassAs<Proxy>()));
1577 } 1577 }
1578 }; 1578 };
1579 1579
1580 TEST(LayerTreeHostTest, LimitPartialUpdates) { 1580 TEST(LayerTreeHostTest, LimitPartialUpdates) {
1581 // When partial updates are not allowed, max updates should be 0. 1581 // When partial updates are not allowed, max updates should be 0.
1582 { 1582 {
1583 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); 1583 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
1584 1584
1585 scoped_ptr<FakeProxy> proxy = 1585 scoped_ptr<FakeProxy> proxy =
1586 make_scoped_ptr(new FakeProxy(scoped_ptr<Thread>())); 1586 make_scoped_ptr(new FakeProxy(scoped_ptr<Thread>()));
1587 proxy->GetRendererCapabilities().allow_partial_texture_updates = false; 1587 proxy->GetRendererCapabilities().allow_partial_texture_updates = false;
1588 proxy->SetMaxPartialTextureUpdates(5); 1588 proxy->SetMaxPartialTextureUpdates(5);
1589 1589
1590 LayerTreeSettings settings; 1590 LayerTreeSettings settings;
1591 settings.max_partial_texture_updates = 10; 1591 settings.max_partial_texture_updates = 10;
1592 1592
1593 LayerTreeHostWithProxy host(&client, settings, proxy.PassAs<Proxy>()); 1593 LayerTreeHostWithProxy host(&client, settings, proxy.Pass());
1594 EXPECT_TRUE(host.InitializeRendererIfNeeded()); 1594 EXPECT_TRUE(host.InitializeRendererIfNeeded());
1595 1595
1596 EXPECT_EQ(0u, host.settings().max_partial_texture_updates); 1596 EXPECT_EQ(0u, host.settings().max_partial_texture_updates);
1597 } 1597 }
1598 1598
1599 // When partial updates are allowed, 1599 // When partial updates are allowed,
1600 // max updates should be limited by the proxy. 1600 // max updates should be limited by the proxy.
1601 { 1601 {
1602 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); 1602 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
1603 1603
1604 scoped_ptr<FakeProxy> proxy = 1604 scoped_ptr<FakeProxy> proxy =
1605 make_scoped_ptr(new FakeProxy(scoped_ptr<Thread>())); 1605 make_scoped_ptr(new FakeProxy(scoped_ptr<Thread>()));
1606 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; 1606 proxy->GetRendererCapabilities().allow_partial_texture_updates = true;
1607 proxy->SetMaxPartialTextureUpdates(5); 1607 proxy->SetMaxPartialTextureUpdates(5);
1608 1608
1609 LayerTreeSettings settings; 1609 LayerTreeSettings settings;
1610 settings.max_partial_texture_updates = 10; 1610 settings.max_partial_texture_updates = 10;
1611 1611
1612 LayerTreeHostWithProxy host(&client, settings, proxy.PassAs<Proxy>()); 1612 LayerTreeHostWithProxy host(&client, settings, proxy.Pass());
1613 EXPECT_TRUE(host.InitializeRendererIfNeeded()); 1613 EXPECT_TRUE(host.InitializeRendererIfNeeded());
1614 1614
1615 EXPECT_EQ(5u, host.settings().max_partial_texture_updates); 1615 EXPECT_EQ(5u, host.settings().max_partial_texture_updates);
1616 } 1616 }
1617 1617
1618 // When partial updates are allowed, 1618 // When partial updates are allowed,
1619 // max updates should also be limited by the settings. 1619 // max updates should also be limited by the settings.
1620 { 1620 {
1621 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); 1621 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
1622 1622
1623 scoped_ptr<FakeProxy> proxy = 1623 scoped_ptr<FakeProxy> proxy =
1624 make_scoped_ptr(new FakeProxy(scoped_ptr<Thread>())); 1624 make_scoped_ptr(new FakeProxy(scoped_ptr<Thread>()));
1625 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; 1625 proxy->GetRendererCapabilities().allow_partial_texture_updates = true;
1626 proxy->SetMaxPartialTextureUpdates(20); 1626 proxy->SetMaxPartialTextureUpdates(20);
1627 1627
1628 LayerTreeSettings settings; 1628 LayerTreeSettings settings;
1629 settings.max_partial_texture_updates = 10; 1629 settings.max_partial_texture_updates = 10;
1630 1630
1631 LayerTreeHostWithProxy host(&client, settings, proxy.PassAs<Proxy>()); 1631 LayerTreeHostWithProxy host(&client, settings, proxy.Pass());
1632 EXPECT_TRUE(host.InitializeRendererIfNeeded()); 1632 EXPECT_TRUE(host.InitializeRendererIfNeeded());
1633 1633
1634 EXPECT_EQ(10u, host.settings().max_partial_texture_updates); 1634 EXPECT_EQ(10u, host.settings().max_partial_texture_updates);
1635 } 1635 }
1636 } 1636 }
1637 1637
1638 TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) { 1638 TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) {
1639 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); 1639 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
1640 1640
1641 LayerTreeSettings settings; 1641 LayerTreeSettings settings;
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
2132 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 2132 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
2133 settings->render_vsync_notification_enabled = true; 2133 settings->render_vsync_notification_enabled = true;
2134 } 2134 }
2135 2135
2136 virtual void BeginTest() OVERRIDE { 2136 virtual void BeginTest() OVERRIDE {
2137 PostSetNeedsCommitToMainThread(); 2137 PostSetNeedsCommitToMainThread();
2138 } 2138 }
2139 2139
2140 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 2140 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
2141 FakeOutputSurface* fake_output_surface = 2141 FakeOutputSurface* fake_output_surface =
2142 reinterpret_cast<FakeOutputSurface*>(host_impl->output_surface()); 2142 static_cast<FakeOutputSurface*>(host_impl->output_surface());
2143
2144 // The vsync notification is turned off now but will get enabled once we
2145 // return, so post a task to trigger it.
2146 ASSERT_FALSE(fake_output_surface->vsync_notification_enabled());
2147 PostVSyncOnImplThread(fake_output_surface); 2143 PostVSyncOnImplThread(fake_output_surface);
2148 } 2144 }
2149 2145
2150 void PostVSyncOnImplThread(FakeOutputSurface* fake_output_surface) { 2146 void PostVSyncOnImplThread(FakeOutputSurface* fake_output_surface) {
2151 DCHECK(ImplThread()); 2147 DCHECK(ImplThread());
2152 ImplThread()->PostTask( 2148 ImplThread()->PostTask(
2153 base::Bind(&LayerTreeHostTestVSyncNotification::DidVSync, 2149 base::Bind(&LayerTreeTest::DidVSync,
2154 base::Unretained(this), 2150 base::Unretained(this),
2155 base::Unretained(fake_output_surface))); 2151 base::Unretained(fake_output_surface)));
2156 } 2152 }
2157 2153
2158 void DidVSync(FakeOutputSurface* fake_output_surface) {
2159 ASSERT_TRUE(fake_output_surface->vsync_notification_enabled());
2160 fake_output_surface->DidVSync(frame_time_);
2161 }
2162
2163 virtual bool PrepareToDrawOnThread( 2154 virtual bool PrepareToDrawOnThread(
2164 LayerTreeHostImpl* host_impl, 2155 LayerTreeHostImpl* host_impl,
2165 LayerTreeHostImpl::FrameData* frame, 2156 LayerTreeHostImpl::FrameData* frame,
2166 bool result) OVERRIDE { 2157 bool result) OVERRIDE {
2167 EndTest(); 2158 EndTest();
2168 return true; 2159 return true;
2169 } 2160 }
2170 2161
2171 virtual void AfterTest() OVERRIDE { 2162 virtual void AfterTest() OVERRIDE {
2172 } 2163 }
2173
2174 private:
2175 base::TimeTicks frame_time_;
2176 }; 2164 };
2177 2165
2178 MULTI_THREAD_TEST_F(LayerTreeHostTestVSyncNotification); 2166 MULTI_THREAD_TEST_F(LayerTreeHostTestVSyncNotification);
2179 2167
2180 } // namespace 2168 } // namespace
2181 } // namespace cc 2169 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698