| OLD | NEW |
| 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 #include "cc/trees/layer_tree_host_in_process.h" | 5 #include "cc/trees/layer_tree_host_in_process.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "cc/blimp/picture_data_conversions.h" | 34 #include "cc/blimp/picture_data_conversions.h" |
| 35 #include "cc/debug/devtools_instrumentation.h" | 35 #include "cc/debug/devtools_instrumentation.h" |
| 36 #include "cc/debug/frame_viewer_instrumentation.h" | 36 #include "cc/debug/frame_viewer_instrumentation.h" |
| 37 #include "cc/debug/rendering_stats_instrumentation.h" | 37 #include "cc/debug/rendering_stats_instrumentation.h" |
| 38 #include "cc/input/layer_selection_bound.h" | 38 #include "cc/input/layer_selection_bound.h" |
| 39 #include "cc/input/page_scale_animation.h" | 39 #include "cc/input/page_scale_animation.h" |
| 40 #include "cc/layers/heads_up_display_layer.h" | 40 #include "cc/layers/heads_up_display_layer.h" |
| 41 #include "cc/layers/heads_up_display_layer_impl.h" | 41 #include "cc/layers/heads_up_display_layer_impl.h" |
| 42 #include "cc/layers/layer.h" | 42 #include "cc/layers/layer.h" |
| 43 #include "cc/layers/layer_iterator.h" | 43 #include "cc/layers/layer_iterator.h" |
| 44 #include "cc/layers/layer_proto_converter.h" | |
| 45 #include "cc/layers/painted_scrollbar_layer.h" | 44 #include "cc/layers/painted_scrollbar_layer.h" |
| 46 #include "cc/proto/gfx_conversions.h" | |
| 47 #include "cc/proto/layer_tree.pb.h" | |
| 48 #include "cc/proto/layer_tree_host.pb.h" | |
| 49 #include "cc/resources/ui_resource_manager.h" | 45 #include "cc/resources/ui_resource_manager.h" |
| 50 #include "cc/trees/draw_property_utils.h" | 46 #include "cc/trees/draw_property_utils.h" |
| 51 #include "cc/trees/layer_tree_host_client.h" | 47 #include "cc/trees/layer_tree_host_client.h" |
| 52 #include "cc/trees/layer_tree_host_common.h" | 48 #include "cc/trees/layer_tree_host_common.h" |
| 53 #include "cc/trees/layer_tree_host_impl.h" | 49 #include "cc/trees/layer_tree_host_impl.h" |
| 54 #include "cc/trees/layer_tree_impl.h" | 50 #include "cc/trees/layer_tree_impl.h" |
| 55 #include "cc/trees/mutator_host.h" | 51 #include "cc/trees/mutator_host.h" |
| 56 #include "cc/trees/property_tree_builder.h" | 52 #include "cc/trees/property_tree_builder.h" |
| 57 #include "cc/trees/proxy_main.h" | 53 #include "cc/trees/proxy_main.h" |
| 58 #include "cc/trees/remote_channel_impl.h" | |
| 59 #include "cc/trees/single_thread_proxy.h" | 54 #include "cc/trees/single_thread_proxy.h" |
| 60 #include "cc/trees/swap_promise_manager.h" | 55 #include "cc/trees/swap_promise_manager.h" |
| 61 #include "cc/trees/tree_synchronizer.h" | 56 #include "cc/trees/tree_synchronizer.h" |
| 62 #include "ui/gfx/geometry/size_conversions.h" | 57 #include "ui/gfx/geometry/size_conversions.h" |
| 63 #include "ui/gfx/geometry/vector2d_conversions.h" | 58 #include "ui/gfx/geometry/vector2d_conversions.h" |
| 64 | 59 |
| 65 namespace { | 60 namespace { |
| 66 static base::StaticAtomicSequenceNumber s_layer_tree_host_sequence_number; | 61 static base::StaticAtomicSequenceNumber s_layer_tree_host_sequence_number; |
| 67 } | 62 } |
| 68 | 63 |
| 69 namespace cc { | 64 namespace cc { |
| 70 namespace { | |
| 71 | |
| 72 std::unique_ptr<base::trace_event::TracedValue> | |
| 73 ComputeLayerTreeHostProtoSizeSplitAsValue(proto::LayerTreeHost* proto) { | |
| 74 std::unique_ptr<base::trace_event::TracedValue> value( | |
| 75 new base::trace_event::TracedValue()); | |
| 76 base::CheckedNumeric<int> base_layer_properties_size = 0; | |
| 77 base::CheckedNumeric<int> picture_layer_properties_size = 0; | |
| 78 base::CheckedNumeric<int> display_item_list_size = 0; | |
| 79 base::CheckedNumeric<int> drawing_display_items_size = 0; | |
| 80 | |
| 81 const proto::LayerUpdate& layer_update_proto = proto->layer_updates(); | |
| 82 for (int i = 0; i < layer_update_proto.layers_size(); ++i) { | |
| 83 const proto::LayerProperties layer_properties_proto = | |
| 84 layer_update_proto.layers(i); | |
| 85 base_layer_properties_size += layer_properties_proto.base().ByteSize(); | |
| 86 | |
| 87 if (layer_properties_proto.has_picture()) { | |
| 88 const proto::PictureLayerProperties& picture_proto = | |
| 89 layer_properties_proto.picture(); | |
| 90 picture_layer_properties_size += picture_proto.ByteSize(); | |
| 91 | |
| 92 const proto::DisplayItemList& display_list_proto = | |
| 93 picture_proto.display_list(); | |
| 94 display_item_list_size += display_list_proto.ByteSize(); | |
| 95 | |
| 96 for (int j = 0; j < display_list_proto.items_size(); ++j) { | |
| 97 const proto::DisplayItem& display_item = display_list_proto.items(j); | |
| 98 if (display_item.type() == proto::DisplayItem::Type_Drawing) | |
| 99 drawing_display_items_size += display_item.ByteSize(); | |
| 100 } | |
| 101 } | |
| 102 } | |
| 103 | |
| 104 value->SetInteger("TotalLayerTreeHostProtoSize", proto->ByteSize()); | |
| 105 value->SetInteger("LayerTreeHierarchySize", | |
| 106 proto->layer_tree().root_layer().ByteSize()); | |
| 107 value->SetInteger("LayerUpdatesSize", proto->layer_updates().ByteSize()); | |
| 108 value->SetInteger("PropertyTreesSize", | |
| 109 proto->layer_tree().property_trees().ByteSize()); | |
| 110 | |
| 111 // LayerUpdate size breakdown. | |
| 112 value->SetInteger("TotalBasePropertiesSize", | |
| 113 base_layer_properties_size.ValueOrDefault(-1)); | |
| 114 value->SetInteger("PictureLayerPropertiesSize", | |
| 115 picture_layer_properties_size.ValueOrDefault(-1)); | |
| 116 value->SetInteger("DisplayItemListSize", | |
| 117 display_item_list_size.ValueOrDefault(-1)); | |
| 118 value->SetInteger("DrawingDisplayItemsSize", | |
| 119 drawing_display_items_size.ValueOrDefault(-1)); | |
| 120 return value; | |
| 121 } | |
| 122 | |
| 123 } // namespace | |
| 124 | 65 |
| 125 LayerTreeHostInProcess::InitParams::InitParams() {} | 66 LayerTreeHostInProcess::InitParams::InitParams() {} |
| 126 | 67 |
| 127 LayerTreeHostInProcess::InitParams::~InitParams() {} | 68 LayerTreeHostInProcess::InitParams::~InitParams() {} |
| 128 | 69 |
| 129 std::unique_ptr<LayerTreeHostInProcess> LayerTreeHostInProcess::CreateThreaded( | 70 std::unique_ptr<LayerTreeHostInProcess> LayerTreeHostInProcess::CreateThreaded( |
| 130 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 71 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 131 InitParams* params) { | 72 InitParams* params) { |
| 132 DCHECK(params->main_task_runner.get()); | 73 DCHECK(params->main_task_runner.get()); |
| 133 DCHECK(impl_task_runner.get()); | 74 DCHECK(impl_task_runner.get()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 144 LayerTreeHostSingleThreadClient* single_thread_client, | 85 LayerTreeHostSingleThreadClient* single_thread_client, |
| 145 InitParams* params) { | 86 InitParams* params) { |
| 146 DCHECK(params->settings); | 87 DCHECK(params->settings); |
| 147 std::unique_ptr<LayerTreeHostInProcess> layer_tree_host( | 88 std::unique_ptr<LayerTreeHostInProcess> layer_tree_host( |
| 148 new LayerTreeHostInProcess(params, CompositorMode::SINGLE_THREADED)); | 89 new LayerTreeHostInProcess(params, CompositorMode::SINGLE_THREADED)); |
| 149 layer_tree_host->InitializeSingleThreaded(single_thread_client, | 90 layer_tree_host->InitializeSingleThreaded(single_thread_client, |
| 150 params->main_task_runner); | 91 params->main_task_runner); |
| 151 return layer_tree_host; | 92 return layer_tree_host; |
| 152 } | 93 } |
| 153 | 94 |
| 154 std::unique_ptr<LayerTreeHostInProcess> | |
| 155 LayerTreeHostInProcess::CreateRemoteServer( | |
| 156 RemoteProtoChannel* remote_proto_channel, | |
| 157 InitParams* params) { | |
| 158 DCHECK(params->main_task_runner.get()); | |
| 159 DCHECK(params->settings); | |
| 160 DCHECK(remote_proto_channel); | |
| 161 TRACE_EVENT0("cc.remote", "LayerTreeHostInProcess::CreateRemoteServer"); | |
| 162 | |
| 163 DCHECK(params->image_serialization_processor); | |
| 164 | |
| 165 std::unique_ptr<LayerTreeHostInProcess> layer_tree_host( | |
| 166 new LayerTreeHostInProcess(params, CompositorMode::REMOTE)); | |
| 167 layer_tree_host->InitializeRemoteServer(remote_proto_channel, | |
| 168 params->main_task_runner); | |
| 169 return layer_tree_host; | |
| 170 } | |
| 171 | |
| 172 std::unique_ptr<LayerTreeHostInProcess> | |
| 173 LayerTreeHostInProcess::CreateRemoteClient( | |
| 174 RemoteProtoChannel* remote_proto_channel, | |
| 175 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | |
| 176 InitParams* params) { | |
| 177 DCHECK(params->main_task_runner.get()); | |
| 178 DCHECK(params->settings); | |
| 179 DCHECK(remote_proto_channel); | |
| 180 DCHECK(params->image_serialization_processor); | |
| 181 | |
| 182 std::unique_ptr<LayerTreeHostInProcess> layer_tree_host( | |
| 183 new LayerTreeHostInProcess(params, CompositorMode::REMOTE)); | |
| 184 layer_tree_host->InitializeRemoteClient( | |
| 185 remote_proto_channel, params->main_task_runner, impl_task_runner); | |
| 186 return layer_tree_host; | |
| 187 } | |
| 188 | |
| 189 LayerTreeHostInProcess::LayerTreeHostInProcess(InitParams* params, | 95 LayerTreeHostInProcess::LayerTreeHostInProcess(InitParams* params, |
| 190 CompositorMode mode) | 96 CompositorMode mode) |
| 191 : LayerTreeHostInProcess( | 97 : LayerTreeHostInProcess( |
| 192 params, | 98 params, |
| 193 mode, | 99 mode, |
| 194 base::MakeUnique<LayerTree>(params->mutator_host, this)) {} | 100 base::MakeUnique<LayerTree>(params->mutator_host, this)) {} |
| 195 | 101 |
| 196 LayerTreeHostInProcess::LayerTreeHostInProcess( | 102 LayerTreeHostInProcess::LayerTreeHostInProcess( |
| 197 InitParams* params, | 103 InitParams* params, |
| 198 CompositorMode mode, | 104 CompositorMode mode, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 209 visible_(false), | 115 visible_(false), |
| 210 has_gpu_rasterization_trigger_(false), | 116 has_gpu_rasterization_trigger_(false), |
| 211 content_is_suitable_for_gpu_rasterization_(true), | 117 content_is_suitable_for_gpu_rasterization_(true), |
| 212 gpu_rasterization_histogram_recorded_(false), | 118 gpu_rasterization_histogram_recorded_(false), |
| 213 did_complete_scale_animation_(false), | 119 did_complete_scale_animation_(false), |
| 214 id_(s_layer_tree_host_sequence_number.GetNext() + 1), | 120 id_(s_layer_tree_host_sequence_number.GetNext() + 1), |
| 215 task_graph_runner_(params->task_graph_runner), | 121 task_graph_runner_(params->task_graph_runner), |
| 216 image_serialization_processor_(params->image_serialization_processor) { | 122 image_serialization_processor_(params->image_serialization_processor) { |
| 217 DCHECK(task_graph_runner_); | 123 DCHECK(task_graph_runner_); |
| 218 DCHECK(layer_tree_); | 124 DCHECK(layer_tree_); |
| 125 DCHECK_NE(compositor_mode_, CompositorMode::REMOTE); |
| 219 | 126 |
| 220 rendering_stats_instrumentation_->set_record_rendering_stats( | 127 rendering_stats_instrumentation_->set_record_rendering_stats( |
| 221 debug_state_.RecordRenderingStats()); | 128 debug_state_.RecordRenderingStats()); |
| 222 } | 129 } |
| 223 | 130 |
| 224 void LayerTreeHostInProcess::InitializeThreaded( | 131 void LayerTreeHostInProcess::InitializeThreaded( |
| 225 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 132 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 226 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 133 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
| 227 task_runner_provider_ = | 134 task_runner_provider_ = |
| 228 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); | 135 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); |
| 229 std::unique_ptr<ProxyMain> proxy_main = | 136 std::unique_ptr<ProxyMain> proxy_main = |
| 230 ProxyMain::CreateThreaded(this, task_runner_provider_.get()); | 137 ProxyMain::CreateThreaded(this, task_runner_provider_.get()); |
| 231 InitializeProxy(std::move(proxy_main)); | 138 InitializeProxy(std::move(proxy_main)); |
| 232 } | 139 } |
| 233 | 140 |
| 234 void LayerTreeHostInProcess::InitializeSingleThreaded( | 141 void LayerTreeHostInProcess::InitializeSingleThreaded( |
| 235 LayerTreeHostSingleThreadClient* single_thread_client, | 142 LayerTreeHostSingleThreadClient* single_thread_client, |
| 236 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) { | 143 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) { |
| 237 task_runner_provider_ = TaskRunnerProvider::Create(main_task_runner, nullptr); | 144 task_runner_provider_ = TaskRunnerProvider::Create(main_task_runner, nullptr); |
| 238 InitializeProxy(SingleThreadProxy::Create(this, single_thread_client, | 145 InitializeProxy(SingleThreadProxy::Create(this, single_thread_client, |
| 239 task_runner_provider_.get())); | 146 task_runner_provider_.get())); |
| 240 } | 147 } |
| 241 | 148 |
| 242 void LayerTreeHostInProcess::InitializeRemoteServer( | |
| 243 RemoteProtoChannel* remote_proto_channel, | |
| 244 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) { | |
| 245 task_runner_provider_ = TaskRunnerProvider::Create(main_task_runner, nullptr); | |
| 246 | |
| 247 if (image_serialization_processor_) { | |
| 248 engine_picture_cache_ = | |
| 249 image_serialization_processor_->CreateEnginePictureCache(); | |
| 250 layer_tree_->set_engine_picture_cache(engine_picture_cache_.get()); | |
| 251 } | |
| 252 InitializeProxy(ProxyMain::CreateRemote(remote_proto_channel, this, | |
| 253 task_runner_provider_.get())); | |
| 254 } | |
| 255 | |
| 256 void LayerTreeHostInProcess::InitializeRemoteClient( | |
| 257 RemoteProtoChannel* remote_proto_channel, | |
| 258 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | |
| 259 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | |
| 260 task_runner_provider_ = | |
| 261 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); | |
| 262 | |
| 263 if (image_serialization_processor_) { | |
| 264 client_picture_cache_ = | |
| 265 image_serialization_processor_->CreateClientPictureCache(); | |
| 266 layer_tree_->set_client_picture_cache(client_picture_cache_.get()); | |
| 267 } | |
| 268 | |
| 269 // For the remote mode, the RemoteChannelImpl implements the Proxy, which is | |
| 270 // owned by the LayerTreeHostInProcess. The RemoteChannelImpl pipes requests | |
| 271 // which need to handled locally, for instance the Output Surface creation to | |
| 272 // the LayerTreeHostInProcess on the client, while the other requests are sent | |
| 273 // to the RemoteChannelMain on the server which directs them to ProxyMain and | |
| 274 // the remote server LayerTreeHostInProcess. | |
| 275 InitializeProxy(base::MakeUnique<RemoteChannelImpl>( | |
| 276 this, remote_proto_channel, task_runner_provider_.get())); | |
| 277 } | |
| 278 | |
| 279 void LayerTreeHostInProcess::InitializeForTesting( | 149 void LayerTreeHostInProcess::InitializeForTesting( |
| 280 std::unique_ptr<TaskRunnerProvider> task_runner_provider, | 150 std::unique_ptr<TaskRunnerProvider> task_runner_provider, |
| 281 std::unique_ptr<Proxy> proxy_for_testing) { | 151 std::unique_ptr<Proxy> proxy_for_testing) { |
| 282 task_runner_provider_ = std::move(task_runner_provider); | 152 task_runner_provider_ = std::move(task_runner_provider); |
| 283 | 153 |
| 284 InitializePictureCacheForTesting(); | 154 InitializePictureCacheForTesting(); |
| 285 | 155 |
| 286 InitializeProxy(std::move(proxy_for_testing)); | 156 InitializeProxy(std::move(proxy_for_testing)); |
| 287 } | 157 } |
| 288 | 158 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 client_->UpdateLayerTreeHost(); | 283 client_->UpdateLayerTreeHost(); |
| 414 } | 284 } |
| 415 | 285 |
| 416 // This function commits the LayerTreeHost to an impl tree. When modifying | 286 // This function commits the LayerTreeHost to an impl tree. When modifying |
| 417 // this function, keep in mind that the function *runs* on the impl thread! Any | 287 // this function, keep in mind that the function *runs* on the impl thread! Any |
| 418 // code that is logically a main thread operation, e.g. deletion of a Layer, | 288 // code that is logically a main thread operation, e.g. deletion of a Layer, |
| 419 // should be delayed until the LayerTreeHostInProcess::CommitComplete, which | 289 // should be delayed until the LayerTreeHostInProcess::CommitComplete, which |
| 420 // will run after the commit, but on the main thread. | 290 // will run after the commit, but on the main thread. |
| 421 void LayerTreeHostInProcess::FinishCommitOnImplThread( | 291 void LayerTreeHostInProcess::FinishCommitOnImplThread( |
| 422 LayerTreeHostImpl* host_impl) { | 292 LayerTreeHostImpl* host_impl) { |
| 423 DCHECK(!IsRemoteServer()); | |
| 424 DCHECK(task_runner_provider_->IsImplThread()); | 293 DCHECK(task_runner_provider_->IsImplThread()); |
| 425 | 294 |
| 426 bool is_new_trace; | 295 bool is_new_trace; |
| 427 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); | 296 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); |
| 428 if (is_new_trace && | 297 if (is_new_trace && |
| 429 frame_viewer_instrumentation::IsTracingLayerTreeSnapshots() && | 298 frame_viewer_instrumentation::IsTracingLayerTreeSnapshots() && |
| 430 layer_tree_->root_layer()) { | 299 layer_tree_->root_layer()) { |
| 431 LayerTreeHostCommon::CallFunctionForEveryLayer( | 300 LayerTreeHostCommon::CallFunctionForEveryLayer( |
| 432 layer_tree_.get(), [](Layer* layer) { layer->DidBeginTracing(); }); | 301 layer_tree_.get(), [](Layer* layer) { layer->DidBeginTracing(); }); |
| 433 } | 302 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 // LayerTreeHostImpl will not keep a pointer to either the old or | 426 // LayerTreeHostImpl will not keep a pointer to either the old or |
| 558 // new CompositorFrameSink after failing to initialize the new one. | 427 // new CompositorFrameSink after failing to initialize the new one. |
| 559 current_compositor_frame_sink_ = nullptr; | 428 current_compositor_frame_sink_ = nullptr; |
| 560 new_compositor_frame_sink_ = nullptr; | 429 new_compositor_frame_sink_ = nullptr; |
| 561 client_->DidFailToInitializeCompositorFrameSink(); | 430 client_->DidFailToInitializeCompositorFrameSink(); |
| 562 } | 431 } |
| 563 | 432 |
| 564 std::unique_ptr<LayerTreeHostImpl> | 433 std::unique_ptr<LayerTreeHostImpl> |
| 565 LayerTreeHostInProcess::CreateLayerTreeHostImpl( | 434 LayerTreeHostInProcess::CreateLayerTreeHostImpl( |
| 566 LayerTreeHostImplClient* client) { | 435 LayerTreeHostImplClient* client) { |
| 567 DCHECK(!IsRemoteServer()); | |
| 568 DCHECK(task_runner_provider_->IsImplThread()); | 436 DCHECK(task_runner_provider_->IsImplThread()); |
| 569 | 437 |
| 570 const bool supports_impl_scrolling = task_runner_provider_->HasImplThread(); | 438 const bool supports_impl_scrolling = task_runner_provider_->HasImplThread(); |
| 571 std::unique_ptr<MutatorHost> mutator_host_impl = | 439 std::unique_ptr<MutatorHost> mutator_host_impl = |
| 572 layer_tree_->mutator_host()->CreateImplInstance(supports_impl_scrolling); | 440 layer_tree_->mutator_host()->CreateImplInstance(supports_impl_scrolling); |
| 573 | 441 |
| 574 std::unique_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( | 442 std::unique_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( |
| 575 settings_, client, task_runner_provider_.get(), | 443 settings_, client, task_runner_provider_.get(), |
| 576 rendering_stats_instrumentation_.get(), task_graph_runner_, | 444 rendering_stats_instrumentation_.get(), task_graph_runner_, |
| 577 std::move(mutator_host_impl), id_); | 445 std::move(mutator_host_impl), id_); |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 | 773 |
| 906 const base::WeakPtr<InputHandler>& LayerTreeHostInProcess::GetInputHandler() | 774 const base::WeakPtr<InputHandler>& LayerTreeHostInProcess::GetInputHandler() |
| 907 const { | 775 const { |
| 908 return input_handler_weak_ptr_; | 776 return input_handler_weak_ptr_; |
| 909 } | 777 } |
| 910 | 778 |
| 911 void LayerTreeHostInProcess::UpdateBrowserControlsState( | 779 void LayerTreeHostInProcess::UpdateBrowserControlsState( |
| 912 BrowserControlsState constraints, | 780 BrowserControlsState constraints, |
| 913 BrowserControlsState current, | 781 BrowserControlsState current, |
| 914 bool animate) { | 782 bool animate) { |
| 915 // Browser controls are only used in threaded or remote mode. | 783 // Browser controls are only used in threaded mode. |
| 916 DCHECK(IsThreaded() || IsRemoteServer()); | 784 DCHECK(IsThreaded()); |
| 917 proxy_->UpdateBrowserControlsState(constraints, current, animate); | 785 proxy_->UpdateBrowserControlsState(constraints, current, animate); |
| 918 } | 786 } |
| 919 | 787 |
| 920 void LayerTreeHostInProcess::AnimateLayers(base::TimeTicks monotonic_time) { | 788 void LayerTreeHostInProcess::AnimateLayers(base::TimeTicks monotonic_time) { |
| 921 MutatorHost* mutator_host = layer_tree_->mutator_host(); | 789 MutatorHost* mutator_host = layer_tree_->mutator_host(); |
| 922 std::unique_ptr<MutatorEvents> events = mutator_host->CreateEvents(); | 790 std::unique_ptr<MutatorEvents> events = mutator_host->CreateEvents(); |
| 923 | 791 |
| 924 if (mutator_host->AnimateLayers(monotonic_time)) | 792 if (mutator_host->AnimateLayers(monotonic_time)) |
| 925 mutator_host->UpdateAnimationState(true, events.get()); | 793 mutator_host->UpdateAnimationState(true, events.get()); |
| 926 | 794 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 952 !task_runner_provider_->HasImplThread()); | 820 !task_runner_provider_->HasImplThread()); |
| 953 return compositor_mode_ == CompositorMode::SINGLE_THREADED; | 821 return compositor_mode_ == CompositorMode::SINGLE_THREADED; |
| 954 } | 822 } |
| 955 | 823 |
| 956 bool LayerTreeHostInProcess::IsThreaded() const { | 824 bool LayerTreeHostInProcess::IsThreaded() const { |
| 957 DCHECK(compositor_mode_ != CompositorMode::THREADED || | 825 DCHECK(compositor_mode_ != CompositorMode::THREADED || |
| 958 task_runner_provider_->HasImplThread()); | 826 task_runner_provider_->HasImplThread()); |
| 959 return compositor_mode_ == CompositorMode::THREADED; | 827 return compositor_mode_ == CompositorMode::THREADED; |
| 960 } | 828 } |
| 961 | 829 |
| 962 bool LayerTreeHostInProcess::IsRemoteServer() const { | |
| 963 // The LayerTreeHostInProcess on the server does not have an impl task runner. | |
| 964 return compositor_mode_ == CompositorMode::REMOTE && | |
| 965 !task_runner_provider_->HasImplThread(); | |
| 966 } | |
| 967 | |
| 968 bool LayerTreeHostInProcess::IsRemoteClient() const { | |
| 969 return compositor_mode_ == CompositorMode::REMOTE && | |
| 970 task_runner_provider_->HasImplThread(); | |
| 971 } | |
| 972 | |
| 973 void LayerTreeHostInProcess::ToProtobufForCommit( | |
| 974 proto::LayerTreeHost* proto, | |
| 975 std::vector<std::unique_ptr<SwapPromise>>* swap_promises) { | |
| 976 DCHECK(engine_picture_cache_); | |
| 977 // Not all fields are serialized, as they are either not needed for a commit, | |
| 978 // or implementation isn't ready yet. | |
| 979 // Unsupported items: | |
| 980 // - animations | |
| 981 // - UI resources | |
| 982 // - instrumentation of stats | |
| 983 // - histograms | |
| 984 // Skipped items: | |
| 985 // - SwapPromise as they are mostly used for perf measurements. | |
| 986 // - The bitmap and GPU memory related items. | |
| 987 // Other notes: | |
| 988 // - The output surfaces are only valid on the client-side so they are | |
| 989 // therefore not serialized. | |
| 990 // - LayerTreeSettings are needed only during construction of the | |
| 991 // LayerTreeHostInProcess, so they are serialized outside of the | |
| 992 // LayerTreeHostInProcess | |
| 993 // serialization. | |
| 994 // - The |visible_| flag will be controlled from the client separately and | |
| 995 // will need special handling outside of the serialization of the | |
| 996 // LayerTreeHostInProcess. | |
| 997 // TODO(nyquist): Figure out how to support animations. See crbug.com/570376. | |
| 998 TRACE_EVENT0("cc.remote", "LayerTreeHostInProcess::ToProtobufForCommit"); | |
| 999 *swap_promises = swap_promise_manager_.TakeSwapPromises(); | |
| 1000 | |
| 1001 proto->set_source_frame_number(source_frame_number_); | |
| 1002 | |
| 1003 // Serialize the LayerTree before serializing the properties. During layer | |
| 1004 // property serialization, we clear the list |layer_that_should_properties_| | |
| 1005 // from the LayerTree. | |
| 1006 // The serialization code here need to serialize the complete state, including | |
| 1007 // the result of the main frame update. | |
| 1008 const bool inputs_only = false; | |
| 1009 layer_tree_->ToProtobuf(proto->mutable_layer_tree(), inputs_only); | |
| 1010 | |
| 1011 LayerProtoConverter::SerializeLayerProperties(this, | |
| 1012 proto->mutable_layer_updates()); | |
| 1013 | |
| 1014 std::vector<PictureData> pictures = | |
| 1015 engine_picture_cache_->CalculateCacheUpdateAndFlush(); | |
| 1016 proto::PictureDataVectorToSkPicturesProto(pictures, | |
| 1017 proto->mutable_pictures()); | |
| 1018 | |
| 1019 debug_state_.ToProtobuf(proto->mutable_debug_state()); | |
| 1020 proto->set_has_gpu_rasterization_trigger(has_gpu_rasterization_trigger_); | |
| 1021 proto->set_content_is_suitable_for_gpu_rasterization( | |
| 1022 content_is_suitable_for_gpu_rasterization_); | |
| 1023 proto->set_id(id_); | |
| 1024 proto->set_next_commit_forces_redraw(next_commit_forces_redraw_); | |
| 1025 | |
| 1026 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( | |
| 1027 "cc.remote", "LayerTreeHostProto", source_frame_number_, | |
| 1028 ComputeLayerTreeHostProtoSizeSplitAsValue(proto)); | |
| 1029 } | |
| 1030 | |
| 1031 void LayerTreeHostInProcess::FromProtobufForCommit( | |
| 1032 const proto::LayerTreeHost& proto) { | |
| 1033 DCHECK(client_picture_cache_); | |
| 1034 source_frame_number_ = proto.source_frame_number(); | |
| 1035 | |
| 1036 layer_tree_->FromProtobuf(proto.layer_tree()); | |
| 1037 | |
| 1038 // Ensure ClientPictureCache contains all the necessary SkPictures before | |
| 1039 // deserializing the properties. | |
| 1040 proto::SkPictures proto_pictures = proto.pictures(); | |
| 1041 std::vector<PictureData> pictures = | |
| 1042 SkPicturesProtoToPictureDataVector(proto_pictures); | |
| 1043 client_picture_cache_->ApplyCacheUpdate(pictures); | |
| 1044 | |
| 1045 LayerProtoConverter::DeserializeLayerProperties(layer_tree_->root_layer(), | |
| 1046 proto.layer_updates()); | |
| 1047 | |
| 1048 // The deserialization is finished, so now clear the cache. | |
| 1049 client_picture_cache_->Flush(); | |
| 1050 | |
| 1051 debug_state_.FromProtobuf(proto.debug_state()); | |
| 1052 has_gpu_rasterization_trigger_ = proto.has_gpu_rasterization_trigger(); | |
| 1053 content_is_suitable_for_gpu_rasterization_ = | |
| 1054 proto.content_is_suitable_for_gpu_rasterization(); | |
| 1055 id_ = proto.id(); | |
| 1056 next_commit_forces_redraw_ = proto.next_commit_forces_redraw(); | |
| 1057 } | |
| 1058 | |
| 1059 } // namespace cc | 830 } // namespace cc |
| OLD | NEW |