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

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

Issue 935193002: cc: Fix missing render surfaces with output requests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | cc/trees/thread_proxy.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.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 6302 matching lines...) Expand 10 before | Expand all | Expand 10 after
6313 } 6313 }
6314 6314
6315 void AfterTest() override { EXPECT_TRUE(did_commit_); } 6315 void AfterTest() override { EXPECT_TRUE(did_commit_); }
6316 6316
6317 private: 6317 private:
6318 bool did_commit_; 6318 bool did_commit_;
6319 }; 6319 };
6320 6320
6321 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); 6321 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit);
6322 6322
6323 // Verify that if a LayerImpl holds onto a copy request for multiple
6324 // frames that it will continue to have a render surface through
6325 // multiple commits, even though the Layer itself has no reason
6326 // to have a render surface.
6327 class LayerPreserveRenderSurfaceFromOutputRequests : public LayerTreeHostTest {
6328 protected:
6329 void SetupTree() override {
6330 scoped_refptr<Layer> root = Layer::Create();
6331 root->CreateRenderSurface();
6332 root->SetBounds(gfx::Size(10, 10));
6333 child_ = Layer::Create();
6334 child_->SetBounds(gfx::Size(20, 20));
6335 root->AddChild(child_);
6336
6337 layer_tree_host()->SetRootLayer(root);
6338 LayerTreeHostTest::SetupTree();
6339 }
6340
6341 static void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {}
6342
6343 void BeginTest() override {
6344 child_->RequestCopyOfOutput(
6345 CopyOutputRequest::CreateBitmapRequest(base::Bind(CopyOutputCallback)));
6346 EXPECT_TRUE(child_->HasCopyRequest());
6347 PostSetNeedsCommitToMainThread();
6348 }
6349
6350 void DidCommit() override { EXPECT_FALSE(child_->HasCopyRequest()); }
6351
6352 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
6353 LayerImpl* child_impl = host_impl->sync_tree()->LayerById(child_->id());
6354 ASSERT_TRUE(child_impl);
danakj 2015/02/19 18:08:39 ASSERT_ in layer tree tests is marginally bleh cuz
enne (OOO) 2015/02/19 18:10:31 But crashing in a unit test ends everything?
danakj 2015/02/19 18:36:44 Not sure what you mean, it ends the test immediate
enne (OOO) 2015/02/19 18:40:33 Ok. Removed asserts.
6355
6356 switch (host_impl->sync_tree()->source_frame_number()) {
6357 case 0:
6358 EXPECT_TRUE(child_impl->HasCopyRequest());
6359 EXPECT_TRUE(child_impl->render_surface());
6360 break;
6361 case 1:
6362 if (host_impl->proxy()->CommitToActiveTree()) {
6363 EXPECT_TRUE(child_impl->HasCopyRequest());
6364 EXPECT_TRUE(child_impl->render_surface());
6365 } else {
6366 EXPECT_FALSE(child_impl->HasCopyRequest());
6367 EXPECT_FALSE(child_impl->render_surface());
6368 }
6369 break;
6370 default:
6371 NOTREACHED();
6372 break;
6373 }
6374 }
6375
6376 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
6377 LayerImpl* child_impl = host_impl->active_tree()->LayerById(child_->id());
6378 ASSERT_TRUE(child_impl);
6379 EXPECT_TRUE(child_impl->HasCopyRequest());
6380 EXPECT_TRUE(child_impl->render_surface());
6381
6382 switch (host_impl->active_tree()->source_frame_number()) {
6383 case 0:
6384 // Lose output surface to prevent drawing and cause another commit.
6385 host_impl->DidLoseOutputSurface();
6386 break;
6387 case 1:
6388 EndTest();
6389 break;
6390 default:
6391 NOTREACHED();
6392 break;
6393 }
6394 }
6395
6396 void AfterTest() override {}
6397
6398 private:
6399 scoped_refptr<Layer> child_;
6400 };
6401
6402 SINGLE_AND_MULTI_THREAD_TEST_F(LayerPreserveRenderSurfaceFromOutputRequests);
6403
6323 } // namespace cc 6404 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | cc/trees/thread_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698