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

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: Fix typo 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,
(...skipping 10 matching lines...) Expand all
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::CancelableClosure output_surface_creation_callback_;
150
117 bool next_frame_is_newly_committed_frame_; 151 bool next_frame_is_newly_committed_frame_;
118 152
119 bool inside_draw_; 153 bool inside_draw_;
154 bool defer_commits_;
155 bool finish_commit_deferred_;
120 156
121 DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy); 157 DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy);
122 }; 158 };
123 159
124 // For use in the single-threaded case. In debug builds, it pretends that the 160 // 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. 161 // code is running on the impl thread to satisfy assertion checks.
126 class DebugScopedSetImplThread { 162 class DebugScopedSetImplThread {
127 public: 163 public:
128 explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) { 164 explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) {
129 #ifndef NDEBUG 165 #ifndef NDEBUG
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 private: 214 private:
179 DebugScopedSetImplThread impl_thread_; 215 DebugScopedSetImplThread impl_thread_;
180 DebugScopedSetMainThreadBlocked main_thread_blocked_; 216 DebugScopedSetMainThreadBlocked main_thread_blocked_;
181 217
182 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked); 218 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked);
183 }; 219 };
184 220
185 } // namespace cc 221 } // namespace cc
186 222
187 #endif // CC_TREES_SINGLE_THREAD_PROXY_H_ 223 #endif // CC_TREES_SINGLE_THREAD_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698