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

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

Issue 2362073002: cc/blimp: Add a LayerTreeHostRemote implementation. (Closed)
Patch Set: Remaining comments from #4 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/compositor_proto_state_sink_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 CompositorProtoStateSink;
25 class LayerTreeHostClient;
26
27 class CC_EXPORT LayerTreeHostRemote : public LayerTreeHost,
28 public CompositorProtoStateSinkClient {
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
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<CompositorProtoStateSink> compositor_proto_state_sink;
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 // CompositorProtoStateSinkClient implementation.
103 void BeginMainFrame() override;
104 base::SingleThreadTaskRunner* GetMainTaskRunner() override;
105
106 void MainFrameRequested(FramePipelineStage requested_pipeline_stage);
107 void ScheduleMainFrameIfNecessary();
108 void MainFrameComplete();
109 void DispatchDrawAndSwapCallbacks();
110
111 int id_;
112 int source_frame_number_;
113 bool visible_;
114 bool defer_commits_;
115
116 // Set to true if a main frame request is pending on the
117 // CompositorProtoStateSink.
118 bool main_frame_requested_from_state_sink_;
119
120 // Set to the pipeline stage we are currently at if we are inside a main frame
121 // update.
122 FramePipelineStage current_pipeline_stage_;
123
124 // Set to the pipeline stage we need to go to for the current main frame
125 // update, if we are inside a main frame update.
126 FramePipelineStage max_pipeline_stage_for_current_frame_;
127
128 // Set to the pipeline stage requested for the next BeginMainFrame.
129 FramePipelineStage requested_pipeline_stage_for_next_frame_;
130
131 LayerTreeHostClient* client_;
132 std::unique_ptr<TaskRunnerProvider> task_runner_provider_;
133
134 // The CompositorProtoStateSink used to submit frame updates to the client.
135 std::unique_ptr<CompositorProtoStateSink> compositor_proto_state_sink_;
136
137 LayerTreeSettings settings_;
138 LayerTreeDebugState debug_state_;
139
140 // The LayerTree holds the root layer and other state on the engine.
141 std::unique_ptr<LayerTree> layer_tree_;
142
143 SwapPromiseManager swap_promise_manager_;
144 SurfaceSequenceGenerator surface_sequence_generator_;
145
146 base::WeakPtr<InputHandler> input_handler_weak_ptr_;
147
148 base::WeakPtrFactory<LayerTreeHostRemote> weak_factory_;
149 };
150
151 } // namespace cc
152
153 #endif // CC_BLIMP_LAYER_TREE_HOST_REMOTE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698