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: cc/trees/thread_proxy.h

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

Powered by Google App Engine
This is Rietveld 408576698