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

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: Mac browser compositor fixes Created 6 years, 5 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 #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 10 matching lines...) Expand all
44 virtual bool CommitRequested() const OVERRIDE; 47 virtual bool CommitRequested() const OVERRIDE;
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 scoped_ptr<base::Value> AsValue() const OVERRIDE; 55 virtual scoped_ptr<base::Value> AsValue() const OVERRIDE;
53 virtual bool CommitPendingForTesting() OVERRIDE; 56 virtual bool CommitPendingForTesting() OVERRIDE;
57 virtual scoped_ptr<base::Value> SchedulerAsValueForTesting() OVERRIDE;
58
59 // SchedulerClient implementation
60 virtual void SetNeedsBeginFrame(bool enable) OVERRIDE;
61 virtual void WillBeginImplFrame(const BeginFrameArgs& args) OVERRIDE;
62 virtual void ScheduledActionSendBeginMainFrame() OVERRIDE;
63 virtual DrawResult ScheduledActionDrawAndSwapIfPossible() OVERRIDE;
64 virtual DrawResult ScheduledActionDrawAndSwapForced() OVERRIDE;
65 virtual void ScheduledActionCommit() OVERRIDE;
66 virtual void ScheduledActionAnimate() OVERRIDE;
67 virtual void ScheduledActionUpdateVisibleTiles() OVERRIDE;
68 virtual void ScheduledActionActivateSyncTree() OVERRIDE;
69 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE;
70 virtual void ScheduledActionManageTiles() OVERRIDE;
71 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) OVERRIDE;
72 virtual base::TimeDelta DrawDurationEstimate() OVERRIDE;
73 virtual base::TimeDelta BeginMainFrameToCommitDurationEstimate() OVERRIDE;
74 virtual base::TimeDelta CommitToActivateDurationEstimate() OVERRIDE;
75 virtual void DidBeginImplFrameDeadline() OVERRIDE;
54 76
55 // LayerTreeHostImplClient implementation 77 // LayerTreeHostImplClient implementation
56 virtual void UpdateRendererCapabilitiesOnImplThread() OVERRIDE; 78 virtual void UpdateRendererCapabilitiesOnImplThread() OVERRIDE;
57 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE; 79 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE;
58 virtual void CommitVSyncParameters(base::TimeTicks timebase, 80 virtual void CommitVSyncParameters(base::TimeTicks timebase,
59 base::TimeDelta interval) OVERRIDE {} 81 base::TimeDelta interval) OVERRIDE {}
60 virtual void SetEstimatedParentDrawTime(base::TimeDelta draw_time) OVERRIDE {} 82 virtual void SetEstimatedParentDrawTime(base::TimeDelta draw_time) OVERRIDE {}
61 virtual void SetMaxSwapsPendingOnImplThread(int max) OVERRIDE {} 83 virtual void SetMaxSwapsPendingOnImplThread(int max) OVERRIDE {}
62 virtual void DidSwapBuffersOnImplThread() OVERRIDE; 84 virtual void DidSwapBuffersOnImplThread() OVERRIDE;
63 virtual void DidSwapBuffersCompleteOnImplThread() OVERRIDE; 85 virtual void DidSwapBuffersCompleteOnImplThread() OVERRIDE;
64 virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE {} 86 virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE;
65 virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE; 87 virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE;
66 virtual void NotifyReadyToActivate() OVERRIDE; 88 virtual void NotifyReadyToActivate() OVERRIDE;
67 virtual void SetNeedsRedrawOnImplThread() OVERRIDE; 89 virtual void SetNeedsRedrawOnImplThread() OVERRIDE;
68 virtual void SetNeedsRedrawRectOnImplThread( 90 virtual void SetNeedsRedrawRectOnImplThread(
69 const gfx::Rect& dirty_rect) OVERRIDE; 91 const gfx::Rect& dirty_rect) OVERRIDE;
70 virtual void SetNeedsAnimateOnImplThread() OVERRIDE; 92 virtual void SetNeedsAnimateOnImplThread() OVERRIDE;
71 virtual void SetNeedsManageTilesOnImplThread() OVERRIDE; 93 virtual void SetNeedsManageTilesOnImplThread() OVERRIDE;
72 virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE; 94 virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE;
73 virtual void SetNeedsCommitOnImplThread() OVERRIDE; 95 virtual void SetNeedsCommitOnImplThread() OVERRIDE;
74 virtual void PostAnimationEventsToMainThreadOnImplThread( 96 virtual void PostAnimationEventsToMainThreadOnImplThread(
75 scoped_ptr<AnimationEventsVector> events) OVERRIDE; 97 scoped_ptr<AnimationEventsVector> events) OVERRIDE;
76 virtual bool ReduceContentsTextureMemoryOnImplThread( 98 virtual bool ReduceContentsTextureMemoryOnImplThread(
77 size_t limit_bytes, 99 size_t limit_bytes,
78 int priority_cutoff) OVERRIDE; 100 int priority_cutoff) OVERRIDE;
79 virtual bool IsInsideDraw() OVERRIDE; 101 virtual bool IsInsideDraw() OVERRIDE;
80 virtual void RenewTreePriority() OVERRIDE {} 102 virtual void RenewTreePriority() OVERRIDE {}
81 virtual void PostDelayedScrollbarFadeOnImplThread( 103 virtual void PostDelayedScrollbarFadeOnImplThread(
82 const base::Closure& start_fade, 104 const base::Closure& start_fade,
83 base::TimeDelta delay) OVERRIDE {} 105 base::TimeDelta delay) OVERRIDE {}
84 virtual void DidActivateSyncTree() OVERRIDE {} 106 virtual void DidActivateSyncTree() OVERRIDE {}
85 virtual void DidManageTiles() OVERRIDE {} 107 virtual void DidManageTiles() OVERRIDE;
86 virtual void SetDebugState(const LayerTreeDebugState& debug_state) OVERRIDE {} 108 virtual void SetDebugState(const LayerTreeDebugState& debug_state) OVERRIDE {}
87 109
88 // Attempts to create the context and renderer synchronously. Calls 110 // Attempts to create the context and renderer synchronously. Calls
89 // LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted with the result. 111 // LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted with the result.
90 void CreateAndInitializeOutputSurface(); 112 void CreateAndInitializeOutputSurface();
91 113
92 // Called by the legacy path where RenderWidget does the scheduling. 114 // Called by the legacy path where RenderWidget does the scheduling.
93 void CompositeImmediately(base::TimeTicks frame_begin_time); 115 void CompositeImmediately(base::TimeTicks frame_begin_time);
94 116
95 private: 117 private:
96 SingleThreadProxy( 118 SingleThreadProxy(
97 LayerTreeHost* layer_tree_host, 119 LayerTreeHost* layer_tree_host,
98 LayerTreeHostSingleThreadClient* client, 120 LayerTreeHostSingleThreadClient* client,
99 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); 121 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner);
100 122
101 void DoCommit(scoped_ptr<ResourceUpdateQueue> queue); 123 void DoCommit(base::TimeTicks frame_begin_time);
102 bool DoComposite(base::TimeTicks frame_begin_time, 124 DrawResult DoComposite(base::TimeTicks frame_begin_time,
103 LayerTreeHostImpl::FrameData* frame); 125 LayerTreeHostImpl::FrameData* frame);
104 void DidSwapFrame(); 126 void DoSwap();
127 void DidCommitAndDrawFrame();
105 128
106 bool ShouldComposite() const; 129 bool ShouldComposite() const;
107 void UpdateBackgroundAnimateTicking(); 130 void UpdateBackgroundAnimateTicking();
108 131
109 // Accessed on main thread only. 132 // Accessed on main thread only.
110 LayerTreeHost* layer_tree_host_; 133 LayerTreeHost* layer_tree_host_;
111 LayerTreeHostSingleThreadClient* client_; 134 LayerTreeHostSingleThreadClient* client_;
112 135
113 // Used on the Thread, but checked on main thread during 136 // Used on the Thread, but checked on main thread during
114 // initialization/shutdown. 137 // initialization/shutdown.
115 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl_; 138 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl_;
116 RendererCapabilities renderer_capabilities_for_main_thread_; 139 RendererCapabilities renderer_capabilities_for_main_thread_;
117 140
141 // Accessed from both threads.
142 scoped_ptr<Scheduler> scheduler_on_impl_thread_;
143 ProxyTimingHistory timing_history_;
144
118 bool next_frame_is_newly_committed_frame_; 145 bool next_frame_is_newly_committed_frame_;
119 146
120 bool inside_draw_; 147 bool inside_draw_;
148 bool defer_commits_;
149 bool commit_was_deferred_;
150 bool commit_requested_;
151
152 base::WeakPtrFactory<SingleThreadProxy> weak_factory_;
121 153
122 DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy); 154 DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy);
123 }; 155 };
124 156
125 // For use in the single-threaded case. In debug builds, it pretends that the 157 // 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. 158 // code is running on the impl thread to satisfy assertion checks.
127 class DebugScopedSetImplThread { 159 class DebugScopedSetImplThread {
128 public: 160 public:
129 explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) { 161 explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) {
130 #if DCHECK_IS_ON 162 #if DCHECK_IS_ON
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 private: 211 private:
180 DebugScopedSetImplThread impl_thread_; 212 DebugScopedSetImplThread impl_thread_;
181 DebugScopedSetMainThreadBlocked main_thread_blocked_; 213 DebugScopedSetMainThreadBlocked main_thread_blocked_;
182 214
183 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked); 215 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked);
184 }; 216 };
185 217
186 } // namespace cc 218 } // namespace cc
187 219
188 #endif // CC_TREES_SINGLE_THREAD_PROXY_H_ 220 #endif // CC_TREES_SINGLE_THREAD_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698