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 allocated_new_local_frame_id = false; | |
304 if (!local_frame_id_.is_valid()) { | 303 if (!local_frame_id_.is_valid()) { |
305 local_frame_id_ = id_allocator_->GenerateId(); | 304 local_frame_id_ = id_allocator_->GenerateId(); |
306 allocated_new_local_frame_id = true; | 305 surface_factory_->Create(local_frame_id_); |
307 } | |
308 | 306 |
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 (allocated_new_local_frame_id) { | |
319 cc::SurfaceSequence sequence = | 307 cc::SurfaceSequence sequence = |
320 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++); | 308 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++); |
321 // The renderer process will satisfy this dependency when it creates a | 309 // The renderer process will satisfy this dependency when it creates a |
322 // SurfaceLayer. | 310 // SurfaceLayer. |
323 cc::SurfaceManager* manager = GetSurfaceManager(); | 311 cc::SurfaceManager* manager = GetSurfaceManager(); |
324 cc::SurfaceId surface_id(frame_sink_id_, local_frame_id_); | 312 cc::SurfaceId surface_id(frame_sink_id_, local_frame_id_); |
325 manager->GetSurfaceForId(surface_id)->AddDestructionDependency(sequence); | 313 manager->GetSurfaceForId(surface_id)->AddDestructionDependency(sequence); |
326 // TODO(wjmaclean): I'm not sure what it means to create a surface id | 314 // TODO(wjmaclean): I'm not sure what it means to create a surface id |
327 // without setting it on the child, though since we will in this case be | 315 // without setting it on the child, though since we will in this case be |
328 // guaranteed to call ClearCompositorSurfaceIfNecessary() below, I suspect | 316 // guaranteed to call ClearCompositorSurfaceIfNecessary() below, I suspect |
329 // skipping SetChildFrameSurface() here is irrelevant. | 317 // skipping SetChildFrameSurface() here is irrelevant. |
330 if (guest_ && !guest_->is_in_destruction()) { | 318 if (guest_ && !guest_->is_in_destruction()) { |
331 guest_->SetChildFrameSurface(surface_id, frame_size, scale_factor, | 319 guest_->SetChildFrameSurface(surface_id, frame_size, scale_factor, |
332 sequence); | 320 sequence); |
333 } | 321 } |
334 } | 322 } |
| 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 |
335 ProcessFrameSwappedCallbacks(); | 333 ProcessFrameSwappedCallbacks(); |
336 | 334 |
337 // If after detaching we are sent a frame, we should finish processing it, and | 335 // If after detaching we are sent a frame, we should finish processing it, and |
338 // then we should clear the surface so that we are not holding resources we | 336 // then we should clear the surface so that we are not holding resources we |
339 // no longer need. | 337 // no longer need. |
340 if (!guest_ || !guest_->attached()) | 338 if (!guest_ || !guest_->attached()) |
341 ClearCompositorSurfaceIfNecessary(); | 339 ClearCompositorSurfaceIfNecessary(); |
342 } | 340 } |
343 | 341 |
344 bool RenderWidgetHostViewGuest::OnMessageReceived(const IPC::Message& msg) { | 342 bool RenderWidgetHostViewGuest::OnMessageReceived(const IPC::Message& msg) { |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 gesture_event.data.scrollUpdate.inertialPhase == | 681 gesture_event.data.scrollUpdate.inertialPhase == |
684 blink::WebGestureEvent::MomentumPhase) { | 682 blink::WebGestureEvent::MomentumPhase) { |
685 return; | 683 return; |
686 } | 684 } |
687 host_->ForwardGestureEvent(gesture_event); | 685 host_->ForwardGestureEvent(gesture_event); |
688 return; | 686 return; |
689 } | 687 } |
690 } | 688 } |
691 | 689 |
692 } // namespace content | 690 } // namespace content |
OLD | NEW |