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

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

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

Powered by Google App Engine
This is Rietveld 408576698