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

Side by Side Diff: cc/scheduler/scheduler_state_machine.cc

Issue 1394263004: android webview: allow cc to fail hardware draw (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: damage before hardware to avoid invalidate-draw loop Created 5 years, 2 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/scheduler/scheduler_state_machine.h" 5 #include "cc/scheduler/scheduler_state_machine.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 22 matching lines...) Expand all
33 prepare_tiles_funnel_(0), 33 prepare_tiles_funnel_(0),
34 consecutive_checkerboard_animations_(0), 34 consecutive_checkerboard_animations_(0),
35 max_pending_swaps_(1), 35 max_pending_swaps_(1),
36 pending_swaps_(0), 36 pending_swaps_(0),
37 swaps_with_current_output_surface_(0), 37 swaps_with_current_output_surface_(0),
38 needs_redraw_(false), 38 needs_redraw_(false),
39 needs_animate_(false), 39 needs_animate_(false),
40 needs_prepare_tiles_(false), 40 needs_prepare_tiles_(false),
41 needs_begin_main_frame_(false), 41 needs_begin_main_frame_(false),
42 visible_(false), 42 visible_(false),
43 resourceless_draw_(false),
43 can_draw_(false), 44 can_draw_(false),
44 has_pending_tree_(false), 45 has_pending_tree_(false),
45 pending_tree_is_ready_for_activation_(false), 46 pending_tree_is_ready_for_activation_(false),
46 active_tree_needs_first_draw_(false), 47 active_tree_needs_first_draw_(false),
47 did_create_and_initialize_first_output_surface_(false), 48 did_create_and_initialize_first_output_surface_(false),
48 impl_latency_takes_priority_(false), 49 impl_latency_takes_priority_(false),
49 main_thread_missed_last_deadline_(false), 50 main_thread_missed_last_deadline_(false),
50 skip_next_begin_main_frame_to_reduce_latency_(false), 51 skip_next_begin_main_frame_to_reduce_latency_(false),
51 children_need_begin_frames_(false), 52 children_need_begin_frames_(false),
52 defer_commits_(false), 53 defer_commits_(false),
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 state->SetInteger("max_pending_swaps_", max_pending_swaps_); 219 state->SetInteger("max_pending_swaps_", max_pending_swaps_);
219 state->SetInteger("pending_swaps_", pending_swaps_); 220 state->SetInteger("pending_swaps_", pending_swaps_);
220 state->SetInteger("swaps_with_current_output_surface", 221 state->SetInteger("swaps_with_current_output_surface",
221 swaps_with_current_output_surface_); 222 swaps_with_current_output_surface_);
222 state->SetBoolean("needs_redraw", needs_redraw_); 223 state->SetBoolean("needs_redraw", needs_redraw_);
223 state->SetBoolean("needs_animate_", needs_animate_); 224 state->SetBoolean("needs_animate_", needs_animate_);
224 state->SetBoolean("needs_prepare_tiles", needs_prepare_tiles_); 225 state->SetBoolean("needs_prepare_tiles", needs_prepare_tiles_);
225 state->SetBoolean("needs_begin_main_frame", needs_begin_main_frame_); 226 state->SetBoolean("needs_begin_main_frame", needs_begin_main_frame_);
226 state->SetBoolean("visible", visible_); 227 state->SetBoolean("visible", visible_);
227 state->SetBoolean("can_draw", can_draw_); 228 state->SetBoolean("can_draw", can_draw_);
229 state->SetBoolean("resourceless_draw", resourceless_draw_);
228 state->SetBoolean("has_pending_tree", has_pending_tree_); 230 state->SetBoolean("has_pending_tree", has_pending_tree_);
229 state->SetBoolean("pending_tree_is_ready_for_activation", 231 state->SetBoolean("pending_tree_is_ready_for_activation",
230 pending_tree_is_ready_for_activation_); 232 pending_tree_is_ready_for_activation_);
231 state->SetBoolean("active_tree_needs_first_draw", 233 state->SetBoolean("active_tree_needs_first_draw",
232 active_tree_needs_first_draw_); 234 active_tree_needs_first_draw_);
233 state->SetBoolean("wait_for_ready_to_draw", wait_for_ready_to_draw_); 235 state->SetBoolean("wait_for_ready_to_draw", wait_for_ready_to_draw_);
234 state->SetBoolean("did_create_and_initialize_first_output_surface", 236 state->SetBoolean("did_create_and_initialize_first_output_surface",
235 did_create_and_initialize_first_output_surface_); 237 did_create_and_initialize_first_output_surface_);
236 state->SetBoolean("impl_latency_takes_priority", 238 state->SetBoolean("impl_latency_takes_priority",
237 impl_latency_takes_priority_); 239 impl_latency_takes_priority_);
(...skipping 11 matching lines...) Expand all
249 did_perform_swap_in_last_draw_); 251 did_perform_swap_in_last_draw_);
250 state->EndDictionary(); 252 state->EndDictionary();
251 } 253 }
252 254
253 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const { 255 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const {
254 // Normally when |visible_| is false, pending activations will be forced and 256 // Normally when |visible_| is false, pending activations will be forced and
255 // draws will be aborted. However, when the embedder is Android WebView, 257 // draws will be aborted. However, when the embedder is Android WebView,
256 // software draws could be scheduled by the Android OS at any time and draws 258 // software draws could be scheduled by the Android OS at any time and draws
257 // should not be aborted in this case. 259 // should not be aborted in this case.
258 bool is_output_surface_lost = (output_surface_state_ == OUTPUT_SURFACE_NONE); 260 bool is_output_surface_lost = (output_surface_state_ == OUTPUT_SURFACE_NONE);
259 if (settings_.using_synchronous_renderer_compositor) 261 if (resourceless_draw_)
260 return is_output_surface_lost || !can_draw_; 262 return is_output_surface_lost || !can_draw_;
261 263
262 // These are all the cases where we normally cannot or do not want to draw 264 // These are all the cases where we normally cannot or do not want to draw
263 // but, if needs_redraw_ is true and we do not draw to make forward progress, 265 // but, if needs_redraw_ is true and we do not draw to make forward progress,
264 // we might deadlock with the main thread. 266 // we might deadlock with the main thread.
265 // This should be a superset of PendingActivationsShouldBeForced() since 267 // This should be a superset of PendingActivationsShouldBeForced() since
266 // activation of the pending tree is blocked by drawing of the active tree and 268 // activation of the pending tree is blocked by drawing of the active tree and
267 // the main thread might be blocked on activation of the most recent commit. 269 // the main thread might be blocked on activation of the most recent commit.
268 return is_output_surface_lost || !can_draw_ || !visible_; 270 return is_output_surface_lost || !can_draw_ || !visible_;
269 } 271 }
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 visible_ = visible; 924 visible_ = visible;
923 925
924 if (visible) 926 if (visible)
925 main_thread_missed_last_deadline_ = false; 927 main_thread_missed_last_deadline_ = false;
926 928
927 // TODO(sunnyps): Change the funnel to a bool to avoid hacks like this. 929 // TODO(sunnyps): Change the funnel to a bool to avoid hacks like this.
928 prepare_tiles_funnel_ = 0; 930 prepare_tiles_funnel_ = 0;
929 wait_for_ready_to_draw_ = false; 931 wait_for_ready_to_draw_ = false;
930 } 932 }
931 933
934 void SchedulerStateMachine::SetResourcelessSoftareDraw(bool resourceless_draw) {
935 resourceless_draw_ = resourceless_draw;
936 }
937
932 void SchedulerStateMachine::SetCanDraw(bool can_draw) { can_draw_ = can_draw; } 938 void SchedulerStateMachine::SetCanDraw(bool can_draw) { can_draw_ = can_draw; }
933 939
934 void SchedulerStateMachine::SetNeedsRedraw() { needs_redraw_ = true; } 940 void SchedulerStateMachine::SetNeedsRedraw() { needs_redraw_ = true; }
935 941
936 void SchedulerStateMachine::SetNeedsAnimate() { 942 void SchedulerStateMachine::SetNeedsAnimate() {
937 needs_animate_ = true; 943 needs_animate_ = true;
938 } 944 }
939 945
940 bool SchedulerStateMachine::OnlyImplSideUpdatesExpected() const { 946 bool SchedulerStateMachine::OnlyImplSideUpdatesExpected() const {
941 bool has_impl_updates = needs_redraw_ || needs_animate_; 947 bool has_impl_updates = needs_redraw_ || needs_animate_;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 case OUTPUT_SURFACE_ACTIVE: 1109 case OUTPUT_SURFACE_ACTIVE:
1104 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: 1110 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT:
1105 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: 1111 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION:
1106 return true; 1112 return true;
1107 } 1113 }
1108 NOTREACHED(); 1114 NOTREACHED();
1109 return false; 1115 return false;
1110 } 1116 }
1111 1117
1112 } // namespace cc 1118 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler_state_machine.h ('k') | cc/scheduler/scheduler_state_machine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698