| 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 6983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7030 const CompositorFrame& frame) override { | 7031 const CompositorFrame& frame) override { |
| 7031 EXPECT_EQ(5U, frame.metadata.content_source_id); | 7032 EXPECT_EQ(5U, frame.metadata.content_source_id); |
| 7032 EndTest(); | 7033 EndTest(); |
| 7033 } | 7034 } |
| 7034 | 7035 |
| 7035 void AfterTest() override {} | 7036 void AfterTest() override {} |
| 7036 }; | 7037 }; |
| 7037 | 7038 |
| 7038 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestContentSourceId); | 7039 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestContentSourceId); |
| 7039 | 7040 |
| 7041 class LayerTreeHostTestBeginFrameSequenceNumbers : public LayerTreeHostTest { |
| 7042 protected: |
| 7043 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 7044 |
| 7045 void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl, |
| 7046 const BeginFrameArgs& args) override { |
| 7047 // First BeginFrame will block activation, second one unblocks. |
| 7048 impl->BlockNotifyReadyToActivateForTesting(false); |
| 7049 |
| 7050 EXPECT_TRUE(args.IsValid()); |
| 7051 current_begin_frame_args_ = args; |
| 7052 } |
| 7053 |
| 7054 void BeginMainFrame(const BeginFrameArgs& args) override { |
| 7055 EXPECT_TRUE(args.IsValid()); |
| 7056 if (!current_begin_main_frame_args_.IsValid()) |
| 7057 current_begin_main_frame_args_ = args; |
| 7058 } |
| 7059 |
| 7060 void BeginCommitOnThread(LayerTreeHostImpl* impl) override { |
| 7061 current_begin_main_frame_args_on_impl_ = current_begin_main_frame_args_; |
| 7062 // Request another subsequent commit. That way, the first commit's |
| 7063 // latest_confirmed_sequence_number should stay at the first BeginFrame's |
| 7064 // sequence number. |
| 7065 PostSetNeedsCommitToMainThread(); |
| 7066 } |
| 7067 |
| 7068 void WillCommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
| 7069 // Defer current commit's activation until second BeginFrame. |
| 7070 impl->BlockNotifyReadyToActivateForTesting(true); |
| 7071 } |
| 7072 |
| 7073 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl, |
| 7074 LayerTreeHostImpl::FrameData* frame_data, |
| 7075 DrawResult draw_result) override { |
| 7076 // We should only draw in second BeginFrame. |
| 7077 EXPECT_TRUE(current_begin_main_frame_args_on_impl_.IsValid()); |
| 7078 EXPECT_LT(current_begin_main_frame_args_on_impl_.sequence_number, |
| 7079 current_begin_frame_args_.sequence_number); |
| 7080 frame_data_ = frame_data; |
| 7081 return draw_result; |
| 7082 } |
| 7083 |
| 7084 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 7085 EXPECT_TRUE(frame_data_); |
| 7086 EXPECT_EQ( |
| 7087 BeginFrameAck(current_begin_frame_args_.source_id, |
| 7088 current_begin_frame_args_.sequence_number, |
| 7089 current_begin_main_frame_args_on_impl_.sequence_number, 0, |
| 7090 true), |
| 7091 frame_data_->begin_frame_ack); |
| 7092 } |
| 7093 |
| 7094 void DisplayReceivedCompositorFrameOnThread( |
| 7095 const CompositorFrame& frame) override { |
| 7096 compositor_frame_submitted_ = true; |
| 7097 EXPECT_EQ( |
| 7098 BeginFrameAck(current_begin_frame_args_.source_id, |
| 7099 current_begin_frame_args_.sequence_number, |
| 7100 current_begin_main_frame_args_on_impl_.sequence_number, 0, |
| 7101 true), |
| 7102 frame.metadata.begin_frame_ack); |
| 7103 EndTest(); |
| 7104 } |
| 7105 |
| 7106 void AfterTest() override { EXPECT_TRUE(compositor_frame_submitted_); } |
| 7107 |
| 7108 private: |
| 7109 bool compositor_frame_submitted_; |
| 7110 BeginFrameArgs current_begin_frame_args_; |
| 7111 BeginFrameArgs current_begin_main_frame_args_; |
| 7112 BeginFrameArgs current_begin_main_frame_args_on_impl_; |
| 7113 LayerTreeHostImpl::FrameData* frame_data_; |
| 7114 }; |
| 7115 |
| 7116 MULTI_THREAD_BLOCKNOTIFY_TEST_F(LayerTreeHostTestBeginFrameSequenceNumbers); |
| 7117 |
| 7040 } // namespace | 7118 } // namespace |
| 7041 } // namespace cc | 7119 } // namespace cc |
| OLD | NEW |