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

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

Issue 2317753002: cc: Abstract the LayerTreeHost. (Closed)
Patch Set: Rebase 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_TREES_LAYER_TREE_HOST_INTERFACE_H_
6 #define CC_TREES_LAYER_TREE_HOST_INTERFACE_H_
7
8 #include "base/macros.h"
9 #include "cc/base/cc_export.h"
10 #include "cc/debug/micro_benchmark.h"
11 #include "cc/input/top_controls_state.h"
12
13 namespace base {
14 class TimeTicks;
15 } // namespace base
16
17 namespace gfx {
18 class Rect;
19 } // namespace gfx
20
21 namespace cc {
22 class InputHandler;
23 class LayerTree;
24 class LayerTreeDebugState;
25 class LayerTreeMutator;
26 class LayerTreeSettings;
27 class OutputSurface;
28 class SwapPromiseMonitor;
29 class TaskRunnerProvider;
30
31 // TODO(khushalsagar): Will be renamed to LayerTreeHost.
32 class CC_EXPORT LayerTreeHostInterface {
33 public:
34 virtual ~LayerTreeHostInterface() {}
35
36 // Returns the process global unique identifier for this LayerTreeHost.
37 virtual int GetId() const = 0;
38
39 // The current source frame number. This is incremented for each main frame
40 // update(commit) pushed to the compositor thread.
41 virtual int SourceFrameNumber() const = 0;
42
43 // Returns the LayerTree that holds the main frame state pushed to the
44 // LayerTreeImpl on commit.
45 virtual LayerTree* GetLayerTree() = 0;
46 virtual const LayerTree* GetLayerTree() const = 0;
47
48 // Returns the TaskRunnerProvider used to access the main and compositor
49 // thread task runners.
50 virtual TaskRunnerProvider* GetTaskRunnerProvider() const = 0;
51
52 // Returns the settings used by this host.
53 virtual const LayerTreeSettings& GetSettings() const = 0;
54
55 // Sets the client id used to generate the SurfaceId that uniquely identifies
56 // the Surfaces produced by this compositor.
57 virtual void SetSurfaceClientId(uint32_t client_id) = 0;
58
59 // Sets the LayerTreeMutator interface used to directly mutate the compositor
60 // state on the compositor thread. (Compositor-Worker)
61 virtual void SetLayerTreeMutator(
62 std::unique_ptr<LayerTreeMutator> mutator) = 0;
63
64 // Call this function when you expect there to be a swap buffer.
65 // See swap_promise.h for how to use SwapPromise.
66 virtual void QueueSwapPromise(std::unique_ptr<SwapPromise> swap_promise) = 0;
67
68 // Sets whether the content is suitable to use Gpu Rasterization.
69 virtual void SetHasGpuRasterizationTrigger(bool has_trigger) = 0;
70
71 // Visibility and OutputSurface -------------------------------
72
73 virtual void SetVisible(bool visible) = 0;
74 virtual bool IsVisible() const = 0;
75
76 // Called in response to an OutputSurface request made to the client using
77 // LayerTreeHostClient::RequestNewOutputSurface. The client will be informed
78 // of the OutputSurface initialization status using DidInitializaOutputSurface
79 // or DidFailToInitializeOutputSurface. The request is completed when the host
80 // successfully initializes an OutputSurface.
81 virtual void SetOutputSurface(
82 std::unique_ptr<OutputSurface> output_surface) = 0;
83
84 // Forces the host to immediately release all references to the OutputSurface,
85 // if any. Can be safely called any time.
86 virtual std::unique_ptr<OutputSurface> ReleaseOutputSurface() = 0;
87
88 // Frame Scheduling (main and compositor frames) requests -------
89
90 // Requests a main frame update even if no content has changed. This is used,
91 // for instance in the case of RequestAnimationFrame from blink to ensure the
92 // main frame update is run on the next tick without pre-emptively forcing a
93 // full commit synchronization or layer updates.
94 virtual void SetNeedsAnimate() = 0;
95
96 // Requests a main frame update and also ensure that the host pulls layer
97 // updates from the client, even if no content might have changed, without
98 // forcing a full commit synchronization.
99 virtual void SetNeedsUpdateLayers() = 0;
100
101 // Requests that the next main frame update performs a full commit
102 // synchronization.
103 virtual void SetNeedsCommit() = 0;
104
105 // Returns true if a main frame (for any pipeline stage above) has been
106 // requested.
107 virtual bool BeginMainFrameRequested() const = 0;
108
109 // Returns true if a main frame with commit synchronization has been
110 // requested.
111 virtual bool CommitRequested() const = 0;
112
113 // Enables/disables the compositor from requesting main frame updates from the
114 // client.
115 virtual void SetDeferCommits(bool defer_commits) = 0;
116
117 // Synchronously performs a main frame update and layer updates. Used only in
118 // single threaded mode when the compositor's internal scheduling is disabled.
119 virtual void LayoutAndUpdateLayers() = 0;
120
121 // Synchronously performs a complete main frame update, commit and compositor
122 // frame. Used only in single threaded mode when the compositor's internal
123 // scheduling is disabled.
124 virtual void Composite(base::TimeTicks frame_begin_time) = 0;
125
126 // Requests a redraw (compositor frame) for the complete viewport.
127 virtual void SetNeedsRedraw() = 0;
128
129 // Requests a redraw (compositor frame) for the given rect.
130 virtual void SetNeedsRedrawRect(const gfx::Rect& damage_rect) = 0;
131
132 // Requests a main frame (including layer updates) and ensures that this main
133 // frame results in a redraw for the complete viewport when producing the
134 // CompositorFrame.
135 virtual void SetNextCommitForcesRedraw() = 0;
136
137 // Input Handling ---------------------------------------------
138
139 // Notifies the compositor that input from the browser is being throttled till
140 // the next commit. The compositor will prioritize activation of the pending
141 // tree so a commit can be performed.
142 virtual void NotifyInputThrottledUntilCommit() = 0;
143
144 // Sets the state of the top controls. (Used for URL bar animations on
145 // android).
146 virtual void UpdateTopControlsState(TopControlsState constraints,
147 TopControlsState current,
148 bool animate) = 0;
149
150 // Returns a reference to the InputHandler used to respond to input events on
151 // the compositor thread.
152 virtual const base::WeakPtr<InputHandler>& GetInputHandler() const = 0;
153
154 // Informs the compositor that an active fling gesture being processed on the
155 // main thread has been finished.
156 virtual void DidStopFlinging() = 0;
157
158 // Debugging and benchmarks ---------------------------------
159 virtual void SetDebugState(const LayerTreeDebugState& debug_state) = 0;
160 virtual const LayerTreeDebugState& GetDebugState() const = 0;
161
162 // Returns the id of the benchmark on success, 0 otherwise.
163 virtual int ScheduleMicroBenchmark(
164 const std::string& benchmark_name,
165 std::unique_ptr<base::Value> value,
166 const MicroBenchmark::DoneCallback& callback) = 0;
167
168 // Returns true if the message was successfully delivered and handled.
169 virtual bool SendMessageToMicroBenchmark(
170 int id,
171 std::unique_ptr<base::Value> value) = 0;
172
173 // Methods used internally in cc. These are not intended to be a part of the
174 // public API for use by the embedder ----------------------
175
176 // When a SwapPromiseMonitor is created on the main thread, it calls
177 // InsertSwapPromiseMonitor() to register itself with LayerTreeHost.
178 // When the monitor is destroyed, it calls RemoveSwapPromiseMonitor()
179 // to unregister itself.
180 virtual void InsertSwapPromiseMonitor(SwapPromiseMonitor* monitor) = 0;
181 virtual void RemoveSwapPromiseMonitor(SwapPromiseMonitor* monitor) = 0;
182 };
183
184 } // namespace cc
185
186 #endif // CC_TREES_LAYER_TREE_HOST_INTERFACE_H_
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | cc/trees/layer_tree_host_pixeltest_readback.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698