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

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

Issue 12662021: cc: Don't draw and swap if the frame will not change. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add perf test Created 7 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 | Annotate | Revision Log
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/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 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 base::Time wall_clock_time = base::Time::Now(); 879 base::Time wall_clock_time = base::Time::Now();
880 880
881 if (input_handler_on_impl_thread_) 881 if (input_handler_on_impl_thread_)
882 input_handler_on_impl_thread_->Animate(monotonic_time); 882 input_handler_on_impl_thread_->Animate(monotonic_time);
883 883
884 layer_tree_host_impl_->ActivatePendingTreeIfNeeded(); 884 layer_tree_host_impl_->ActivatePendingTreeIfNeeded();
885 layer_tree_host_impl_->Animate(monotonic_time, wall_clock_time); 885 layer_tree_host_impl_->Animate(monotonic_time, wall_clock_time);
886 886
887 // This method is called on a forced draw, regardless of whether we are able 887 // This method is called on a forced draw, regardless of whether we are able
888 // to produce a frame, as the calling site on main thread is blocked until its 888 // to produce a frame, as the calling site on main thread is blocked until its
889 // request completes, and we signal completion here. If canDraw() is false, we 889 // request completes, and we signal completion here. If CanDraw() is false, we
890 // will indicate success=false to the caller, but we must still signal 890 // will indicate success=false to the caller, but we must still signal
891 // completion to avoid deadlock. 891 // completion to avoid deadlock.
892 892
893 // We guard prepareToDraw() with canDraw() because it always returns a valid 893 // We guard PrepareToDraw() with CanDraw() because it always returns a valid
894 // frame, so can only be used when such a frame is possible. Since 894 // frame, so can only be used when such a frame is possible. Since
895 // drawLayers() depends on the result of prepareToDraw(), it is guarded on 895 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on
896 // canDraw() as well. 896 // CanDraw() as well.
897
898 // If it is a forced draw, make sure we do a draw and swap.
899 gfx::Rect readback_rect;
900 if (readback_request_on_impl_thread_)
901 readback_rect = readback_request_on_impl_thread_->rect;
897 902
898 LayerTreeHostImpl::FrameData frame; 903 LayerTreeHostImpl::FrameData frame;
899 bool draw_frame = 904 bool draw_frame =
900 layer_tree_host_impl_->CanDraw() && 905 layer_tree_host_impl_->CanDraw() &&
901 (layer_tree_host_impl_->PrepareToDraw(&frame) || forced_draw); 906 (layer_tree_host_impl_->PrepareToDraw(&frame, readback_rect) ||
907 forced_draw);
902 if (draw_frame) { 908 if (draw_frame) {
903 layer_tree_host_impl_->DrawLayers( 909 layer_tree_host_impl_->DrawLayers(
904 &frame, 910 &frame,
905 scheduler_on_impl_thread_->LastVSyncTime()); 911 scheduler_on_impl_thread_->LastVSyncTime());
906 result.did_draw= true; 912 result.did_draw = true;
907 } 913 }
908 layer_tree_host_impl_->DidDrawAllLayers(frame); 914 layer_tree_host_impl_->DidDrawAllLayers(frame);
909 915
910 // Check for tree activation. 916 // Check for tree activation.
911 if (completion_event_for_commit_held_on_tree_activation_ && 917 if (completion_event_for_commit_held_on_tree_activation_ &&
912 !layer_tree_host_impl_->pending_tree()) { 918 !layer_tree_host_impl_->pending_tree()) {
913 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation"); 919 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation");
914 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); 920 DCHECK(layer_tree_host_impl_->settings().impl_side_painting);
915 completion_event_for_commit_held_on_tree_activation_->Signal(); 921 completion_event_for_commit_held_on_tree_activation_->Signal();
916 completion_event_for_commit_held_on_tree_activation_ = NULL; 922 completion_event_for_commit_held_on_tree_activation_ = NULL;
917 } 923 }
918 924
919 // Check for a pending CompositeAndReadback. 925 // Check for a pending CompositeAndReadback.
920 if (readback_request_on_impl_thread_) { 926 if (readback_request_on_impl_thread_) {
921 readback_request_on_impl_thread_->success = false; 927 readback_request_on_impl_thread_->success = false;
922 if (draw_frame) { 928 if (draw_frame) {
923 layer_tree_host_impl_->Readback(readback_request_on_impl_thread_->pixels, 929 layer_tree_host_impl_->Readback(readback_request_on_impl_thread_->pixels,
924 readback_request_on_impl_thread_->rect); 930 readback_request_on_impl_thread_->rect);
925 readback_request_on_impl_thread_->success = 931 readback_request_on_impl_thread_->success =
926 !layer_tree_host_impl_->IsContextLost(); 932 !layer_tree_host_impl_->IsContextLost();
927 } 933 }
928 readback_request_on_impl_thread_->completion.Signal(); 934 readback_request_on_impl_thread_->completion.Signal();
929 readback_request_on_impl_thread_ = NULL; 935 readback_request_on_impl_thread_ = NULL;
930 } else if (draw_frame) { 936 } else if (draw_frame) {
931 result.did_swap = layer_tree_host_impl_->SwapBuffers(); 937 result.did_swap = layer_tree_host_impl_->SwapBuffers(frame);
932 938
933 if (frame.contains_incomplete_tile) 939 if (frame.contains_incomplete_tile)
934 DidSwapUseIncompleteTileOnImplThread(); 940 DidSwapUseIncompleteTileOnImplThread();
935 } 941 }
936 942
937 // Tell the main thread that the the newly-commited frame was drawn. 943 // Tell the main thread that the the newly-commited frame was drawn.
938 if (next_frame_is_newly_committed_frame_on_impl_thread_) { 944 if (next_frame_is_newly_committed_frame_on_impl_thread_) {
939 next_frame_is_newly_committed_frame_on_impl_thread_ = false; 945 next_frame_is_newly_committed_frame_on_impl_thread_ = false;
940 Proxy::MainThread()->PostTask( 946 Proxy::MainThread()->PostTask(
941 base::Bind(&ThreadProxy::DidCommitAndDrawFrame, main_thread_weak_ptr_)); 947 base::Bind(&ThreadProxy::DidCommitAndDrawFrame, main_thread_weak_ptr_));
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread, 1317 base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread,
1312 impl_thread_weak_ptr_), 1318 impl_thread_weak_ptr_),
1313 delay); 1319 delay);
1314 } 1320 }
1315 1321
1316 void ThreadProxy::StartScrollbarAnimationOnImplThread() { 1322 void ThreadProxy::StartScrollbarAnimationOnImplThread() {
1317 layer_tree_host_impl_->StartScrollbarAnimation(base::TimeTicks::Now()); 1323 layer_tree_host_impl_->StartScrollbarAnimation(base::TimeTicks::Now());
1318 } 1324 }
1319 1325
1320 } // namespace cc 1326 } // namespace cc
OLDNEW
« cc/trees/layer_tree_host_unittest_damage.cc ('K') | « cc/trees/single_thread_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698