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

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

Issue 1287043002: cc: Setup API to release OutputSurface from LTHClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tests updated. Created 5 years, 3 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_impl.cc ('k') | cc/trees/proxy.h » ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "cc/layers/delegated_frame_provider.h" 8 #include "cc/layers/delegated_frame_provider.h"
9 #include "cc/layers/delegated_frame_resource_collection.h" 9 #include "cc/layers/delegated_frame_resource_collection.h"
10 #include "cc/layers/heads_up_display_layer.h" 10 #include "cc/layers/heads_up_display_layer.h"
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 375 }
376 376
377 void DidInitializeOutputSurface() override { EXPECT_TRUE(false); } 377 void DidInitializeOutputSurface() override { EXPECT_TRUE(false); }
378 378
379 void AfterTest() override {} 379 void AfterTest() override {}
380 }; 380 };
381 381
382 SINGLE_AND_MULTI_THREAD_TEST_F( 382 SINGLE_AND_MULTI_THREAD_TEST_F(
383 LayerTreeHostClientNotReadyDoesNotCreateOutputSurface); 383 LayerTreeHostClientNotReadyDoesNotCreateOutputSurface);
384 384
385 // This tests the OutputSurface release logic in the following sequence.
386 // SetUp LTH and create and init OutputSurface
387 // LTH::SetVisible(false);
388 // LTH::ReleaseOutputSurface();
389 // ...
390 // Create and init new OutputSurface
391 // LTH::SetVisible(true);
392 class LayerTreeHostClientTakeAwayOutputSurface
393 : public LayerTreeHostContextTest {
394 public:
395 LayerTreeHostClientTakeAwayOutputSurface()
396 : LayerTreeHostContextTest(), setos_counter_(0) {}
397
398 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
399
400 void RequestNewOutputSurface() override {
401 if (layer_tree_host()->visible())
402 CreateAndSetOutputSurface();
403 else
404 EndTest();
no sievers 2015/09/14 21:28:13 Can we still go through and create another OutputS
sohanjg 2015/09/15 06:39:34 Yes, in the current form we were getting RequestNe
405 }
406
407 void CreateAndSetOutputSurface() {
408 scoped_ptr<OutputSurface> surface =
409 LayerTreeHostContextTest::CreateOutputSurface();
410 CHECK(surface);
411 setos_counter_++;
412 layer_tree_host()->SetOutputSurface(surface.Pass());
413 }
414
415 void HideAndReleaseOutputSurface() {
416 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread());
417 layer_tree_host()->SetVisible(false);
418 scoped_ptr<OutputSurface> surface =
419 layer_tree_host()->ReleaseOutputSurface();
420 CHECK(surface);
421 surface->context_provider()->DetachFromThread();
422 MainThreadTaskRunner()->PostTask(
423 FROM_HERE,
424 base::Bind(&LayerTreeHostClientTakeAwayOutputSurface::MakeVisible,
425 base::Unretained(this)));
426 }
427
428 void DidInitializeOutputSurface() override {
429 if (setos_counter_ == 1) {
430 EXPECT_TRUE(layer_tree_host()->visible());
no sievers 2015/09/14 21:28:13 I think you can pull this out of the if-block rega
sohanjg 2015/09/15 06:39:34 Done.
431 MainThreadTaskRunner()->PostTask(
432 FROM_HERE, base::Bind(&LayerTreeHostClientTakeAwayOutputSurface::
433 HideAndReleaseOutputSurface,
434 base::Unretained(this)));
435 }
436 }
437
438 void MakeVisible() {
439 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread());
440 layer_tree_host()->SetVisible(true);
441 }
442
443 void AfterTest() override {}
444
445 int setos_counter_;
446 };
447
448 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostClientTakeAwayOutputSurface);
449
385 class MultipleCompositeDoesNotCreateOutputSurface 450 class MultipleCompositeDoesNotCreateOutputSurface
386 : public LayerTreeHostContextTest { 451 : public LayerTreeHostContextTest {
387 public: 452 public:
388 MultipleCompositeDoesNotCreateOutputSurface() 453 MultipleCompositeDoesNotCreateOutputSurface()
389 : LayerTreeHostContextTest(), request_count_(0) {} 454 : LayerTreeHostContextTest(), request_count_(0) {}
390 455
391 void InitializeSettings(LayerTreeSettings* settings) override { 456 void InitializeSettings(LayerTreeSettings* settings) override {
392 settings->single_thread_proxy_scheduler = false; 457 settings->single_thread_proxy_scheduler = false;
393 settings->use_zero_copy = true; 458 settings->use_zero_copy = true;
394 } 459 }
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1558 void AfterTest() override {} 1623 void AfterTest() override {}
1559 1624
1560 bool deferred_; 1625 bool deferred_;
1561 }; 1626 };
1562 1627
1563 SINGLE_AND_MULTI_THREAD_TEST_F( 1628 SINGLE_AND_MULTI_THREAD_TEST_F(
1564 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); 1629 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame);
1565 1630
1566 } // namespace 1631 } // namespace
1567 } // namespace cc 1632 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698