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

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

Issue 2400923002: Move BlimpInputManager to BlimpDocument from BlimpCompositor. (Closed)
Patch Set: Removed unnecessary DCHECK. 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 CheckPendingCommitCounts(true /* flush */); 86 CheckPendingCommitCounts(true /* flush */);
87 } 87 }
88 88
89 void BlimpCompositor::SetVisible(bool visible) { 89 void BlimpCompositor::SetVisible(bool visible) {
90 host_->SetVisible(visible); 90 host_->SetVisible(visible);
91 91
92 if (!visible) 92 if (!visible)
93 CheckPendingCommitCounts(true /* flush */); 93 CheckPendingCommitCounts(true /* flush */);
94 } 94 }
95 95
96 bool BlimpCompositor::OnTouchEvent(const ui::MotionEvent& motion_event) {
97 if (input_manager_)
98 return input_manager_->OnTouchEvent(motion_event);
99 return false;
100 }
101
102 void BlimpCompositor::NotifyWhenDonePendingCommits(base::Closure callback) { 96 void BlimpCompositor::NotifyWhenDonePendingCommits(base::Closure callback) {
103 if (outstanding_commits_ == 0) { 97 if (outstanding_commits_ == 0) {
104 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); 98 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback);
105 return; 99 return;
106 } 100 }
107 101
108 pending_commit_trackers_.push_back( 102 pending_commit_trackers_.push_back(
109 std::make_pair(outstanding_commits_, callback)); 103 std::make_pair(outstanding_commits_, callback));
110 } 104 }
111 105
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 UMA_HISTOGRAM_MEMORY_KB("Blimp.Compositor.CommitSizeKb", 155 UMA_HISTOGRAM_MEMORY_KB("Blimp.Compositor.CommitSizeKb",
162 (float)message->ByteSize() / 1024); 156 (float)message->ByteSize() / 1024);
163 default: 157 default:
164 // We should have a receiver if we're getting compositor messages that 158 // We should have a receiver if we're getting compositor messages that
165 // are not INITIALIZE_IMPL or CLOSE_IMPL. 159 // are not INITIALIZE_IMPL or CLOSE_IMPL.
166 DCHECK(remote_proto_channel_receiver_); 160 DCHECK(remote_proto_channel_receiver_);
167 remote_proto_channel_receiver_->OnProtoReceived(std::move(message)); 161 remote_proto_channel_receiver_->OnProtoReceived(std::move(message));
168 } 162 }
169 } 163 }
170 164
165 // Returns a reference to the InputHandler owned by layer tree host.
166 const base::WeakPtr<cc::InputHandler>& BlimpCompositor::GetInputHandler() {
167 return host_->GetInputHandler();
168 }
169
171 void BlimpCompositor::OnContextProvidersCreated( 170 void BlimpCompositor::OnContextProvidersCreated(
172 const scoped_refptr<cc::ContextProvider>& compositor_context_provider, 171 const scoped_refptr<cc::ContextProvider>& compositor_context_provider,
173 const scoped_refptr<cc::ContextProvider>& worker_context_provider) { 172 const scoped_refptr<cc::ContextProvider>& worker_context_provider) {
174 DCHECK(!surface_factory_) << "Any connection to the old CompositorFrameSink " 173 DCHECK(!surface_factory_) << "Any connection to the old CompositorFrameSink "
175 "should have been destroyed"; 174 "should have been destroyed";
176 175
177 // Make sure we still have a host and we're still expecting a 176 // Make sure we still have a host and we're still expecting a
178 // CompositorFrameSink. This can happen if the host dies while the request is 177 // CompositorFrameSink. This can happen if the host dies while the request is
179 // outstanding and we build a new one that hasn't asked for a surface yet. 178 // outstanding and we build a new one that hasn't asked for a surface yet.
180 if (!compositor_frame_sink_request_pending_) 179 if (!compositor_frame_sink_request_pending_)
181 return; 180 return;
182 181
183 // Try again if the context creation failed. 182 // Try again if the context creation failed.
184 if (!compositor_context_provider) { 183 if (!compositor_context_provider) {
185 GetEmbedderDeps()->GetContextProviders( 184 GetEmbedderDeps()->GetContextProviders(
186 base::Bind(&BlimpCompositor::OnContextProvidersCreated, 185 base::Bind(&BlimpCompositor::OnContextProvidersCreated,
187 weak_ptr_factory_.GetWeakPtr())); 186 weak_ptr_factory_.GetWeakPtr()));
188 return; 187 return;
189 } 188 }
190 189
191 auto compositor_frame_sink = base::MakeUnique<BlimpCompositorFrameSink>( 190 auto compositor_frame_sink = base::MakeUnique<BlimpCompositorFrameSink>(
192 std::move(compositor_context_provider), 191 std::move(compositor_context_provider),
193 std::move(worker_context_provider), base::ThreadTaskRunnerHandle::Get(), 192 std::move(worker_context_provider), base::ThreadTaskRunnerHandle::Get(),
194 weak_ptr_factory_.GetWeakPtr()); 193 weak_ptr_factory_.GetWeakPtr());
195 194
196 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); 195 host_->SetCompositorFrameSink(std::move(compositor_frame_sink));
197 } 196 }
198 197
199 void BlimpCompositor::SendWebGestureEvent(
200 const blink::WebGestureEvent& gesture_event) {
201 client_->SendWebGestureEvent(gesture_event);
202 }
203
204 void BlimpCompositor::BindToProxyClient( 198 void BlimpCompositor::BindToProxyClient(
205 base::WeakPtr<BlimpCompositorFrameSinkProxyClient> proxy_client) { 199 base::WeakPtr<BlimpCompositorFrameSinkProxyClient> proxy_client) {
206 DCHECK(thread_checker_.CalledOnValidThread()); 200 DCHECK(thread_checker_.CalledOnValidThread());
207 DCHECK(!surface_factory_); 201 DCHECK(!surface_factory_);
208 202
209 proxy_client_ = proxy_client; 203 proxy_client_ = proxy_client;
210 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>( 204 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>(
211 frame_sink_id_, GetEmbedderDeps()->GetSurfaceManager(), this); 205 frame_sink_id_, GetEmbedderDeps()->GetSurfaceManager(), this);
212 } 206 }
213 207
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 settings->abort_commit_before_compositor_frame_sink_creation = false; 296 settings->abort_commit_before_compositor_frame_sink_creation = false;
303 params.settings = settings; 297 params.settings = settings;
304 298
305 params.animation_host = cc::AnimationHost::CreateMainInstance(); 299 params.animation_host = cc::AnimationHost::CreateMainInstance();
306 300
307 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner = 301 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner =
308 compositor_dependencies_->GetCompositorTaskRunner(); 302 compositor_dependencies_->GetCompositorTaskRunner();
309 303
310 host_ = cc::LayerTreeHostInProcess::CreateRemoteClient( 304 host_ = cc::LayerTreeHostInProcess::CreateRemoteClient(
311 this /* remote_proto_channel */, compositor_task_runner, &params); 305 this /* remote_proto_channel */, compositor_task_runner, &params);
312
313 DCHECK(!input_manager_);
314 input_manager_ = BlimpInputManager::Create(
315 this, base::ThreadTaskRunnerHandle::Get(), compositor_task_runner,
316 host_->GetInputHandler());
317 } 306 }
318 307
319 void BlimpCompositor::DestroyLayerTreeHost() { 308 void BlimpCompositor::DestroyLayerTreeHost() {
320 DCHECK(host_); 309 DCHECK(host_);
321 VLOG(1) << "Destroying LayerTreeHost."; 310 VLOG(1) << "Destroying LayerTreeHost.";
322 311
323 // Tear down the output surface connection with the old LayerTreeHost 312 // Tear down the output surface connection with the old LayerTreeHost
324 // instance. 313 // instance.
325 DestroyDelegatedContent(); 314 DestroyDelegatedContent();
326 surface_factory_.reset(); 315 surface_factory_.reset();
327 316
328 // Destroy the old LayerTreeHost state. 317 // Destroy the old LayerTreeHost state.
329 host_.reset(); 318 host_.reset();
330 319
331 // Destroy the old input manager state.
332 // It is important to destroy the LayerTreeHost before destroying the input
333 // manager as it has a reference to the cc::InputHandlerClient owned by the
334 // BlimpInputManager.
335 input_manager_.reset();
336
337 // Cancel any outstanding CompositorFrameSink requests. That way if we get an 320 // Cancel any outstanding CompositorFrameSink requests. That way if we get an
338 // async callback related to the old request we know to drop it. 321 // async callback related to the old request we know to drop it.
339 compositor_frame_sink_request_pending_ = false; 322 compositor_frame_sink_request_pending_ = false;
340 323
341 // Make sure we don't have a receiver at this point. 324 // Make sure we don't have a receiver at this point.
342 DCHECK(!remote_proto_channel_receiver_); 325 DCHECK(!remote_proto_channel_receiver_);
343 } 326 }
344 327
345 void BlimpCompositor::CheckPendingCommitCounts(bool flush) { 328 void BlimpCompositor::CheckPendingCommitCounts(bool flush) {
346 for (auto it = pending_commit_trackers_.begin(); 329 for (auto it = pending_commit_trackers_.begin();
347 it != pending_commit_trackers_.end();) { 330 it != pending_commit_trackers_.end();) {
348 if (flush || --it->first == 0) { 331 if (flush || --it->first == 0) {
349 it->second.Run(); 332 it->second.Run();
350 it = pending_commit_trackers_.erase(it); 333 it = pending_commit_trackers_.erase(it);
351 } else { 334 } else {
352 ++it; 335 ++it;
353 } 336 }
354 } 337 }
355 } 338 }
356 339
357 } // namespace client 340 } // namespace client
358 } // namespace blimp 341 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/client/core/compositor/blimp_compositor.h ('k') | blimp/client/core/compositor/blimp_compositor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698