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

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

Issue 845393002: cc: Create ProxyBeginFrameSource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 2129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2140 2140
2141 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 2141 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
2142 new TestSharedBitmapManager()); 2142 new TestSharedBitmapManager());
2143 scoped_ptr<LayerTreeHost> host = 2143 scoped_ptr<LayerTreeHost> host =
2144 LayerTreeHost::CreateSingleThreaded(&client, 2144 LayerTreeHost::CreateSingleThreaded(&client,
2145 &client, 2145 &client,
2146 shared_bitmap_manager.get(), 2146 shared_bitmap_manager.get(),
2147 NULL, 2147 NULL,
2148 settings, 2148 settings,
2149 base::MessageLoopProxy::current(), 2149 base::MessageLoopProxy::current(),
2150 nullptr,
2150 nullptr); 2151 nullptr);
2151 client.SetLayerTreeHost(host.get()); 2152 client.SetLayerTreeHost(host.get());
2152 host->Composite(base::TimeTicks::Now()); 2153 host->Composite(base::TimeTicks::Now());
2153 2154
2154 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); 2155 EXPECT_EQ(4u, host->settings().max_partial_texture_updates);
2155 } 2156 }
2156 2157
2157 TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) { 2158 TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) {
2158 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_SOFTWARE); 2159 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_SOFTWARE);
2159 2160
2160 LayerTreeSettings settings; 2161 LayerTreeSettings settings;
2161 settings.max_partial_texture_updates = 4; 2162 settings.max_partial_texture_updates = 4;
2162 settings.single_thread_proxy_scheduler = false; 2163 settings.single_thread_proxy_scheduler = false;
2163 2164
2164 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 2165 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
2165 new TestSharedBitmapManager()); 2166 new TestSharedBitmapManager());
2166 scoped_ptr<LayerTreeHost> host = 2167 scoped_ptr<LayerTreeHost> host =
2167 LayerTreeHost::CreateSingleThreaded(&client, 2168 LayerTreeHost::CreateSingleThreaded(&client,
2168 &client, 2169 &client,
2169 shared_bitmap_manager.get(), 2170 shared_bitmap_manager.get(),
2170 NULL, 2171 NULL,
2171 settings, 2172 settings,
2172 base::MessageLoopProxy::current(), 2173 base::MessageLoopProxy::current(),
2174 nullptr,
2173 nullptr); 2175 nullptr);
2174 client.SetLayerTreeHost(host.get()); 2176 client.SetLayerTreeHost(host.get());
2175 host->Composite(base::TimeTicks::Now()); 2177 host->Composite(base::TimeTicks::Now());
2176 2178
2177 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); 2179 EXPECT_EQ(4u, host->settings().max_partial_texture_updates);
2178 } 2180 }
2179 2181
2180 TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) { 2182 TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) {
2181 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_3D); 2183 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_3D);
2182 2184
2183 LayerTreeSettings settings; 2185 LayerTreeSettings settings;
2184 settings.max_partial_texture_updates = 4; 2186 settings.max_partial_texture_updates = 4;
2185 settings.single_thread_proxy_scheduler = false; 2187 settings.single_thread_proxy_scheduler = false;
2186 2188
2187 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 2189 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
2188 new TestSharedBitmapManager()); 2190 new TestSharedBitmapManager());
2189 scoped_ptr<LayerTreeHost> host = 2191 scoped_ptr<LayerTreeHost> host =
2190 LayerTreeHost::CreateSingleThreaded(&client, 2192 LayerTreeHost::CreateSingleThreaded(&client,
2191 &client, 2193 &client,
2192 shared_bitmap_manager.get(), 2194 shared_bitmap_manager.get(),
2193 NULL, 2195 NULL,
2194 settings, 2196 settings,
2195 base::MessageLoopProxy::current(), 2197 base::MessageLoopProxy::current(),
2198 nullptr,
2196 nullptr); 2199 nullptr);
2197 client.SetLayerTreeHost(host.get()); 2200 client.SetLayerTreeHost(host.get());
2198 host->Composite(base::TimeTicks::Now()); 2201 host->Composite(base::TimeTicks::Now());
2199 2202
2200 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); 2203 EXPECT_EQ(0u, host->MaxPartialTextureUpdates());
2201 } 2204 }
2202 2205
2203 TEST(LayerTreeHostTest, 2206 TEST(LayerTreeHostTest,
2204 PartialUpdatesWithDelegatingRendererAndSoftwareContent) { 2207 PartialUpdatesWithDelegatingRendererAndSoftwareContent) {
2205 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_SOFTWARE); 2208 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_SOFTWARE);
2206 2209
2207 LayerTreeSettings settings; 2210 LayerTreeSettings settings;
2208 settings.max_partial_texture_updates = 4; 2211 settings.max_partial_texture_updates = 4;
2209 settings.single_thread_proxy_scheduler = false; 2212 settings.single_thread_proxy_scheduler = false;
2210 2213
2211 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 2214 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
2212 new TestSharedBitmapManager()); 2215 new TestSharedBitmapManager());
2213 scoped_ptr<LayerTreeHost> host = 2216 scoped_ptr<LayerTreeHost> host =
2214 LayerTreeHost::CreateSingleThreaded(&client, 2217 LayerTreeHost::CreateSingleThreaded(&client,
2215 &client, 2218 &client,
2216 shared_bitmap_manager.get(), 2219 shared_bitmap_manager.get(),
2217 NULL, 2220 NULL,
2218 settings, 2221 settings,
2219 base::MessageLoopProxy::current(), 2222 base::MessageLoopProxy::current(),
2223 nullptr,
2220 nullptr); 2224 nullptr);
2221 client.SetLayerTreeHost(host.get()); 2225 client.SetLayerTreeHost(host.get());
2222 host->Composite(base::TimeTicks::Now()); 2226 host->Composite(base::TimeTicks::Now());
2223 2227
2224 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); 2228 EXPECT_EQ(0u, host->MaxPartialTextureUpdates());
2225 } 2229 }
2226 2230
2227 // TODO(sohanjg) : Remove it once impl-side painting ships everywhere. 2231 // TODO(sohanjg) : Remove it once impl-side painting ships everywhere.
2228 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted 2232 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted
2229 : public LayerTreeHostTest { 2233 : public LayerTreeHostTest {
(...skipping 3052 matching lines...) Expand 10 before | Expand all | Expand 10 after
5282 int num_draws_; 5286 int num_draws_;
5283 const gfx::Size bounds_; 5287 const gfx::Size bounds_;
5284 FakeContentLayerClient client_; 5288 FakeContentLayerClient client_;
5285 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; 5289 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_;
5286 scoped_refptr<FakePictureLayer> picture_layer_; 5290 scoped_refptr<FakePictureLayer> picture_layer_;
5287 Layer* child_layer_; 5291 Layer* child_layer_;
5288 }; 5292 };
5289 5293
5290 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); 5294 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting);
5291 5295
5296 class TestBeginFrameObserver : public BeginFrameObserverMixIn {
5297 public:
5298 TestBeginFrameObserver() {}
5299 ~TestBeginFrameObserver() override {}
5300
5301 protected:
5302 bool OnBeginFrameMixInDelegate(const BeginFrameArgs& args) override {
5303 return true;
5304 }
5305 };
5306
5292 class LayerTreeHostTestSendBeginFramesToChildren : public LayerTreeHostTest { 5307 class LayerTreeHostTestSendBeginFramesToChildren : public LayerTreeHostTest {
5293 public: 5308 public:
5294 LayerTreeHostTestSendBeginFramesToChildren() 5309 LayerTreeHostTestSendBeginFramesToChildren()
5295 : begin_frame_sent_to_children_(false) { 5310 : begin_frame_sent_to_children_(false) {
5311 begin_frame_observer_.reset(new TestBeginFrameObserver);
5296 } 5312 }
5297 5313
5298 void InitializeSettings(LayerTreeSettings* settings) override { 5314 void InitializeSettings(LayerTreeSettings* settings) override {
5299 settings->forward_begin_frames_to_children = true; 5315 settings->forward_begin_frames_to_children = true;
5300 } 5316 }
5301 5317
5302 void BeginTest() override { 5318 void BeginTest() override {
5303 // Kick off the test with a commit. 5319 // Kick off the test with a commit.
5304 PostSetNeedsCommitToMainThread(); 5320 PostSetNeedsCommitToMainThread();
5305 } 5321 }
5306 5322
5307 void SendBeginFramesToChildren(const BeginFrameArgs& args) override { 5323 void SendBeginFramesToChildren(const BeginFrameArgs& args) override {
5308 begin_frame_sent_to_children_ = true; 5324 begin_frame_sent_to_children_ = true;
5309 EndTest(); 5325 EndTest();
5310 } 5326 }
5311 5327
5312 void DidBeginMainFrame() override { 5328 void DidBeginMainFrame() override {
5313 // Children requested BeginFrames. 5329 // Add observer will trigger BeginFrame.
5314 layer_tree_host()->SetChildrenNeedBeginFrames(true); 5330 proxy_begin_frame_source()->AddObserver(begin_frame_observer_.get());
5315 } 5331 }
5316 5332
5317 void AfterTest() override { 5333 void AfterTest() override {
5318 // Ensure that BeginFrame message is sent to children during parent 5334 // Ensure that BeginFrame message is sent to children during parent
5319 // scheduler handles its BeginFrame. 5335 // scheduler handles its BeginFrame.
5320 EXPECT_TRUE(begin_frame_sent_to_children_); 5336 EXPECT_TRUE(begin_frame_sent_to_children_);
5337 proxy_begin_frame_source()->RemoveObserver(begin_frame_observer_.get());
5321 } 5338 }
5322 5339
5323 private: 5340 private:
5324 bool begin_frame_sent_to_children_; 5341 bool begin_frame_sent_to_children_;
5342 scoped_ptr<TestBeginFrameObserver> begin_frame_observer_;
5325 }; 5343 };
5326 5344
5327 SINGLE_THREAD_TEST_F(LayerTreeHostTestSendBeginFramesToChildren); 5345 SINGLE_THREAD_TEST_F(LayerTreeHostTestSendBeginFramesToChildren);
5328 5346
5329 class LayerTreeHostTestSendBeginFramesToChildrenWithExternalBFS 5347 class LayerTreeHostTestSendBeginFramesToChildrenWithExternalBFS
5330 : public LayerTreeHostTest { 5348 : public LayerTreeHostTest {
5331 public: 5349 public:
5332 LayerTreeHostTestSendBeginFramesToChildrenWithExternalBFS() 5350 LayerTreeHostTestSendBeginFramesToChildrenWithExternalBFS()
5333 : begin_frame_sent_to_children_(false) { 5351 : begin_frame_sent_to_children_(false) {
5352 begin_frame_observer_.reset(new TestBeginFrameObserver);
5334 } 5353 }
5335 5354
5336 void InitializeSettings(LayerTreeSettings* settings) override { 5355 void InitializeSettings(LayerTreeSettings* settings) override {
5337 settings->use_external_begin_frame_source = true; 5356 settings->use_external_begin_frame_source = true;
5338 settings->forward_begin_frames_to_children = true; 5357 settings->forward_begin_frames_to_children = true;
5339 } 5358 }
5340 5359
5341 void BeginTest() override { 5360 void BeginTest() override {
5342 // Kick off the test with a commit. 5361 // Kick off the test with a commit.
5343 PostSetNeedsCommitToMainThread(); 5362 PostSetNeedsCommitToMainThread();
5344 } 5363 }
5345 5364
5346 void SendBeginFramesToChildren(const BeginFrameArgs& args) override { 5365 void SendBeginFramesToChildren(const BeginFrameArgs& args) override {
5347 begin_frame_sent_to_children_ = true; 5366 begin_frame_sent_to_children_ = true;
5348 EndTest(); 5367 EndTest();
5349 } 5368 }
5350 5369
5351 void DidBeginMainFrame() override { 5370 void DidBeginMainFrame() override {
5352 // Children requested BeginFrames. 5371 // Add observer will trigger BeginFrame.
5353 layer_tree_host()->SetChildrenNeedBeginFrames(true); 5372 proxy_begin_frame_source()->AddObserver(begin_frame_observer_.get());
5354 } 5373 }
5355 5374
5356 void AfterTest() override { 5375 void AfterTest() override {
5357 // Ensure that BeginFrame message is sent to children during parent 5376 // Ensure that BeginFrame message is sent to children during parent
5358 // scheduler handles its BeginFrame. 5377 // scheduler handles its BeginFrame.
5359 EXPECT_TRUE(begin_frame_sent_to_children_); 5378 EXPECT_TRUE(begin_frame_sent_to_children_);
5379 proxy_begin_frame_source()->RemoveObserver(begin_frame_observer_.get());
5360 } 5380 }
5361 5381
5362 private: 5382 private:
5363 bool begin_frame_sent_to_children_; 5383 bool begin_frame_sent_to_children_;
5384 scoped_ptr<TestBeginFrameObserver> begin_frame_observer_;
5364 }; 5385 };
5365 5386
5366 SINGLE_THREAD_TEST_F(LayerTreeHostTestSendBeginFramesToChildrenWithExternalBFS); 5387 SINGLE_THREAD_TEST_F(LayerTreeHostTestSendBeginFramesToChildrenWithExternalBFS);
5367 5388
5368 class LayerTreeHostTestActivateOnInvisible : public LayerTreeHostTest { 5389 class LayerTreeHostTestActivateOnInvisible : public LayerTreeHostTest {
5369 public: 5390 public:
5370 LayerTreeHostTestActivateOnInvisible() 5391 LayerTreeHostTestActivateOnInvisible()
5371 : activation_count_(0), visible_(true) {} 5392 : activation_count_(0), visible_(true) {}
5372 5393
5373 void InitializeSettings(LayerTreeSettings* settings) override { 5394 void InitializeSettings(LayerTreeSettings* settings) override {
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
6174 6195
6175 void AfterTest() override { EXPECT_TRUE(did_commit_); } 6196 void AfterTest() override { EXPECT_TRUE(did_commit_); }
6176 6197
6177 private: 6198 private:
6178 bool did_commit_; 6199 bool did_commit_;
6179 }; 6200 };
6180 6201
6181 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); 6202 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit);
6182 6203
6183 } // namespace cc 6204 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698