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

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

Issue 1111743002: cc: Adding DidFinishImplFrame to LTHI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase onto master after landing other patch. Created 5 years, 7 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
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/location.h" 10 #include "base/location.h"
(...skipping 2265 matching lines...) Expand 10 before | Expand all | Expand 10 after
2276 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousInvalidate); 2276 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousInvalidate);
2277 2277
2278 class LayerTreeHostTestDeferCommits : public LayerTreeHostTest { 2278 class LayerTreeHostTestDeferCommits : public LayerTreeHostTest {
2279 public: 2279 public:
2280 LayerTreeHostTestDeferCommits() 2280 LayerTreeHostTestDeferCommits()
2281 : num_will_begin_impl_frame_(0), 2281 : num_will_begin_impl_frame_(0),
2282 num_send_begin_main_frame_(0) {} 2282 num_send_begin_main_frame_(0) {}
2283 2283
2284 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 2284 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
2285 2285
2286 void WillBeginImplFrame(const BeginFrameArgs& args) override { 2286 void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl,
2287 const BeginFrameArgs& args) override {
2287 num_will_begin_impl_frame_++; 2288 num_will_begin_impl_frame_++;
2288 switch (num_will_begin_impl_frame_) { 2289 switch (num_will_begin_impl_frame_) {
2289 case 1: 2290 case 1:
2290 break; 2291 break;
2291 case 2: 2292 case 2:
2292 case 3: 2293 case 3:
2293 case 4: 2294 case 4:
2294 // Post a number of frames to increase the chance that, if there exist 2295 // Post a number of frames to increase the chance that, if there exist
2295 // bugs, an unexpected BeginMainFrame will be issued. 2296 // bugs, an unexpected BeginMainFrame will be issued.
2296 PostSetNeedsCommitToMainThread(); 2297 PostSetNeedsCommitToMainThread();
(...skipping 3189 matching lines...) Expand 10 before | Expand all | Expand 10 after
5486 int num_draws_; 5487 int num_draws_;
5487 const gfx::Size bounds_; 5488 const gfx::Size bounds_;
5488 FakeContentLayerClient client_; 5489 FakeContentLayerClient client_;
5489 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; 5490 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_;
5490 scoped_refptr<FakePictureLayer> picture_layer_; 5491 scoped_refptr<FakePictureLayer> picture_layer_;
5491 Layer* child_layer_; 5492 Layer* child_layer_;
5492 }; 5493 };
5493 5494
5494 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); 5495 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting);
5495 5496
5497 class LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame
5498 : public LayerTreeHostTest {
5499 public:
5500 enum { kExpectedNumImplFrames = 10 };
5501
5502 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame()
5503 : threaded_(false),
5504 will_begin_impl_frame_count_(0),
5505 did_finish_impl_frame_count_(0) {}
5506
5507 void RunTest(bool threaded,
5508 bool delegating_renderer,
5509 bool impl_side_painting) override {
5510 threaded_ = threaded;
5511 LayerTreeHostTest::RunTest(threaded, delegating_renderer,
5512 impl_side_painting);
5513 }
5514
5515 void BeginTest() override {
5516 // Kick off the test with a commit.
5517 PostSetNeedsCommitToMainThread();
5518 }
5519
5520 void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl,
5521 const BeginFrameArgs& args) override {
5522 EXPECT_EQ(will_begin_impl_frame_count_, did_finish_impl_frame_count_);
5523 EXPECT_FALSE(TestEnded());
5524 will_begin_impl_frame_count_++;
5525 }
5526
5527 void DidFinishImplFrameOnThread(LayerTreeHostImpl* host_impl) override {
5528 did_finish_impl_frame_count_++;
5529 EXPECT_EQ(will_begin_impl_frame_count_, did_finish_impl_frame_count_);
5530
5531 // Request a number of commits to cause multiple impl frames. We expect to
5532 // get one more impl frames than the number of commits requested because
5533 // after a commit it takes one frame to become idle.
5534 if (did_finish_impl_frame_count_ < kExpectedNumImplFrames - 1)
5535 PostSetNeedsCommitToMainThread();
5536 }
5537
5538 void SendBeginMainFrameNotExpectedSoon() override { EndTest(); }
5539
5540 void AfterTest() override {
5541 EXPECT_GT(will_begin_impl_frame_count_, 0);
5542 EXPECT_GT(did_finish_impl_frame_count_, 0);
5543 EXPECT_EQ(will_begin_impl_frame_count_, did_finish_impl_frame_count_);
5544
5545 // TODO(mithro): Figure out why the multithread version of this test
5546 // sometimes has one more frame then expected. Possibly related to
5547 // http://crbug.com/443185
5548 if (!threaded_) {
danakj 2015/05/04 17:39:19 You can just do HasImplThread() there's a function
mithro-old 2015/05/05 04:13:13 I tried to use HasImplThread() here but it seems t
danakj 2015/05/05 18:42:00 It looks to me that your threaded_ is always false
mithro-old 2015/05/06 02:14:11 I tracked down the issue and uploaded a patch at h
5549 EXPECT_EQ(will_begin_impl_frame_count_, kExpectedNumImplFrames);
5550 EXPECT_EQ(did_finish_impl_frame_count_, kExpectedNumImplFrames);
5551 }
5552 }
5553
5554 private:
5555 bool threaded_;
5556 int will_begin_impl_frame_count_;
5557 int did_finish_impl_frame_count_;
5558 };
5559
5560 SINGLE_AND_MULTI_THREAD_TEST_F(
5561 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame);
5562
5496 class LayerTreeHostTestSendBeginFramesToChildren : public LayerTreeHostTest { 5563 class LayerTreeHostTestSendBeginFramesToChildren : public LayerTreeHostTest {
5497 public: 5564 public:
5498 LayerTreeHostTestSendBeginFramesToChildren() 5565 LayerTreeHostTestSendBeginFramesToChildren()
5499 : begin_frame_sent_to_children_(false) { 5566 : begin_frame_sent_to_children_(false) {
5500 } 5567 }
5501 5568
5502 void BeginTest() override { 5569 void BeginTest() override {
5503 // Kick off the test with a commit. 5570 // Kick off the test with a commit.
5504 PostSetNeedsCommitToMainThread(); 5571 PostSetNeedsCommitToMainThread();
5505 } 5572 }
(...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after
6992 void AfterTest() override {} 7059 void AfterTest() override {}
6993 7060
6994 scoped_refptr<FakePictureLayer> content_child_layer_; 7061 scoped_refptr<FakePictureLayer> content_child_layer_;
6995 FakeContentLayerClient client_; 7062 FakeContentLayerClient client_;
6996 }; 7063 };
6997 7064
6998 SINGLE_AND_MULTI_THREAD_TEST_F( 7065 SINGLE_AND_MULTI_THREAD_TEST_F(
6999 LayerTreeTestReflectionMaskLayerForSurfaceWithUnclippedChild); 7066 LayerTreeTestReflectionMaskLayerForSurfaceWithUnclippedChild);
7000 7067
7001 } // namespace cc 7068 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698