| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "blimp/client/core/compositor/blimp_compositor.h" | 5 #include "blimp/client/core/compositor/blimp_compositor.h" |
| 6 | 6 |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 if (!surface) { | 51 if (!surface) { |
| 52 LOG(ERROR) << "Attempting to require callback on nonexistent surface"; | 52 LOG(ERROR) << "Attempting to require callback on nonexistent surface"; |
| 53 return; | 53 return; |
| 54 } | 54 } |
| 55 surface->AddDestructionDependency(sequence); | 55 surface->AddDestructionDependency(sequence); |
| 56 } | 56 } |
| 57 | 57 |
| 58 } // namespace | 58 } // namespace |
| 59 | 59 |
| 60 BlimpCompositor::BlimpCompositor( | 60 BlimpCompositor::BlimpCompositor( |
| 61 int render_widget_id, | |
| 62 BlimpCompositorDependencies* compositor_dependencies, | 61 BlimpCompositorDependencies* compositor_dependencies, |
| 63 BlimpCompositorClient* client) | 62 BlimpCompositorClient* client) |
| 64 : render_widget_id_(render_widget_id), | 63 : client_(client), |
| 65 client_(client), | |
| 66 compositor_dependencies_(compositor_dependencies), | 64 compositor_dependencies_(compositor_dependencies), |
| 67 frame_sink_id_(compositor_dependencies_->GetEmbedderDependencies() | 65 frame_sink_id_(compositor_dependencies_->GetEmbedderDependencies() |
| 68 ->AllocateFrameSinkId()), | 66 ->AllocateFrameSinkId()), |
| 69 proxy_client_(nullptr), | 67 proxy_client_(nullptr), |
| 70 compositor_frame_sink_request_pending_(false), | 68 compositor_frame_sink_request_pending_(false), |
| 71 layer_(cc::Layer::Create()), | 69 layer_(cc::Layer::Create()), |
| 72 remote_proto_channel_receiver_(nullptr), | 70 remote_proto_channel_receiver_(nullptr), |
| 73 outstanding_commits_(0U), | 71 outstanding_commits_(0U), |
| 74 weak_ptr_factory_(this) { | 72 weak_ptr_factory_(this) { |
| 75 DCHECK(thread_checker_.CalledOnValidThread()); | 73 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 131 |
| 134 CheckPendingCommitCounts(false /* flush */); | 132 CheckPendingCommitCounts(false /* flush */); |
| 135 } | 133 } |
| 136 | 134 |
| 137 void BlimpCompositor::SetProtoReceiver(ProtoReceiver* receiver) { | 135 void BlimpCompositor::SetProtoReceiver(ProtoReceiver* receiver) { |
| 138 remote_proto_channel_receiver_ = receiver; | 136 remote_proto_channel_receiver_ = receiver; |
| 139 } | 137 } |
| 140 | 138 |
| 141 void BlimpCompositor::SendCompositorProto( | 139 void BlimpCompositor::SendCompositorProto( |
| 142 const cc::proto::CompositorMessage& proto) { | 140 const cc::proto::CompositorMessage& proto) { |
| 143 client_->SendCompositorMessage(render_widget_id_, proto); | 141 client_->SendCompositorMessage(proto); |
| 144 } | 142 } |
| 145 | 143 |
| 146 void BlimpCompositor::OnCompositorMessageReceived( | 144 void BlimpCompositor::OnCompositorMessageReceived( |
| 147 std::unique_ptr<cc::proto::CompositorMessage> message) { | 145 std::unique_ptr<cc::proto::CompositorMessage> message) { |
| 148 DCHECK(message->has_to_impl()); | 146 DCHECK(message->has_to_impl()); |
| 149 const cc::proto::CompositorMessageToImpl& to_impl_proto = message->to_impl(); | 147 const cc::proto::CompositorMessageToImpl& to_impl_proto = message->to_impl(); |
| 150 | 148 |
| 151 DCHECK(to_impl_proto.has_message_type()); | 149 DCHECK(to_impl_proto.has_message_type()); |
| 152 | 150 |
| 153 if (to_impl_proto.message_type() == | 151 if (to_impl_proto.message_type() == |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 auto compositor_frame_sink = base::MakeUnique<BlimpCompositorFrameSink>( | 191 auto compositor_frame_sink = base::MakeUnique<BlimpCompositorFrameSink>( |
| 194 std::move(compositor_context_provider), | 192 std::move(compositor_context_provider), |
| 195 std::move(worker_context_provider), base::ThreadTaskRunnerHandle::Get(), | 193 std::move(worker_context_provider), base::ThreadTaskRunnerHandle::Get(), |
| 196 weak_ptr_factory_.GetWeakPtr()); | 194 weak_ptr_factory_.GetWeakPtr()); |
| 197 | 195 |
| 198 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); | 196 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); |
| 199 } | 197 } |
| 200 | 198 |
| 201 void BlimpCompositor::SendWebGestureEvent( | 199 void BlimpCompositor::SendWebGestureEvent( |
| 202 const blink::WebGestureEvent& gesture_event) { | 200 const blink::WebGestureEvent& gesture_event) { |
| 203 client_->SendWebGestureEvent(render_widget_id_, gesture_event); | 201 client_->SendWebGestureEvent(gesture_event); |
| 204 } | 202 } |
| 205 | 203 |
| 206 void BlimpCompositor::BindToProxyClient( | 204 void BlimpCompositor::BindToProxyClient( |
| 207 base::WeakPtr<BlimpCompositorFrameSinkProxyClient> proxy_client) { | 205 base::WeakPtr<BlimpCompositorFrameSinkProxyClient> proxy_client) { |
| 208 DCHECK(thread_checker_.CalledOnValidThread()); | 206 DCHECK(thread_checker_.CalledOnValidThread()); |
| 209 DCHECK(!surface_factory_); | 207 DCHECK(!surface_factory_); |
| 210 | 208 |
| 211 proxy_client_ = proxy_client; | 209 proxy_client_ = proxy_client; |
| 212 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>( | 210 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>( |
| 213 frame_sink_id_, GetEmbedderDeps()->GetSurfaceManager(), this); | 211 frame_sink_id_, GetEmbedderDeps()->GetSurfaceManager(), this); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 276 |
| 279 // Remove any references for the surface layer that uses this | 277 // Remove any references for the surface layer that uses this |
| 280 // |local_frame_id_|. | 278 // |local_frame_id_|. |
| 281 layer_->RemoveAllChildren(); | 279 layer_->RemoveAllChildren(); |
| 282 surface_factory_->Destroy(local_frame_id_); | 280 surface_factory_->Destroy(local_frame_id_); |
| 283 local_frame_id_ = cc::LocalFrameId(); | 281 local_frame_id_ = cc::LocalFrameId(); |
| 284 } | 282 } |
| 285 | 283 |
| 286 void BlimpCompositor::CreateLayerTreeHost() { | 284 void BlimpCompositor::CreateLayerTreeHost() { |
| 287 DCHECK(!host_); | 285 DCHECK(!host_); |
| 288 VLOG(1) << "Creating LayerTreeHost for render widget: " << render_widget_id_; | 286 VLOG(1) << "Creating LayerTreeHost."; |
| 289 | 287 |
| 290 // Create the LayerTreeHost | 288 // Create the LayerTreeHost |
| 291 cc::LayerTreeHostInProcess::InitParams params; | 289 cc::LayerTreeHostInProcess::InitParams params; |
| 292 params.client = this; | 290 params.client = this; |
| 293 params.task_graph_runner = compositor_dependencies_->GetTaskGraphRunner(); | 291 params.task_graph_runner = compositor_dependencies_->GetTaskGraphRunner(); |
| 294 params.gpu_memory_buffer_manager = | 292 params.gpu_memory_buffer_manager = |
| 295 GetEmbedderDeps()->GetGpuMemoryBufferManager(); | 293 GetEmbedderDeps()->GetGpuMemoryBufferManager(); |
| 296 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); | 294 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); |
| 297 params.image_serialization_processor = | 295 params.image_serialization_processor = |
| 298 compositor_dependencies_->GetImageSerializationProcessor(); | 296 compositor_dependencies_->GetImageSerializationProcessor(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 313 this /* remote_proto_channel */, compositor_task_runner, ¶ms); | 311 this /* remote_proto_channel */, compositor_task_runner, ¶ms); |
| 314 | 312 |
| 315 DCHECK(!input_manager_); | 313 DCHECK(!input_manager_); |
| 316 input_manager_ = BlimpInputManager::Create( | 314 input_manager_ = BlimpInputManager::Create( |
| 317 this, base::ThreadTaskRunnerHandle::Get(), compositor_task_runner, | 315 this, base::ThreadTaskRunnerHandle::Get(), compositor_task_runner, |
| 318 host_->GetInputHandler()); | 316 host_->GetInputHandler()); |
| 319 } | 317 } |
| 320 | 318 |
| 321 void BlimpCompositor::DestroyLayerTreeHost() { | 319 void BlimpCompositor::DestroyLayerTreeHost() { |
| 322 DCHECK(host_); | 320 DCHECK(host_); |
| 323 VLOG(1) << "Destroying LayerTreeHost for render widget: " | 321 VLOG(1) << "Destroying LayerTreeHost."; |
| 324 << render_widget_id_; | 322 |
| 325 // Tear down the output surface connection with the old LayerTreeHost | 323 // Tear down the output surface connection with the old LayerTreeHost |
| 326 // instance. | 324 // instance. |
| 327 DestroyDelegatedContent(); | 325 DestroyDelegatedContent(); |
| 328 surface_factory_.reset(); | 326 surface_factory_.reset(); |
| 329 | 327 |
| 330 // Destroy the old LayerTreeHost state. | 328 // Destroy the old LayerTreeHost state. |
| 331 host_.reset(); | 329 host_.reset(); |
| 332 | 330 |
| 333 // Destroy the old input manager state. | 331 // Destroy the old input manager state. |
| 334 // It is important to destroy the LayerTreeHost before destroying the input | 332 // It is important to destroy the LayerTreeHost before destroying the input |
| (...skipping 16 matching lines...) Expand all Loading... |
| 351 it->second.Run(); | 349 it->second.Run(); |
| 352 it = pending_commit_trackers_.erase(it); | 350 it = pending_commit_trackers_.erase(it); |
| 353 } else { | 351 } else { |
| 354 ++it; | 352 ++it; |
| 355 } | 353 } |
| 356 } | 354 } |
| 357 } | 355 } |
| 358 | 356 |
| 359 } // namespace client | 357 } // namespace client |
| 360 } // namespace blimp | 358 } // namespace blimp |
| OLD | NEW |