| OLD | NEW |
| 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" |
| 11 #include "cc/animation/animation_events.h" | 11 #include "cc/animation/animation_events.h" |
| 12 #include "cc/base/completion_event.h" | 12 #include "cc/base/completion_event.h" |
| 13 #include "cc/resources/resource_update_controller.h" | 13 #include "cc/resources/resource_update_controller.h" |
| 14 #include "cc/scheduler/scheduler.h" | 14 #include "cc/scheduler/scheduler.h" |
| 15 #include "cc/scheduler/vsync_time_source.h" | |
| 16 #include "cc/trees/layer_tree_host_impl.h" | 15 #include "cc/trees/layer_tree_host_impl.h" |
| 17 #include "cc/trees/proxy.h" | 16 #include "cc/trees/proxy.h" |
| 18 | 17 |
| 19 namespace cc { | 18 namespace cc { |
| 20 | 19 |
| 21 class ContextProvider; | 20 class ContextProvider; |
| 22 class InputHandlerClient; | 21 class InputHandlerClient; |
| 23 class LayerTreeHost; | 22 class LayerTreeHost; |
| 24 class ResourceUpdateQueue; | 23 class ResourceUpdateQueue; |
| 25 class Scheduler; | 24 class Scheduler; |
| 26 class ScopedThreadProxy; | 25 class ScopedThreadProxy; |
| 27 class Thread; | 26 class Thread; |
| 28 | 27 |
| 29 class ThreadProxy : public Proxy, | 28 class ThreadProxy : public Proxy, |
| 30 LayerTreeHostImplClient, | 29 LayerTreeHostImplClient, |
| 31 SchedulerClient, | 30 SchedulerClient, |
| 32 ResourceUpdateControllerClient, | 31 ResourceUpdateControllerClient { |
| 33 VSyncProvider { | |
| 34 public: | 32 public: |
| 35 static scoped_ptr<Proxy> Create(LayerTreeHost* layer_tree_host, | 33 static scoped_ptr<Proxy> Create(LayerTreeHost* layer_tree_host, |
| 36 scoped_ptr<Thread> impl_thread); | 34 scoped_ptr<Thread> impl_thread); |
| 37 | 35 |
| 38 virtual ~ThreadProxy(); | 36 virtual ~ThreadProxy(); |
| 39 | 37 |
| 40 // Proxy implementation | 38 // Proxy implementation |
| 41 virtual bool CompositeAndReadback(void* pixels, gfx::Rect rect) OVERRIDE; | 39 virtual bool CompositeAndReadback(void* pixels, gfx::Rect rect) OVERRIDE; |
| 42 virtual void FinishAllRendering() OVERRIDE; | 40 virtual void FinishAllRendering() OVERRIDE; |
| 43 virtual bool IsStarted() const OVERRIDE; | 41 virtual bool IsStarted() const OVERRIDE; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 56 virtual size_t MaxPartialTextureUpdates() const OVERRIDE; | 54 virtual size_t MaxPartialTextureUpdates() const OVERRIDE; |
| 57 virtual void AcquireLayerTextures() OVERRIDE; | 55 virtual void AcquireLayerTextures() OVERRIDE; |
| 58 virtual void ForceSerializeOnSwapBuffers() OVERRIDE; | 56 virtual void ForceSerializeOnSwapBuffers() OVERRIDE; |
| 59 virtual skia::RefPtr<SkPicture> CapturePicture() OVERRIDE; | 57 virtual skia::RefPtr<SkPicture> CapturePicture() OVERRIDE; |
| 60 virtual scoped_ptr<base::Value> AsValue() const OVERRIDE; | 58 virtual scoped_ptr<base::Value> AsValue() const OVERRIDE; |
| 61 virtual bool CommitPendingForTesting() OVERRIDE; | 59 virtual bool CommitPendingForTesting() OVERRIDE; |
| 62 | 60 |
| 63 // LayerTreeHostImplClient implementation | 61 // LayerTreeHostImplClient implementation |
| 64 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE; | 62 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE; |
| 65 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE; | 63 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE; |
| 66 virtual void OnVSyncParametersChanged(base::TimeTicks timebase, | 64 virtual void BeginFrameOnImplThread(base::TimeTicks frame_time) OVERRIDE; |
| 67 base::TimeDelta interval) OVERRIDE; | |
| 68 virtual void BeginFrameOnImplThread(base::TimeTicks frame_time) | |
| 69 OVERRIDE; | |
| 70 virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE; | 65 virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE; |
| 71 virtual void OnHasPendingTreeStateChanged(bool has_pending_tree) OVERRIDE; | 66 virtual void OnHasPendingTreeStateChanged(bool has_pending_tree) OVERRIDE; |
| 72 virtual void SetNeedsRedrawOnImplThread() OVERRIDE; | 67 virtual void SetNeedsRedrawOnImplThread() OVERRIDE; |
| 73 virtual void SetNeedsRedrawRectOnImplThread(gfx::Rect dirty_rect) OVERRIDE; | 68 virtual void SetNeedsRedrawRectOnImplThread(gfx::Rect dirty_rect) OVERRIDE; |
| 74 virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE; | 69 virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE; |
| 75 virtual void SetNeedsCommitOnImplThread() OVERRIDE; | 70 virtual void SetNeedsCommitOnImplThread() OVERRIDE; |
| 76 virtual void SetNeedsManageTilesOnImplThread() OVERRIDE; | 71 virtual void SetNeedsManageTilesOnImplThread() OVERRIDE; |
| 77 virtual void PostAnimationEventsToMainThreadOnImplThread( | 72 virtual void PostAnimationEventsToMainThreadOnImplThread( |
| 78 scoped_ptr<AnimationEventsVector> queue, | 73 scoped_ptr<AnimationEventsVector> queue, |
| 79 base::Time wall_clock_time) OVERRIDE; | 74 base::Time wall_clock_time) OVERRIDE; |
| 80 virtual bool ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes, | 75 virtual bool ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes, |
| 81 int priority_cutoff) | 76 int priority_cutoff) |
| 82 OVERRIDE; | 77 OVERRIDE; |
| 83 virtual void ReduceWastedContentsTextureMemoryOnImplThread() OVERRIDE; | 78 virtual void ReduceWastedContentsTextureMemoryOnImplThread() OVERRIDE; |
| 84 virtual void SendManagedMemoryStats() OVERRIDE; | 79 virtual void SendManagedMemoryStats() OVERRIDE; |
| 85 virtual bool IsInsideDraw() OVERRIDE; | 80 virtual bool IsInsideDraw() OVERRIDE; |
| 86 virtual void RenewTreePriority() OVERRIDE; | 81 virtual void RenewTreePriority() OVERRIDE; |
| 87 virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay) | 82 virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay) |
| 88 OVERRIDE; | 83 OVERRIDE; |
| 89 virtual void DidReceiveLastInputEventForBeginFrameOnImplThread( | 84 virtual void DidReceiveLastInputEventForBeginFrameOnImplThread( |
| 90 base::TimeTicks frame_time) OVERRIDE; | 85 base::TimeTicks frame_time) OVERRIDE; |
| 91 virtual void DidActivatePendingTree() OVERRIDE; | 86 virtual void DidActivatePendingTree() OVERRIDE; |
| 92 | 87 |
| 93 // SchedulerClient implementation | 88 // SchedulerClient implementation |
| 89 virtual void SetNeedsBeginFrameOnImplThread(bool enable) OVERRIDE; |
| 94 virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE; | 90 virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE; |
| 95 virtual ScheduledActionDrawAndSwapResult | 91 virtual ScheduledActionDrawAndSwapResult |
| 96 ScheduledActionDrawAndSwapIfPossible() OVERRIDE; | 92 ScheduledActionDrawAndSwapIfPossible() OVERRIDE; |
| 97 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced() | 93 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced() |
| 98 OVERRIDE; | 94 OVERRIDE; |
| 99 virtual void ScheduledActionCommit() OVERRIDE; | 95 virtual void ScheduledActionCommit() OVERRIDE; |
| 100 virtual void ScheduledActionCheckForCompletedTileUploads() OVERRIDE; | 96 virtual void ScheduledActionCheckForCompletedTileUploads() OVERRIDE; |
| 101 virtual void ScheduledActionActivatePendingTreeIfNeeded() OVERRIDE; | 97 virtual void ScheduledActionActivatePendingTreeIfNeeded() OVERRIDE; |
| 102 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE; | 98 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE; |
| 103 virtual void ScheduledActionAcquireLayerTexturesForMainThread() OVERRIDE; | 99 virtual void ScheduledActionAcquireLayerTexturesForMainThread() OVERRIDE; |
| 104 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) OVERRIDE; | 100 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) OVERRIDE; |
| 105 | 101 |
| 106 // ResourceUpdateControllerClient implementation | 102 // ResourceUpdateControllerClient implementation |
| 107 virtual void ReadyToFinalizeTextureUpdates() OVERRIDE; | 103 virtual void ReadyToFinalizeTextureUpdates() OVERRIDE; |
| 108 | 104 |
| 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: | 105 private: |
| 121 ThreadProxy(LayerTreeHost* layer_tree_host, scoped_ptr<Thread> impl_thread); | 106 ThreadProxy(LayerTreeHost* layer_tree_host, scoped_ptr<Thread> impl_thread); |
| 122 | 107 |
| 123 struct BeginFrameAndCommitState { | 108 struct BeginFrameAndCommitState { |
| 124 BeginFrameAndCommitState(); | 109 BeginFrameAndCommitState(); |
| 125 ~BeginFrameAndCommitState(); | 110 ~BeginFrameAndCommitState(); |
| 126 | 111 |
| 127 base::TimeTicks monotonic_frame_begin_time; | 112 base::TimeTicks monotonic_frame_begin_time; |
| 128 scoped_ptr<ScrollAndScaleSet> scroll_info; | 113 scoped_ptr<ScrollAndScaleSet> scroll_info; |
| 129 size_t memory_allocation_limit_bytes; | 114 size_t memory_allocation_limit_bytes; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 scoped_ptr<ResourceUpdateController> | 229 scoped_ptr<ResourceUpdateController> |
| 245 current_resource_update_controller_on_impl_thread_; | 230 current_resource_update_controller_on_impl_thread_; |
| 246 | 231 |
| 247 // Set when the next draw should post DidCommitAndDrawFrame to the main | 232 // Set when the next draw should post DidCommitAndDrawFrame to the main |
| 248 // thread. | 233 // thread. |
| 249 bool next_frame_is_newly_committed_frame_on_impl_thread_; | 234 bool next_frame_is_newly_committed_frame_on_impl_thread_; |
| 250 | 235 |
| 251 bool throttle_frame_production_; | 236 bool throttle_frame_production_; |
| 252 bool begin_frame_scheduling_enabled_; | 237 bool begin_frame_scheduling_enabled_; |
| 253 bool using_synchronous_renderer_compositor_; | 238 bool using_synchronous_renderer_compositor_; |
| 254 VSyncClient* vsync_client_; | |
| 255 | 239 |
| 256 bool inside_draw_; | 240 bool inside_draw_; |
| 257 | 241 |
| 258 bool defer_commits_; | 242 bool defer_commits_; |
| 259 scoped_ptr<BeginFrameAndCommitState> pending_deferred_commit_; | 243 scoped_ptr<BeginFrameAndCommitState> pending_deferred_commit_; |
| 260 | 244 |
| 261 base::TimeTicks smoothness_takes_priority_expiration_time_; | 245 base::TimeTicks smoothness_takes_priority_expiration_time_; |
| 262 bool renew_tree_priority_on_impl_thread_pending_; | 246 bool renew_tree_priority_on_impl_thread_pending_; |
| 263 | 247 |
| 264 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); | 248 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); |
| 265 }; | 249 }; |
| 266 | 250 |
| 267 } // namespace cc | 251 } // namespace cc |
| 268 | 252 |
| 269 #endif // CC_TREES_THREAD_PROXY_H_ | 253 #endif // CC_TREES_THREAD_PROXY_H_ |
| OLD | NEW |