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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_unittest_context.cc
diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc
index 7c766fe8bedc60376fafb543e8f51667e2c40682..06719989aee376f605aa1e959e1cb7d029d5b208 100644
--- a/cc/trees/layer_tree_host_unittest_context.cc
+++ b/cc/trees/layer_tree_host_unittest_context.cc
@@ -382,6 +382,71 @@ class LayerTreeHostClientNotReadyDoesNotCreateOutputSurface
SINGLE_AND_MULTI_THREAD_TEST_F(
LayerTreeHostClientNotReadyDoesNotCreateOutputSurface);
+// This tests the OutputSurface release logic in the following sequence.
+// SetUp LTH and create and init OutputSurface
+// LTH::SetVisible(false);
+// LTH::ReleaseOutputSurface();
+// ...
+// Create and init new OutputSurface
+// LTH::SetVisible(true);
+class LayerTreeHostClientTakeAwayOutputSurface
+ : public LayerTreeHostContextTest {
+ public:
+ LayerTreeHostClientTakeAwayOutputSurface()
+ : LayerTreeHostContextTest(), setos_counter_(0) {}
+
+ void BeginTest() override { PostSetNeedsCommitToMainThread(); }
+
+ void RequestNewOutputSurface() override {
+ if (layer_tree_host()->visible())
+ CreateAndSetOutputSurface();
+ else
+ 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
+ }
+
+ void CreateAndSetOutputSurface() {
+ scoped_ptr<OutputSurface> surface =
+ LayerTreeHostContextTest::CreateOutputSurface();
+ CHECK(surface);
+ setos_counter_++;
+ layer_tree_host()->SetOutputSurface(surface.Pass());
+ }
+
+ void HideAndReleaseOutputSurface() {
+ EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread());
+ layer_tree_host()->SetVisible(false);
+ scoped_ptr<OutputSurface> surface =
+ layer_tree_host()->ReleaseOutputSurface();
+ CHECK(surface);
+ surface->context_provider()->DetachFromThread();
+ MainThreadTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&LayerTreeHostClientTakeAwayOutputSurface::MakeVisible,
+ base::Unretained(this)));
+ }
+
+ void DidInitializeOutputSurface() override {
+ if (setos_counter_ == 1) {
+ 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.
+ MainThreadTaskRunner()->PostTask(
+ FROM_HERE, base::Bind(&LayerTreeHostClientTakeAwayOutputSurface::
+ HideAndReleaseOutputSurface,
+ base::Unretained(this)));
+ }
+ }
+
+ void MakeVisible() {
+ EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread());
+ layer_tree_host()->SetVisible(true);
+ }
+
+ void AfterTest() override {}
+
+ int setos_counter_;
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostClientTakeAwayOutputSurface);
+
class MultipleCompositeDoesNotCreateOutputSurface
: public LayerTreeHostContextTest {
public:
« 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