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

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

Issue 2340143002: cc: Rename LayerTreeHost to LayerTreeHostInProcess. (Closed)
Patch Set: content test 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_in_process.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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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_LAYER_TREE_HOST_H_ 5 #ifndef CC_TREES_LAYER_TREE_HOST_IN_PROCESS_H_
6 #define CC_TREES_LAYER_TREE_HOST_H_ 6 #define CC_TREES_LAYER_TREE_HOST_IN_PROCESS_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <limits> 11 #include <limits>
12 #include <memory> 12 #include <memory>
13 #include <set> 13 #include <set>
14 #include <string> 14 #include <string>
15 #include <unordered_map> 15 #include <unordered_map>
16 #include <vector> 16 #include <vector>
(...skipping 12 matching lines...) Expand all
29 #include "cc/input/layer_selection_bound.h" 29 #include "cc/input/layer_selection_bound.h"
30 #include "cc/input/scrollbar.h" 30 #include "cc/input/scrollbar.h"
31 #include "cc/input/top_controls_state.h" 31 #include "cc/input/top_controls_state.h"
32 #include "cc/layers/layer_collections.h" 32 #include "cc/layers/layer_collections.h"
33 #include "cc/layers/layer_list_iterator.h" 33 #include "cc/layers/layer_list_iterator.h"
34 #include "cc/output/compositor_frame_sink.h" 34 #include "cc/output/compositor_frame_sink.h"
35 #include "cc/output/swap_promise.h" 35 #include "cc/output/swap_promise.h"
36 #include "cc/resources/resource_format.h" 36 #include "cc/resources/resource_format.h"
37 #include "cc/trees/compositor_mode.h" 37 #include "cc/trees/compositor_mode.h"
38 #include "cc/trees/layer_tree.h" 38 #include "cc/trees/layer_tree.h"
39 #include "cc/trees/layer_tree_host.h"
39 #include "cc/trees/layer_tree_host_client.h" 40 #include "cc/trees/layer_tree_host_client.h"
40 #include "cc/trees/layer_tree_host_interface.h"
41 #include "cc/trees/layer_tree_settings.h" 41 #include "cc/trees/layer_tree_settings.h"
42 #include "cc/trees/proxy.h" 42 #include "cc/trees/proxy.h"
43 #include "cc/trees/surface_sequence_generator.h" 43 #include "cc/trees/surface_sequence_generator.h"
44 #include "cc/trees/swap_promise_manager.h" 44 #include "cc/trees/swap_promise_manager.h"
45 #include "third_party/skia/include/core/SkColor.h" 45 #include "third_party/skia/include/core/SkColor.h"
46 #include "ui/gfx/geometry/rect.h" 46 #include "ui/gfx/geometry/rect.h"
47 47
48 namespace gpu { 48 namespace gpu {
49 class GpuMemoryBufferManager; 49 class GpuMemoryBufferManager;
50 } 50 } // namespace gpu
51 51
52 namespace cc { 52 namespace cc {
53 53 class AnimationHost;
54 class AnimationEvents; 54 class AnimationEvents;
55 class AnimationHost;
56 class BeginFrameSource; 55 class BeginFrameSource;
57 class ClientPictureCache; 56 class ClientPictureCache;
58 class EnginePictureCache; 57 class EnginePictureCache;
59 class HeadsUpDisplayLayer; 58 class HeadsUpDisplayLayer;
60 class ImageSerializationProcessor; 59 class ImageSerializationProcessor;
61 class Layer; 60 class Layer;
61 class LayerTreeHostClient;
62 class LayerTreeHostImpl; 62 class LayerTreeHostImpl;
63 class LayerTreeHostImplClient; 63 class LayerTreeHostImplClient;
64 class LayerTreeHostSingleThreadClient; 64 class LayerTreeHostSingleThreadClient;
65 class LayerTreeMutator; 65 class LayerTreeMutator;
66 class PropertyTrees; 66 class PropertyTrees;
67 class Region; 67 class Region;
68 class RemoteProtoChannel; 68 class RemoteProtoChannel;
69 class RenderingStatsInstrumentation; 69 class RenderingStatsInstrumentation;
70 class ResourceProvider; 70 class ResourceProvider;
71 class ResourceUpdateQueue; 71 class ResourceUpdateQueue;
72 class SharedBitmapManager; 72 class SharedBitmapManager;
73 class TaskGraphRunner; 73 class TaskGraphRunner;
74 class TopControlsManager; 74 class TopControlsManager;
75 struct PendingPageScaleAnimation; 75 struct PendingPageScaleAnimation;
76 struct RenderingStats; 76 struct RenderingStats;
77 struct ScrollAndScaleSet; 77 struct ScrollAndScaleSet;
78 78
79 namespace proto { 79 namespace proto {
80 class LayerTreeHost; 80 class LayerTreeHost;
81 } 81 }
82 82
83 // This class is being refactored to an interface, see LayerTreeHostInterface, 83 class CC_EXPORT LayerTreeHostInProcess : public LayerTreeHost {
84 // which is the API for the cc embedder. When adding new code to this class,
85 // consider the following:
86 // 1) If its state/data that gets pushed to the LayerTreeImpl during commit, add
87 // it to the LayerTree.
88 // 2) If it's a call from the embedder, add it to the LayerTreeHostInterface.
89 // 3) If it's a call from any of the internal cc classes, i.e., LayerTree or
90 // PropertyTreeBuilder, etc., add it to the LayerTreeHostInterface.
91 // 4) If it's a notification from the impl thread or a call from Proxy, add it
92 // to this class.
93 // This class will be renamed to LayerTreeHostInProcess and will be the
94 // LayerTreeHost implementation for when the impl thread for the compositor runs
95 // in the same process, and thus uses a Proxy.
96 class CC_EXPORT LayerTreeHost : public LayerTreeHostInterface {
97 public: 84 public:
98 // TODO(sad): InitParams should be a movable type so that it can be 85 // TODO(sad): InitParams should be a movable type so that it can be
99 // std::move()d to the Create* functions. 86 // std::move()d to the Create* functions.
100 struct CC_EXPORT InitParams { 87 struct CC_EXPORT InitParams {
101 LayerTreeHostClient* client = nullptr; 88 LayerTreeHostClient* client = nullptr;
102 SharedBitmapManager* shared_bitmap_manager = nullptr; 89 SharedBitmapManager* shared_bitmap_manager = nullptr;
103 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = nullptr; 90 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = nullptr;
104 TaskGraphRunner* task_graph_runner = nullptr; 91 TaskGraphRunner* task_graph_runner = nullptr;
105 LayerTreeSettings const* settings = nullptr; 92 LayerTreeSettings const* settings = nullptr;
106 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner; 93 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner;
107 std::unique_ptr<BeginFrameSource> external_begin_frame_source; 94 std::unique_ptr<BeginFrameSource> external_begin_frame_source;
108 ImageSerializationProcessor* image_serialization_processor = nullptr; 95 ImageSerializationProcessor* image_serialization_processor = nullptr;
109 std::unique_ptr<AnimationHost> animation_host; 96 std::unique_ptr<AnimationHost> animation_host;
110 97
111 InitParams(); 98 InitParams();
112 ~InitParams(); 99 ~InitParams();
113 }; 100 };
114 101
115 // The SharedBitmapManager will be used on the compositor thread. 102 // The SharedBitmapManager will be used on the compositor thread.
116 static std::unique_ptr<LayerTreeHostInterface> CreateThreaded( 103 static std::unique_ptr<LayerTreeHostInProcess> CreateThreaded(
117 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, 104 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
118 InitParams* params); 105 InitParams* params);
119 106
120 static std::unique_ptr<LayerTreeHost> CreateSingleThreaded( 107 static std::unique_ptr<LayerTreeHostInProcess> CreateSingleThreaded(
121 LayerTreeHostSingleThreadClient* single_thread_client, 108 LayerTreeHostSingleThreadClient* single_thread_client,
122 InitParams* params); 109 InitParams* params);
123 110
124 static std::unique_ptr<LayerTreeHostInterface> CreateRemoteServer( 111 static std::unique_ptr<LayerTreeHostInProcess> CreateRemoteServer(
125 RemoteProtoChannel* remote_proto_channel, 112 RemoteProtoChannel* remote_proto_channel,
126 InitParams* params); 113 InitParams* params);
127 114
128 // The lifetime of this LayerTreeHost is tied to the lifetime of the remote 115 // The lifetime of this LayerTreeHostInProcess is tied to the lifetime of the
129 // server LayerTreeHost. It should be created on receiving 116 // remote server LayerTreeHostInProcess. It should be created on receiving
130 // CompositorMessageToImpl::InitializeImpl message and destroyed on receiving 117 // CompositorMessageToImpl::InitializeImpl message and destroyed on receiving
131 // a CompositorMessageToImpl::CloseImpl message from the server. This ensures 118 // a CompositorMessageToImpl::CloseImpl message from the server. This ensures
132 // that the client will not send any compositor messages once the 119 // that the client will not send any compositor messages once the
133 // LayerTreeHost on the server is destroyed. 120 // LayerTreeHostInProcess on the server is destroyed.
134 static std::unique_ptr<LayerTreeHostInterface> CreateRemoteClient( 121 static std::unique_ptr<LayerTreeHostInProcess> CreateRemoteClient(
135 RemoteProtoChannel* remote_proto_channel, 122 RemoteProtoChannel* remote_proto_channel,
136 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, 123 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
137 InitParams* params); 124 InitParams* params);
138 125
139 ~LayerTreeHost() override; 126 ~LayerTreeHostInProcess() override;
140 127
141 // LayerTreeHostInterface implementation. 128 // LayerTreeHost implementation.
142 int GetId() const override; 129 int GetId() const override;
143 int SourceFrameNumber() const override; 130 int SourceFrameNumber() const override;
144 LayerTree* GetLayerTree() override; 131 LayerTree* GetLayerTree() override;
145 const LayerTree* GetLayerTree() const override; 132 const LayerTree* GetLayerTree() const override;
146 UIResourceManager* GetUIResourceManager() const override; 133 UIResourceManager* GetUIResourceManager() const override;
147 TaskRunnerProvider* GetTaskRunnerProvider() const override; 134 TaskRunnerProvider* GetTaskRunnerProvider() const override;
148 const LayerTreeSettings& GetSettings() const override; 135 const LayerTreeSettings& GetSettings() const override;
149 void SetSurfaceClientId(uint32_t client_id) override; 136 void SetSurfaceClientId(uint32_t client_id) override;
150 void SetLayerTreeMutator(std::unique_ptr<LayerTreeMutator> mutator) override; 137 void SetLayerTreeMutator(std::unique_ptr<LayerTreeMutator> mutator) override;
151 void QueueSwapPromise(std::unique_ptr<SwapPromise> swap_promise) override; 138 void QueueSwapPromise(std::unique_ptr<SwapPromise> swap_promise) override;
(...skipping 23 matching lines...) Expand all
175 void DidStopFlinging() override; 162 void DidStopFlinging() override;
176 void SetDebugState(const LayerTreeDebugState& debug_state) override; 163 void SetDebugState(const LayerTreeDebugState& debug_state) override;
177 const LayerTreeDebugState& GetDebugState() const override; 164 const LayerTreeDebugState& GetDebugState() const override;
178 int ScheduleMicroBenchmark( 165 int ScheduleMicroBenchmark(
179 const std::string& benchmark_name, 166 const std::string& benchmark_name,
180 std::unique_ptr<base::Value> value, 167 std::unique_ptr<base::Value> value,
181 const MicroBenchmark::DoneCallback& callback) override; 168 const MicroBenchmark::DoneCallback& callback) override;
182 bool SendMessageToMicroBenchmark(int id, 169 bool SendMessageToMicroBenchmark(int id,
183 std::unique_ptr<base::Value> value) override; 170 std::unique_ptr<base::Value> value) override;
184 SurfaceSequenceGenerator* GetSurfaceSequenceGenerator() override; 171 SurfaceSequenceGenerator* GetSurfaceSequenceGenerator() override;
172 void SetNextCommitWaitsForActivation() override;
173 void ResetGpuRasterizationTracking() override;
185 174
186 // LayerTreeHost interface to Proxy. 175 // LayerTreeHostInProcess interface to Proxy.
187 void WillBeginMainFrame(); 176 void WillBeginMainFrame();
188 void DidBeginMainFrame(); 177 void DidBeginMainFrame();
189 void BeginMainFrame(const BeginFrameArgs& args); 178 void BeginMainFrame(const BeginFrameArgs& args);
190 void BeginMainFrameNotExpectedSoon(); 179 void BeginMainFrameNotExpectedSoon();
191 void AnimateLayers(base::TimeTicks monotonic_frame_begin_time); 180 void AnimateLayers(base::TimeTicks monotonic_frame_begin_time);
192 void RequestMainFrameUpdate(); 181 void RequestMainFrameUpdate();
193 void FinishCommitOnImplThread(LayerTreeHostImpl* host_impl); 182 void FinishCommitOnImplThread(LayerTreeHostImpl* host_impl);
194 void WillCommit(); 183 void WillCommit();
195 void CommitComplete(); 184 void CommitComplete();
196 void RequestNewCompositorFrameSink(); 185 void RequestNewCompositorFrameSink();
(...skipping 14 matching lines...) Expand all
211 bool gpu_rasterization_histogram_recorded() const { 200 bool gpu_rasterization_histogram_recorded() const {
212 return gpu_rasterization_histogram_recorded_; 201 return gpu_rasterization_histogram_recorded_;
213 } 202 }
214 203
215 void CollectRenderingStats(RenderingStats* stats) const; 204 void CollectRenderingStats(RenderingStats* stats) const;
216 205
217 RenderingStatsInstrumentation* rendering_stats_instrumentation() const { 206 RenderingStatsInstrumentation* rendering_stats_instrumentation() const {
218 return rendering_stats_instrumentation_.get(); 207 return rendering_stats_instrumentation_.get();
219 } 208 }
220 209
221 void SetNextCommitWaitsForActivation();
222
223 void SetAnimationEvents(std::unique_ptr<AnimationEvents> events); 210 void SetAnimationEvents(std::unique_ptr<AnimationEvents> events);
224 211
225 bool has_gpu_rasterization_trigger() const { 212 bool has_gpu_rasterization_trigger() const {
226 return has_gpu_rasterization_trigger_; 213 return has_gpu_rasterization_trigger_;
227 } 214 }
228 215
229 Proxy* proxy() const { return proxy_.get(); } 216 Proxy* proxy() const { return proxy_.get(); }
230 217
231 // Serializes the parts of this LayerTreeHost that is needed for a commit to a 218 // Serializes the parts of this LayerTreeHostInProcess that is needed for a
232 // protobuf message. Not all members are serialized as they are not helpful 219 // commit to a protobuf message. Not all members are serialized as they are
233 // for remote usage. 220 // not helpful for remote usage.
234 // The |swap_promise_list_| is transferred to the serializer in 221 // The |swap_promise_list_| is transferred to the serializer in
235 // |swap_promises|. 222 // |swap_promises|.
236 void ToProtobufForCommit( 223 void ToProtobufForCommit(
237 proto::LayerTreeHost* proto, 224 proto::LayerTreeHost* proto,
238 std::vector<std::unique_ptr<SwapPromise>>* swap_promises); 225 std::vector<std::unique_ptr<SwapPromise>>* swap_promises);
239 226
240 // Deserializes the protobuf into this LayerTreeHost before a commit. The 227 // Deserializes the protobuf into this LayerTreeHostInProcess before a commit.
241 // expected input is a serialized remote LayerTreeHost. After deserializing 228 // The expected input is a serialized remote LayerTreeHost. After
242 // the protobuf, the normal commit-flow should continue. 229 // deserializing the protobuf, the normal commit-flow should continue.
243 void FromProtobufForCommit(const proto::LayerTreeHost& proto); 230 void FromProtobufForCommit(const proto::LayerTreeHost& proto);
244 231
245 bool IsSingleThreaded() const; 232 bool IsSingleThreaded() const;
246 bool IsThreaded() const; 233 bool IsThreaded() const;
247 bool IsRemoteServer() const; 234 bool IsRemoteServer() const;
248 bool IsRemoteClient() const; 235 bool IsRemoteClient() const;
249 236
250 ImageSerializationProcessor* image_serialization_processor() const { 237 ImageSerializationProcessor* image_serialization_processor() const {
251 return image_serialization_processor_; 238 return image_serialization_processor_;
252 } 239 }
253 240
254 EnginePictureCache* engine_picture_cache() const { 241 EnginePictureCache* engine_picture_cache() const {
255 return engine_picture_cache_ ? engine_picture_cache_.get() : nullptr; 242 return engine_picture_cache_ ? engine_picture_cache_.get() : nullptr;
256 } 243 }
257 244
258 ClientPictureCache* client_picture_cache() const { 245 ClientPictureCache* client_picture_cache() const {
259 return client_picture_cache_ ? client_picture_cache_.get() : nullptr; 246 return client_picture_cache_ ? client_picture_cache_.get() : nullptr;
260 } 247 }
261 248
262 void ResetGpuRasterizationTracking();
263
264 protected: 249 protected:
265 // Allow tests to inject the LayerTree. 250 // Allow tests to inject the LayerTree.
266 LayerTreeHost(InitParams* params, 251 LayerTreeHostInProcess(InitParams* params,
267 CompositorMode mode, 252 CompositorMode mode,
268 std::unique_ptr<LayerTree> layer_tree); 253 std::unique_ptr<LayerTree> layer_tree);
269 LayerTreeHost(InitParams* params, CompositorMode mode); 254 LayerTreeHostInProcess(InitParams* params, CompositorMode mode);
270 255
271 void InitializeThreaded( 256 void InitializeThreaded(
272 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 257 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
273 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, 258 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
274 std::unique_ptr<BeginFrameSource> external_begin_frame_source); 259 std::unique_ptr<BeginFrameSource> external_begin_frame_source);
275 void InitializeSingleThreaded( 260 void InitializeSingleThreaded(
276 LayerTreeHostSingleThreadClient* single_thread_client, 261 LayerTreeHostSingleThreadClient* single_thread_client,
277 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 262 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
278 std::unique_ptr<BeginFrameSource> external_begin_frame_source); 263 std::unique_ptr<BeginFrameSource> external_begin_frame_source);
279 void InitializeRemoteServer( 264 void InitializeRemoteServer(
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 std::unique_ptr<Proxy> proxy_; 329 std::unique_ptr<Proxy> proxy_;
345 std::unique_ptr<TaskRunnerProvider> task_runner_provider_; 330 std::unique_ptr<TaskRunnerProvider> task_runner_provider_;
346 331
347 int source_frame_number_; 332 int source_frame_number_;
348 std::unique_ptr<RenderingStatsInstrumentation> 333 std::unique_ptr<RenderingStatsInstrumentation>
349 rendering_stats_instrumentation_; 334 rendering_stats_instrumentation_;
350 335
351 SwapPromiseManager swap_promise_manager_; 336 SwapPromiseManager swap_promise_manager_;
352 337
353 // |current_compositor_frame_sink_| can't be updated until we've successfully 338 // |current_compositor_frame_sink_| can't be updated until we've successfully
354 // initialized a new CompositorFrameSink. |new_compositor_frame_sink_| 339 // initialized a new output surface. |new_compositor_frame_sink_| contains the
enne (OOO) 2016/09/16 18:19:42 This paragraph looks like a bad rebase? There are
Khushal 2016/09/16 18:38:40 Woops, thanks for catching that. Done.
355 // contains the new CompositorFrameSink that is currently being initialized. 340 // new output surface that is currently being initialized. If initialization
356 // If initialization is successful then |new_compositor_frame_sink_| replaces 341 // is successful then |new_compositor_frame_sink_| replaces
357 // |current_compositor_frame_sink_|. 342 // |current_compositor_frame_sink_|.
358 std::unique_ptr<CompositorFrameSink> new_compositor_frame_sink_; 343 std::unique_ptr<CompositorFrameSink> new_compositor_frame_sink_;
359 std::unique_ptr<CompositorFrameSink> current_compositor_frame_sink_; 344 std::unique_ptr<CompositorFrameSink> current_compositor_frame_sink_;
360 345
361 const LayerTreeSettings settings_; 346 const LayerTreeSettings settings_;
362 LayerTreeDebugState debug_state_; 347 LayerTreeDebugState debug_state_;
363 348
364 bool visible_; 349 bool visible_;
365 350
366 bool has_gpu_rasterization_trigger_; 351 bool has_gpu_rasterization_trigger_;
(...skipping 11 matching lines...) Expand all
378 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; 363 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_;
379 TaskGraphRunner* task_graph_runner_; 364 TaskGraphRunner* task_graph_runner_;
380 365
381 ImageSerializationProcessor* image_serialization_processor_; 366 ImageSerializationProcessor* image_serialization_processor_;
382 std::unique_ptr<EnginePictureCache> engine_picture_cache_; 367 std::unique_ptr<EnginePictureCache> engine_picture_cache_;
383 std::unique_ptr<ClientPictureCache> client_picture_cache_; 368 std::unique_ptr<ClientPictureCache> client_picture_cache_;
384 369
385 SurfaceSequenceGenerator surface_sequence_generator_; 370 SurfaceSequenceGenerator surface_sequence_generator_;
386 uint32_t num_consecutive_frames_suitable_for_gpu_ = 0; 371 uint32_t num_consecutive_frames_suitable_for_gpu_ = 0;
387 372
388 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); 373 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostInProcess);
389 }; 374 };
390 375
391 } // namespace cc 376 } // namespace cc
392 377
393 #endif // CC_TREES_LAYER_TREE_HOST_H_ 378 #endif // CC_TREES_LAYER_TREE_HOST_IN_PROCESS_H_
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_in_process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698