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

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

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

Powered by Google App Engine
This is Rietveld 408576698