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

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: Remove asserts 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
6355 switch (host_impl->sync_tree()->source_frame_number()) {
6356 case 0:
6357 EXPECT_TRUE(child_impl->HasCopyRequest());
6358 EXPECT_TRUE(child_impl->render_surface());
6359 break;
6360 case 1:
6361 if (host_impl->proxy()->CommitToActiveTree()) {
6362 EXPECT_TRUE(child_impl->HasCopyRequest());
6363 EXPECT_TRUE(child_impl->render_surface());
6364 } else {
6365 EXPECT_FALSE(child_impl->HasCopyRequest());
6366 EXPECT_FALSE(child_impl->render_surface());
6367 }
6368 break;
6369 default:
6370 NOTREACHED();
6371 break;
6372 }
6373 }
6374
6375 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
6376 LayerImpl* child_impl = host_impl->active_tree()->LayerById(child_->id());
6377 EXPECT_TRUE(child_impl->HasCopyRequest());
6378 EXPECT_TRUE(child_impl->render_surface());
6379
6380 switch (host_impl->active_tree()->source_frame_number()) {
6381 case 0:
6382 // Lose output surface to prevent drawing and cause another commit.
6383 host_impl->DidLoseOutputSurface();
6384 break;
6385 case 1:
6386 EndTest();
6387 break;
6388 default:
6389 NOTREACHED();
6390 break;
6391 }
6392 }
6393
6394 void AfterTest() override {}
6395
6396 private:
6397 scoped_refptr<Layer> child_;
6398 };
6399
6400 SINGLE_AND_MULTI_THREAD_TEST_F(LayerPreserveRenderSurfaceFromOutputRequests);
6401
6323 } // namespace cc 6402 } // 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