OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/frame_host/render_widget_host_view_guest.h" | 5 #include "content/browser/frame_host/render_widget_host_view_guest.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
293 ClearCompositorSurfaceIfNecessary(); | 293 ClearCompositorSurfaceIfNecessary(); |
294 // If the renderer changed its frame sink, reset the surface factory to | 294 // If the renderer changed its frame sink, reset the surface factory to |
295 // avoid returning stale resources. | 295 // avoid returning stale resources. |
296 if (compositor_frame_sink_id != last_compositor_frame_sink_id_) | 296 if (compositor_frame_sink_id != last_compositor_frame_sink_id_) |
297 surface_factory_->Reset(); | 297 surface_factory_->Reset(); |
298 last_compositor_frame_sink_id_ = compositor_frame_sink_id; | 298 last_compositor_frame_sink_id_ = compositor_frame_sink_id; |
299 current_surface_size_ = frame_size; | 299 current_surface_size_ = frame_size; |
300 current_surface_scale_factor_ = scale_factor; | 300 current_surface_scale_factor_ = scale_factor; |
301 } | 301 } |
302 | 302 |
303 bool was_null = false; | |
Fady Samuel
2016/11/11 19:47:57
nit: allocated_new_local_frame_id
| |
303 if (!local_frame_id_.is_valid()) { | 304 if (!local_frame_id_.is_valid()) { |
304 local_frame_id_ = id_allocator_->GenerateId(); | 305 local_frame_id_ = id_allocator_->GenerateId(); |
305 surface_factory_->Create(local_frame_id_); | 306 was_null = true; |
307 } | |
306 | 308 |
309 cc::SurfaceFactory::DrawCallback ack_callback = base::Bind( | |
310 &RenderWidgetHostViewChildFrame::SurfaceDrawn, | |
311 RenderWidgetHostViewChildFrame::AsWeakPtr(), compositor_frame_sink_id); | |
312 ack_pending_count_++; | |
313 // If this value grows very large, something is going wrong. | |
314 DCHECK(ack_pending_count_ < 1000); | |
315 surface_factory_->SubmitCompositorFrame(local_frame_id_, std::move(frame), | |
316 ack_callback); | |
317 | |
318 if (was_null) { | |
307 cc::SurfaceSequence sequence = | 319 cc::SurfaceSequence sequence = |
308 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++); | 320 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++); |
309 // The renderer process will satisfy this dependency when it creates a | 321 // The renderer process will satisfy this dependency when it creates a |
310 // SurfaceLayer. | 322 // SurfaceLayer. |
311 cc::SurfaceManager* manager = GetSurfaceManager(); | 323 cc::SurfaceManager* manager = GetSurfaceManager(); |
312 cc::SurfaceId surface_id(frame_sink_id_, local_frame_id_); | 324 cc::SurfaceId surface_id(frame_sink_id_, local_frame_id_); |
313 manager->GetSurfaceForId(surface_id)->AddDestructionDependency(sequence); | 325 manager->GetSurfaceForId(surface_id)->AddDestructionDependency(sequence); |
314 // TODO(wjmaclean): I'm not sure what it means to create a surface id | 326 // TODO(wjmaclean): I'm not sure what it means to create a surface id |
315 // without setting it on the child, though since we will in this case be | 327 // without setting it on the child, though since we will in this case be |
316 // guaranteed to call ClearCompositorSurfaceIfNecessary() below, I suspect | 328 // guaranteed to call ClearCompositorSurfaceIfNecessary() below, I suspect |
317 // skipping SetChildFrameSurface() here is irrelevant. | 329 // skipping SetChildFrameSurface() here is irrelevant. |
318 if (guest_ && !guest_->is_in_destruction()) { | 330 if (guest_ && !guest_->is_in_destruction()) { |
319 guest_->SetChildFrameSurface(surface_id, frame_size, scale_factor, | 331 guest_->SetChildFrameSurface(surface_id, frame_size, scale_factor, |
320 sequence); | 332 sequence); |
321 } | 333 } |
322 } | 334 } |
323 | |
324 cc::SurfaceFactory::DrawCallback ack_callback = base::Bind( | |
325 &RenderWidgetHostViewChildFrame::SurfaceDrawn, | |
326 RenderWidgetHostViewChildFrame::AsWeakPtr(), compositor_frame_sink_id); | |
327 ack_pending_count_++; | |
328 // If this value grows very large, something is going wrong. | |
329 DCHECK(ack_pending_count_ < 1000); | |
330 surface_factory_->SubmitCompositorFrame(local_frame_id_, std::move(frame), | |
331 ack_callback); | |
332 | |
333 ProcessFrameSwappedCallbacks(); | 335 ProcessFrameSwappedCallbacks(); |
334 | 336 |
335 // If after detaching we are sent a frame, we should finish processing it, and | 337 // If after detaching we are sent a frame, we should finish processing it, and |
336 // then we should clear the surface so that we are not holding resources we | 338 // then we should clear the surface so that we are not holding resources we |
337 // no longer need. | 339 // no longer need. |
338 if (!guest_ || !guest_->attached()) | 340 if (!guest_ || !guest_->attached()) |
339 ClearCompositorSurfaceIfNecessary(); | 341 ClearCompositorSurfaceIfNecessary(); |
340 } | 342 } |
341 | 343 |
342 bool RenderWidgetHostViewGuest::OnMessageReceived(const IPC::Message& msg) { | 344 bool RenderWidgetHostViewGuest::OnMessageReceived(const IPC::Message& msg) { |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
681 gesture_event.data.scrollUpdate.inertialPhase == | 683 gesture_event.data.scrollUpdate.inertialPhase == |
682 blink::WebGestureEvent::MomentumPhase) { | 684 blink::WebGestureEvent::MomentumPhase) { |
683 return; | 685 return; |
684 } | 686 } |
685 host_->ForwardGestureEvent(gesture_event); | 687 host_->ForwardGestureEvent(gesture_event); |
686 return; | 688 return; |
687 } | 689 } |
688 } | 690 } |
689 | 691 |
690 } // namespace content | 692 } // namespace content |
OLD | NEW |