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

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

Issue 17125004: Revert 206020 "cc: Emulate BeginFrame in OutputSurfaces that don..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 6 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 | « trunk/src/cc/trees/single_thread_proxy.h ('k') | trunk/src/cc/trees/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_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 <string>
9
10 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
12 #include "base/time.h" 10 #include "base/time.h"
13 #include "cc/animation/animation_events.h" 11 #include "cc/animation/animation_events.h"
14 #include "cc/base/completion_event.h" 12 #include "cc/base/completion_event.h"
15 #include "cc/resources/resource_update_controller.h" 13 #include "cc/resources/resource_update_controller.h"
16 #include "cc/scheduler/scheduler.h" 14 #include "cc/scheduler/scheduler.h"
15 #include "cc/scheduler/vsync_time_source.h"
17 #include "cc/trees/layer_tree_host_impl.h" 16 #include "cc/trees/layer_tree_host_impl.h"
18 #include "cc/trees/proxy.h" 17 #include "cc/trees/proxy.h"
19 18
20 namespace cc { 19 namespace cc {
21 20
22 class ContextProvider; 21 class ContextProvider;
23 class InputHandlerClient; 22 class InputHandlerClient;
24 class LayerTreeHost; 23 class LayerTreeHost;
25 class ResourceUpdateQueue; 24 class ResourceUpdateQueue;
26 class Scheduler; 25 class Scheduler;
27 class ScopedThreadProxy; 26 class ScopedThreadProxy;
28 class Thread; 27 class Thread;
29 28
30 class ThreadProxy : public Proxy, 29 class ThreadProxy : public Proxy,
31 LayerTreeHostImplClient, 30 LayerTreeHostImplClient,
32 SchedulerClient, 31 SchedulerClient,
33 ResourceUpdateControllerClient { 32 ResourceUpdateControllerClient,
33 VSyncProvider {
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 void SetLayerTreeHostClientReady() OVERRIDE; 44 virtual void SetLayerTreeHostClientReady() OVERRIDE;
45 virtual void SetVisible(bool visible) OVERRIDE; 45 virtual void SetVisible(bool visible) OVERRIDE;
46 virtual void CreateAndInitializeOutputSurface() OVERRIDE; 46 virtual void CreateAndInitializeOutputSurface() OVERRIDE;
47 virtual const RendererCapabilities& GetRendererCapabilities() const OVERRIDE; 47 virtual const RendererCapabilities& GetRendererCapabilities() const OVERRIDE;
48 virtual void SetNeedsAnimate() OVERRIDE; 48 virtual void SetNeedsAnimate() OVERRIDE;
49 virtual void SetNeedsCommit() OVERRIDE; 49 virtual void SetNeedsCommit() OVERRIDE;
50 virtual void SetNeedsRedraw(gfx::Rect damage_rect) OVERRIDE; 50 virtual void SetNeedsRedraw(gfx::Rect damage_rect) OVERRIDE;
51 virtual void SetDeferCommits(bool defer_commits) OVERRIDE; 51 virtual void SetDeferCommits(bool defer_commits) OVERRIDE;
52 virtual bool CommitRequested() const OVERRIDE; 52 virtual bool CommitRequested() const OVERRIDE;
53 virtual void MainThreadHasStoppedFlinging() OVERRIDE; 53 virtual void MainThreadHasStoppedFlinging() OVERRIDE;
54 virtual void Start(scoped_ptr<OutputSurface> first_output_surface) OVERRIDE; 54 virtual void Start(scoped_ptr<OutputSurface> first_output_surface) OVERRIDE;
55 virtual void Stop() OVERRIDE; 55 virtual void Stop() OVERRIDE;
56 virtual size_t MaxPartialTextureUpdates() const OVERRIDE; 56 virtual size_t MaxPartialTextureUpdates() const OVERRIDE;
57 virtual void AcquireLayerTextures() OVERRIDE; 57 virtual void AcquireLayerTextures() OVERRIDE;
58 virtual void ForceSerializeOnSwapBuffers() OVERRIDE; 58 virtual void ForceSerializeOnSwapBuffers() OVERRIDE;
59 virtual skia::RefPtr<SkPicture> CapturePicture() OVERRIDE; 59 virtual skia::RefPtr<SkPicture> CapturePicture() OVERRIDE;
60 virtual scoped_ptr<base::Value> AsValue() const OVERRIDE; 60 virtual scoped_ptr<base::Value> AsValue() const OVERRIDE;
61 virtual bool CommitPendingForTesting() OVERRIDE; 61 virtual bool CommitPendingForTesting() OVERRIDE;
62 virtual std::string SchedulerStateAsStringForTesting() OVERRIDE;
63 62
64 // LayerTreeHostImplClient implementation 63 // LayerTreeHostImplClient implementation
65 virtual void DidTryInitializeRendererOnImplThread( 64 virtual void DidTryInitializeRendererOnImplThread(
66 bool success, 65 bool success,
67 scoped_refptr<ContextProvider> offscreen_context_provider) OVERRIDE; 66 scoped_refptr<ContextProvider> offscreen_context_provider) OVERRIDE;
68 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE; 67 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE;
69 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE; 68 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE;
70 virtual void BeginFrameOnImplThread(base::TimeTicks frame_time) OVERRIDE; 69 virtual void OnVSyncParametersChanged(base::TimeTicks timebase,
70 base::TimeDelta interval) OVERRIDE;
71 virtual void BeginFrameOnImplThread(base::TimeTicks frame_time)
72 OVERRIDE;
71 virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE; 73 virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE;
72 virtual void OnHasPendingTreeStateChanged(bool has_pending_tree) OVERRIDE; 74 virtual void OnHasPendingTreeStateChanged(bool has_pending_tree) OVERRIDE;
73 virtual void SetNeedsRedrawOnImplThread() OVERRIDE; 75 virtual void SetNeedsRedrawOnImplThread() OVERRIDE;
74 virtual void SetNeedsRedrawRectOnImplThread(gfx::Rect dirty_rect) OVERRIDE; 76 virtual void SetNeedsRedrawRectOnImplThread(gfx::Rect dirty_rect) OVERRIDE;
75 virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE; 77 virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE;
76 virtual void SetNeedsCommitOnImplThread() OVERRIDE; 78 virtual void SetNeedsCommitOnImplThread() OVERRIDE;
77 virtual void PostAnimationEventsToMainThreadOnImplThread( 79 virtual void PostAnimationEventsToMainThreadOnImplThread(
78 scoped_ptr<AnimationEventsVector> queue, 80 scoped_ptr<AnimationEventsVector> queue,
79 base::Time wall_clock_time) OVERRIDE; 81 base::Time wall_clock_time) OVERRIDE;
80 virtual bool ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes, 82 virtual bool ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes,
81 int priority_cutoff) 83 int priority_cutoff)
82 OVERRIDE; 84 OVERRIDE;
83 virtual void ReduceWastedContentsTextureMemoryOnImplThread() OVERRIDE; 85 virtual void ReduceWastedContentsTextureMemoryOnImplThread() OVERRIDE;
84 virtual void SendManagedMemoryStats() OVERRIDE; 86 virtual void SendManagedMemoryStats() OVERRIDE;
85 virtual bool IsInsideDraw() OVERRIDE; 87 virtual bool IsInsideDraw() OVERRIDE;
86 virtual void RenewTreePriority() OVERRIDE; 88 virtual void RenewTreePriority() OVERRIDE;
87 virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay) 89 virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay)
88 OVERRIDE; 90 OVERRIDE;
89 virtual void DidActivatePendingTree() OVERRIDE; 91 virtual void DidActivatePendingTree() OVERRIDE;
90 92
91 // SchedulerClient implementation 93 // SchedulerClient implementation
92 virtual void SetNeedsBeginFrameOnImplThread(bool enable) OVERRIDE;
93 virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE; 94 virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE;
94 virtual ScheduledActionDrawAndSwapResult 95 virtual ScheduledActionDrawAndSwapResult
95 ScheduledActionDrawAndSwapIfPossible() OVERRIDE; 96 ScheduledActionDrawAndSwapIfPossible() OVERRIDE;
96 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced() 97 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced()
97 OVERRIDE; 98 OVERRIDE;
98 virtual void ScheduledActionCommit() OVERRIDE; 99 virtual void ScheduledActionCommit() OVERRIDE;
99 virtual void ScheduledActionCheckForCompletedTileUploads() OVERRIDE; 100 virtual void ScheduledActionCheckForCompletedTileUploads() OVERRIDE;
100 virtual void ScheduledActionActivatePendingTreeIfNeeded() OVERRIDE; 101 virtual void ScheduledActionActivatePendingTreeIfNeeded() OVERRIDE;
101 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE; 102 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE;
102 virtual void ScheduledActionAcquireLayerTexturesForMainThread() OVERRIDE; 103 virtual void ScheduledActionAcquireLayerTexturesForMainThread() OVERRIDE;
103 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) OVERRIDE; 104 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) OVERRIDE;
104 105
105 // ResourceUpdateControllerClient implementation 106 // ResourceUpdateControllerClient implementation
106 virtual void ReadyToFinalizeTextureUpdates() OVERRIDE; 107 virtual void ReadyToFinalizeTextureUpdates() OVERRIDE;
107 108
109 // VSyncProvider implementation
110 virtual void RequestVSyncNotification(VSyncClient* client) OVERRIDE;
111
112 int MaxFramesPendingForTesting() const {
113 return scheduler_on_impl_thread_->MaxFramesPending();
114 }
115
116 int NumFramesPendingForTesting() const {
117 return scheduler_on_impl_thread_->NumFramesPendingForTesting();
118 }
119
108 private: 120 private:
109 ThreadProxy(LayerTreeHost* layer_tree_host, scoped_ptr<Thread> impl_thread); 121 ThreadProxy(LayerTreeHost* layer_tree_host, scoped_ptr<Thread> impl_thread);
110 122
111 struct BeginFrameAndCommitState { 123 struct BeginFrameAndCommitState {
112 BeginFrameAndCommitState(); 124 BeginFrameAndCommitState();
113 ~BeginFrameAndCommitState(); 125 ~BeginFrameAndCommitState();
114 126
115 base::TimeTicks monotonic_frame_begin_time; 127 base::TimeTicks monotonic_frame_begin_time;
116 scoped_ptr<ScrollAndScaleSet> scroll_info; 128 scoped_ptr<ScrollAndScaleSet> scroll_info;
117 size_t memory_allocation_limit_bytes; 129 size_t memory_allocation_limit_bytes;
118 }; 130 };
119 131
120 // Called on main thread. 132 // Called on main thread.
121 void BeginFrameOnMainThread( 133 void BeginFrameOnMainThread(
122 scoped_ptr<BeginFrameAndCommitState> begin_frame_state); 134 scoped_ptr<BeginFrameAndCommitState> begin_frame_state);
123 void DidCommitAndDrawFrame(); 135 void DidCommitAndDrawFrame();
124 void DidCompleteSwapBuffers(); 136 void DidCompleteSwapBuffers();
125 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue, 137 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue,
126 base::Time wall_clock_time); 138 base::Time wall_clock_time);
127 void DoCreateAndInitializeOutputSurface(); 139 void DoCreateAndInitializeOutputSurface();
128 // |capabilities| is set only when |success| is true. 140 // |capabilities| is set only when |success| is true.
129 void OnOutputSurfaceInitializeAttempted( 141 void OnOutputSurfaceInitializeAttempted(
130 bool success, 142 bool success,
131 const RendererCapabilities& capabilities); 143 const RendererCapabilities& capabilities);
132 144
133 // Called on impl thread. 145 // Called on impl thread.
134 struct ReadbackRequest; 146 struct ReadbackRequest {
135 struct CommitPendingRequest; 147 CompletionEvent completion;
136 struct SchedulerStateRequest; 148 bool success;
137 149 void* pixels;
150 gfx::Rect rect;
151 };
152 struct CommitPendingRequest {
153 CompletionEvent completion;
154 bool commit_pending;
155 };
138 void ForceCommitOnImplThread(CompletionEvent* completion); 156 void ForceCommitOnImplThread(CompletionEvent* completion);
139 void StartCommitOnImplThread( 157 void StartCommitOnImplThread(
140 CompletionEvent* completion, 158 CompletionEvent* completion,
141 ResourceUpdateQueue* queue, 159 ResourceUpdateQueue* queue,
142 scoped_refptr<cc::ContextProvider> offscreen_context_provider); 160 scoped_refptr<cc::ContextProvider> offscreen_context_provider);
143 void BeginFrameAbortedByMainThreadOnImplThread(); 161 void BeginFrameAbortedByMainThreadOnImplThread();
144 void RequestReadbackOnImplThread(ReadbackRequest* request); 162 void RequestReadbackOnImplThread(ReadbackRequest* request);
145 void FinishAllRenderingOnImplThread(CompletionEvent* completion); 163 void FinishAllRenderingOnImplThread(CompletionEvent* completion);
146 void InitializeImplOnImplThread(CompletionEvent* completion); 164 void InitializeImplOnImplThread(CompletionEvent* completion);
147 void SetLayerTreeHostClientReadyOnImplThread(); 165 void SetLayerTreeHostClientReadyOnImplThread();
148 void SetVisibleOnImplThread(CompletionEvent* completion, bool visible); 166 void SetVisibleOnImplThread(CompletionEvent* completion, bool visible);
149 void HasInitializedOutputSurfaceOnImplThread( 167 void HasInitializedOutputSurfaceOnImplThread(
150 CompletionEvent* completion, 168 CompletionEvent* completion,
151 bool* has_initialized_output_surface); 169 bool* has_initialized_output_surface);
152 void InitializeOutputSurfaceOnImplThread( 170 void InitializeOutputSurfaceOnImplThread(
153 CompletionEvent* completion, 171 CompletionEvent* completion,
154 scoped_ptr<OutputSurface> output_surface, 172 scoped_ptr<OutputSurface> output_surface,
155 scoped_refptr<ContextProvider> offscreen_context_provider, 173 scoped_refptr<ContextProvider> offscreen_context_provider,
156 bool* success, 174 bool* success,
157 RendererCapabilities* capabilities); 175 RendererCapabilities* capabilities);
158 void FinishGLOnImplThread(CompletionEvent* completion); 176 void FinishGLOnImplThread(CompletionEvent* completion);
159 void LayerTreeHostClosedOnImplThread(CompletionEvent* completion); 177 void LayerTreeHostClosedOnImplThread(CompletionEvent* completion);
160 void AcquireLayerTexturesForMainThreadOnImplThread( 178 void AcquireLayerTexturesForMainThreadOnImplThread(
161 CompletionEvent* completion); 179 CompletionEvent* completion);
162 ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapInternal( 180 ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapInternal(
163 bool forced_draw); 181 bool forced_draw);
164 void ForceSerializeOnSwapBuffersOnImplThread(CompletionEvent* completion); 182 void ForceSerializeOnSwapBuffersOnImplThread(CompletionEvent* completion);
165 void CheckOutputSurfaceStatusOnImplThread(); 183 void CheckOutputSurfaceStatusOnImplThread();
166 void CommitPendingOnImplThreadForTesting(CommitPendingRequest* request); 184 void CommitPendingOnImplThreadForTesting(CommitPendingRequest* request);
167 void SchedulerStateAsStringOnImplThreadForTesting(
168 SchedulerStateRequest* request);
169 void CapturePictureOnImplThread(CompletionEvent* completion, 185 void CapturePictureOnImplThread(CompletionEvent* completion,
170 skia::RefPtr<SkPicture>* picture); 186 skia::RefPtr<SkPicture>* picture);
171 void AsValueOnImplThread(CompletionEvent* completion, 187 void AsValueOnImplThread(CompletionEvent* completion,
172 base::DictionaryValue* state) const; 188 base::DictionaryValue* state) const;
173 void RenewTreePriorityOnImplThread(); 189 void RenewTreePriorityOnImplThread();
174 void DidSwapUseIncompleteTileOnImplThread(); 190 void DidSwapUseIncompleteTileOnImplThread();
175 void StartScrollbarAnimationOnImplThread(); 191 void StartScrollbarAnimationOnImplThread();
176 void MainThreadHasStoppedFlingingOnImplThread(); 192 void MainThreadHasStoppedFlingingOnImplThread();
177 193
178 // Accessed on main thread only. 194 // Accessed on main thread only.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 scoped_ptr<ResourceUpdateController> 243 scoped_ptr<ResourceUpdateController>
228 current_resource_update_controller_on_impl_thread_; 244 current_resource_update_controller_on_impl_thread_;
229 245
230 // Set when the next draw should post DidCommitAndDrawFrame to the main 246 // Set when the next draw should post DidCommitAndDrawFrame to the main
231 // thread. 247 // thread.
232 bool next_frame_is_newly_committed_frame_on_impl_thread_; 248 bool next_frame_is_newly_committed_frame_on_impl_thread_;
233 249
234 bool throttle_frame_production_; 250 bool throttle_frame_production_;
235 bool begin_frame_scheduling_enabled_; 251 bool begin_frame_scheduling_enabled_;
236 bool using_synchronous_renderer_compositor_; 252 bool using_synchronous_renderer_compositor_;
253 VSyncClient* vsync_client_;
237 254
238 bool inside_draw_; 255 bool inside_draw_;
239 256
240 bool defer_commits_; 257 bool defer_commits_;
241 scoped_ptr<BeginFrameAndCommitState> pending_deferred_commit_; 258 scoped_ptr<BeginFrameAndCommitState> pending_deferred_commit_;
242 259
243 base::TimeTicks smoothness_takes_priority_expiration_time_; 260 base::TimeTicks smoothness_takes_priority_expiration_time_;
244 bool renew_tree_priority_on_impl_thread_pending_; 261 bool renew_tree_priority_on_impl_thread_pending_;
245 262
246 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); 263 DISALLOW_COPY_AND_ASSIGN(ThreadProxy);
247 }; 264 };
248 265
249 } // namespace cc 266 } // namespace cc
250 267
251 #endif // CC_TREES_THREAD_PROXY_H_ 268 #endif // CC_TREES_THREAD_PROXY_H_
OLDNEW
« no previous file with comments | « trunk/src/cc/trees/single_thread_proxy.h ('k') | trunk/src/cc/trees/thread_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698