| 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 DidActivatePendingTree() OVERRIDE; | 84 virtual void DidActivatePendingTree() OVERRIDE; |
| 90 | 85 |
| 91 // SchedulerClient implementation | 86 // SchedulerClient implementation |
| 87 virtual void SetNeedsBeginFrameOnImplThread(bool enable) OVERRIDE; |
| 92 virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE; | 88 virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE; |
| 93 virtual ScheduledActionDrawAndSwapResult | 89 virtual ScheduledActionDrawAndSwapResult |
| 94 ScheduledActionDrawAndSwapIfPossible() OVERRIDE; | 90 ScheduledActionDrawAndSwapIfPossible() OVERRIDE; |
| 95 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced() | 91 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced() |
| 96 OVERRIDE; | 92 OVERRIDE; |
| 97 virtual void ScheduledActionCommit() OVERRIDE; | 93 virtual void ScheduledActionCommit() OVERRIDE; |
| 98 virtual void ScheduledActionCheckForCompletedTileUploads() OVERRIDE; | 94 virtual void ScheduledActionCheckForCompletedTileUploads() OVERRIDE; |
| 99 virtual void ScheduledActionActivatePendingTreeIfNeeded() OVERRIDE; | 95 virtual void ScheduledActionActivatePendingTreeIfNeeded() OVERRIDE; |
| 100 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE; | 96 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE; |
| 101 virtual void ScheduledActionAcquireLayerTexturesForMainThread() OVERRIDE; | 97 virtual void ScheduledActionAcquireLayerTexturesForMainThread() OVERRIDE; |
| 102 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) OVERRIDE; | 98 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) OVERRIDE; |
| 103 | 99 |
| 104 // ResourceUpdateControllerClient implementation | 100 // ResourceUpdateControllerClient implementation |
| 105 virtual void ReadyToFinalizeTextureUpdates() OVERRIDE; | 101 virtual void ReadyToFinalizeTextureUpdates() OVERRIDE; |
| 106 | 102 |
| 107 // VSyncProvider implementation | |
| 108 virtual void RequestVSyncNotification(VSyncClient* client) OVERRIDE; | |
| 109 | |
| 110 int MaxFramesPendingForTesting() const { | |
| 111 return scheduler_on_impl_thread_->MaxFramesPending(); | |
| 112 } | |
| 113 | |
| 114 int NumFramesPendingForTesting() const { | |
| 115 return scheduler_on_impl_thread_->NumFramesPendingForTesting(); | |
| 116 } | |
| 117 | |
| 118 private: | 103 private: |
| 119 ThreadProxy(LayerTreeHost* layer_tree_host, scoped_ptr<Thread> impl_thread); | 104 ThreadProxy(LayerTreeHost* layer_tree_host, scoped_ptr<Thread> impl_thread); |
| 120 | 105 |
| 121 struct BeginFrameAndCommitState { | 106 struct BeginFrameAndCommitState { |
| 122 BeginFrameAndCommitState(); | 107 BeginFrameAndCommitState(); |
| 123 ~BeginFrameAndCommitState(); | 108 ~BeginFrameAndCommitState(); |
| 124 | 109 |
| 125 base::TimeTicks monotonic_frame_begin_time; | 110 base::TimeTicks monotonic_frame_begin_time; |
| 126 scoped_ptr<ScrollAndScaleSet> scroll_info; | 111 scoped_ptr<ScrollAndScaleSet> scroll_info; |
| 127 size_t memory_allocation_limit_bytes; | 112 size_t memory_allocation_limit_bytes; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 scoped_ptr<ResourceUpdateController> | 227 scoped_ptr<ResourceUpdateController> |
| 243 current_resource_update_controller_on_impl_thread_; | 228 current_resource_update_controller_on_impl_thread_; |
| 244 | 229 |
| 245 // Set when the next draw should post DidCommitAndDrawFrame to the main | 230 // Set when the next draw should post DidCommitAndDrawFrame to the main |
| 246 // thread. | 231 // thread. |
| 247 bool next_frame_is_newly_committed_frame_on_impl_thread_; | 232 bool next_frame_is_newly_committed_frame_on_impl_thread_; |
| 248 | 233 |
| 249 bool throttle_frame_production_; | 234 bool throttle_frame_production_; |
| 250 bool begin_frame_scheduling_enabled_; | 235 bool begin_frame_scheduling_enabled_; |
| 251 bool using_synchronous_renderer_compositor_; | 236 bool using_synchronous_renderer_compositor_; |
| 252 VSyncClient* vsync_client_; | |
| 253 | 237 |
| 254 bool inside_draw_; | 238 bool inside_draw_; |
| 255 | 239 |
| 256 bool defer_commits_; | 240 bool defer_commits_; |
| 257 scoped_ptr<BeginFrameAndCommitState> pending_deferred_commit_; | 241 scoped_ptr<BeginFrameAndCommitState> pending_deferred_commit_; |
| 258 | 242 |
| 259 base::TimeTicks smoothness_takes_priority_expiration_time_; | 243 base::TimeTicks smoothness_takes_priority_expiration_time_; |
| 260 bool renew_tree_priority_on_impl_thread_pending_; | 244 bool renew_tree_priority_on_impl_thread_pending_; |
| 261 | 245 |
| 262 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); | 246 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); |
| 263 }; | 247 }; |
| 264 | 248 |
| 265 } // namespace cc | 249 } // namespace cc |
| 266 | 250 |
| 267 #endif // CC_TREES_THREAD_PROXY_H_ | 251 #endif // CC_TREES_THREAD_PROXY_H_ |
| OLD | NEW |