Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_PROXY_MAIN_H_ | 5 #ifndef CC_TREES_PROXY_MAIN_H_ |
| 6 #define CC_TREES_PROXY_MAIN_H_ | 6 #define CC_TREES_PROXY_MAIN_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | |
| 8 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 9 #include "cc/animation/animation_events.h" | 10 #include "cc/animation/animation_events.h" |
| 10 #include "cc/base/cc_export.h" | 11 #include "cc/base/cc_export.h" |
| 11 #include "cc/debug/frame_timing_tracker.h" | 12 #include "cc/debug/frame_timing_tracker.h" |
| 13 #include "cc/input/top_controls_state.h" | |
| 14 #include "cc/output/output_surface.h" | |
| 12 #include "cc/output/renderer_capabilities.h" | 15 #include "cc/output/renderer_capabilities.h" |
| 16 #include "cc/trees/channel_main.h" | |
| 17 #include "cc/trees/proxy.h" | |
| 13 #include "cc/trees/proxy_common.h" | 18 #include "cc/trees/proxy_common.h" |
| 14 | 19 |
| 15 namespace cc { | 20 namespace cc { |
| 16 class ThreadedChannel; | 21 class BeginFrameSource; |
| 22 class ChannelMain; | |
| 23 class LayerTreeHost; | |
| 17 | 24 |
| 18 // TODO(khushalsagar): The main side of ThreadProxy. It is currently defined as | 25 // This class aggregates all interactions that the impl side of the compositor |
| 19 // an interface with the implementation provided by ThreadProxy and will be | 26 // needs to have with the main side. |
| 20 // made an independent class. | 27 // The class is created and lives on the main thread. |
| 21 // The methods added to this interface should only use the MainThreadOnly or | 28 class CC_EXPORT ProxyMain : public Proxy { |
| 22 // BlockedMainThread variables from ThreadProxy. | |
| 23 // See crbug/527200. | |
| 24 class CC_EXPORT ProxyMain { | |
| 25 public: | 29 public: |
| 26 // TODO(khushalsagar): Make this ChannelMain*. When ProxyMain and | 30 static scoped_ptr<ProxyMain> Create( |
| 27 // ProxyImpl are split, ProxyImpl will be passed a reference to ChannelImpl | 31 LayerTreeHost* layer_tree_host, |
| 28 // at creation. Right now we just set it directly from ThreadedChannel | 32 TaskRunnerProvider* task_runner_provider, |
| 29 // when the impl side is initialized. | 33 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
| 30 virtual void SetChannel(scoped_ptr<ThreadedChannel> threaded_channel) = 0; | 34 |
| 35 ~ProxyMain() override; | |
| 36 | |
| 37 // Commits between the main and impl threads are processed through a pipeline | |
| 38 // with the following stages. For efficiency we can early out at any stage if | |
| 39 // we decide that no further processing is necessary. | |
| 40 enum CommitPipelineStage { | |
| 41 NO_PIPELINE_STAGE, | |
| 42 ANIMATE_PIPELINE_STAGE, | |
| 43 UPDATE_LAYERS_PIPELINE_STAGE, | |
| 44 COMMIT_PIPELINE_STAGE, | |
| 45 }; | |
| 46 | |
| 47 // This sets the channel used by ProxyMain to communicate with ProxyImpl. | |
| 48 // The channel must be set before starting ProxyMain. | |
| 49 void SetChannel(scoped_ptr<ChannelMain> channel_main); | |
| 50 | |
| 51 // Virtual for testing. | |
|
vmpstr
2015/12/04 00:25:41
All of them? (I'm genuinely asking :) )
Khushal
2015/12/04 22:45:22
The channel tests verify that each call reaches th
| |
| 52 virtual void DidCompleteSwapBuffers(); | |
| 53 virtual void SetRendererCapabilitiesMainCopy( | |
| 54 const RendererCapabilities& capabilities); | |
| 55 virtual void BeginMainFrameNotExpectedSoon(); | |
| 56 virtual void DidCommitAndDrawFrame(); | |
| 57 virtual void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue); | |
| 58 virtual void DidLoseOutputSurface(); | |
| 59 virtual void RequestNewOutputSurface(); | |
| 60 virtual void DidInitializeOutputSurface( | |
| 61 bool success, | |
| 62 const RendererCapabilities& capabilities); | |
| 63 virtual void DidCompletePageScaleAnimation(); | |
| 64 virtual void PostFrameTimingEventsOnMain( | |
| 65 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | |
| 66 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events); | |
| 67 virtual void BeginMainFrame( | |
| 68 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state); | |
| 69 | |
| 70 ChannelMain* channel_main() const { return channel_main_.get(); } | |
| 71 CommitPipelineStage max_requested_pipeline_stage() const { | |
| 72 return max_requested_pipeline_stage_; | |
| 73 } | |
| 74 CommitPipelineStage current_pipeline_stage() const { | |
| 75 return current_pipeline_stage_; | |
| 76 } | |
| 77 CommitPipelineStage final_pipeline_stage() const { | |
| 78 return final_pipeline_stage_; | |
| 79 } | |
| 31 | 80 |
| 32 protected: | 81 protected: |
| 33 virtual ~ProxyMain() {} | 82 ProxyMain(LayerTreeHost* layer_tree_host, |
| 83 TaskRunnerProvider* task_runner_provider, | |
| 84 scoped_ptr<BeginFrameSource> external_begin_frame_source); | |
| 34 | 85 |
| 35 private: | 86 private: |
| 36 friend class ThreadedChannel; | 87 friend class ProxyMainForTest; |
|
vmpstr
2015/12/04 00:25:41
If this is the only override, then maybe just make
Khushal
2015/12/04 22:45:22
I think having just the test class as friend class
| |
| 37 // Callback for main side commands received from the Channel. | |
| 38 virtual void DidCompleteSwapBuffers() = 0; | |
| 39 virtual void SetRendererCapabilitiesMainCopy( | |
| 40 const RendererCapabilities& capabilities) = 0; | |
| 41 virtual void BeginMainFrameNotExpectedSoon() = 0; | |
| 42 virtual void DidCommitAndDrawFrame() = 0; | |
| 43 virtual void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue) = 0; | |
| 44 virtual void DidLoseOutputSurface() = 0; | |
| 45 virtual void RequestNewOutputSurface() = 0; | |
| 46 virtual void DidInitializeOutputSurface( | |
| 47 bool success, | |
| 48 const RendererCapabilities& capabilities) = 0; | |
| 49 virtual void DidCompletePageScaleAnimation() = 0; | |
| 50 virtual void PostFrameTimingEventsOnMain( | |
| 51 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | |
| 52 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) = 0; | |
| 53 virtual void BeginMainFrame( | |
| 54 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) = 0; | |
| 55 | 88 |
| 56 // TODO(khushalsagar): Rename as GetWeakPtr() once ThreadProxy is split. | 89 // Proxy implementation. |
| 57 virtual base::WeakPtr<ProxyMain> GetMainWeakPtr() = 0; | 90 void FinishAllRendering() override; |
| 91 bool IsStarted() const override; | |
| 92 bool CommitToActiveTree() const override; | |
| 93 void SetOutputSurface(OutputSurface* output_surface) override; | |
| 94 void SetVisible(bool visible) override; | |
| 95 void SetThrottleFrameProduction(bool throttle) override; | |
| 96 const RendererCapabilities& GetRendererCapabilities() const override; | |
| 97 void SetNeedsAnimate() override; | |
| 98 void SetNeedsUpdateLayers() override; | |
| 99 void SetNeedsCommit() override; | |
| 100 void SetNeedsRedraw(const gfx::Rect& damage_rect) override; | |
| 101 void SetNextCommitWaitsForActivation() override; | |
| 102 void NotifyInputThrottledUntilCommit() override; | |
| 103 void SetDeferCommits(bool defer_commits) override; | |
| 104 bool CommitRequested() const override; | |
| 105 bool BeginMainFrameRequested() const override; | |
| 106 void MainThreadHasStoppedFlinging() override; | |
| 107 void Start() override; | |
| 108 void Stop() override; | |
| 109 bool SupportsImplScrolling() const override; | |
| 110 bool MainFrameWillHappenForTesting() override; | |
| 111 void SetChildrenNeedBeginFrames(bool children_need_begin_frames) override; | |
| 112 void SetAuthoritativeVSyncInterval(const base::TimeDelta& interval) override; | |
| 113 void ReleaseOutputSurface() override; | |
| 114 void UpdateTopControlsState(TopControlsState constraints, | |
| 115 TopControlsState current, | |
| 116 bool animate) override; | |
| 117 | |
| 118 // Returns |true| if the request was actually sent, |false| if one was | |
| 119 // already outstanding. | |
| 120 bool SendCommitRequestToImplThreadIfNeeded( | |
| 121 CommitPipelineStage required_stage); | |
| 122 bool IsMainThread() const; | |
| 123 | |
| 124 LayerTreeHost* layer_tree_host_; | |
| 125 | |
| 126 TaskRunnerProvider* task_runner_provider_; | |
| 127 | |
| 128 const int layer_tree_host_id_; | |
| 129 | |
| 130 // The furthest pipeline stage which has been requested for the next | |
| 131 // commit. | |
| 132 CommitPipelineStage max_requested_pipeline_stage_; | |
| 133 // The commit pipeline stage that is currently being processed. | |
| 134 CommitPipelineStage current_pipeline_stage_; | |
| 135 // The commit pipeline stage at which processing for the current commit | |
| 136 // will stop. Only valid while we are executing the pipeline (i.e., | |
| 137 // |current_pipeline_stage| is set to a pipeline stage). | |
| 138 CommitPipelineStage final_pipeline_stage_; | |
| 139 | |
| 140 bool commit_waits_for_activation_; | |
| 141 | |
| 142 // Set when the Proxy is started using Proxy::Start() and reset when it is | |
| 143 // stopped using Proxy::Stop(). | |
| 144 bool started_; | |
| 145 | |
| 146 bool defer_commits_; | |
| 147 | |
| 148 RendererCapabilities renderer_capabilities_main_thread_copy_; | |
| 149 | |
| 150 // This holds a valid value only until ProxyImpl is created on the impl thread | |
| 151 // with InitializeImplOnImpl(). | |
| 152 scoped_ptr<BeginFrameSource> external_begin_frame_source_; | |
| 153 | |
| 154 scoped_ptr<ChannelMain> channel_main_; | |
| 155 | |
| 156 DISALLOW_COPY_AND_ASSIGN(ProxyMain); | |
| 58 }; | 157 }; |
| 59 | 158 |
| 60 } // namespace cc | 159 } // namespace cc |
| 61 | 160 |
| 62 #endif // CC_TREES_PROXY_MAIN_H_ | 161 #endif // CC_TREES_PROXY_MAIN_H_ |
| OLD | NEW |