Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Side by Side Diff: cc/trees/proxy_main.h

Issue 1417053005: cc: Split ThreadProxy into ProxyMain and ProxyImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
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 class CC_EXPORT ProxyMain : public Proxy {
19 // an interface with the implementation provided by ThreadProxy and will be
20 // made an independent class.
21 // The methods added to this interface should only use the MainThreadOnly or
22 // BlockedMainThread variables from ThreadProxy.
23 // See crbug/527200.
24 class CC_EXPORT ProxyMain {
25 public: 26 public:
26 // TODO(khushalsagar): Make this ChannelMain*. When ProxyMain and 27 static scoped_ptr<ProxyMain> Create(
27 // ProxyImpl are split, ProxyImpl will be passed a reference to ChannelImpl 28 LayerTreeHost* layer_tree_host,
28 // at creation. Right now we just set it directly from ThreadedChannel 29 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
29 // when the impl side is initialized. 30 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
30 virtual void SetChannel(scoped_ptr<ThreadedChannel> threaded_channel) = 0; 31 scoped_ptr<BeginFrameSource> external_begin_frame_source);
32
33 ~ProxyMain() override;
34
35 // Commits between the main and impl threads are processed through a pipeline
36 // with the following stages. For efficiency we can early out at any stage if
37 // we decide that no further processing is necessary.
38 enum CommitPipelineStage {
39 NO_PIPELINE_STAGE,
40 ANIMATE_PIPELINE_STAGE,
41 UPDATE_LAYERS_PIPELINE_STAGE,
42 COMMIT_PIPELINE_STAGE,
43 };
44
45 // Proxy implementation
46 void FinishAllRendering() override;
47 bool IsStarted() const override;
48 bool CommitToActiveTree() const override;
49 void SetOutputSurface(OutputSurface* output_surface) override;
50 void SetVisible(bool visible) override;
51 void SetThrottleFrameProduction(bool throttle) override;
52 const RendererCapabilities& GetRendererCapabilities() const override;
53 void SetNeedsAnimate() override;
54 void SetNeedsUpdateLayers() override;
55 void SetNeedsCommit() override;
56 void SetNeedsRedraw(const gfx::Rect& damage_rect) override;
57 void SetNextCommitWaitsForActivation() override;
58 void NotifyInputThrottledUntilCommit() override;
59 void SetDeferCommits(bool defer_commits) override;
60 bool CommitRequested() const override;
61 bool BeginMainFrameRequested() const override;
62 void MainThreadHasStoppedFlinging() override;
63 void Start() override;
64 void Stop() override;
65 bool SupportsImplScrolling() const override;
66 bool MainFrameWillHappenForTesting() override;
67 void SetChildrenNeedBeginFrames(bool children_need_begin_frames) override;
68 void SetAuthoritativeVSyncInterval(const base::TimeDelta& interval) override;
69 void ReleaseOutputSurface() override;
70 void UpdateTopControlsState(TopControlsState constraints,
71 TopControlsState current,
72 bool animate) override;
73
74 // This sets the channel used by ProxyMain to communicate with ProxyImpl.
75 // The channel must be set before starting ProxyMain.
76 void SetChannel(scoped_ptr<ChannelMain> channel_main);
77
78 ChannelMain* channel_main() const { return channel_main_.get(); }
79 CommitPipelineStage max_requested_pipeline_stage() const {
80 return max_requested_pipeline_stage_;
81 }
82 CommitPipelineStage current_pipeline_stage() const {
83 return current_pipeline_stage_;
84 }
85 CommitPipelineStage final_pipeline_stage() const {
86 return final_pipeline_stage_;
87 }
31 88
32 protected: 89 protected:
33 virtual ~ProxyMain() {} 90 ProxyMain(LayerTreeHost* layer_tree_host,
91 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
92 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
93 scoped_ptr<BeginFrameSource> external_begin_frame_source);
34 94
35 private: 95 private:
36 friend class ThreadedChannel; 96 friend class ThreadedChannel;
97 friend class ProxyMainForTest;
98
99 // Returns |true| if the request was actually sent, |false| if one was
100 // already outstanding.
101 bool SendCommitRequestToImplThreadIfNeeded(
102 CommitPipelineStage required_stage);
103
37 // Callback for main side commands received from the Channel. 104 // Callback for main side commands received from the Channel.
38 virtual void DidCompleteSwapBuffers() = 0; 105 // virtual for testing.
106 virtual void DidCompleteSwapBuffers();
39 virtual void SetRendererCapabilitiesMainCopy( 107 virtual void SetRendererCapabilitiesMainCopy(
40 const RendererCapabilities& capabilities) = 0; 108 const RendererCapabilities& capabilities);
41 virtual void BeginMainFrameNotExpectedSoon() = 0; 109 virtual void BeginMainFrameNotExpectedSoon();
42 virtual void DidCommitAndDrawFrame() = 0; 110 virtual void DidCommitAndDrawFrame();
43 virtual void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue) = 0; 111 virtual void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue);
44 virtual void DidLoseOutputSurface() = 0; 112 virtual void DidLoseOutputSurface();
45 virtual void RequestNewOutputSurface() = 0; 113 virtual void RequestNewOutputSurface();
46 virtual void DidInitializeOutputSurface( 114 virtual void DidInitializeOutputSurface(
47 bool success, 115 bool success,
48 const RendererCapabilities& capabilities) = 0; 116 const RendererCapabilities& capabilities);
49 virtual void DidCompletePageScaleAnimation() = 0; 117 virtual void DidCompletePageScaleAnimation();
50 virtual void PostFrameTimingEventsOnMain( 118 virtual void PostFrameTimingEventsOnMain(
51 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, 119 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
52 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) = 0; 120 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events);
53 virtual void BeginMainFrame( 121 virtual void BeginMainFrame(
54 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) = 0; 122 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state);
55 123
56 // TODO(khushalsagar): Rename as GetWeakPtr() once ThreadProxy is split. 124 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
57 virtual base::WeakPtr<ProxyMain> GetMainWeakPtr() = 0; 125
126 LayerTreeHost* layer_tree_host_;
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 bool started_;
143 bool prepare_tiles_pending_;
144 bool defer_commits_;
145
146 RendererCapabilities renderer_capabilities_main_thread_copy_;
147
148 // This holds a valid value only until ProxyImpl is created on the impl thread
149 // with InitializeImplOnImpl().
150 scoped_ptr<BeginFrameSource> external_begin_frame_source_;
151
152 scoped_ptr<ChannelMain> channel_main_;
153
154 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
155 base::WeakPtrFactory<ProxyMain> weak_factory_;
156
157 DISALLOW_COPY_AND_ASSIGN(ProxyMain);
58 }; 158 };
59 159
60 } // namespace cc 160 } // namespace cc
61 161
62 #endif // CC_TREES_PROXY_MAIN_H_ 162 #endif // CC_TREES_PROXY_MAIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698