Chromium Code Reviews| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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), | 57 last_compositor_frame_sink_id_(0), |
| 58 current_surface_scale_factor_(1.f), | 58 current_surface_scale_factor_(1.f), |
| 59 ack_pending_count_(0), | |
| 60 frame_connector_(nullptr), | 59 frame_connector_(nullptr), |
| 61 begin_frame_source_(nullptr), | |
| 62 weak_factory_(this) { | 60 weak_factory_(this) { |
| 63 id_allocator_.reset(new cc::LocalSurfaceIdAllocator()); | 61 id_allocator_.reset(new cc::LocalSurfaceIdAllocator()); |
| 64 auto* manager = GetSurfaceManager(); | 62 GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_); |
| 65 manager->RegisterFrameSinkId(frame_sink_id_); | 63 CreateCompositorFrameSinkSupport(); |
| 66 surface_factory_ = | |
| 67 base::MakeUnique<cc::SurfaceFactory>(frame_sink_id_, manager, this); | |
| 68 } | 64 } |
| 69 | 65 |
| 70 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() { | 66 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() { |
| 71 surface_factory_->EvictSurface(); | 67 ResetCompositorFrameSinkSupport(); |
| 72 if (GetSurfaceManager()) | 68 if (GetSurfaceManager()) |
| 73 GetSurfaceManager()->InvalidateFrameSinkId(frame_sink_id_); | 69 GetSurfaceManager()->InvalidateFrameSinkId(frame_sink_id_); |
| 74 } | 70 } |
| 75 | 71 |
| 76 void RenderWidgetHostViewChildFrame::Init() { | 72 void RenderWidgetHostViewChildFrame::Init() { |
| 77 RegisterFrameSinkId(); | 73 RegisterFrameSinkId(); |
| 78 host_->SetView(this); | 74 host_->SetView(this); |
| 79 GetTextInputManager(); | 75 GetTextInputManager(); |
| 80 } | 76 } |
| 81 | 77 |
| 82 void RenderWidgetHostViewChildFrame::SetCrossProcessFrameConnector( | 78 void RenderWidgetHostViewChildFrame::SetCrossProcessFrameConnector( |
| 83 CrossProcessFrameConnector* frame_connector) { | 79 CrossProcessFrameConnector* frame_connector) { |
| 84 if (frame_connector_ == frame_connector) | 80 if (frame_connector_ == frame_connector) |
| 85 return; | 81 return; |
| 86 | 82 |
| 87 if (frame_connector_) { | 83 if (frame_connector_) { |
| 88 if (parent_frame_sink_id_.is_valid()) { | 84 ResetCompositorFrameSinkSupport(); |
| 89 GetSurfaceManager()->UnregisterFrameSinkHierarchy(parent_frame_sink_id_, | |
| 90 frame_sink_id_); | |
| 91 } | |
| 92 // Unregister the client here, as it is not guaranteed in tests that the | |
| 93 // destructor will be called. | |
| 94 GetSurfaceManager()->UnregisterSurfaceFactoryClient(frame_sink_id_); | |
| 95 | |
| 96 parent_frame_sink_id_ = cc::FrameSinkId(); | 85 parent_frame_sink_id_ = cc::FrameSinkId(); |
| 97 | 86 |
| 98 // After the RenderWidgetHostViewChildFrame loses the frame_connector, it | |
| 99 // won't be able to walk up the frame tree anymore. Clean up anything that | |
| 100 // needs to be done through the CrossProcessFrameConnector before it's gone. | |
| 101 | |
| 102 // Unlocks the mouse if this RenderWidgetHostView holds the lock. | 87 // Unlocks the mouse if this RenderWidgetHostView holds the lock. |
| 103 UnlockMouse(); | 88 UnlockMouse(); |
| 104 } | 89 } |
| 105 frame_connector_ = frame_connector; | 90 frame_connector_ = frame_connector; |
| 106 if (frame_connector_) { | 91 if (frame_connector_) { |
| 107 GetSurfaceManager()->RegisterSurfaceFactoryClient(frame_sink_id_, this); | 92 ResetCompositorFrameSinkSupport(); |
| 108 RenderWidgetHostViewBase* parent_view = | 93 RenderWidgetHostViewBase* parent_view = |
| 109 frame_connector_->GetParentRenderWidgetHostView(); | 94 frame_connector_->GetParentRenderWidgetHostView(); |
| 110 if (parent_view) { | 95 if (parent_view) { |
| 111 parent_frame_sink_id_ = parent_view->GetFrameSinkId(); | 96 parent_frame_sink_id_ = parent_view->GetFrameSinkId(); |
| 112 DCHECK(parent_frame_sink_id_.is_valid()); | 97 DCHECK(parent_frame_sink_id_.is_valid()); |
| 113 GetSurfaceManager()->RegisterFrameSinkHierarchy(parent_frame_sink_id_, | |
| 114 frame_sink_id_); | |
| 115 } | 98 } |
| 99 CreateCompositorFrameSinkSupport(); | |
| 116 } | 100 } |
| 117 } | 101 } |
| 118 | 102 |
| 119 void RenderWidgetHostViewChildFrame::InitAsChild( | 103 void RenderWidgetHostViewChildFrame::InitAsChild( |
| 120 gfx::NativeView parent_view) { | 104 gfx::NativeView parent_view) { |
| 121 NOTREACHED(); | 105 NOTREACHED(); |
| 122 } | 106 } |
| 123 | 107 |
| 124 RenderWidgetHost* RenderWidgetHostViewChildFrame::GetRenderWidgetHost() const { | 108 RenderWidgetHost* RenderWidgetHostViewChildFrame::GetRenderWidgetHost() const { |
| 125 return host_; | 109 return host_; |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 // always forwarded and handled according to current scroll state in the | 331 // always forwarded and handled according to current scroll state in the |
| 348 // RenderWidgetHostInputEventRouter. | 332 // RenderWidgetHostInputEventRouter. |
| 349 if (!frame_connector_) | 333 if (!frame_connector_) |
| 350 return; | 334 return; |
| 351 if ((event.type() == blink::WebInputEvent::GestureScrollUpdate && | 335 if ((event.type() == blink::WebInputEvent::GestureScrollUpdate && |
| 352 not_consumed) || | 336 not_consumed) || |
| 353 event.type() == blink::WebInputEvent::GestureScrollEnd) | 337 event.type() == blink::WebInputEvent::GestureScrollEnd) |
| 354 frame_connector_->BubbleScrollEvent(event); | 338 frame_connector_->BubbleScrollEvent(event); |
| 355 } | 339 } |
| 356 | 340 |
| 357 void RenderWidgetHostViewChildFrame::SurfaceDrawn( | 341 void RenderWidgetHostViewChildFrame::DidReceiveCompositorFrameAck() { |
| 358 uint32_t compositor_frame_sink_id) { | 342 if (!host_) |
| 359 DCHECK_GT(ack_pending_count_, 0U); | 343 return; |
| 360 if (host_) { | 344 host_->Send(new ViewMsg_ReclaimCompositorResources( |
| 361 host_->Send(new ViewMsg_ReclaimCompositorResources( | 345 host_->GetRoutingID(), last_compositor_frame_sink_id_, |
| 362 host_->GetRoutingID(), compositor_frame_sink_id, true /* is_swap_ack */, | 346 true /* is_swap_ack */, cc::ReturnedResourceArray())); |
| 363 surface_returned_resources_)); | |
| 364 surface_returned_resources_.clear(); | |
| 365 } | |
| 366 ack_pending_count_--; | |
| 367 } | 347 } |
| 368 | 348 |
| 369 bool RenderWidgetHostViewChildFrame::ShouldCreateNewSurfaceId( | 349 bool RenderWidgetHostViewChildFrame::ShouldCreateNewSurfaceId( |
| 370 uint32_t compositor_frame_sink_id, | 350 uint32_t compositor_frame_sink_id, |
| 371 const cc::CompositorFrame& frame) { | 351 const cc::CompositorFrame& frame) { |
| 372 gfx::Size new_frame_size = frame.render_pass_list.back()->output_rect.size(); | 352 gfx::Size new_frame_size = frame.render_pass_list.back()->output_rect.size(); |
| 373 float new_scale_factor = frame.metadata.device_scale_factor; | 353 float new_scale_factor = frame.metadata.device_scale_factor; |
| 374 | 354 |
| 375 return compositor_frame_sink_id != last_compositor_frame_sink_id_ || | 355 return compositor_frame_sink_id != last_compositor_frame_sink_id_ || |
| 376 new_frame_size != current_surface_size_ || | 356 new_frame_size != current_surface_size_ || |
| 377 new_scale_factor != current_surface_scale_factor_; | 357 new_scale_factor != current_surface_scale_factor_; |
| 378 } | 358 } |
| 379 | 359 |
| 380 void RenderWidgetHostViewChildFrame::ProcessCompositorFrame( | 360 void RenderWidgetHostViewChildFrame::ProcessCompositorFrame( |
| 381 uint32_t compositor_frame_sink_id, | 361 uint32_t compositor_frame_sink_id, |
| 382 cc::CompositorFrame frame) { | 362 cc::CompositorFrame frame) { |
| 383 if (ShouldCreateNewSurfaceId(compositor_frame_sink_id, frame)) { | 363 if (ShouldCreateNewSurfaceId(compositor_frame_sink_id, frame)) { |
| 384 ClearCompositorSurfaceIfNecessary(); | 364 ClearCompositorSurfaceIfNecessary(); |
| 385 // If the renderer changed its frame sink, reset the surface factory to | 365 // If the renderer changed its frame sink, reset the |
| 386 // avoid returning stale resources. | 366 // CompositorFrameSinkSupport to avoid returning stale resources. |
| 387 if (compositor_frame_sink_id != last_compositor_frame_sink_id_) | 367 if (compositor_frame_sink_id != last_compositor_frame_sink_id_) { |
| 388 surface_factory_->Reset(); | 368 ResetCompositorFrameSinkSupport(); |
| 369 CreateCompositorFrameSinkSupport(); | |
| 370 } | |
| 389 last_compositor_frame_sink_id_ = compositor_frame_sink_id; | 371 last_compositor_frame_sink_id_ = compositor_frame_sink_id; |
| 390 current_surface_size_ = frame.render_pass_list.back()->output_rect.size(); | 372 current_surface_size_ = frame.render_pass_list.back()->output_rect.size(); |
| 391 current_surface_scale_factor_ = frame.metadata.device_scale_factor; | 373 current_surface_scale_factor_ = frame.metadata.device_scale_factor; |
| 392 } | 374 } |
| 393 | 375 |
| 394 bool allocated_new_local_surface_id = false; | 376 bool allocated_new_local_surface_id = false; |
| 395 if (!local_surface_id_.is_valid()) { | 377 if (!local_surface_id_.is_valid()) { |
| 396 local_surface_id_ = id_allocator_->GenerateId(); | 378 local_surface_id_ = id_allocator_->GenerateId(); |
| 397 allocated_new_local_surface_id = true; | 379 allocated_new_local_surface_id = true; |
| 398 } | 380 } |
| 399 | 381 |
| 400 cc::SurfaceFactory::DrawCallback ack_callback = | 382 support_->SubmitCompositorFrame(local_surface_id_, std::move(frame)); |
| 401 base::Bind(&RenderWidgetHostViewChildFrame::SurfaceDrawn, AsWeakPtr(), | |
| 402 compositor_frame_sink_id); | |
| 403 ack_pending_count_++; | |
| 404 // If this value grows very large, something is going wrong. | |
| 405 DCHECK_LT(ack_pending_count_, 1000U); | |
| 406 surface_factory_->SubmitCompositorFrame(local_surface_id_, std::move(frame), | |
| 407 ack_callback); | |
| 408 if (allocated_new_local_surface_id) | 383 if (allocated_new_local_surface_id) |
| 409 SendSurfaceInfoToEmbedder(); | 384 SendSurfaceInfoToEmbedder(); |
| 410 ProcessFrameSwappedCallbacks(); | 385 ProcessFrameSwappedCallbacks(); |
| 411 } | 386 } |
| 412 | 387 |
| 413 void RenderWidgetHostViewChildFrame::SendSurfaceInfoToEmbedder() { | 388 void RenderWidgetHostViewChildFrame::SendSurfaceInfoToEmbedder() { |
| 414 cc::SurfaceSequence sequence = | 389 cc::SurfaceSequence sequence = |
| 415 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++); | 390 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++); |
| 416 cc::SurfaceManager* manager = GetSurfaceManager(); | 391 cc::SurfaceManager* manager = GetSurfaceManager(); |
| 417 cc::SurfaceId surface_id(frame_sink_id_, local_surface_id_); | 392 cc::SurfaceId surface_id(frame_sink_id_, local_surface_id_); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 620 SubmitSurfaceCopyRequest(src_subrect, output_size, callback, | 595 SubmitSurfaceCopyRequest(src_subrect, output_size, callback, |
| 621 preferred_color_type); | 596 preferred_color_type); |
| 622 } | 597 } |
| 623 | 598 |
| 624 void RenderWidgetHostViewChildFrame::SubmitSurfaceCopyRequest( | 599 void RenderWidgetHostViewChildFrame::SubmitSurfaceCopyRequest( |
| 625 const gfx::Rect& src_subrect, | 600 const gfx::Rect& src_subrect, |
| 626 const gfx::Size& output_size, | 601 const gfx::Size& output_size, |
| 627 const ReadbackRequestCallback& callback, | 602 const ReadbackRequestCallback& callback, |
| 628 const SkColorType preferred_color_type) { | 603 const SkColorType preferred_color_type) { |
| 629 DCHECK(IsSurfaceAvailableForCopy()); | 604 DCHECK(IsSurfaceAvailableForCopy()); |
| 605 DCHECK(support_); | |
| 630 | 606 |
| 631 std::unique_ptr<cc::CopyOutputRequest> request = | 607 std::unique_ptr<cc::CopyOutputRequest> request = |
| 632 cc::CopyOutputRequest::CreateRequest( | 608 cc::CopyOutputRequest::CreateRequest( |
| 633 base::Bind(&CopyFromCompositingSurfaceHasResult, output_size, | 609 base::Bind(&CopyFromCompositingSurfaceHasResult, output_size, |
| 634 preferred_color_type, callback)); | 610 preferred_color_type, callback)); |
| 635 if (!src_subrect.IsEmpty()) | 611 if (!src_subrect.IsEmpty()) |
| 636 request->set_area(src_subrect); | 612 request->set_area(src_subrect); |
| 637 | 613 |
| 638 surface_factory_->RequestCopyOfSurface(std::move(request)); | 614 support_->RequestCopyOfSurface(std::move(request)); |
| 639 } | 615 } |
| 640 | 616 |
| 641 void RenderWidgetHostViewChildFrame::CopyFromCompositingSurfaceToVideoFrame( | 617 void RenderWidgetHostViewChildFrame::CopyFromCompositingSurfaceToVideoFrame( |
| 642 const gfx::Rect& src_subrect, | 618 const gfx::Rect& src_subrect, |
| 643 const scoped_refptr<media::VideoFrame>& target, | 619 const scoped_refptr<media::VideoFrame>& target, |
| 644 const base::Callback<void(const gfx::Rect&, bool)>& callback) { | 620 const base::Callback<void(const gfx::Rect&, bool)>& callback) { |
| 645 NOTIMPLEMENTED(); | 621 NOTIMPLEMENTED(); |
| 646 callback.Run(gfx::Rect(), false); | 622 callback.Run(gfx::Rect(), false); |
| 647 } | 623 } |
| 648 | 624 |
| 649 bool RenderWidgetHostViewChildFrame::CanCopyToVideoFrame() const { | 625 bool RenderWidgetHostViewChildFrame::CanCopyToVideoFrame() const { |
| 650 return false; | 626 return false; |
| 651 } | 627 } |
| 652 | 628 |
| 653 bool RenderWidgetHostViewChildFrame::HasAcceleratedSurface( | 629 bool RenderWidgetHostViewChildFrame::HasAcceleratedSurface( |
| 654 const gfx::Size& desired_size) { | 630 const gfx::Size& desired_size) { |
| 655 return false; | 631 return false; |
| 656 } | 632 } |
| 657 | 633 |
| 658 // cc::SurfaceFactoryClient implementation. | 634 void RenderWidgetHostViewChildFrame::ReclaimResources( |
| 659 void RenderWidgetHostViewChildFrame::ReturnResources( | |
| 660 const cc::ReturnedResourceArray& resources) { | 635 const cc::ReturnedResourceArray& resources) { |
| 661 if (resources.empty()) | 636 if (!host_) |
| 662 return; | 637 return; |
| 663 | 638 host_->Send(new ViewMsg_ReclaimCompositorResources( |
| 664 if (!ack_pending_count_ && host_) { | 639 host_->GetRoutingID(), last_compositor_frame_sink_id_, |
| 665 host_->Send(new ViewMsg_ReclaimCompositorResources( | 640 false /* is_swap_ack */, resources)); |
| 666 host_->GetRoutingID(), last_compositor_frame_sink_id_, | |
| 667 false /* is_swap_ack */, resources)); | |
| 668 return; | |
| 669 } | |
| 670 | |
| 671 std::copy(resources.begin(), resources.end(), | |
| 672 std::back_inserter(surface_returned_resources_)); | |
| 673 } | |
| 674 | |
| 675 void RenderWidgetHostViewChildFrame::SetBeginFrameSource( | |
| 676 cc::BeginFrameSource* source) { | |
| 677 bool needs_begin_frames = host_->needs_begin_frames(); | |
| 678 if (begin_frame_source_ && needs_begin_frames) | |
| 679 begin_frame_source_->RemoveObserver(this); | |
| 680 begin_frame_source_ = source; | |
| 681 if (begin_frame_source_ && needs_begin_frames) | |
| 682 begin_frame_source_->AddObserver(this); | |
| 683 } | 641 } |
| 684 | 642 |
| 685 void RenderWidgetHostViewChildFrame::OnBeginFrame( | 643 void RenderWidgetHostViewChildFrame::OnBeginFrame( |
| 686 const cc::BeginFrameArgs& args) { | 644 const cc::BeginFrameArgs& args) { |
| 687 host_->Send(new ViewMsg_BeginFrame(host_->GetRoutingID(), args)); | 645 host_->Send(new ViewMsg_BeginFrame(host_->GetRoutingID(), args)); |
| 688 last_begin_frame_args_ = args; | |
| 689 } | |
| 690 | |
| 691 const cc::BeginFrameArgs& | |
| 692 RenderWidgetHostViewChildFrame::LastUsedBeginFrameArgs() const { | |
| 693 return last_begin_frame_args_; | |
| 694 } | |
| 695 | |
| 696 void RenderWidgetHostViewChildFrame::OnBeginFrameSourcePausedChanged( | |
| 697 bool paused) { | |
| 698 // Only used on Android WebView. | |
| 699 } | 646 } |
| 700 | 647 |
| 701 void RenderWidgetHostViewChildFrame::SetNeedsBeginFrames( | 648 void RenderWidgetHostViewChildFrame::SetNeedsBeginFrames( |
| 702 bool needs_begin_frames) { | 649 bool needs_begin_frames) { |
| 703 if (!begin_frame_source_) | 650 needs_begin_frame_ = needs_begin_frames; |
| 704 return; | 651 if (support_) |
|
lfg
2017/02/27 22:58:25
Why would support_ be null?
Saman Sami
2017/02/28 19:17:10
I don't fully understand how RenderWidget stuff wo
| |
| 705 | 652 support_->SetNeedsBeginFrame(needs_begin_frames); |
| 706 if (needs_begin_frames) | |
| 707 begin_frame_source_->AddObserver(this); | |
| 708 else | |
| 709 begin_frame_source_->RemoveObserver(this); | |
| 710 } | 653 } |
| 711 | 654 |
| 712 InputEventAckState RenderWidgetHostViewChildFrame::FilterInputEvent( | 655 InputEventAckState RenderWidgetHostViewChildFrame::FilterInputEvent( |
| 713 const blink::WebInputEvent& input_event) { | 656 const blink::WebInputEvent& input_event) { |
| 714 if (input_event.type() == blink::WebInputEvent::GestureFlingStart) { | 657 if (input_event.type() == blink::WebInputEvent::GestureFlingStart) { |
| 715 const blink::WebGestureEvent& gesture_event = | 658 const blink::WebGestureEvent& gesture_event = |
| 716 static_cast<const blink::WebGestureEvent&>(input_event); | 659 static_cast<const blink::WebGestureEvent&>(input_event); |
| 717 // Zero-velocity touchpad flings are an Aura-specific signal that the | 660 // Zero-velocity touchpad flings are an Aura-specific signal that the |
| 718 // touchpad scroll has ended, and should not be forwarded to the renderer. | 661 // touchpad scroll has ended, and should not be forwarded to the renderer. |
| 719 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad && | 662 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad && |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 735 } | 678 } |
| 736 | 679 |
| 737 BrowserAccessibilityManager* | 680 BrowserAccessibilityManager* |
| 738 RenderWidgetHostViewChildFrame::CreateBrowserAccessibilityManager( | 681 RenderWidgetHostViewChildFrame::CreateBrowserAccessibilityManager( |
| 739 BrowserAccessibilityDelegate* delegate, bool for_root_frame) { | 682 BrowserAccessibilityDelegate* delegate, bool for_root_frame) { |
| 740 return BrowserAccessibilityManager::Create( | 683 return BrowserAccessibilityManager::Create( |
| 741 BrowserAccessibilityManager::GetEmptyDocument(), delegate); | 684 BrowserAccessibilityManager::GetEmptyDocument(), delegate); |
| 742 } | 685 } |
| 743 | 686 |
| 744 void RenderWidgetHostViewChildFrame::ClearCompositorSurfaceIfNecessary() { | 687 void RenderWidgetHostViewChildFrame::ClearCompositorSurfaceIfNecessary() { |
| 745 surface_factory_->EvictSurface(); | 688 if (support_) |
|
lfg
2017/02/27 22:58:25
Same as above.
Saman Sami
2017/02/28 19:17:10
The one above turned out to be necessary. I feel s
| |
| 689 support_->EvictFrame(); | |
| 746 local_surface_id_ = cc::LocalSurfaceId(); | 690 local_surface_id_ = cc::LocalSurfaceId(); |
| 747 } | 691 } |
| 748 | 692 |
| 749 bool RenderWidgetHostViewChildFrame::IsChildFrameForTesting() const { | 693 bool RenderWidgetHostViewChildFrame::IsChildFrameForTesting() const { |
| 750 return true; | 694 return true; |
| 751 } | 695 } |
| 752 | 696 |
| 753 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const { | 697 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const { |
| 754 return cc::SurfaceId(frame_sink_id_, local_surface_id_); | 698 return cc::SurfaceId(frame_sink_id_, local_surface_id_); |
| 755 }; | 699 }; |
| 756 | 700 |
| 701 void RenderWidgetHostViewChildFrame::CreateCompositorFrameSinkSupport() { | |
| 702 DCHECK(!support_); | |
| 703 support_ = base::MakeUnique<cc::CompositorFrameSinkSupport>( | |
| 704 this, GetSurfaceManager(), frame_sink_id_, false /* is_root */, | |
| 705 false /* handles_frame_sink_id_invalidation */, | |
| 706 true /* needs_sync_points */); | |
| 707 if (parent_frame_sink_id_.is_valid()) { | |
| 708 GetSurfaceManager()->RegisterFrameSinkHierarchy(parent_frame_sink_id_, | |
| 709 frame_sink_id_); | |
| 710 } | |
| 711 if (needs_begin_frame_) | |
| 712 support_->SetNeedsBeginFrame(needs_begin_frame_); | |
| 713 } | |
| 714 | |
| 715 void RenderWidgetHostViewChildFrame::ResetCompositorFrameSinkSupport() { | |
| 716 if (!support_) | |
| 717 return; | |
| 718 if (parent_frame_sink_id_.is_valid()) { | |
| 719 GetSurfaceManager()->UnregisterFrameSinkHierarchy(parent_frame_sink_id_, | |
| 720 frame_sink_id_); | |
| 721 } | |
| 722 support_.reset(); | |
| 723 } | |
| 724 | |
| 757 } // namespace content | 725 } // namespace content |
| OLD | NEW |