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

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: Change ThreadedChannel::GetProxyImpl to GetProxyImplForTesting 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 // This class is a proxy to the LayerTreeHost and the main side of the
19 // an interface with the implementation provided by ThreadProxy and will be 26 // compositor. The class is created and lives on the main thread.
20 // made an independent class. 27 class CC_EXPORT ProxyMain : public Proxy {
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: 28 public:
26 // TODO(khushalsagar): Make this ChannelMain*. When ProxyMain and 29 static scoped_ptr<ProxyMain> Create(
27 // ProxyImpl are split, ProxyImpl will be passed a reference to ChannelImpl 30 LayerTreeHost* layer_tree_host,
28 // at creation. Right now we just set it directly from ThreadedChannel 31 TaskRunnerProvider* task_runner_provider,
29 // when the impl side is initialized. 32 scoped_ptr<BeginFrameSource> external_begin_frame_source);
30 virtual void SetChannel(scoped_ptr<ThreadedChannel> threaded_channel) = 0; 33
34 ~ProxyMain() override;
35
36 // Commits between the main and impl threads are processed through a pipeline
37 // with the following stages. For efficiency we can early out at any stage if
38 // we decide that no further processing is necessary.
39 enum CommitPipelineStage {
40 NO_PIPELINE_STAGE,
41 ANIMATE_PIPELINE_STAGE,
42 UPDATE_LAYERS_PIPELINE_STAGE,
43 COMMIT_PIPELINE_STAGE,
44 };
45
46 // Proxy implementation
47 void FinishAllRendering() override;
48 bool IsStarted() const override;
49 bool CommitToActiveTree() const override;
50 void SetOutputSurface(OutputSurface* output_surface) override;
51 void SetVisible(bool visible) override;
52 void SetThrottleFrameProduction(bool throttle) override;
53 const RendererCapabilities& GetRendererCapabilities() const override;
54 void SetNeedsAnimate() override;
55 void SetNeedsUpdateLayers() override;
56 void SetNeedsCommit() override;
57 void SetNeedsRedraw(const gfx::Rect& damage_rect) override;
58 void SetNextCommitWaitsForActivation() override;
59 void NotifyInputThrottledUntilCommit() override;
60 void SetDeferCommits(bool defer_commits) override;
61 bool CommitRequested() const override;
62 bool BeginMainFrameRequested() const override;
63 void MainThreadHasStoppedFlinging() override;
64 void Start() override;
65 void Stop() override;
66 bool SupportsImplScrolling() const override;
67 bool MainFrameWillHappenForTesting() override;
68 void SetChildrenNeedBeginFrames(bool children_need_begin_frames) override;
69 void SetAuthoritativeVSyncInterval(const base::TimeDelta& interval) override;
70 void ReleaseOutputSurface() override;
71 void UpdateTopControlsState(TopControlsState constraints,
72 TopControlsState current,
73 bool animate) override;
74
75 // This sets the channel used by ProxyMain to communicate with ProxyImpl.
76 // The channel must be set before starting ProxyMain.
77 void SetChannel(scoped_ptr<ChannelMain> channel_main);
78
79 ChannelMain* channel_main() const { return channel_main_.get(); }
80 CommitPipelineStage max_requested_pipeline_stage() const {
81 return max_requested_pipeline_stage_;
82 }
83 CommitPipelineStage current_pipeline_stage() const {
84 return current_pipeline_stage_;
85 }
86 CommitPipelineStage final_pipeline_stage() const {
87 return final_pipeline_stage_;
88 }
31 89
32 protected: 90 protected:
33 virtual ~ProxyMain() {} 91 ProxyMain(LayerTreeHost* layer_tree_host,
92 TaskRunnerProvider* task_runner_provider,
93 scoped_ptr<BeginFrameSource> external_begin_frame_source);
34 94
35 private: 95 private:
36 friend class ThreadedChannel; 96 friend class ThreadedChannel;
37 // Callback for main side commands received from the Channel. 97 friend class ProxyMainForTest;
38 virtual void DidCompleteSwapBuffers() = 0; 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
104 // ProxyMain interface for the channel.
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 bool IsMainThread() const;
57 virtual base::WeakPtr<ProxyMain> GetMainWeakPtr() = 0; 125
126 LayerTreeHost* layer_tree_host_;
127
128 TaskRunnerProvider* task_runner_provider_;
129
130 const int layer_tree_host_id_;
131
132 // The furthest pipeline stage which has been requested for the next
133 // commit.
134 CommitPipelineStage max_requested_pipeline_stage_;
135 // The commit pipeline stage that is currently being processed.
136 CommitPipelineStage current_pipeline_stage_;
137 // The commit pipeline stage at which processing for the current commit
138 // will stop. Only valid while we are executing the pipeline (i.e.,
139 // |current_pipeline_stage| is set to a pipeline stage).
140 CommitPipelineStage final_pipeline_stage_;
141
142 bool commit_waits_for_activation_;
143
144 bool started_;
145 bool prepare_tiles_pending_;
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698