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

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

Issue 2712983003: [cc] Set BeginFrame sequence numbers on CompositorFrames from Scheduler. (Closed)
Patch Set: sync Created 3 years, 9 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 6998 matching lines...) Expand 10 before | Expand all | Expand 10 after
7009 EXPECT_EQ(21u, frame.resource_list.size()); 7009 EXPECT_EQ(21u, frame.resource_list.size());
7010 7010
7011 EndTest(); 7011 EndTest();
7012 } 7012 }
7013 7013
7014 void AfterTest() override {} 7014 void AfterTest() override {}
7015 }; 7015 };
7016 7016
7017 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSubmitFrameResources); 7017 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSubmitFrameResources);
7018 7018
7019 class LayerTreeHostTestBeginFrameSequenceNumbers : public LayerTreeHostTest {
7020 protected:
7021 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
7022
7023 void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl,
7024 const BeginFrameArgs& args) override {
7025 if (current_begin_frame_args_.IsValid()) {
brianderson 2017/02/24 01:08:36 This if condition probably isn't needed.
Eric Seckler 2017/02/27 11:50:32 Done.
7026 // We've received a second BeginFrame, stop blocking activation.
7027 impl->BlockNotifyReadyToActivateForTesting(false);
7028 }
7029
7030 EXPECT_TRUE(args.IsValid());
7031 current_begin_frame_args_ = args;
7032 }
7033
7034 void WillBeginMainFrame() override {
7035 // Request another commit but defer it indefinitely. That way, the current
7036 // commit's latest_confirmed_sequence_number should stay at the first
7037 // BeginFrame's sequence number.
7038 layer_tree_host()->SetDeferCommits(true);
brianderson 2017/02/24 01:08:37 I think you can avoid this if you use the BeginCom
Eric Seckler 2017/02/27 11:50:32 Not entirely sure whether I understood this correc
7039 PostSetNeedsCommitToMainThread();
7040 }
7041
7042 void BeginMainFrame(const BeginFrameArgs& args) override {
7043 EXPECT_FALSE(current_begin_main_frame_args_.IsValid());
7044 EXPECT_TRUE(args.IsValid());
7045 current_begin_main_frame_args_ = args;
7046 }
7047
7048 void WillCommitCompleteOnThread(LayerTreeHostImpl* impl) override {
7049 // Defer current commit's activation until second BeginFrame.
7050 impl->BlockNotifyReadyToActivateForTesting(true);
7051 }
7052
7053 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl,
7054 LayerTreeHostImpl::FrameData* frame_data,
7055 DrawResult draw_result) override {
7056 // We should only draw in second BeginFrame.
7057 EXPECT_TRUE(current_begin_main_frame_args_.IsValid());
7058 EXPECT_LT(current_begin_main_frame_args_.sequence_number,
7059 current_begin_frame_args_.sequence_number);
7060 frame_data_ = frame_data;
7061 return draw_result;
7062 }
7063
7064 void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
7065 EXPECT_TRUE(frame_data_);
7066 EXPECT_EQ(current_begin_frame_args_.source_id,
7067 frame_data_->begin_frame_source_id);
7068 EXPECT_EQ(current_begin_frame_args_.sequence_number,
7069 frame_data_->begin_frame_sequence_number);
7070 EXPECT_EQ(current_begin_main_frame_args_.sequence_number,
7071 frame_data_->latest_confirmed_begin_frame_sequence_number);
7072 }
7073
7074 void DisplayReceivedCompositorFrameOnThread(
7075 const CompositorFrame& frame) override {
7076 compositor_frame_submitted_ = true;
7077 EXPECT_EQ(current_begin_frame_args_.source_id,
7078 frame.metadata.begin_frame_source_id);
7079 EXPECT_EQ(current_begin_frame_args_.sequence_number,
7080 frame.metadata.begin_frame_sequence_number);
7081 EXPECT_EQ(current_begin_main_frame_args_.sequence_number,
7082 frame.metadata.latest_confirmed_begin_frame_sequence_number);
7083 EndTest();
7084 }
7085
7086 void AfterTest() override { EXPECT_TRUE(compositor_frame_submitted_); }
7087
7088 private:
7089 bool compositor_frame_submitted_;
7090 BeginFrameArgs current_begin_frame_args_;
7091 BeginFrameArgs current_begin_main_frame_args_;
7092 LayerTreeHostImpl::FrameData* frame_data_;
7093 };
7094
7095 MULTI_THREAD_BLOCKNOTIFY_TEST_F(LayerTreeHostTestBeginFrameSequenceNumbers);
7096
7019 } // namespace 7097 } // namespace
7020 } // namespace cc 7098 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698