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_child_frame.h" | 5 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 return view; | 47 return view; |
48 } | 48 } |
49 | 49 |
50 RenderWidgetHostViewChildFrame::RenderWidgetHostViewChildFrame( | 50 RenderWidgetHostViewChildFrame::RenderWidgetHostViewChildFrame( |
51 RenderWidgetHost* widget_host) | 51 RenderWidgetHost* widget_host) |
52 : host_(RenderWidgetHostImpl::From(widget_host)), | 52 : host_(RenderWidgetHostImpl::From(widget_host)), |
53 frame_sink_id_( | 53 frame_sink_id_( |
54 base::checked_cast<uint32_t>(widget_host->GetProcess()->GetID()), | 54 base::checked_cast<uint32_t>(widget_host->GetProcess()->GetID()), |
55 base::checked_cast<uint32_t>(widget_host->GetRoutingID())), | 55 base::checked_cast<uint32_t>(widget_host->GetRoutingID())), |
56 next_surface_sequence_(1u), | 56 next_surface_sequence_(1u), |
57 last_compositor_frame_sink_id_(0), | |
58 current_surface_scale_factor_(1.f), | 57 current_surface_scale_factor_(1.f), |
59 frame_connector_(nullptr), | 58 frame_connector_(nullptr), |
60 weak_factory_(this) { | 59 weak_factory_(this) { |
61 GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_); | 60 GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_); |
62 CreateCompositorFrameSinkSupport(); | 61 CreateCompositorFrameSinkSupport(); |
63 } | 62 } |
64 | 63 |
65 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() { | 64 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() { |
66 ResetCompositorFrameSinkSupport(); | 65 ResetCompositorFrameSinkSupport(); |
67 if (GetSurfaceManager()) | 66 if (GetSurfaceManager()) |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 return; | 335 return; |
337 if ((event.type() == blink::WebInputEvent::GestureScrollUpdate && | 336 if ((event.type() == blink::WebInputEvent::GestureScrollUpdate && |
338 not_consumed) || | 337 not_consumed) || |
339 event.type() == blink::WebInputEvent::GestureScrollEnd) | 338 event.type() == blink::WebInputEvent::GestureScrollEnd) |
340 frame_connector_->BubbleScrollEvent(event); | 339 frame_connector_->BubbleScrollEvent(event); |
341 } | 340 } |
342 | 341 |
343 void RenderWidgetHostViewChildFrame::DidReceiveCompositorFrameAck() { | 342 void RenderWidgetHostViewChildFrame::DidReceiveCompositorFrameAck() { |
344 if (!host_) | 343 if (!host_) |
345 return; | 344 return; |
346 host_->Send(new ViewMsg_ReclaimCompositorResources( | 345 host_->SendReclaimCompositorResources(true /* is_swap_ack */, |
347 host_->GetRoutingID(), last_compositor_frame_sink_id_, | 346 cc::ReturnedResourceArray()); |
348 true /* is_swap_ack */, cc::ReturnedResourceArray())); | 347 } |
| 348 |
| 349 void RenderWidgetHostViewChildFrame::DidCreateNewRendererCompositorFrameSink() { |
| 350 ResetCompositorFrameSinkSupport(); |
| 351 CreateCompositorFrameSinkSupport(); |
| 352 has_frame_ = false; |
349 } | 353 } |
350 | 354 |
351 void RenderWidgetHostViewChildFrame::ProcessCompositorFrame( | 355 void RenderWidgetHostViewChildFrame::ProcessCompositorFrame( |
352 uint32_t compositor_frame_sink_id, | |
353 const cc::LocalSurfaceId& local_surface_id, | 356 const cc::LocalSurfaceId& local_surface_id, |
354 cc::CompositorFrame frame) { | 357 cc::CompositorFrame frame) { |
355 // If the renderer changed its frame sink, reset the | |
356 // CompositorFrameSinkSupport to avoid returning stale resources. | |
357 if (compositor_frame_sink_id != last_compositor_frame_sink_id_) { | |
358 ResetCompositorFrameSinkSupport(); | |
359 CreateCompositorFrameSinkSupport(); | |
360 last_compositor_frame_sink_id_ = compositor_frame_sink_id; | |
361 } | |
362 | |
363 current_surface_size_ = frame.render_pass_list.back()->output_rect.size(); | 358 current_surface_size_ = frame.render_pass_list.back()->output_rect.size(); |
364 current_surface_scale_factor_ = frame.metadata.device_scale_factor; | 359 current_surface_scale_factor_ = frame.metadata.device_scale_factor; |
365 | 360 |
366 support_->SubmitCompositorFrame(local_surface_id, std::move(frame)); | 361 support_->SubmitCompositorFrame(local_surface_id, std::move(frame)); |
367 has_frame_ = true; | 362 has_frame_ = true; |
368 | 363 |
369 if (local_surface_id_ != local_surface_id || HasEmbedderChanged()) { | 364 if (local_surface_id_ != local_surface_id || HasEmbedderChanged()) { |
370 local_surface_id_ = local_surface_id; | 365 local_surface_id_ = local_surface_id; |
371 SendSurfaceInfoToEmbedder(); | 366 SendSurfaceInfoToEmbedder(); |
372 } | 367 } |
(...skipping 13 matching lines...) Expand all Loading... |
386 current_surface_size_); | 381 current_surface_size_); |
387 SendSurfaceInfoToEmbedderImpl(surface_info, sequence); | 382 SendSurfaceInfoToEmbedderImpl(surface_info, sequence); |
388 } | 383 } |
389 | 384 |
390 void RenderWidgetHostViewChildFrame::SendSurfaceInfoToEmbedderImpl( | 385 void RenderWidgetHostViewChildFrame::SendSurfaceInfoToEmbedderImpl( |
391 const cc::SurfaceInfo& surface_info, | 386 const cc::SurfaceInfo& surface_info, |
392 const cc::SurfaceSequence& sequence) { | 387 const cc::SurfaceSequence& sequence) { |
393 frame_connector_->SetChildFrameSurface(surface_info, sequence); | 388 frame_connector_->SetChildFrameSurface(surface_info, sequence); |
394 } | 389 } |
395 | 390 |
396 void RenderWidgetHostViewChildFrame::OnSwapCompositorFrame( | 391 void RenderWidgetHostViewChildFrame::SubmitCompositorFrame( |
397 uint32_t compositor_frame_sink_id, | |
398 const cc::LocalSurfaceId& local_surface_id, | 392 const cc::LocalSurfaceId& local_surface_id, |
399 cc::CompositorFrame frame) { | 393 cc::CompositorFrame frame) { |
400 TRACE_EVENT0("content", | 394 TRACE_EVENT0("content", |
401 "RenderWidgetHostViewChildFrame::OnSwapCompositorFrame"); | 395 "RenderWidgetHostViewChildFrame::OnSwapCompositorFrame"); |
402 last_scroll_offset_ = frame.metadata.root_scroll_offset; | 396 last_scroll_offset_ = frame.metadata.root_scroll_offset; |
403 if (!frame_connector_) | 397 if (!frame_connector_) |
404 return; | 398 return; |
405 ProcessCompositorFrame(compositor_frame_sink_id, local_surface_id, | 399 ProcessCompositorFrame(local_surface_id, std::move(frame)); |
406 std::move(frame)); | |
407 } | 400 } |
408 | 401 |
409 void RenderWidgetHostViewChildFrame::OnBeginFrameDidNotSwap( | 402 void RenderWidgetHostViewChildFrame::OnBeginFrameDidNotSwap( |
410 const cc::BeginFrameAck& ack) { | 403 const cc::BeginFrameAck& ack) { |
411 support_->BeginFrameDidNotSwap(ack); | 404 support_->BeginFrameDidNotSwap(ack); |
412 } | 405 } |
413 | 406 |
414 void RenderWidgetHostViewChildFrame::ProcessFrameSwappedCallbacks() { | 407 void RenderWidgetHostViewChildFrame::ProcessFrameSwappedCallbacks() { |
415 // We only use callbacks once, therefore we make a new list for registration | 408 // We only use callbacks once, therefore we make a new list for registration |
416 // before we start, and discard the old list entries when we are done. | 409 // before we start, and discard the old list entries when we are done. |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 | 605 |
613 bool RenderWidgetHostViewChildFrame::HasAcceleratedSurface( | 606 bool RenderWidgetHostViewChildFrame::HasAcceleratedSurface( |
614 const gfx::Size& desired_size) { | 607 const gfx::Size& desired_size) { |
615 return false; | 608 return false; |
616 } | 609 } |
617 | 610 |
618 void RenderWidgetHostViewChildFrame::ReclaimResources( | 611 void RenderWidgetHostViewChildFrame::ReclaimResources( |
619 const cc::ReturnedResourceArray& resources) { | 612 const cc::ReturnedResourceArray& resources) { |
620 if (!host_) | 613 if (!host_) |
621 return; | 614 return; |
622 host_->Send(new ViewMsg_ReclaimCompositorResources( | 615 host_->SendReclaimCompositorResources(false /* is_swap_ack */, resources); |
623 host_->GetRoutingID(), last_compositor_frame_sink_id_, | |
624 false /* is_swap_ack */, resources)); | |
625 } | 616 } |
626 | 617 |
627 void RenderWidgetHostViewChildFrame::OnBeginFrame( | 618 void RenderWidgetHostViewChildFrame::OnBeginFrame( |
628 const cc::BeginFrameArgs& args) { | 619 const cc::BeginFrameArgs& args) { |
629 host_->Send(new ViewMsg_BeginFrame(host_->GetRoutingID(), args)); | 620 host_->Send(new ViewMsg_BeginFrame(host_->GetRoutingID(), args)); |
630 } | 621 } |
631 | 622 |
632 void RenderWidgetHostViewChildFrame::SetNeedsBeginFrames( | 623 void RenderWidgetHostViewChildFrame::SetNeedsBeginFrames( |
633 bool needs_begin_frames) { | 624 bool needs_begin_frames) { |
634 if (support_) | 625 if (support_) |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 frame_sink_id_); | 695 frame_sink_id_); |
705 } | 696 } |
706 support_.reset(); | 697 support_.reset(); |
707 } | 698 } |
708 | 699 |
709 bool RenderWidgetHostViewChildFrame::HasEmbedderChanged() { | 700 bool RenderWidgetHostViewChildFrame::HasEmbedderChanged() { |
710 return false; | 701 return false; |
711 } | 702 } |
712 | 703 |
713 } // namespace content | 704 } // namespace content |
OLD | NEW |