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

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: More danakj review Created 6 years, 10 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 SingleThreadProxy : public Proxy, LayerTreeHostImplClient { 24 class SingleThreadProxy : public Proxy,
25 LayerTreeHostImplClient,
26 SchedulerClient {
23 public: 27 public:
24 static scoped_ptr<Proxy> Create( 28 static scoped_ptr<Proxy> Create(
25 LayerTreeHost* layer_tree_host, 29 LayerTreeHost* layer_tree_host,
26 LayerTreeHostSingleThreadClient* client); 30 LayerTreeHostSingleThreadClient* client);
27 virtual ~SingleThreadProxy(); 31 virtual ~SingleThreadProxy();
28 32
29 // Proxy implementation 33 // Proxy implementation
30 virtual bool CompositeAndReadback(void* pixels, 34 virtual bool CompositeAndReadback(void* pixels,
31 const gfx::Rect& rect) OVERRIDE; 35 const gfx::Rect& rect) OVERRIDE;
32 virtual void FinishAllRendering() OVERRIDE; 36 virtual void FinishAllRendering() OVERRIDE;
(...skipping 12 matching lines...) Expand all
45 virtual bool CommitRequested() const OVERRIDE; 49 virtual bool CommitRequested() const OVERRIDE;
46 virtual bool BeginMainFrameRequested() const OVERRIDE; 50 virtual bool BeginMainFrameRequested() const OVERRIDE;
47 virtual void MainThreadHasStoppedFlinging() OVERRIDE {} 51 virtual void MainThreadHasStoppedFlinging() OVERRIDE {}
48 virtual void Start() OVERRIDE; 52 virtual void Start() OVERRIDE;
49 virtual void Stop() OVERRIDE; 53 virtual void Stop() OVERRIDE;
50 virtual size_t MaxPartialTextureUpdates() const OVERRIDE; 54 virtual size_t MaxPartialTextureUpdates() const OVERRIDE;
51 virtual void AcquireLayerTextures() OVERRIDE {} 55 virtual void AcquireLayerTextures() OVERRIDE {}
52 virtual void ForceSerializeOnSwapBuffers() OVERRIDE; 56 virtual void ForceSerializeOnSwapBuffers() OVERRIDE;
53 virtual scoped_ptr<base::Value> AsValue() const OVERRIDE; 57 virtual scoped_ptr<base::Value> AsValue() const OVERRIDE;
54 virtual bool CommitPendingForTesting() OVERRIDE; 58 virtual bool CommitPendingForTesting() OVERRIDE;
59 virtual scoped_ptr<base::Value> SchedulerStateAsValueForTesting() OVERRIDE;
60
61 // SchedulerClient implementation
62 virtual void SetNeedsBeginImplFrame(bool enable) OVERRIDE;
63 virtual void ScheduledActionSendBeginMainFrame() OVERRIDE;
64 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapIfPossible()
65 OVERRIDE;
66 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapForced() OVERRIDE;
67 virtual DrawSwapReadbackResult ScheduledActionDrawAndReadback() OVERRIDE;
68 virtual void ScheduledActionCommit() OVERRIDE;
69 virtual void ScheduledActionUpdateVisibleTiles() OVERRIDE;
70 virtual void ScheduledActionActivatePendingTree() OVERRIDE;
71 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE;
72 virtual void ScheduledActionAcquireLayerTexturesForMainThread() OVERRIDE;
73 virtual void ScheduledActionManageTiles() OVERRIDE;
74 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) OVERRIDE;
75 virtual base::TimeDelta DrawDurationEstimate() OVERRIDE;
76 virtual base::TimeDelta BeginMainFrameToCommitDurationEstimate() OVERRIDE;
77 virtual base::TimeDelta CommitToActivateDurationEstimate() OVERRIDE;
78 virtual void PostBeginImplFrameDeadline(const base::Closure& closure,
79 base::TimeTicks deadline) OVERRIDE;
80 virtual void DidBeginImplFrameDeadline() OVERRIDE;
55 81
56 // LayerTreeHostImplClient implementation 82 // LayerTreeHostImplClient implementation
57 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE; 83 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE;
58 virtual void DidSwapBuffersOnImplThread() OVERRIDE; 84 virtual void DidSwapBuffersOnImplThread() OVERRIDE;
59 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE; 85 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE;
60 virtual void BeginImplFrame(const BeginFrameArgs& args) 86 virtual void BeginImplFrame(const BeginFrameArgs& args) OVERRIDE;
61 OVERRIDE {}
62 virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE; 87 virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE;
63 virtual void NotifyReadyToActivate() OVERRIDE; 88 virtual void NotifyReadyToActivate() OVERRIDE;
64 virtual void SetNeedsRedrawOnImplThread() OVERRIDE; 89 virtual void SetNeedsRedrawOnImplThread() OVERRIDE;
65 virtual void SetNeedsRedrawRectOnImplThread( 90 virtual void SetNeedsRedrawRectOnImplThread(
66 const gfx::Rect& dirty_rect) OVERRIDE; 91 const gfx::Rect& dirty_rect) OVERRIDE;
67 virtual void SetNeedsManageTilesOnImplThread() OVERRIDE; 92 virtual void SetNeedsManageTilesOnImplThread() OVERRIDE;
68 virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE; 93 virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE;
69 virtual void SetNeedsCommitOnImplThread() OVERRIDE; 94 virtual void SetNeedsCommitOnImplThread() OVERRIDE;
70 virtual void PostAnimationEventsToMainThreadOnImplThread( 95 virtual void PostAnimationEventsToMainThreadOnImplThread(
71 scoped_ptr<AnimationEventsVector> events, 96 scoped_ptr<AnimationEventsVector> events,
72 base::Time wall_clock_time) OVERRIDE; 97 base::Time wall_clock_time) OVERRIDE;
73 virtual bool ReduceContentsTextureMemoryOnImplThread( 98 virtual bool ReduceContentsTextureMemoryOnImplThread(
74 size_t limit_bytes, 99 size_t limit_bytes,
75 int priority_cutoff) OVERRIDE; 100 int priority_cutoff) OVERRIDE;
76 virtual void SendManagedMemoryStats() OVERRIDE; 101 virtual void SendManagedMemoryStats() OVERRIDE;
77 virtual bool IsInsideDraw() OVERRIDE; 102 virtual bool IsInsideDraw() OVERRIDE;
78 virtual void RenewTreePriority() OVERRIDE {} 103 virtual void RenewTreePriority() OVERRIDE {}
79 virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay) 104 virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay)
80 OVERRIDE {} 105 OVERRIDE {}
81 virtual void DidActivatePendingTree() OVERRIDE {} 106 virtual void DidActivatePendingTree() OVERRIDE;
82 virtual void DidManageTiles() OVERRIDE {} 107 virtual void DidManageTiles() OVERRIDE;
83 108
84 // Called by the legacy path where RenderWidget does the scheduling. 109 // Called by the legacy path where RenderWidget does the scheduling.
85 void CompositeImmediately(base::TimeTicks frame_begin_time); 110 void CompositeImmediately(base::TimeTicks frame_begin_time);
86 111
87 private: 112 private:
88 SingleThreadProxy(LayerTreeHost* layer_tree_host, 113 SingleThreadProxy(LayerTreeHost* layer_tree_host,
89 LayerTreeHostSingleThreadClient* client); 114 LayerTreeHostSingleThreadClient* client);
90 115
91 void OnOutputSurfaceInitializeAttempted(bool success); 116 void OnOutputSurfaceInitializeAttempted(bool success);
92 bool CommitAndComposite(base::TimeTicks frame_begin_time, 117 void DoCommit(base::TimeTicks frame_begin_time);
93 const gfx::Rect& device_viewport_damage_rect, 118 DrawSwapReadbackResult::DrawResult DoComposite(
94 bool for_readback, 119 scoped_refptr<ContextProvider> offscreen_context_provider,
95 LayerTreeHostImpl::FrameData* frame); 120 base::TimeTicks frame_begin_time,
96 void DoCommit(scoped_ptr<ResourceUpdateQueue> queue); 121 const gfx::Rect& device_viewport_damage_rect,
97 bool DoComposite(scoped_refptr<ContextProvider> offscreen_context_provider, 122 bool for_readback,
98 base::TimeTicks frame_begin_time, 123 LayerTreeHostImpl::FrameData* frame);
99 const gfx::Rect& device_viewport_damage_rect, 124 DrawSwapReadbackResult CommitAndCompositeInternal(
100 bool for_readback, 125 base::TimeTicks frame_begin_time,
101 LayerTreeHostImpl::FrameData* frame); 126 gfx::Rect device_viewport_damage_rect,
102 void DidSwapFrame(); 127 bool do_commit,
128 bool for_readback);
129 void DidCommitAndDrawFrame();
103 130
104 bool ShouldComposite() const; 131 bool ShouldComposite() const;
105 void UpdateBackgroundAnimateTicking(); 132 void UpdateBackgroundAnimateTicking();
133 scoped_refptr<ContextProvider> OffscreenContextProvider();
106 134
107 // Accessed on main thread only. 135 // Accessed on main thread only.
108 LayerTreeHost* layer_tree_host_; 136 LayerTreeHost* layer_tree_host_;
109 LayerTreeHostSingleThreadClient* client_; 137 LayerTreeHostSingleThreadClient* client_;
110 bool created_offscreen_context_provider_; 138 bool created_offscreen_context_provider_;
111 139
112 // Used on the Thread, but checked on main thread during 140 // Used on the Thread, but checked on main thread during
113 // initialization/shutdown. 141 // initialization/shutdown.
114 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl_; 142 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl_;
115 RendererCapabilities renderer_capabilities_for_main_thread_; 143 RendererCapabilities renderer_capabilities_for_main_thread_;
116 144
145 // Accessed from both threads.
146 scoped_ptr<Scheduler> scheduler_on_impl_thread_;
147 ProxyTimingHistory timing_history_;
148
149 base::WeakPtrFactory<SingleThreadProxy> weak_factory_;
danakj 2014/02/20 20:56:40 This should be the last member of the class.
enne (OOO) 2014/02/20 21:07:13 Done.
150 base::WeakPtr<SingleThreadProxy> weak_ptr_;
151
117 bool next_frame_is_newly_committed_frame_; 152 bool next_frame_is_newly_committed_frame_;
118 153
119 bool inside_draw_; 154 bool inside_draw_;
155 bool defer_commits_;
156 bool finish_commit_deferred_;
120 157
121 DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy); 158 DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy);
122 }; 159 };
123 160
124 // For use in the single-threaded case. In debug builds, it pretends that the 161 // For use in the single-threaded case. In debug builds, it pretends that the
125 // code is running on the impl thread to satisfy assertion checks. 162 // code is running on the impl thread to satisfy assertion checks.
126 class DebugScopedSetImplThread { 163 class DebugScopedSetImplThread {
127 public: 164 public:
128 explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) { 165 explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) {
129 #ifndef NDEBUG 166 #ifndef NDEBUG
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 private: 215 private:
179 DebugScopedSetImplThread impl_thread_; 216 DebugScopedSetImplThread impl_thread_;
180 DebugScopedSetMainThreadBlocked main_thread_blocked_; 217 DebugScopedSetMainThreadBlocked main_thread_blocked_;
181 218
182 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked); 219 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked);
183 }; 220 };
184 221
185 } // namespace cc 222 } // namespace cc
186 223
187 #endif // CC_TREES_SINGLE_THREAD_PROXY_H_ 224 #endif // CC_TREES_SINGLE_THREAD_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698