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

Side by Side Diff: blimp/client/core/compositor/blimp_compositor.cc

Issue 2382733007: Add BlimpDocument, pull out functions in BlimpCompositor. (Closed)
Patch Set: Fix linux client. Created 4 years, 2 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
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
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 proxy_client_(nullptr), 65 proxy_client_(nullptr),
68 compositor_frame_sink_request_pending_(false), 66 compositor_frame_sink_request_pending_(false),
69 layer_(cc::Layer::Create()), 67 layer_(cc::Layer::Create()),
70 remote_proto_channel_receiver_(nullptr), 68 remote_proto_channel_receiver_(nullptr),
71 outstanding_commits_(0U), 69 outstanding_commits_(0U),
72 weak_ptr_factory_(this) { 70 weak_ptr_factory_(this) {
73 DCHECK(thread_checker_.CalledOnValidThread()); 71 DCHECK(thread_checker_.CalledOnValidThread());
74 72
75 surface_id_allocator_ = base::MakeUnique<cc::SurfaceIdAllocator>( 73 surface_id_allocator_ = base::MakeUnique<cc::SurfaceIdAllocator>(
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 132
135 CheckPendingCommitCounts(false /* flush */); 133 CheckPendingCommitCounts(false /* flush */);
136 } 134 }
137 135
138 void BlimpCompositor::SetProtoReceiver(ProtoReceiver* receiver) { 136 void BlimpCompositor::SetProtoReceiver(ProtoReceiver* receiver) {
139 remote_proto_channel_receiver_ = receiver; 137 remote_proto_channel_receiver_ = receiver;
140 } 138 }
141 139
142 void BlimpCompositor::SendCompositorProto( 140 void BlimpCompositor::SendCompositorProto(
143 const cc::proto::CompositorMessage& proto) { 141 const cc::proto::CompositorMessage& proto) {
144 client_->SendCompositorMessage(render_widget_id_, proto); 142 client_->SendCompositorMessage(proto);
145 } 143 }
146 144
147 void BlimpCompositor::OnCompositorMessageReceived( 145 void BlimpCompositor::OnCompositorMessageReceived(
148 std::unique_ptr<cc::proto::CompositorMessage> message) { 146 std::unique_ptr<cc::proto::CompositorMessage> message) {
149 DCHECK(message->has_to_impl()); 147 DCHECK(message->has_to_impl());
150 const cc::proto::CompositorMessageToImpl& to_impl_proto = message->to_impl(); 148 const cc::proto::CompositorMessageToImpl& to_impl_proto = message->to_impl();
151 149
152 DCHECK(to_impl_proto.has_message_type()); 150 DCHECK(to_impl_proto.has_message_type());
153 151
154 if (to_impl_proto.message_type() == 152 if (to_impl_proto.message_type() ==
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 auto compositor_frame_sink = base::MakeUnique<BlimpCompositorFrameSink>( 192 auto compositor_frame_sink = base::MakeUnique<BlimpCompositorFrameSink>(
195 std::move(compositor_context_provider), 193 std::move(compositor_context_provider),
196 std::move(worker_context_provider), base::ThreadTaskRunnerHandle::Get(), 194 std::move(worker_context_provider), base::ThreadTaskRunnerHandle::Get(),
197 weak_ptr_factory_.GetWeakPtr()); 195 weak_ptr_factory_.GetWeakPtr());
198 196
199 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); 197 host_->SetCompositorFrameSink(std::move(compositor_frame_sink));
200 } 198 }
201 199
202 void BlimpCompositor::SendWebGestureEvent( 200 void BlimpCompositor::SendWebGestureEvent(
203 const blink::WebGestureEvent& gesture_event) { 201 const blink::WebGestureEvent& gesture_event) {
204 client_->SendWebGestureEvent(render_widget_id_, gesture_event); 202 client_->SendWebGestureEvent(gesture_event);
205 } 203 }
206 204
207 void BlimpCompositor::BindToProxyClient( 205 void BlimpCompositor::BindToProxyClient(
208 base::WeakPtr<BlimpCompositorFrameSinkProxyClient> proxy_client) { 206 base::WeakPtr<BlimpCompositorFrameSinkProxyClient> proxy_client) {
209 DCHECK(thread_checker_.CalledOnValidThread()); 207 DCHECK(thread_checker_.CalledOnValidThread());
210 DCHECK(!surface_factory_); 208 DCHECK(!surface_factory_);
211 209
212 proxy_client_ = proxy_client; 210 proxy_client_ = proxy_client;
213 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>( 211 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>(
214 GetEmbedderDeps()->GetSurfaceManager(), this); 212 GetEmbedderDeps()->GetSurfaceManager(), this);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 return; 274 return;
277 275
278 // Remove any references for the surface layer that uses this |surface_id_|. 276 // Remove any references for the surface layer that uses this |surface_id_|.
279 layer_->RemoveAllChildren(); 277 layer_->RemoveAllChildren();
280 surface_factory_->Destroy(surface_id_); 278 surface_factory_->Destroy(surface_id_);
281 surface_id_ = cc::SurfaceId(); 279 surface_id_ = cc::SurfaceId();
282 } 280 }
283 281
284 void BlimpCompositor::CreateLayerTreeHost() { 282 void BlimpCompositor::CreateLayerTreeHost() {
285 DCHECK(!host_); 283 DCHECK(!host_);
286 VLOG(1) << "Creating LayerTreeHost for render widget: " << render_widget_id_; 284 VLOG(1) << "Creating LayerTreeHost.";
287 285
288 // Create the LayerTreeHost 286 // Create the LayerTreeHost
289 cc::LayerTreeHostInProcess::InitParams params; 287 cc::LayerTreeHostInProcess::InitParams params;
290 params.client = this; 288 params.client = this;
291 params.task_graph_runner = compositor_dependencies_->GetTaskGraphRunner(); 289 params.task_graph_runner = compositor_dependencies_->GetTaskGraphRunner();
292 params.gpu_memory_buffer_manager = 290 params.gpu_memory_buffer_manager =
293 GetEmbedderDeps()->GetGpuMemoryBufferManager(); 291 GetEmbedderDeps()->GetGpuMemoryBufferManager();
294 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); 292 params.main_task_runner = base::ThreadTaskRunnerHandle::Get();
295 params.image_serialization_processor = 293 params.image_serialization_processor =
296 compositor_dependencies_->GetImageSerializationProcessor(); 294 compositor_dependencies_->GetImageSerializationProcessor();
(...skipping 14 matching lines...) Expand all
311 this /* remote_proto_channel */, compositor_task_runner, &params); 309 this /* remote_proto_channel */, compositor_task_runner, &params);
312 310
313 DCHECK(!input_manager_); 311 DCHECK(!input_manager_);
314 input_manager_ = BlimpInputManager::Create( 312 input_manager_ = BlimpInputManager::Create(
315 this, base::ThreadTaskRunnerHandle::Get(), compositor_task_runner, 313 this, base::ThreadTaskRunnerHandle::Get(), compositor_task_runner,
316 host_->GetInputHandler()); 314 host_->GetInputHandler());
317 } 315 }
318 316
319 void BlimpCompositor::DestroyLayerTreeHost() { 317 void BlimpCompositor::DestroyLayerTreeHost() {
320 DCHECK(host_); 318 DCHECK(host_);
321 VLOG(1) << "Destroying LayerTreeHost for render widget: " 319 VLOG(1) << "Destroying LayerTreeHost.";
322 << render_widget_id_; 320
323 // Tear down the output surface connection with the old LayerTreeHost 321 // Tear down the output surface connection with the old LayerTreeHost
324 // instance. 322 // instance.
325 DestroyDelegatedContent(); 323 DestroyDelegatedContent();
326 surface_factory_.reset(); 324 surface_factory_.reset();
327 325
328 // Destroy the old LayerTreeHost state. 326 // Destroy the old LayerTreeHost state.
329 host_.reset(); 327 host_.reset();
330 328
331 // Destroy the old input manager state. 329 // Destroy the old input manager state.
332 // It is important to destroy the LayerTreeHost before destroying the input 330 // It is important to destroy the LayerTreeHost before destroying the input
(...skipping 16 matching lines...) Expand all
349 it->second.Run(); 347 it->second.Run();
350 it = pending_commit_trackers_.erase(it); 348 it = pending_commit_trackers_.erase(it);
351 } else { 349 } else {
352 ++it; 350 ++it;
353 } 351 }
354 } 352 }
355 } 353 }
356 354
357 } // namespace client 355 } // namespace client
358 } // namespace blimp 356 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698