| 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/scheduler/scheduler.h" | 5 #include "cc/scheduler/scheduler.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "cc/debug/traced_value.h" | 10 #include "cc/debug/traced_value.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 has_pending_begin_frame_ = false; | 144 has_pending_begin_frame_ = false; |
| 145 client_->SetNeedsBeginFrameOnImplThread(needs_begin_frame); | 145 client_->SetNeedsBeginFrameOnImplThread(needs_begin_frame); |
| 146 last_set_needs_begin_frame_ = needs_begin_frame; | 146 last_set_needs_begin_frame_ = needs_begin_frame; |
| 147 } | 147 } |
| 148 | 148 |
| 149 // Request another BeginFrame if we haven't drawn for now until we have | 149 // Request another BeginFrame if we haven't drawn for now until we have |
| 150 // deadlines implemented. | 150 // deadlines implemented. |
| 151 if (state_machine_.inside_begin_frame() && has_pending_begin_frame_) { | 151 if (state_machine_.inside_begin_frame() && has_pending_begin_frame_) { |
| 152 has_pending_begin_frame_ = false; | 152 has_pending_begin_frame_ = false; |
| 153 client_->SetNeedsBeginFrameOnImplThread(true); | 153 client_->SetNeedsBeginFrameOnImplThread(true); |
| 154 return; | 154 } |
| 155 |
| 156 // Setup PollForAnticipatedDrawTriggers for cases where we want a proactive |
| 157 // BeginFrame but aren't requesting one. |
| 158 if (!needs_begin_frame && |
| 159 state_machine_.ProactiveBeginFrameWantedByImplThread()) { |
| 160 if (poll_for_draw_triggers_closure_.IsCancelled()) { |
| 161 poll_for_draw_triggers_closure_.Reset( |
| 162 base::Bind(&Scheduler::PollForAnticipatedDrawTriggers, |
| 163 weak_factory_.GetWeakPtr())); |
| 164 base::MessageLoop::current()->PostDelayedTask( |
| 165 FROM_HERE, |
| 166 poll_for_draw_triggers_closure_.callback(), |
| 167 last_begin_frame_args_.interval); |
| 168 } |
| 169 } else { |
| 170 poll_for_draw_triggers_closure_.Cancel(); |
| 155 } | 171 } |
| 156 } | 172 } |
| 157 | 173 |
| 158 void Scheduler::BeginFrame(const BeginFrameArgs& args) { | 174 void Scheduler::BeginFrame(const BeginFrameArgs& args) { |
| 159 TRACE_EVENT0("cc", "Scheduler::BeginFrame"); | 175 TRACE_EVENT0("cc", "Scheduler::BeginFrame"); |
| 160 DCHECK(!has_pending_begin_frame_); | 176 DCHECK(!has_pending_begin_frame_); |
| 161 has_pending_begin_frame_ = true; | 177 has_pending_begin_frame_ = true; |
| 162 last_begin_frame_args_ = args; | 178 last_begin_frame_args_ = args; |
| 163 state_machine_.DidEnterBeginFrame(args); | 179 state_machine_.DidEnterBeginFrame(args); |
| 164 ProcessScheduledActions(); | 180 ProcessScheduledActions(); |
| 165 state_machine_.DidLeaveBeginFrame(); | 181 state_machine_.DidLeaveBeginFrame(); |
| 166 } | 182 } |
| 167 | 183 |
| 184 void Scheduler::PollForAnticipatedDrawTriggers() { |
| 185 TRACE_EVENT0("cc", "Scheduler::PollForAnticipatedDrawTriggers"); |
| 186 state_machine_.PollForAnticipatedDrawTriggers(); |
| 187 ProcessScheduledActions(); |
| 188 } |
| 189 |
| 168 void Scheduler::DrawAndSwapIfPossible() { | 190 void Scheduler::DrawAndSwapIfPossible() { |
| 169 DrawSwapReadbackResult result = | 191 DrawSwapReadbackResult result = |
| 170 client_->ScheduledActionDrawAndSwapIfPossible(); | 192 client_->ScheduledActionDrawAndSwapIfPossible(); |
| 171 state_machine_.DidDrawIfPossibleCompleted(result.did_draw); | 193 state_machine_.DidDrawIfPossibleCompleted(result.did_draw); |
| 172 if (result.did_swap) | 194 if (result.did_swap) |
| 173 has_pending_begin_frame_ = false; | 195 has_pending_begin_frame_ = false; |
| 174 } | 196 } |
| 175 | 197 |
| 176 void Scheduler::DrawAndSwapForced() { | 198 void Scheduler::DrawAndSwapForced() { |
| 177 DrawSwapReadbackResult result = client_->ScheduledActionDrawAndSwapForced(); | 199 DrawSwapReadbackResult result = client_->ScheduledActionDrawAndSwapForced(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 262 |
| 241 SetupNextBeginFrameIfNeeded(); | 263 SetupNextBeginFrameIfNeeded(); |
| 242 client_->DidAnticipatedDrawTimeChange(AnticipatedDrawTime()); | 264 client_->DidAnticipatedDrawTimeChange(AnticipatedDrawTime()); |
| 243 } | 265 } |
| 244 | 266 |
| 245 bool Scheduler::WillDrawIfNeeded() const { | 267 bool Scheduler::WillDrawIfNeeded() const { |
| 246 return !state_machine_.PendingDrawsShouldBeAborted(); | 268 return !state_machine_.PendingDrawsShouldBeAborted(); |
| 247 } | 269 } |
| 248 | 270 |
| 249 } // namespace cc | 271 } // namespace cc |
| OLD | NEW |