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

Side by Side Diff: cc/blimp/layer_tree_host_remote.h

Issue 2362073002: cc/blimp: Add a LayerTreeHostRemote implementation. (Closed)
Patch Set: win Created 4 years, 2 months 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CC_BLIMP_LAYER_TREE_HOST_REMOTE_H_
6 #define CC_BLIMP_LAYER_TREE_HOST_REMOTE_H_
7
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "cc/base/cc_export.h"
11 #include "cc/blimp/remote_compositor_bridge_client.h"
12 #include "cc/debug/layer_tree_debug_state.h"
13 #include "cc/trees/layer_tree_host.h"
14 #include "cc/trees/layer_tree_settings.h"
15 #include "cc/trees/surface_sequence_generator.h"
16 #include "cc/trees/swap_promise_manager.h"
17
18 namespace base {
19 class SingleThreadTaskRunner;
20 } // namespace base
21
22 namespace cc {
23 class AnimationHost;
24 class RemoteCompositorBridge;
25 class LayerTreeHostClient;
26
27 class CC_EXPORT LayerTreeHostRemote : public LayerTreeHost,
28 public RemoteCompositorBridgeClient {
29 public:
30 // The remote LayerTreeHost doesn't perform any compositing, so we don't need
31 // any resources (OutputSurface, TaskGraphRunner, etc.) needed by the
danakj 2016/09/30 22:37:13 TBH commenting on the absence of these is a bit we
Khushal 2016/10/01 00:53:48 Removed.
32 // compositor.
33 struct InitParams {
34 LayerTreeHostClient* client = nullptr;
35 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner;
36 std::unique_ptr<AnimationHost> animation_host;
37 std::unique_ptr<RemoteCompositorBridge> remote_compositor_bridge;
38 LayerTreeSettings const* settings = nullptr;
39
40 InitParams();
41 ~InitParams();
42 };
43
44 explicit LayerTreeHostRemote(InitParams* params);
45 ~LayerTreeHostRemote() override;
46
47 // LayerTreeHost implementation.
48 int GetId() const override;
49 int SourceFrameNumber() const override;
50 LayerTree* GetLayerTree() override;
51 const LayerTree* GetLayerTree() const override;
52 UIResourceManager* GetUIResourceManager() override;
53 TaskRunnerProvider* GetTaskRunnerProvider() const override;
54 const LayerTreeSettings& GetSettings() const override;
55 void SetSurfaceClientId(uint32_t client_id) override;
56 void SetLayerTreeMutator(std::unique_ptr<LayerTreeMutator> mutator) override;
57 void QueueSwapPromise(std::unique_ptr<SwapPromise> swap_promise) override;
58 SwapPromiseManager* GetSwapPromiseManager() override;
59 void SetHasGpuRasterizationTrigger(bool has_trigger) override;
60 void SetVisible(bool visible) override;
61 bool IsVisible() const override;
62 void SetCompositorFrameSink(
63 std::unique_ptr<CompositorFrameSink> compositor_frame_sink) override;
64 std::unique_ptr<CompositorFrameSink> ReleaseCompositorFrameSink() override;
65 void SetNeedsAnimate() override;
66 void SetNeedsUpdateLayers() override;
67 void SetNeedsCommit() override;
68 bool BeginMainFrameRequested() const override;
69 bool CommitRequested() const override;
70 void SetDeferCommits(bool defer_commits) override;
71 void LayoutAndUpdateLayers() override;
72 void Composite(base::TimeTicks frame_begin_time) override;
73 void SetNeedsRedraw() override;
74 void SetNeedsRedrawRect(const gfx::Rect& damage_rect) override;
75 void SetNextCommitForcesRedraw() override;
76 void NotifyInputThrottledUntilCommit() override;
77 void UpdateTopControlsState(TopControlsState constraints,
78 TopControlsState current,
79 bool animate) override;
80 const base::WeakPtr<InputHandler>& GetInputHandler() const override;
81 void DidStopFlinging() override;
82 void SetDebugState(const LayerTreeDebugState& debug_state) override;
83 const LayerTreeDebugState& GetDebugState() const override;
84 int ScheduleMicroBenchmark(
85 const std::string& benchmark_name,
86 std::unique_ptr<base::Value> value,
87 const MicroBenchmark::DoneCallback& callback) override;
88 bool SendMessageToMicroBenchmark(int id,
89 std::unique_ptr<base::Value> value) override;
90 SurfaceSequenceGenerator* GetSurfaceSequenceGenerator() override;
91 void SetNextCommitWaitsForActivation() override;
92 void ResetGpuRasterizationTracking() override;
93
94 protected:
95 // Protected for testing. Allows tests to inject the LayerTree.
96 LayerTreeHostRemote(InitParams* params,
97 std::unique_ptr<LayerTree> layer_tree);
98
99 private:
100 enum class FramePipelineStage { NONE, ANIMATE, UPDATE_LAYERS, COMMIT };
101
102 // RemoteCompositorBridgeClient implementation.
danakj 2016/09/30 22:37:13 nit: Im not a super fan of private inheriting func
Khushal 2016/10/01 00:53:48 I just think that it makes it more explicit that t
danakj 2016/10/03 21:02:48 They may cast it accidentally. It can be done impl
Khushal 2016/10/04 01:27:09 Can you share an example of this one? I thought th
danakj 2016/10/04 01:40:57 BaseClass* GetSubclass() { Subclass* s = ... r
103 void BeginMainFrame() override;
104
105 base::SingleThreadTaskRunner* MainTaskRunner();
106
107 void MainFrameRequested(FramePipelineStage requested_pipeline_stage);
108 void ScheduleMainFrameIfNecessary();
109 void MainFrameComplete();
110 void DispatchDrawAndSwapCallbacks();
111
112 int id_;
danakj 2016/09/30 22:37:13 const?
Khushal 2016/10/01 00:53:48 Done.
113 int source_frame_number_;
114 bool visible_;
115 bool defer_commits_;
116
117 // Set to true if a main frame request is pending on the
118 // RemoteCompositorBridge.
119 bool main_frame_requested_from_bridge_;
120
121 // Set to the pipeline stage we are currently at if we are inside a main frame
122 // update.
123 FramePipelineStage current_pipeline_stage_;
124
125 // Set to the pipeline stage we need to go to for the current main frame
126 // update, if we are inside a main frame update.
127 FramePipelineStage max_pipeline_stage_for_current_frame_;
128
129 // Set to the pipeline stage requested for the next BeginMainFrame.
130 FramePipelineStage requested_pipeline_stage_for_next_frame_;
131
132 LayerTreeHostClient* client_;
133 std::unique_ptr<TaskRunnerProvider> task_runner_provider_;
134
135 // The RemoteCompositorBridge used to submit frame updates to the client.
136 std::unique_ptr<RemoteCompositorBridge> remote_compositor_bridge_;
137
138 LayerTreeSettings settings_;
139 LayerTreeDebugState debug_state_;
140
141 // The LayerTree holds the root layer and other state on the engine.
142 std::unique_ptr<LayerTree> layer_tree_;
143
144 SwapPromiseManager swap_promise_manager_;
145 SurfaceSequenceGenerator surface_sequence_generator_;
146
147 base::WeakPtr<InputHandler> input_handler_weak_ptr_;
148
149 base::WeakPtrFactory<LayerTreeHostRemote> weak_factory_;
150 };
151
152 } // namespace cc
153
154 #endif // CC_BLIMP_LAYER_TREE_HOST_REMOTE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698