Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 16 matching lines...) Expand all Loading... | |
| 27 #include "cc/layers/video_layer.h" | 27 #include "cc/layers/video_layer.h" |
| 28 #include "cc/output/begin_frame_args.h" | 28 #include "cc/output/begin_frame_args.h" |
| 29 #include "cc/output/copy_output_request.h" | 29 #include "cc/output/copy_output_request.h" |
| 30 #include "cc/output/copy_output_result.h" | 30 #include "cc/output/copy_output_result.h" |
| 31 #include "cc/output/output_surface.h" | 31 #include "cc/output/output_surface.h" |
| 32 #include "cc/output/swap_promise.h" | 32 #include "cc/output/swap_promise.h" |
| 33 #include "cc/quads/draw_quad.h" | 33 #include "cc/quads/draw_quad.h" |
| 34 #include "cc/quads/render_pass_draw_quad.h" | 34 #include "cc/quads/render_pass_draw_quad.h" |
| 35 #include "cc/quads/tile_draw_quad.h" | 35 #include "cc/quads/tile_draw_quad.h" |
| 36 #include "cc/resources/ui_resource_manager.h" | 36 #include "cc/resources/ui_resource_manager.h" |
| 37 #include "cc/test/begin_frame_args_test.h" | |
| 37 #include "cc/test/fake_content_layer_client.h" | 38 #include "cc/test/fake_content_layer_client.h" |
| 38 #include "cc/test/fake_layer_tree_host_client.h" | 39 #include "cc/test/fake_layer_tree_host_client.h" |
| 39 #include "cc/test/fake_output_surface.h" | 40 #include "cc/test/fake_output_surface.h" |
| 40 #include "cc/test/fake_painted_scrollbar_layer.h" | 41 #include "cc/test/fake_painted_scrollbar_layer.h" |
| 41 #include "cc/test/fake_picture_layer.h" | 42 #include "cc/test/fake_picture_layer.h" |
| 42 #include "cc/test/fake_picture_layer_impl.h" | 43 #include "cc/test/fake_picture_layer_impl.h" |
| 43 #include "cc/test/fake_proxy.h" | 44 #include "cc/test/fake_proxy.h" |
| 44 #include "cc/test/fake_recording_source.h" | 45 #include "cc/test/fake_recording_source.h" |
| 45 #include "cc/test/fake_scoped_ui_resource.h" | 46 #include "cc/test/fake_scoped_ui_resource.h" |
| 46 #include "cc/test/fake_video_frame_provider.h" | 47 #include "cc/test/fake_video_frame_provider.h" |
| (...skipping 6953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7000 EXPECT_EQ(21u, frame.resource_list.size()); | 7001 EXPECT_EQ(21u, frame.resource_list.size()); |
| 7001 | 7002 |
| 7002 EndTest(); | 7003 EndTest(); |
| 7003 } | 7004 } |
| 7004 | 7005 |
| 7005 void AfterTest() override {} | 7006 void AfterTest() override {} |
| 7006 }; | 7007 }; |
| 7007 | 7008 |
| 7008 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSubmitFrameResources); | 7009 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSubmitFrameResources); |
| 7009 | 7010 |
| 7011 class LayerTreeHostTestBeginFrameSequenceNumbers : public LayerTreeHostTest { | |
| 7012 protected: | |
| 7013 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | |
| 7014 | |
| 7015 void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl, | |
| 7016 const BeginFrameArgs& args) override { | |
| 7017 // First BeginFrame will block activation, second one unblocks. | |
| 7018 impl->BlockNotifyReadyToActivateForTesting(false); | |
| 7019 | |
| 7020 EXPECT_TRUE(args.IsValid()); | |
| 7021 current_begin_frame_args_ = args; | |
| 7022 } | |
| 7023 | |
| 7024 void BeginMainFrame(const BeginFrameArgs& args) override { | |
| 7025 EXPECT_TRUE(args.IsValid()); | |
| 7026 if (!current_begin_main_frame_args_.IsValid()) | |
| 7027 current_begin_main_frame_args_ = args; | |
|
brianderson
2017/03/02 19:53:36
current_begin_main_frame_args_ is written on the m
Eric Seckler
2017/03/07 12:26:56
Ah, I see. Added a copy to impl.
| |
| 7028 } | |
| 7029 | |
| 7030 void BeginCommitOnThread(LayerTreeHostImpl* impl) override { | |
| 7031 // Request another subsequent commit. That way, the first commit's | |
| 7032 // latest_confirmed_sequence_number should stay at the first BeginFrame's | |
| 7033 // sequence number. | |
| 7034 PostSetNeedsCommitToMainThread(); | |
| 7035 } | |
| 7036 | |
| 7037 void WillCommitCompleteOnThread(LayerTreeHostImpl* impl) override { | |
| 7038 // Defer current commit's activation until second BeginFrame. | |
| 7039 impl->BlockNotifyReadyToActivateForTesting(true); | |
| 7040 } | |
| 7041 | |
| 7042 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl, | |
| 7043 LayerTreeHostImpl::FrameData* frame_data, | |
| 7044 DrawResult draw_result) override { | |
| 7045 // We should only draw in second BeginFrame. | |
| 7046 EXPECT_TRUE(current_begin_main_frame_args_.IsValid()); | |
| 7047 EXPECT_LT(current_begin_main_frame_args_.sequence_number, | |
| 7048 current_begin_frame_args_.sequence_number); | |
| 7049 frame_data_ = frame_data; | |
| 7050 return draw_result; | |
| 7051 } | |
| 7052 | |
| 7053 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { | |
| 7054 EXPECT_TRUE(frame_data_); | |
| 7055 EXPECT_EQ( | |
| 7056 BeginFrameAck(current_begin_frame_args_.source_id, | |
| 7057 current_begin_frame_args_.sequence_number, | |
| 7058 current_begin_main_frame_args_.sequence_number, 0, true), | |
| 7059 frame_data_->begin_frame_ack); | |
| 7060 } | |
| 7061 | |
| 7062 void DisplayReceivedCompositorFrameOnThread( | |
| 7063 const CompositorFrame& frame) override { | |
| 7064 compositor_frame_submitted_ = true; | |
| 7065 EXPECT_EQ( | |
| 7066 BeginFrameAck(current_begin_frame_args_.source_id, | |
| 7067 current_begin_frame_args_.sequence_number, | |
| 7068 current_begin_main_frame_args_.sequence_number, 0, true), | |
| 7069 frame.metadata.begin_frame_ack); | |
| 7070 EndTest(); | |
| 7071 } | |
| 7072 | |
| 7073 void AfterTest() override { EXPECT_TRUE(compositor_frame_submitted_); } | |
| 7074 | |
| 7075 private: | |
| 7076 bool compositor_frame_submitted_; | |
| 7077 BeginFrameArgs current_begin_frame_args_; | |
| 7078 BeginFrameArgs current_begin_main_frame_args_; | |
| 7079 LayerTreeHostImpl::FrameData* frame_data_; | |
| 7080 }; | |
| 7081 | |
| 7082 MULTI_THREAD_BLOCKNOTIFY_TEST_F(LayerTreeHostTestBeginFrameSequenceNumbers); | |
| 7083 | |
| 7010 } // namespace | 7084 } // namespace |
| 7011 } // namespace cc | 7085 } // namespace cc |
| OLD | NEW |