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/compositor/blimp_compositor.cc

Issue 1430623004: blimp: Add support for input handling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 5 years 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/compositor/blimp_compositor.h" 5 #include "blimp/client/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/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/numerics/safe_conversions.h" 10 #include "base/numerics/safe_conversions.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 64 }
65 65
66 BlimpCompositor::~BlimpCompositor() { 66 BlimpCompositor::~BlimpCompositor() {
67 render_widget_processor_.RemoveDelegate(kDummyTabId); 67 render_widget_processor_.RemoveDelegate(kDummyTabId);
68 SetVisible(false); 68 SetVisible(false);
69 69
70 // Destroy |host_| first, as it has a reference to the |settings_| and runs 70 // Destroy |host_| first, as it has a reference to the |settings_| and runs
71 // tasks on |compositor_thread_|. 71 // tasks on |compositor_thread_|.
72 host_.reset(); 72 host_.reset();
73 settings_.reset(); 73 settings_.reset();
74
75 // We must destroy |host_| before the |input_manager_|.
76 input_manager_.reset();
77
74 if (compositor_thread_) 78 if (compositor_thread_)
75 compositor_thread_->Stop(); 79 compositor_thread_->Stop();
76 } 80 }
77 81
78 void BlimpCompositor::SetVisible(bool visible) { 82 void BlimpCompositor::SetVisible(bool visible) {
79 // For testing. Remove once we bind to the network layer. 83 // For testing. Remove once we bind to the network layer.
80 if (!host_) 84 if (!host_)
81 CreateLayerTreeHost(nullptr); 85 CreateLayerTreeHost(nullptr);
82 86
83 host_should_be_visible_ = visible; 87 host_should_be_visible_ = visible;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 void BlimpCompositor::ReleaseAcceleratedWidget() { 128 void BlimpCompositor::ReleaseAcceleratedWidget() {
125 if (window_ == gfx::kNullAcceleratedWidget) 129 if (window_ == gfx::kNullAcceleratedWidget)
126 return; 130 return;
127 131
128 // Hide the compositor and drop the output surface if necessary. 132 // Hide the compositor and drop the output surface if necessary.
129 SetVisible(false); 133 SetVisible(false);
130 134
131 window_ = gfx::kNullAcceleratedWidget; 135 window_ = gfx::kNullAcceleratedWidget;
132 } 136 }
133 137
138 bool BlimpCompositor::OnTouchEvent(const ui::MotionEvent& motion_event) {
139 if (input_manager_)
140 return input_manager_->OnTouchEvent(motion_event);
141 return false;
142 }
143
134 void BlimpCompositor::WillBeginMainFrame() {} 144 void BlimpCompositor::WillBeginMainFrame() {}
135 145
136 void BlimpCompositor::DidBeginMainFrame() {} 146 void BlimpCompositor::DidBeginMainFrame() {}
137 147
138 void BlimpCompositor::BeginMainFrame(const cc::BeginFrameArgs& args) {} 148 void BlimpCompositor::BeginMainFrame(const cc::BeginFrameArgs& args) {}
139 149
140 void BlimpCompositor::BeginMainFrameNotExpectedSoon() {} 150 void BlimpCompositor::BeginMainFrameNotExpectedSoon() {}
141 151
142 void BlimpCompositor::UpdateLayerTreeHost() {} 152 void BlimpCompositor::UpdateLayerTreeHost() {}
143 153
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } 191 }
182 192
183 void BlimpCompositor::OnRenderWidgetInitialized() { 193 void BlimpCompositor::OnRenderWidgetInitialized() {
184 // Tear down the output surface connection with the old LayerTreeHost 194 // Tear down the output surface connection with the old LayerTreeHost
185 // instance. 195 // instance.
186 SetVisible(false); 196 SetVisible(false);
187 197
188 // Destroy the old LayerTreeHost state. 198 // Destroy the old LayerTreeHost state.
189 host_.reset(); 199 host_.reset();
190 200
201 // Destroy the old input manager state.
202 // It is important to destroy the LayerTreeHost before destroying the input
203 // manager as it has a reference to the cc::InputHandlerClient owned by the
204 // BlimpInputManager.
205 input_manager_.reset();
206
191 // Reset other state. 207 // Reset other state.
192 output_surface_request_pending_ = false; 208 output_surface_request_pending_ = false;
193 209
194 // Make sure we don't have a receiver at this point. 210 // Make sure we don't have a receiver at this point.
195 DCHECK(!remote_proto_channel_receiver_); 211 DCHECK(!remote_proto_channel_receiver_);
196 } 212 }
197 213
198 void BlimpCompositor::OnCompositorMessageReceived( 214 void BlimpCompositor::OnCompositorMessageReceived(
199 scoped_ptr<cc::proto::CompositorMessage> message) { 215 scoped_ptr<cc::proto::CompositorMessage> message) {
200 // TODO(dtrainor, khushalsagar): Look into the CompositorMessage. If it is 216 // TODO(dtrainor, khushalsagar): Look into the CompositorMessage. If it is
201 // initialize or shutdown, create or destroy |host_|. 217 // initialize or shutdown, create or destroy |host_|.
202 218
203 // We should have a receiver if we're getting compositor messages that aren't 219 // We should have a receiver if we're getting compositor messages that aren't
204 // initialize. 220 // initialize.
205 DCHECK(remote_proto_channel_receiver_); 221 DCHECK(remote_proto_channel_receiver_);
206 remote_proto_channel_receiver_->OnProtoReceived(std::move(message)); 222 remote_proto_channel_receiver_->OnProtoReceived(std::move(message));
207 } 223 }
208 224
209 void BlimpCompositor::GenerateLayerTreeSettings( 225 void BlimpCompositor::GenerateLayerTreeSettings(
210 cc::LayerTreeSettings* settings) { 226 cc::LayerTreeSettings* settings) {
211 PopulateCommonLayerTreeSettings(settings); 227 PopulateCommonLayerTreeSettings(settings);
212 } 228 }
213 229
230 void BlimpCompositor::SendWebInputEvent(
231 const blink::WebInputEvent& input_event) {
232 render_widget_processor_.SendInputEvent(kDummyTabId, input_event);
233 }
234
214 void BlimpCompositor::CreateLayerTreeHost( 235 void BlimpCompositor::CreateLayerTreeHost(
215 scoped_ptr<cc::proto::CompositorMessage> message) { 236 scoped_ptr<cc::proto::CompositorMessage> message) {
216 if (!settings_) { 237 if (!settings_) {
217 settings_.reset(new cc::LayerTreeSettings); 238 settings_.reset(new cc::LayerTreeSettings);
218 GenerateLayerTreeSettings(settings_.get()); 239 GenerateLayerTreeSettings(settings_.get());
219 } 240 }
220 241
221 // Create the LayerTreeHost 242 // Create the LayerTreeHost
222 cc::LayerTreeHost::InitParams params; 243 cc::LayerTreeHost::InitParams params;
223 params.client = this; 244 params.client = this;
(...skipping 12 matching lines...) Expand all
236 host_->SetVisible(true); 257 host_->SetVisible(true);
237 258
238 host_->SetViewportSize(viewport_size_); 259 host_->SetViewportSize(viewport_size_);
239 host_->SetDeviceScaleFactor(device_scale_factor_); 260 host_->SetDeviceScaleFactor(device_scale_factor_);
240 261
241 // For testing, set the dummy Layer. 262 // For testing, set the dummy Layer.
242 scoped_refptr<cc::Layer> root( 263 scoped_refptr<cc::Layer> root(
243 cc::Layer::Create(BlimpCompositor::LayerSettings())); 264 cc::Layer::Create(BlimpCompositor::LayerSettings()));
244 host_->SetRootLayer(root); 265 host_->SetRootLayer(root);
245 g_dummy_layer_driver.Pointer()->SetParentLayer(root); 266 g_dummy_layer_driver.Pointer()->SetParentLayer(root);
267
268 // TODO(khushalsagar): Create this after successful initialization of the
269 // remote client compositor when implemented.
270 DCHECK(!input_manager_);
271 input_manager_ =
272 BlimpInputManager::Create(this,
273 base::ThreadTaskRunnerHandle::Get(),
274 GetCompositorTaskRunner(),
275 host_->GetInputHandler());
246 } 276 }
247 277
248 scoped_refptr<base::SingleThreadTaskRunner> 278 scoped_refptr<base::SingleThreadTaskRunner>
249 BlimpCompositor::GetCompositorTaskRunner() { 279 BlimpCompositor::GetCompositorTaskRunner() {
250 if (compositor_thread_) 280 if (compositor_thread_)
251 return compositor_thread_->task_runner(); 281 return compositor_thread_->task_runner();
252 282
253 base::Thread::Options thread_options; 283 base::Thread::Options thread_options;
254 #if defined(OS_ANDROID) 284 #if defined(OS_ANDROID)
255 thread_options.priority = base::ThreadPriority::DISPLAY; 285 thread_options.priority = base::ThreadPriority::DISPLAY;
(...skipping 29 matching lines...) Expand all
285 output_surface_request_pending_ = false; 315 output_surface_request_pending_ = false;
286 } 316 }
287 317
288 cc::LayerSettings BlimpCompositor::LayerSettings() { 318 cc::LayerSettings BlimpCompositor::LayerSettings() {
289 cc::LayerSettings settings; 319 cc::LayerSettings settings;
290 settings.use_compositor_animation_timelines = true; 320 settings.use_compositor_animation_timelines = true;
291 return settings; 321 return settings;
292 } 322 }
293 323
294 } // namespace blimp 324 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698