Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

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

Issue 12544032: Initialize cc::Renderer in vsync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address moar comments Created 7 years, 8 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_THREAD_PROXY_H_ 5 #ifndef CC_TREES_THREAD_PROXY_H_
6 #define CC_TREES_THREAD_PROXY_H_ 6 #define CC_TREES_THREAD_PROXY_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 23 matching lines...) Expand all
34 public: 34 public:
35 static scoped_ptr<Proxy> Create(LayerTreeHost* layer_tree_host, 35 static scoped_ptr<Proxy> Create(LayerTreeHost* layer_tree_host,
36 scoped_ptr<Thread> impl_thread); 36 scoped_ptr<Thread> impl_thread);
37 37
38 virtual ~ThreadProxy(); 38 virtual ~ThreadProxy();
39 39
40 // Proxy implementation 40 // Proxy implementation
41 virtual bool CompositeAndReadback(void* pixels, gfx::Rect rect) OVERRIDE; 41 virtual bool CompositeAndReadback(void* pixels, gfx::Rect rect) OVERRIDE;
42 virtual void FinishAllRendering() OVERRIDE; 42 virtual void FinishAllRendering() OVERRIDE;
43 virtual bool IsStarted() const OVERRIDE; 43 virtual bool IsStarted() const OVERRIDE;
44 virtual bool InitializeOutputSurface() OVERRIDE;
45 virtual void SetSurfaceReady() OVERRIDE; 44 virtual void SetSurfaceReady() OVERRIDE;
46 virtual void SetVisible(bool visible) OVERRIDE; 45 virtual void SetVisible(bool visible) OVERRIDE;
47 virtual bool InitializeRenderer() OVERRIDE; 46 virtual void CreateAndInitializeOutputSurface() OVERRIDE;
48 virtual bool RecreateOutputSurface() OVERRIDE;
49 virtual const RendererCapabilities& GetRendererCapabilities() const OVERRIDE; 47 virtual const RendererCapabilities& GetRendererCapabilities() const OVERRIDE;
50 virtual void SetNeedsAnimate() OVERRIDE; 48 virtual void SetNeedsAnimate() OVERRIDE;
51 virtual void SetNeedsCommit() OVERRIDE; 49 virtual void SetNeedsCommit() OVERRIDE;
52 virtual void SetNeedsRedraw(gfx::Rect damage_rect) OVERRIDE; 50 virtual void SetNeedsRedraw(gfx::Rect damage_rect) OVERRIDE;
53 virtual void SetDeferCommits(bool defer_commits) OVERRIDE; 51 virtual void SetDeferCommits(bool defer_commits) OVERRIDE;
54 virtual bool CommitRequested() const OVERRIDE; 52 virtual bool CommitRequested() const OVERRIDE;
55 virtual void MainThreadHasStoppedFlinging() OVERRIDE; 53 virtual void MainThreadHasStoppedFlinging() OVERRIDE;
56 virtual void Start() OVERRIDE; 54 virtual void Start() OVERRIDE;
57 virtual void Stop() OVERRIDE; 55 virtual void Stop() OVERRIDE;
58 virtual size_t MaxPartialTextureUpdates() const OVERRIDE; 56 virtual size_t MaxPartialTextureUpdates() const OVERRIDE;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 89
92 // SchedulerClient implementation 90 // SchedulerClient implementation
93 virtual void ScheduledActionBeginFrame() OVERRIDE; 91 virtual void ScheduledActionBeginFrame() OVERRIDE;
94 virtual ScheduledActionDrawAndSwapResult 92 virtual ScheduledActionDrawAndSwapResult
95 ScheduledActionDrawAndSwapIfPossible() OVERRIDE; 93 ScheduledActionDrawAndSwapIfPossible() OVERRIDE;
96 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced() 94 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced()
97 OVERRIDE; 95 OVERRIDE;
98 virtual void ScheduledActionCommit() OVERRIDE; 96 virtual void ScheduledActionCommit() OVERRIDE;
99 virtual void ScheduledActionCheckForCompletedTileUploads() OVERRIDE; 97 virtual void ScheduledActionCheckForCompletedTileUploads() OVERRIDE;
100 virtual void ScheduledActionActivatePendingTreeIfNeeded() OVERRIDE; 98 virtual void ScheduledActionActivatePendingTreeIfNeeded() OVERRIDE;
101 virtual void ScheduledActionBeginContextRecreation() OVERRIDE; 99 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE;
102 virtual void ScheduledActionAcquireLayerTexturesForMainThread() OVERRIDE; 100 virtual void ScheduledActionAcquireLayerTexturesForMainThread() OVERRIDE;
103 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) OVERRIDE; 101 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) OVERRIDE;
104 102
105 // ResourceUpdateControllerClient implementation 103 // ResourceUpdateControllerClient implementation
106 virtual void ReadyToFinalizeTextureUpdates() OVERRIDE; 104 virtual void ReadyToFinalizeTextureUpdates() OVERRIDE;
107 105
108 // VSyncProvider implementation 106 // VSyncProvider implementation
109 virtual void RequestVSyncNotification(VSyncClient* client) OVERRIDE; 107 virtual void RequestVSyncNotification(VSyncClient* client) OVERRIDE;
110 108
111 int MaxFramesPendingForTesting() const { 109 int MaxFramesPendingForTesting() const {
(...skipping 12 matching lines...) Expand all
124 gfx::Transform impl_transform; 122 gfx::Transform impl_transform;
125 size_t memory_allocation_limit_bytes; 123 size_t memory_allocation_limit_bytes;
126 }; 124 };
127 125
128 // Called on main thread. 126 // Called on main thread.
129 void BeginFrame(scoped_ptr<BeginFrameAndCommitState> begin_frame_state); 127 void BeginFrame(scoped_ptr<BeginFrameAndCommitState> begin_frame_state);
130 void DidCommitAndDrawFrame(); 128 void DidCommitAndDrawFrame();
131 void DidCompleteSwapBuffers(); 129 void DidCompleteSwapBuffers();
132 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue, 130 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue,
133 base::Time wall_clock_time); 131 base::Time wall_clock_time);
134 void BeginContextRecreation(); 132 void DoCreateAndInitializeOutputSurface();
135 void TryToRecreateOutputSurface(); 133 // |capabilities| is set only when |success| is true.
134 void OnOutputSurfaceInitializeAttempted(
135 bool success,
136 const RendererCapabilities& capabilities);
136 137
137 // Called on impl thread. 138 // Called on impl thread.
138 struct ReadbackRequest { 139 struct ReadbackRequest {
139 CompletionEvent completion; 140 CompletionEvent completion;
140 bool success; 141 bool success;
141 void* pixels; 142 void* pixels;
142 gfx::Rect rect; 143 gfx::Rect rect;
143 }; 144 };
144 struct CommitPendingRequest { 145 struct CommitPendingRequest {
145 CompletionEvent completion; 146 CompletionEvent completion;
146 bool commit_pending; 147 bool commit_pending;
147 }; 148 };
148 void ForceBeginFrameOnImplThread(CompletionEvent* completion); 149 void ForceBeginFrameOnImplThread(CompletionEvent* completion);
149 void BeginFrameCompleteOnImplThread( 150 void BeginFrameCompleteOnImplThread(
150 CompletionEvent* completion, 151 CompletionEvent* completion,
151 ResourceUpdateQueue* queue, 152 ResourceUpdateQueue* queue,
152 scoped_refptr<cc::ContextProvider> offscreen_context_provider); 153 scoped_refptr<cc::ContextProvider> offscreen_context_provider);
153 void BeginFrameAbortedOnImplThread(); 154 void BeginFrameAbortedOnImplThread();
154 void RequestReadbackOnImplThread(ReadbackRequest* request); 155 void RequestReadbackOnImplThread(ReadbackRequest* request);
155 void FinishAllRenderingOnImplThread(CompletionEvent* completion); 156 void FinishAllRenderingOnImplThread(CompletionEvent* completion);
156 void InitializeImplOnImplThread(CompletionEvent* completion, 157 void InitializeImplOnImplThread(CompletionEvent* completion,
157 InputHandler* input_handler); 158 InputHandler* input_handler);
158 void SetSurfaceReadyOnImplThread(); 159 void SetSurfaceReadyOnImplThread();
159 void SetVisibleOnImplThread(CompletionEvent* completion, bool visible); 160 void SetVisibleOnImplThread(CompletionEvent* completion, bool visible);
160 void InitializeOutputSurfaceOnImplThread( 161 void InitializeOutputSurfaceOnImplThread(
161 scoped_ptr<OutputSurface> output_surface); 162 CompletionEvent* completion,
162 void InitializeRendererOnImplThread(CompletionEvent* completion, 163 scoped_ptr<OutputSurface> output_surface,
163 bool* initialize_succeeded, 164 scoped_refptr<ContextProvider> offscreen_context_provider,
164 RendererCapabilities* capabilities); 165 bool* success,
166 RendererCapabilities* capabilities);
165 void LayerTreeHostClosedOnImplThread(CompletionEvent* completion); 167 void LayerTreeHostClosedOnImplThread(CompletionEvent* completion);
166 void ManageTilesOnImplThread(); 168 void ManageTilesOnImplThread();
167 void SetViewportDamageOnImplThread(gfx::Rect damage_rect); 169 void SetViewportDamageOnImplThread(gfx::Rect damage_rect);
168 void AcquireLayerTexturesForMainThreadOnImplThread( 170 void AcquireLayerTexturesForMainThreadOnImplThread(
169 CompletionEvent* completion); 171 CompletionEvent* completion);
170 void RecreateOutputSurfaceOnImplThread(
171 CompletionEvent* completion,
172 scoped_ptr<OutputSurface> output_surface,
173 scoped_refptr<cc::ContextProvider> offscreen_context_provider,
174 bool* recreate_succeeded,
175 RendererCapabilities* capabilities);
176 ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapInternal( 172 ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapInternal(
177 bool forced_draw); 173 bool forced_draw);
178 void ForceSerializeOnSwapBuffersOnImplThread(CompletionEvent* completion); 174 void ForceSerializeOnSwapBuffersOnImplThread(CompletionEvent* completion);
179 void SetNeedsForcedCommitOnImplThread(); 175 void SetNeedsForcedCommitOnImplThread();
180 void CheckOutputSurfaceStatusOnImplThread(); 176 void CheckOutputSurfaceStatusOnImplThread();
181 void CommitPendingOnImplThreadForTesting(CommitPendingRequest* request); 177 void CommitPendingOnImplThreadForTesting(CommitPendingRequest* request);
182 void CapturePictureOnImplThread(CompletionEvent* completion, 178 void CapturePictureOnImplThread(CompletionEvent* completion,
183 skia::RefPtr<SkPicture>* picture); 179 skia::RefPtr<SkPicture>* picture);
184 void AsValueOnImplThread(CompletionEvent* completion, 180 void AsValueOnImplThread(CompletionEvent* completion,
185 base::DictionaryValue* state) const; 181 base::DictionaryValue* state) const;
186 void RenewTreePriorityOnImplThread(); 182 void RenewTreePriorityOnImplThread();
187 void DidSwapUseIncompleteTileOnImplThread(); 183 void DidSwapUseIncompleteTileOnImplThread();
188 void StartScrollbarAnimationOnImplThread(); 184 void StartScrollbarAnimationOnImplThread();
189 185
190 // Accessed on main thread only. 186 // Accessed on main thread only.
191 187
192 // Set only when SetNeedsAnimate is called. 188 // Set only when SetNeedsAnimate is called.
193 bool animate_requested_; 189 bool animate_requested_;
194 // Set only when SetNeedsCommit is called. 190 // Set only when SetNeedsCommit is called.
195 bool commit_requested_; 191 bool commit_requested_;
196 // Set by SetNeedsCommit and SetNeedsAnimate. 192 // Set by SetNeedsCommit and SetNeedsAnimate.
197 bool commit_request_sent_to_impl_thread_; 193 bool commit_request_sent_to_impl_thread_;
198 // Set by BeginFrame 194 // Set by BeginFrame
199 bool created_offscreen_context_provider_; 195 bool created_offscreen_context_provider_;
200 base::CancelableClosure output_surface_recreation_callback_; 196 base::CancelableClosure output_surface_creation_callback_;
201 LayerTreeHost* layer_tree_host_; 197 LayerTreeHost* layer_tree_host_;
202 bool renderer_initialized_;
203 RendererCapabilities renderer_capabilities_main_thread_copy_; 198 RendererCapabilities renderer_capabilities_main_thread_copy_;
204 bool started_; 199 bool started_;
205 bool textures_acquired_; 200 bool textures_acquired_;
206 bool in_composite_and_readback_; 201 bool in_composite_and_readback_;
207 bool manage_tiles_pending_; 202 bool manage_tiles_pending_;
203
danakj 2013/04/24 15:38:42 nit: extraneous whitespace
208 // Weak pointer to use when posting tasks to the impl thread. 204 // Weak pointer to use when posting tasks to the impl thread.
209 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; 205 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_;
210 206
211 base::WeakPtrFactory<ThreadProxy> weak_factory_on_impl_thread_; 207 base::WeakPtrFactory<ThreadProxy> weak_factory_on_impl_thread_;
212 208
213 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; 209 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_;
214 base::WeakPtrFactory<ThreadProxy> weak_factory_; 210 base::WeakPtrFactory<ThreadProxy> weak_factory_;
215 211
216 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl_; 212 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl_;
217 213
218 scoped_ptr<InputHandler> input_handler_on_impl_thread_; 214 scoped_ptr<InputHandler> input_handler_on_impl_thread_;
219 215
220 scoped_ptr<Scheduler> scheduler_on_impl_thread_; 216 scoped_ptr<Scheduler> scheduler_on_impl_thread_;
221 217
222 // Holds on to the context we might use for compositing in between
223 // InitializeContext() and InitializeRenderer() calls.
224 scoped_ptr<OutputSurface>
225 output_surface_before_initialization_on_impl_thread_;
226
227 // Set when the main thread is waiting on a ScheduledActionBeginFrame to be 218 // Set when the main thread is waiting on a ScheduledActionBeginFrame to be
228 // issued. 219 // issued.
229 CompletionEvent* begin_frame_completion_event_on_impl_thread_; 220 CompletionEvent* begin_frame_completion_event_on_impl_thread_;
230 221
231 // Set when the main thread is waiting on a readback. 222 // Set when the main thread is waiting on a readback.
232 ReadbackRequest* readback_request_on_impl_thread_; 223 ReadbackRequest* readback_request_on_impl_thread_;
233 224
234 // Set when the main thread is waiting on a commit to complete. 225 // Set when the main thread is waiting on a commit to complete.
235 CompletionEvent* commit_completion_event_on_impl_thread_; 226 CompletionEvent* commit_completion_event_on_impl_thread_;
236 227
(...skipping 21 matching lines...) Expand all
258 249
259 base::TimeTicks smoothness_takes_priority_expiration_time_; 250 base::TimeTicks smoothness_takes_priority_expiration_time_;
260 bool renew_tree_priority_on_impl_thread_pending_; 251 bool renew_tree_priority_on_impl_thread_pending_;
261 252
262 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); 253 DISALLOW_COPY_AND_ASSIGN(ThreadProxy);
263 }; 254 };
264 255
265 } // namespace cc 256 } // namespace cc
266 257
267 #endif // CC_TREES_THREAD_PROXY_H_ 258 #endif // CC_TREES_THREAD_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698