Chromium Code Reviews| Index: cc/trees/proxy_main.h |
| diff --git a/cc/trees/proxy_main.h b/cc/trees/proxy_main.h |
| index fbe191d57a67f587b06fd493a19e07a7cc3539a9..44a9e97d64a86e69565aaec1a7d4fa18f8e0843f 100644 |
| --- a/cc/trees/proxy_main.h |
| +++ b/cc/trees/proxy_main.h |
| @@ -5,56 +5,156 @@ |
| #ifndef CC_TREES_PROXY_MAIN_H_ |
| #define CC_TREES_PROXY_MAIN_H_ |
| +#include "base/macros.h" |
| #include "base/memory/weak_ptr.h" |
| #include "cc/animation/animation_events.h" |
| #include "cc/base/cc_export.h" |
| #include "cc/debug/frame_timing_tracker.h" |
| +#include "cc/input/top_controls_state.h" |
| +#include "cc/output/output_surface.h" |
| #include "cc/output/renderer_capabilities.h" |
| +#include "cc/trees/channel_main.h" |
| +#include "cc/trees/proxy.h" |
| #include "cc/trees/proxy_common.h" |
| namespace cc { |
| -class ThreadedChannel; |
| - |
| -// TODO(khushalsagar): The main side of ThreadProxy. It is currently defined as |
| -// an interface with the implementation provided by ThreadProxy and will be |
| -// made an independent class. |
| -// The methods added to this interface should only use the MainThreadOnly or |
| -// BlockedMainThread variables from ThreadProxy. |
| -// See crbug/527200. |
| -class CC_EXPORT ProxyMain { |
| +class BeginFrameSource; |
| +class ChannelMain; |
| +class LayerTreeHost; |
| + |
| +class CC_EXPORT ProxyMain : public Proxy { |
| public: |
| - // TODO(khushalsagar): Make this ChannelMain*. When ProxyMain and |
| - // ProxyImpl are split, ProxyImpl will be passed a reference to ChannelImpl |
| - // at creation. Right now we just set it directly from ThreadedChannel |
| - // when the impl side is initialized. |
| - virtual void SetChannel(scoped_ptr<ThreadedChannel> threaded_channel) = 0; |
| + static scoped_ptr<ProxyMain> Create( |
| + LayerTreeHost* layer_tree_host, |
| + scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| + scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| + scoped_ptr<BeginFrameSource> external_begin_frame_source); |
| + |
| + ~ProxyMain() override; |
| + |
| + // Commits between the main and impl threads are processed through a pipeline |
| + // with the following stages. For efficiency we can early out at any stage if |
| + // we decide that no further processing is necessary. |
| + enum CommitPipelineStage { |
| + NO_PIPELINE_STAGE, |
| + ANIMATE_PIPELINE_STAGE, |
| + UPDATE_LAYERS_PIPELINE_STAGE, |
| + COMMIT_PIPELINE_STAGE, |
| + }; |
| + |
| + // Proxy implementation |
| + void FinishAllRendering() override; |
| + bool IsStarted() const override; |
| + bool CommitToActiveTree() const override; |
| + void SetOutputSurface(OutputSurface* output_surface) override; |
| + void SetVisible(bool visible) override; |
| + void SetThrottleFrameProduction(bool throttle) override; |
| + const RendererCapabilities& GetRendererCapabilities() const override; |
| + void SetNeedsAnimate() override; |
| + void SetNeedsUpdateLayers() override; |
| + void SetNeedsCommit() override; |
| + void SetNeedsRedraw(const gfx::Rect& damage_rect) override; |
| + void SetNextCommitWaitsForActivation() override; |
| + void NotifyInputThrottledUntilCommit() override; |
| + void SetDeferCommits(bool defer_commits) override; |
| + bool CommitRequested() const override; |
| + bool BeginMainFrameRequested() const override; |
| + void MainThreadHasStoppedFlinging() override; |
| + void Start() override; |
| + void Stop() override; |
| + bool SupportsImplScrolling() const override; |
| + bool MainFrameWillHappenForTesting() override; |
| + void SetChildrenNeedBeginFrames(bool children_need_begin_frames) override; |
| + void SetAuthoritativeVSyncInterval(const base::TimeDelta& interval) override; |
| + void ReleaseOutputSurface() override; |
| + void UpdateTopControlsState(TopControlsState constraints, |
| + TopControlsState current, |
| + bool animate) override; |
| + |
| + // This sets the channel used by ProxyMain to communicate with ProxyImpl. |
| + // The channel must be set before starting ProxyMain. |
| + void SetChannel(scoped_ptr<ChannelMain> channel_main); |
| + |
| + ChannelMain* channel_main() const { return channel_main_.get(); } |
| + CommitPipelineStage max_requested_pipeline_stage() const { |
| + return max_requested_pipeline_stage_; |
| + } |
| + CommitPipelineStage current_pipeline_stage() const { |
| + return current_pipeline_stage_; |
| + } |
| + CommitPipelineStage final_pipeline_stage() const { |
| + return final_pipeline_stage_; |
| + } |
| protected: |
| - virtual ~ProxyMain() {} |
| + ProxyMain(LayerTreeHost* layer_tree_host, |
| + scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| + scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| + scoped_ptr<BeginFrameSource> external_begin_frame_source); |
| private: |
| friend class ThreadedChannel; |
| + friend class ProxyMainForTest; |
| + |
| + // Returns |true| if the request was actually sent, |false| if one was |
| + // already outstanding. |
| + bool SendCommitRequestToImplThreadIfNeeded( |
| + CommitPipelineStage required_stage); |
| + |
| // Callback for main side commands received from the Channel. |
| - virtual void DidCompleteSwapBuffers() = 0; |
| + // virtual for testing. |
| + virtual void DidCompleteSwapBuffers(); |
| virtual void SetRendererCapabilitiesMainCopy( |
| - const RendererCapabilities& capabilities) = 0; |
| - virtual void BeginMainFrameNotExpectedSoon() = 0; |
| - virtual void DidCommitAndDrawFrame() = 0; |
| - virtual void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue) = 0; |
| - virtual void DidLoseOutputSurface() = 0; |
| - virtual void RequestNewOutputSurface() = 0; |
| + const RendererCapabilities& capabilities); |
| + virtual void BeginMainFrameNotExpectedSoon(); |
| + virtual void DidCommitAndDrawFrame(); |
| + virtual void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue); |
| + virtual void DidLoseOutputSurface(); |
| + virtual void RequestNewOutputSurface(); |
| virtual void DidInitializeOutputSurface( |
| bool success, |
| - const RendererCapabilities& capabilities) = 0; |
| - virtual void DidCompletePageScaleAnimation() = 0; |
| + const RendererCapabilities& capabilities); |
| + virtual void DidCompletePageScaleAnimation(); |
| virtual void PostFrameTimingEventsOnMain( |
| scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
| - scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) = 0; |
| + scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events); |
| virtual void BeginMainFrame( |
| - scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) = 0; |
| + scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state); |
| + |
| + base::WeakPtr<ProxyMain> GetWeakPtr(); |
|
Wez
2015/11/10 01:41:51
Why do you have this _and_ the |main_thread_weak_p
Khushal
2015/11/11 04:17:47
main_thread_weak_ptr_ is not needed anymore.
This
|
| + |
| + LayerTreeHost* layer_tree_host_; |
| + |
| + const int layer_tree_host_id_; |
| + |
| + // The furthest pipeline stage which has been requested for the next |
| + // commit. |
| + CommitPipelineStage max_requested_pipeline_stage_; |
| + // The commit pipeline stage that is currently being processed. |
| + CommitPipelineStage current_pipeline_stage_; |
| + // The commit pipeline stage at which processing for the current commit |
| + // will stop. Only valid while we are executing the pipeline (i.e., |
| + // |current_pipeline_stage| is set to a pipeline stage). |
| + CommitPipelineStage final_pipeline_stage_; |
| + |
| + bool commit_waits_for_activation_; |
| + |
| + bool started_; |
| + bool prepare_tiles_pending_; |
| + bool defer_commits_; |
| + |
| + RendererCapabilities renderer_capabilities_main_thread_copy_; |
| + |
| + // This holds a valid value only until ProxyImpl is created on the impl thread |
| + // with InitializeImplOnImpl(). |
| + scoped_ptr<BeginFrameSource> external_begin_frame_source_; |
| + |
| + scoped_ptr<ChannelMain> channel_main_; |
| + |
| + base::WeakPtr<ProxyMain> main_thread_weak_ptr_; |
|
Wez
2015/11/10 01:41:51
You appear to set this but never use it?
Also, wh
Khushal
2015/11/11 04:17:47
Again, thread proxy had this as main_thread_weak_p
Wez
2015/11/12 22:30:18
I'm not sure what you mean by "the thread the poin
Khushal
2015/11/13 04:02:17
Yeah. It was meant to denote the thread the WeakPt
|
| + base::WeakPtrFactory<ProxyMain> weak_factory_; |
| - // TODO(khushalsagar): Rename as GetWeakPtr() once ThreadProxy is split. |
| - virtual base::WeakPtr<ProxyMain> GetMainWeakPtr() = 0; |
| + DISALLOW_COPY_AND_ASSIGN(ProxyMain); |
| }; |
| } // namespace cc |