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

Side by Side Diff: cc/trees/single_thread_proxy.h

Issue 134623005: Make SingleThreadProxy a SchedulerClient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add scoped_abort_remaining_swap_promises.h Created 6 years, 4 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
« no previous file with comments | « cc/trees/scoped_abort_remaining_swap_promises.h ('k') | cc/trees/single_thread_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef CC_TREES_SINGLE_THREAD_PROXY_H_ 5 #ifndef CC_TREES_SINGLE_THREAD_PROXY_H_
6 #define CC_TREES_SINGLE_THREAD_PROXY_H_ 6 #define CC_TREES_SINGLE_THREAD_PROXY_H_
7 7
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "cc/animation/animation_events.h" 11 #include "cc/animation/animation_events.h"
12 #include "cc/output/begin_frame_args.h" 12 #include "cc/output/begin_frame_args.h"
13 #include "cc/scheduler/scheduler.h"
13 #include "cc/trees/layer_tree_host_impl.h" 14 #include "cc/trees/layer_tree_host_impl.h"
14 #include "cc/trees/proxy.h" 15 #include "cc/trees/proxy.h"
16 #include "cc/trees/proxy_timing_history.h"
15 17
16 namespace cc { 18 namespace cc {
17 19
18 class ContextProvider; 20 class ContextProvider;
19 class LayerTreeHost; 21 class LayerTreeHost;
20 class LayerTreeHostSingleThreadClient; 22 class LayerTreeHostSingleThreadClient;
21 23
22 class CC_EXPORT SingleThreadProxy : public Proxy, 24 class CC_EXPORT SingleThreadProxy : public Proxy,
23 NON_EXPORTED_BASE(LayerTreeHostImplClient) { 25 NON_EXPORTED_BASE(LayerTreeHostImplClient),
26 SchedulerClient {
24 public: 27 public:
25 static scoped_ptr<Proxy> Create( 28 static scoped_ptr<Proxy> Create(
26 LayerTreeHost* layer_tree_host, 29 LayerTreeHost* layer_tree_host,
27 LayerTreeHostSingleThreadClient* client, 30 LayerTreeHostSingleThreadClient* client,
28 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); 31 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner);
29 virtual ~SingleThreadProxy(); 32 virtual ~SingleThreadProxy();
30 33
31 // Proxy implementation 34 // Proxy implementation
32 virtual void FinishAllRendering() OVERRIDE; 35 virtual void FinishAllRendering() OVERRIDE;
33 virtual bool IsStarted() const OVERRIDE; 36 virtual bool IsStarted() const OVERRIDE;
(...skipping 11 matching lines...) Expand all
45 virtual bool BeginMainFrameRequested() const OVERRIDE; 48 virtual bool BeginMainFrameRequested() const OVERRIDE;
46 virtual void MainThreadHasStoppedFlinging() OVERRIDE {} 49 virtual void MainThreadHasStoppedFlinging() OVERRIDE {}
47 virtual void Start() OVERRIDE; 50 virtual void Start() OVERRIDE;
48 virtual void Stop() OVERRIDE; 51 virtual void Stop() OVERRIDE;
49 virtual size_t MaxPartialTextureUpdates() const OVERRIDE; 52 virtual size_t MaxPartialTextureUpdates() const OVERRIDE;
50 virtual void ForceSerializeOnSwapBuffers() OVERRIDE; 53 virtual void ForceSerializeOnSwapBuffers() OVERRIDE;
51 virtual bool SupportsImplScrolling() const OVERRIDE; 54 virtual bool SupportsImplScrolling() const OVERRIDE;
52 virtual void AsValueInto(base::debug::TracedValue* state) const OVERRIDE; 55 virtual void AsValueInto(base::debug::TracedValue* state) const OVERRIDE;
53 virtual bool MainFrameWillHappenForTesting() OVERRIDE; 56 virtual bool MainFrameWillHappenForTesting() OVERRIDE;
54 57
58 // SchedulerClient implementation
59 virtual void SetNeedsBeginFrame(bool enable) OVERRIDE;
60 virtual void WillBeginImplFrame(const BeginFrameArgs& args) OVERRIDE;
61 virtual void ScheduledActionSendBeginMainFrame() OVERRIDE;
62 virtual DrawResult ScheduledActionDrawAndSwapIfPossible() OVERRIDE;
63 virtual DrawResult ScheduledActionDrawAndSwapForced() OVERRIDE;
64 virtual void ScheduledActionCommit() OVERRIDE;
65 virtual void ScheduledActionAnimate() OVERRIDE;
66 virtual void ScheduledActionUpdateVisibleTiles() OVERRIDE;
67 virtual void ScheduledActionActivateSyncTree() OVERRIDE;
68 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE;
69 virtual void ScheduledActionManageTiles() OVERRIDE;
70 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) OVERRIDE;
71 virtual base::TimeDelta DrawDurationEstimate() OVERRIDE;
72 virtual base::TimeDelta BeginMainFrameToCommitDurationEstimate() OVERRIDE;
73 virtual base::TimeDelta CommitToActivateDurationEstimate() OVERRIDE;
74 virtual void DidBeginImplFrameDeadline() OVERRIDE;
75
55 // LayerTreeHostImplClient implementation 76 // LayerTreeHostImplClient implementation
56 virtual void UpdateRendererCapabilitiesOnImplThread() OVERRIDE; 77 virtual void UpdateRendererCapabilitiesOnImplThread() OVERRIDE;
57 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE; 78 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE;
58 virtual void CommitVSyncParameters(base::TimeTicks timebase, 79 virtual void CommitVSyncParameters(base::TimeTicks timebase,
59 base::TimeDelta interval) OVERRIDE {} 80 base::TimeDelta interval) OVERRIDE {}
60 virtual void SetEstimatedParentDrawTime(base::TimeDelta draw_time) OVERRIDE {} 81 virtual void SetEstimatedParentDrawTime(base::TimeDelta draw_time) OVERRIDE {}
61 virtual void SetMaxSwapsPendingOnImplThread(int max) OVERRIDE {} 82 virtual void SetMaxSwapsPendingOnImplThread(int max) OVERRIDE {}
62 virtual void DidSwapBuffersOnImplThread() OVERRIDE; 83 virtual void DidSwapBuffersOnImplThread() OVERRIDE;
63 virtual void DidSwapBuffersCompleteOnImplThread() OVERRIDE; 84 virtual void DidSwapBuffersCompleteOnImplThread() OVERRIDE;
64 virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE {} 85 virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE;
65 virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE; 86 virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE;
66 virtual void NotifyReadyToActivate() OVERRIDE; 87 virtual void NotifyReadyToActivate() OVERRIDE;
67 virtual void SetNeedsRedrawOnImplThread() OVERRIDE; 88 virtual void SetNeedsRedrawOnImplThread() OVERRIDE;
68 virtual void SetNeedsRedrawRectOnImplThread( 89 virtual void SetNeedsRedrawRectOnImplThread(
69 const gfx::Rect& dirty_rect) OVERRIDE; 90 const gfx::Rect& dirty_rect) OVERRIDE;
70 virtual void SetNeedsAnimateOnImplThread() OVERRIDE; 91 virtual void SetNeedsAnimateOnImplThread() OVERRIDE;
71 virtual void SetNeedsManageTilesOnImplThread() OVERRIDE; 92 virtual void SetNeedsManageTilesOnImplThread() OVERRIDE;
72 virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE; 93 virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE;
73 virtual void SetNeedsCommitOnImplThread() OVERRIDE; 94 virtual void SetNeedsCommitOnImplThread() OVERRIDE;
74 virtual void PostAnimationEventsToMainThreadOnImplThread( 95 virtual void PostAnimationEventsToMainThreadOnImplThread(
75 scoped_ptr<AnimationEventsVector> events) OVERRIDE; 96 scoped_ptr<AnimationEventsVector> events) OVERRIDE;
76 virtual bool ReduceContentsTextureMemoryOnImplThread( 97 virtual bool ReduceContentsTextureMemoryOnImplThread(
77 size_t limit_bytes, 98 size_t limit_bytes,
78 int priority_cutoff) OVERRIDE; 99 int priority_cutoff) OVERRIDE;
79 virtual bool IsInsideDraw() OVERRIDE; 100 virtual bool IsInsideDraw() OVERRIDE;
80 virtual void RenewTreePriority() OVERRIDE {} 101 virtual void RenewTreePriority() OVERRIDE {}
81 virtual void PostDelayedScrollbarFadeOnImplThread( 102 virtual void PostDelayedScrollbarFadeOnImplThread(
82 const base::Closure& start_fade, 103 const base::Closure& start_fade,
83 base::TimeDelta delay) OVERRIDE {} 104 base::TimeDelta delay) OVERRIDE {}
84 virtual void DidActivateSyncTree() OVERRIDE {} 105 virtual void DidActivateSyncTree() OVERRIDE {}
85 virtual void DidManageTiles() OVERRIDE {} 106 virtual void DidManageTiles() OVERRIDE;
86 virtual void SetDebugState(const LayerTreeDebugState& debug_state) OVERRIDE {} 107 virtual void SetDebugState(const LayerTreeDebugState& debug_state) OVERRIDE {}
87 108
88 // Attempts to create the context and renderer synchronously. Calls 109 // Attempts to create the context and renderer synchronously. Calls
89 // LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted with the result. 110 // LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted with the result.
90 void CreateAndInitializeOutputSurface(); 111 void CreateAndInitializeOutputSurface();
91 112
92 // Called by the legacy path where RenderWidget does the scheduling. 113 // Called by the legacy path where RenderWidget does the scheduling.
93 void CompositeImmediately(base::TimeTicks frame_begin_time); 114 void CompositeImmediately(base::TimeTicks frame_begin_time);
94 115
95 private: 116 private:
96 SingleThreadProxy( 117 SingleThreadProxy(
97 LayerTreeHost* layer_tree_host, 118 LayerTreeHost* layer_tree_host,
98 LayerTreeHostSingleThreadClient* client, 119 LayerTreeHostSingleThreadClient* client,
99 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); 120 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner);
100 121
101 void DoCommit(scoped_ptr<ResourceUpdateQueue> queue); 122 void BeginMainFrame();
102 bool DoComposite(base::TimeTicks frame_begin_time, 123 void BeginMainFrameAbortedOnImplThread();
103 LayerTreeHostImpl::FrameData* frame); 124 void DoCommit(const BeginFrameArgs& begin_frame_args);
104 void DidSwapFrame(); 125 DrawResult DoComposite(base::TimeTicks frame_begin_time,
126 LayerTreeHostImpl::FrameData* frame);
127 void DoSwap();
128 void DidCommitAndDrawFrame();
105 129
106 bool ShouldComposite() const; 130 bool ShouldComposite() const;
107 void UpdateBackgroundAnimateTicking(); 131 void UpdateBackgroundAnimateTicking();
108 132
109 // Accessed on main thread only. 133 // Accessed on main thread only.
110 LayerTreeHost* layer_tree_host_; 134 LayerTreeHost* layer_tree_host_;
111 LayerTreeHostSingleThreadClient* client_; 135 LayerTreeHostSingleThreadClient* client_;
112 136
113 // Used on the Thread, but checked on main thread during 137 // Used on the Thread, but checked on main thread during
114 // initialization/shutdown. 138 // initialization/shutdown.
115 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl_; 139 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl_;
116 RendererCapabilities renderer_capabilities_for_main_thread_; 140 RendererCapabilities renderer_capabilities_for_main_thread_;
117 141
142 // Accessed from both threads.
143 scoped_ptr<Scheduler> scheduler_on_impl_thread_;
144 ProxyTimingHistory timing_history_;
145
118 bool next_frame_is_newly_committed_frame_; 146 bool next_frame_is_newly_committed_frame_;
119 147
120 bool inside_draw_; 148 bool inside_draw_;
149 bool defer_commits_;
150 bool commit_was_deferred_;
151 bool commit_requested_;
152
153 base::WeakPtrFactory<SingleThreadProxy> weak_factory_;
121 154
122 DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy); 155 DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy);
123 }; 156 };
124 157
125 // For use in the single-threaded case. In debug builds, it pretends that the 158 // For use in the single-threaded case. In debug builds, it pretends that the
126 // code is running on the impl thread to satisfy assertion checks. 159 // code is running on the impl thread to satisfy assertion checks.
127 class DebugScopedSetImplThread { 160 class DebugScopedSetImplThread {
128 public: 161 public:
129 explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) { 162 explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) {
130 #if DCHECK_IS_ON 163 #if DCHECK_IS_ON
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 private: 212 private:
180 DebugScopedSetImplThread impl_thread_; 213 DebugScopedSetImplThread impl_thread_;
181 DebugScopedSetMainThreadBlocked main_thread_blocked_; 214 DebugScopedSetMainThreadBlocked main_thread_blocked_;
182 215
183 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked); 216 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked);
184 }; 217 };
185 218
186 } // namespace cc 219 } // namespace cc
187 220
188 #endif // CC_TREES_SINGLE_THREAD_PROXY_H_ 221 #endif // CC_TREES_SINGLE_THREAD_PROXY_H_
OLDNEW
« no previous file with comments | « cc/trees/scoped_abort_remaining_swap_promises.h ('k') | cc/trees/single_thread_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698