summaryrefslogtreecommitdiff
path: root/chromium/cc/scheduler/scheduler.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/cc/scheduler/scheduler.h')
-rw-r--r--chromium/cc/scheduler/scheduler.h114
1 files changed, 45 insertions, 69 deletions
diff --git a/chromium/cc/scheduler/scheduler.h b/chromium/cc/scheduler/scheduler.h
index 13daf008cc3..d6fc074c541 100644
--- a/chromium/cc/scheduler/scheduler.h
+++ b/chromium/cc/scheduler/scheduler.h
@@ -14,8 +14,8 @@
#include "base/time/time.h"
#include "cc/base/cc_export.h"
#include "cc/output/begin_frame_args.h"
-#include "cc/output/vsync_parameter_observer.h"
#include "cc/scheduler/begin_frame_source.h"
+#include "cc/scheduler/begin_frame_tracker.h"
#include "cc/scheduler/delay_based_time_source.h"
#include "cc/scheduler/draw_result.h"
#include "cc/scheduler/scheduler_settings.h"
@@ -30,6 +30,8 @@ class SingleThreadTaskRunner;
namespace cc {
+class CompositorTimingHistory;
+
class SchedulerClient {
public:
virtual void WillBeginImplFrame(const BeginFrameArgs& args) = 0;
@@ -42,10 +44,6 @@ class SchedulerClient {
virtual void ScheduledActionBeginOutputSurfaceCreation() = 0;
virtual void ScheduledActionPrepareTiles() = 0;
virtual void ScheduledActionInvalidateOutputSurface() = 0;
- virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) = 0;
- virtual base::TimeDelta DrawDurationEstimate() = 0;
- virtual base::TimeDelta BeginMainFrameToCommitDurationEstimate() = 0;
- virtual base::TimeDelta CommitToActivateDurationEstimate() = 0;
virtual void DidFinishImplFrame() = 0;
virtual void SendBeginFramesToChildren(const BeginFrameArgs& args) = 0;
virtual void SendBeginMainFrameNotExpectedSoon() = 0;
@@ -54,45 +52,20 @@ class SchedulerClient {
virtual ~SchedulerClient() {}
};
-class Scheduler;
-// This class exists to allow tests to override the frame source construction.
-// A virtual method can't be used as this needs to happen in the constructor
-// (see C++ FAQ / Section 23 - http://goo.gl/fnrwom for why).
-// This class exists solely long enough to construct the frame sources.
-class CC_EXPORT SchedulerFrameSourcesConstructor {
- public:
- virtual ~SchedulerFrameSourcesConstructor() {}
- virtual BeginFrameSource* ConstructPrimaryFrameSource(Scheduler* scheduler);
- virtual BeginFrameSource* ConstructUnthrottledFrameSource(
- Scheduler* scheduler);
-
- protected:
- SchedulerFrameSourcesConstructor() {}
-
- friend class Scheduler;
-};
-
-class CC_EXPORT Scheduler : public BeginFrameObserverMixIn {
+class CC_EXPORT Scheduler : public BeginFrameObserverBase {
public:
static scoped_ptr<Scheduler> Create(
SchedulerClient* client,
const SchedulerSettings& scheduler_settings,
int layer_tree_host_id,
- const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
- scoped_ptr<BeginFrameSource> external_begin_frame_source) {
- SchedulerFrameSourcesConstructor frame_sources_constructor;
- return make_scoped_ptr(new Scheduler(client,
- scheduler_settings,
- layer_tree_host_id,
- task_runner,
- external_begin_frame_source.Pass(),
- &frame_sources_constructor));
- }
+ base::SingleThreadTaskRunner* task_runner,
+ BeginFrameSource* external_frame_source,
+ scoped_ptr<CompositorTimingHistory> compositor_timing_history);
~Scheduler() override;
- // BeginFrameObserverMixin
- bool OnBeginFrameMixInDelegate(const BeginFrameArgs& args) override;
+ // BeginFrameObserverBase
+ bool OnBeginFrameDerivedImpl(const BeginFrameArgs& args) override;
void OnDrawForOutputSurface();
@@ -128,7 +101,9 @@ class CC_EXPORT Scheduler : public BeginFrameObserverMixIn {
void NotifyReadyToCommit();
void BeginMainFrameAborted(CommitEarlyOutReason reason);
+ void DidCommit();
+ void WillPrepareTiles();
void DidPrepareTiles();
void DidLoseOutputSurface();
void DidCreateAndInitializeOutputSurface();
@@ -145,14 +120,12 @@ class CC_EXPORT Scheduler : public BeginFrameObserverMixIn {
bool PrepareTilesPending() const {
return state_machine_.PrepareTilesPending();
}
- bool MainThreadIsInHighLatencyMode() const {
- return state_machine_.MainThreadIsInHighLatencyMode();
- }
bool BeginImplFrameDeadlinePending() const {
return !begin_impl_frame_deadline_task_.IsCancelled();
}
-
- base::TimeTicks AnticipatedDrawTime() const;
+ bool ImplLatencyTakesPriority() const {
+ return state_machine_.impl_latency_takes_priority();
+ }
void NotifyBeginMainFrameStarted();
@@ -176,46 +149,41 @@ class CC_EXPORT Scheduler : public BeginFrameObserverMixIn {
Scheduler(SchedulerClient* client,
const SchedulerSettings& scheduler_settings,
int layer_tree_host_id,
- const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
- scoped_ptr<BeginFrameSource> external_begin_frame_source,
- SchedulerFrameSourcesConstructor* frame_sources_constructor);
+ base::SingleThreadTaskRunner* task_runner,
+ BeginFrameSource* external_frame_source,
+ scoped_ptr<SyntheticBeginFrameSource> synthetic_frame_source,
+ scoped_ptr<BackToBackBeginFrameSource> unthrottled_frame_source,
+ scoped_ptr<CompositorTimingHistory> compositor_timing_history);
- // virtual for testing - Don't call these in the constructor or
- // destructor!
+ // Virtual for testing.
virtual base::TimeTicks Now() const;
- scoped_ptr<BeginFrameSourceMultiplexer> frame_source_;
- BeginFrameSource* primary_frame_source_;
- BeginFrameSource* unthrottled_frame_source_;
+ const SchedulerSettings settings_;
+ SchedulerClient* client_;
+ int layer_tree_host_id_;
+ base::SingleThreadTaskRunner* task_runner_;
+ BeginFrameSource* external_frame_source_;
+ scoped_ptr<SyntheticBeginFrameSource> synthetic_frame_source_;
+ scoped_ptr<BackToBackBeginFrameSource> unthrottled_frame_source_;
- // Storage when frame sources are internal
- scoped_ptr<BeginFrameSource> primary_frame_source_internal_;
- scoped_ptr<BeginFrameSource> unthrottled_frame_source_internal_;
+ scoped_ptr<BeginFrameSourceMultiplexer> frame_source_;
+ bool throttle_frame_production_;
- VSyncParameterObserver* vsync_observer_;
base::TimeDelta authoritative_vsync_interval_;
base::TimeTicks last_vsync_timebase_;
- bool throttle_frame_production_;
-
- const SchedulerSettings settings_;
- SchedulerClient* client_;
- int layer_tree_host_id_;
- scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
-
+ scoped_ptr<CompositorTimingHistory> compositor_timing_history_;
base::TimeDelta estimated_parent_draw_time_;
std::deque<BeginFrameArgs> begin_retro_frame_args_;
- BeginFrameArgs begin_impl_frame_args_;
SchedulerStateMachine::BeginImplFrameDeadlineMode
begin_impl_frame_deadline_mode_;
+ BeginFrameTracker begin_impl_frame_tracker_;
base::Closure begin_retro_frame_closure_;
base::Closure begin_impl_frame_deadline_closure_;
- base::Closure advance_commit_state_closure_;
base::CancelableClosure begin_retro_frame_task_;
base::CancelableClosure begin_impl_frame_deadline_task_;
- base::CancelableClosure advance_commit_state_task_;
SchedulerStateMachine state_machine_;
bool inside_process_scheduled_actions_;
@@ -226,16 +194,19 @@ class CC_EXPORT Scheduler : public BeginFrameObserverMixIn {
void ScheduleBeginImplFrameDeadlineIfNeeded();
void SetupNextBeginFrameIfNeeded();
void PostBeginRetroFrameIfNeeded();
- void SetupPollingMechanisms();
void DrawAndSwapIfPossible();
+ void DrawAndSwapForced();
void ProcessScheduledActions();
- bool CanCommitAndActivateBeforeDeadline() const;
+ void UpdateCompositorTimingHistoryRecordingEnabled();
+ bool ShouldRecoverMainLatency(const BeginFrameArgs& args) const;
+ bool ShouldRecoverImplLatency(const BeginFrameArgs& args) const;
+ bool CanCommitAndActivateBeforeDeadline(const BeginFrameArgs& args) const;
void AdvanceCommitStateIfPossible();
bool IsBeginMainFrameSentOrStarted() const;
void BeginRetroFrame();
void BeginImplFrameWithDeadline(const BeginFrameArgs& args);
void BeginImplFrameSynchronous(const BeginFrameArgs& args);
- void BeginImplFrame();
+ void BeginImplFrame(const BeginFrameArgs& args);
void FinishImplFrame();
void OnBeginImplFrameDeadline();
void PollToAdvanceCommitState();
@@ -248,10 +219,15 @@ class CC_EXPORT Scheduler : public BeginFrameObserverMixIn {
return inside_action_ == action;
}
- base::WeakPtrFactory<Scheduler> weak_factory_;
+ BeginFrameSource* primary_frame_source() {
+ if (settings_.use_external_begin_frame_source) {
+ DCHECK(external_frame_source_);
+ return external_frame_source_;
+ }
+ return synthetic_frame_source_.get();
+ }
- friend class SchedulerFrameSourcesConstructor;
- friend class TestSchedulerFrameSourcesConstructor;
+ base::WeakPtrFactory<Scheduler> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(Scheduler);
};