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

Unified Diff: cc/trees/layer_tree_host_unittest.cc

Issue 14273026: cc: Make async readback path use async glRreadPixels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: There, I fixed it Created 7 years, 8 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
Index: cc/trees/layer_tree_host_unittest.cc
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
index f32d0d8b36ed6b498c8d75eb3e1748ea61dd9dfe..7f3cf1b4f2bdd692e8e32100a271a15c07da972f 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -2578,6 +2578,18 @@ class LayerTreeHostTestAsyncReadback : public LayerTreeHostTest {
}
virtual void DidCommitAndDrawFrame() {
+ WaitForCallback();
+ }
+
+ void WaitForCallback() {
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &LayerTreeHostTestAsyncReadback::NextStep,
+ base::Unretained(this)));
+ }
+
+ void NextStep() {
int frame = layer_tree_host()->commit_number();
switch (frame) {
case 1:
@@ -2587,11 +2599,11 @@ class LayerTreeHostTestAsyncReadback : public LayerTreeHostTest {
EXPECT_EQ(0u, callbacks_.size());
break;
case 2:
- // Flush the message loops and make sure the callbacks run.
- layer_tree_host()->SetNeedsCommit();
- break;
- case 3:
- ASSERT_EQ(1u, callbacks_.size());
+ if (callbacks_.size() < 1u) {
+ WaitForCallback();
+ return;
+ }
+ EXPECT_EQ(1u, callbacks_.size());
EXPECT_EQ(gfx::Size(10, 10).ToString(), callbacks_[0].ToString());
child->RequestCopyAsBitmap(base::Bind(
@@ -2605,12 +2617,12 @@ class LayerTreeHostTestAsyncReadback : public LayerTreeHostTest {
base::Unretained(this)));
EXPECT_EQ(1u, callbacks_.size());
break;
- case 4:
- // Flush the message loops and make sure the callbacks run.
- layer_tree_host()->SetNeedsCommit();
- break;
- case 5:
- ASSERT_EQ(4u, callbacks_.size());
+ case 3:
+ if (callbacks_.size() < 4u) {
+ WaitForCallback();
+ return;
+ }
+ EXPECT_EQ(4u, callbacks_.size());
// The child was copied to a bitmap and passed back twice.
EXPECT_EQ(gfx::Size(10, 10).ToString(), callbacks_[1].ToString());
EXPECT_EQ(gfx::Size(10, 10).ToString(), callbacks_[2].ToString());
@@ -2627,7 +2639,9 @@ class LayerTreeHostTestAsyncReadback : public LayerTreeHostTest {
callbacks_.push_back(gfx::Size(bitmap->width(), bitmap->height()));
}
- virtual void AfterTest() {}
+ virtual void AfterTest() {
+ EXPECT_EQ(4u, callbacks_.size());
+ }
virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE {
if (use_gl_renderer_)

Powered by Google App Engine
This is Rietveld 408576698