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/thread_proxy.h" | 5 #include "cc/trees/thread_proxy.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "cc/base/thread.h" | 10 #include "cc/base/thread.h" |
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 // to produce a frame, as the calling site on main thread is blocked until its | 887 // to produce a frame, as the calling site on main thread is blocked until its |
888 // request completes, and we signal completion here. If CanDraw() is false, we | 888 // request completes, and we signal completion here. If CanDraw() is false, we |
889 // will indicate success=false to the caller, but we must still signal | 889 // will indicate success=false to the caller, but we must still signal |
890 // completion to avoid deadlock. | 890 // completion to avoid deadlock. |
891 | 891 |
892 // We guard PrepareToDraw() with CanDraw() because it always returns a valid | 892 // We guard PrepareToDraw() with CanDraw() because it always returns a valid |
893 // frame, so can only be used when such a frame is possible. Since | 893 // frame, so can only be used when such a frame is possible. Since |
894 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on | 894 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on |
895 // CanDraw() as well. | 895 // CanDraw() as well. |
896 | 896 |
| 897 // If it is a forced draw, make sure we do a draw and swap. |
| 898 gfx::Rect readback_rect; |
| 899 if (readback_request_on_impl_thread_) |
| 900 readback_rect = readback_request_on_impl_thread_->rect; |
| 901 |
897 LayerTreeHostImpl::FrameData frame; | 902 LayerTreeHostImpl::FrameData frame; |
898 bool draw_frame = false; | 903 bool draw_frame = false; |
899 bool start_ready_animations = true; | 904 bool start_ready_animations = true; |
900 | 905 |
901 if (layer_tree_host_impl_->CanDraw()) { | 906 if (layer_tree_host_impl_->CanDraw()) { |
902 // Do not start animations if we skip drawing the frame to avoid | 907 // Do not start animations if we skip drawing the frame to avoid |
903 // checkerboarding. | 908 // checkerboarding. |
904 if (layer_tree_host_impl_->PrepareToDraw(&frame) || forced_draw) | 909 if (layer_tree_host_impl_->PrepareToDraw(&frame, readback_rect) || |
| 910 forced_draw) |
905 draw_frame = true; | 911 draw_frame = true; |
906 else | 912 else |
907 start_ready_animations = false; | 913 start_ready_animations = false; |
908 } | 914 } |
909 | 915 |
910 if (draw_frame) { | 916 if (draw_frame) { |
911 layer_tree_host_impl_->DrawLayers( | 917 layer_tree_host_impl_->DrawLayers( |
912 &frame, | 918 &frame, |
913 scheduler_on_impl_thread_->LastVSyncTime()); | 919 scheduler_on_impl_thread_->LastVSyncTime()); |
914 result.did_draw = true; | 920 result.did_draw = true; |
(...skipping 17 matching lines...) Expand all Loading... |
932 readback_request_on_impl_thread_->success = false; | 938 readback_request_on_impl_thread_->success = false; |
933 if (draw_frame) { | 939 if (draw_frame) { |
934 layer_tree_host_impl_->Readback(readback_request_on_impl_thread_->pixels, | 940 layer_tree_host_impl_->Readback(readback_request_on_impl_thread_->pixels, |
935 readback_request_on_impl_thread_->rect); | 941 readback_request_on_impl_thread_->rect); |
936 readback_request_on_impl_thread_->success = | 942 readback_request_on_impl_thread_->success = |
937 !layer_tree_host_impl_->IsContextLost(); | 943 !layer_tree_host_impl_->IsContextLost(); |
938 } | 944 } |
939 readback_request_on_impl_thread_->completion.Signal(); | 945 readback_request_on_impl_thread_->completion.Signal(); |
940 readback_request_on_impl_thread_ = NULL; | 946 readback_request_on_impl_thread_ = NULL; |
941 } else if (draw_frame) { | 947 } else if (draw_frame) { |
942 result.did_swap = layer_tree_host_impl_->SwapBuffers(); | 948 result.did_swap = layer_tree_host_impl_->SwapBuffers(frame); |
943 | 949 |
944 if (frame.contains_incomplete_tile) | 950 if (frame.contains_incomplete_tile) |
945 DidSwapUseIncompleteTileOnImplThread(); | 951 DidSwapUseIncompleteTileOnImplThread(); |
946 } | 952 } |
947 | 953 |
948 // Tell the main thread that the the newly-commited frame was drawn. | 954 // Tell the main thread that the the newly-commited frame was drawn. |
949 if (next_frame_is_newly_committed_frame_on_impl_thread_) { | 955 if (next_frame_is_newly_committed_frame_on_impl_thread_) { |
950 next_frame_is_newly_committed_frame_on_impl_thread_ = false; | 956 next_frame_is_newly_committed_frame_on_impl_thread_ = false; |
951 Proxy::MainThread()->PostTask( | 957 Proxy::MainThread()->PostTask( |
952 base::Bind(&ThreadProxy::DidCommitAndDrawFrame, main_thread_weak_ptr_)); | 958 base::Bind(&ThreadProxy::DidCommitAndDrawFrame, main_thread_weak_ptr_)); |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread, | 1336 base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread, |
1331 impl_thread_weak_ptr_), | 1337 impl_thread_weak_ptr_), |
1332 delay); | 1338 delay); |
1333 } | 1339 } |
1334 | 1340 |
1335 void ThreadProxy::StartScrollbarAnimationOnImplThread() { | 1341 void ThreadProxy::StartScrollbarAnimationOnImplThread() { |
1336 layer_tree_host_impl_->StartScrollbarAnimation(base::TimeTicks::Now()); | 1342 layer_tree_host_impl_->StartScrollbarAnimation(base::TimeTicks::Now()); |
1337 } | 1343 } |
1338 | 1344 |
1339 } // namespace cc | 1345 } // namespace cc |
OLD | NEW |