Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: content/browser/frame_host/render_widget_host_view_child_frame.cc

Issue 2484013002: Make SurfaceFactory lifetime match frame_sink_id_ registration in RWHVChildFrame (Closed)
Patch Set: Fix RenderWidgetHostViewGuest Created 4 years, 1 month 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
« no previous file with comments | « no previous file | content/browser/frame_host/render_widget_host_view_guest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 base::checked_cast<uint32_t>(widget_host->GetProcess()->GetID()), 55 base::checked_cast<uint32_t>(widget_host->GetProcess()->GetID()),
56 base::checked_cast<uint32_t>(widget_host->GetRoutingID())), 56 base::checked_cast<uint32_t>(widget_host->GetRoutingID())),
57 next_surface_sequence_(1u), 57 next_surface_sequence_(1u),
58 last_compositor_frame_sink_id_(0), 58 last_compositor_frame_sink_id_(0),
59 current_surface_scale_factor_(1.f), 59 current_surface_scale_factor_(1.f),
60 ack_pending_count_(0), 60 ack_pending_count_(0),
61 frame_connector_(nullptr), 61 frame_connector_(nullptr),
62 begin_frame_source_(nullptr), 62 begin_frame_source_(nullptr),
63 weak_factory_(this) { 63 weak_factory_(this) {
64 id_allocator_.reset(new cc::SurfaceIdAllocator()); 64 id_allocator_.reset(new cc::SurfaceIdAllocator());
65 GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_); 65 auto* manager = GetSurfaceManager();
66 manager->RegisterFrameSinkId(frame_sink_id_);
67 surface_factory_ =
68 base::MakeUnique<cc::SurfaceFactory>(frame_sink_id_, manager, this);
66 } 69 }
67 70
68 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() { 71 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() {
69 if (!local_frame_id_.is_null()) 72 if (!local_frame_id_.is_null())
70 surface_factory_->Destroy(local_frame_id_); 73 surface_factory_->Destroy(local_frame_id_);
71 74
72 if (GetSurfaceManager()) 75 if (GetSurfaceManager())
73 GetSurfaceManager()->InvalidateFrameSinkId(frame_sink_id_); 76 GetSurfaceManager()->InvalidateFrameSinkId(frame_sink_id_);
74 } 77 }
75 78
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 void RenderWidgetHostViewChildFrame::Focus() { 144 void RenderWidgetHostViewChildFrame::Focus() {
142 } 145 }
143 146
144 bool RenderWidgetHostViewChildFrame::HasFocus() const { 147 bool RenderWidgetHostViewChildFrame::HasFocus() const {
145 if (frame_connector_) 148 if (frame_connector_)
146 return frame_connector_->HasFocus(); 149 return frame_connector_->HasFocus();
147 return false; 150 return false;
148 } 151 }
149 152
150 bool RenderWidgetHostViewChildFrame::IsSurfaceAvailableForCopy() const { 153 bool RenderWidgetHostViewChildFrame::IsSurfaceAvailableForCopy() const {
151 return surface_factory_ && !local_frame_id_.is_null(); 154 return !local_frame_id_.is_null();
152 } 155 }
153 156
154 void RenderWidgetHostViewChildFrame::Show() { 157 void RenderWidgetHostViewChildFrame::Show() {
155 if (!host_->is_hidden()) 158 if (!host_->is_hidden())
156 return; 159 return;
157 host_->WasShown(ui::LatencyInfo()); 160 host_->WasShown(ui::LatencyInfo());
158 } 161 }
159 162
160 void RenderWidgetHostViewChildFrame::Hide() { 163 void RenderWidgetHostViewChildFrame::Hide() {
161 if (host_->is_hidden()) 164 if (host_->is_hidden())
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 379
377 if (!frame_connector_) 380 if (!frame_connector_)
378 return; 381 return;
379 382
380 cc::RenderPass* root_pass = frame.render_pass_list.back().get(); 383 cc::RenderPass* root_pass = frame.render_pass_list.back().get();
381 384
382 gfx::Size frame_size = root_pass->output_rect.size(); 385 gfx::Size frame_size = root_pass->output_rect.size();
383 float scale_factor = frame.metadata.device_scale_factor; 386 float scale_factor = frame.metadata.device_scale_factor;
384 387
385 // Check whether we need to recreate the cc::Surface, which means the child 388 // Check whether we need to recreate the cc::Surface, which means the child
386 // frame renderer has changed its output surface, or size, or scale factor. 389 // frame renderer has changed its frame sink, or size, or scale factor.
387 if (compositor_frame_sink_id != last_compositor_frame_sink_id_ &&
388 surface_factory_) {
389 surface_factory_->Destroy(local_frame_id_);
390 surface_factory_.reset();
391 }
392 if (compositor_frame_sink_id != last_compositor_frame_sink_id_ || 390 if (compositor_frame_sink_id != last_compositor_frame_sink_id_ ||
393 frame_size != current_surface_size_ || 391 frame_size != current_surface_size_ ||
394 scale_factor != current_surface_scale_factor_) { 392 scale_factor != current_surface_scale_factor_) {
395 ClearCompositorSurfaceIfNecessary(); 393 ClearCompositorSurfaceIfNecessary();
394 // If the renderer changed its frame sink, reset the surface factory to
395 // avoid returning stale resources.
396 if (compositor_frame_sink_id != last_compositor_frame_sink_id_)
397 surface_factory_->Reset();
396 last_compositor_frame_sink_id_ = compositor_frame_sink_id; 398 last_compositor_frame_sink_id_ = compositor_frame_sink_id;
397 current_surface_size_ = frame_size; 399 current_surface_size_ = frame_size;
398 current_surface_scale_factor_ = scale_factor; 400 current_surface_scale_factor_ = scale_factor;
399 } 401 }
400 402
401 if (!surface_factory_) {
402 cc::SurfaceManager* manager = GetSurfaceManager();
403 surface_factory_ =
404 base::MakeUnique<cc::SurfaceFactory>(frame_sink_id_, manager, this);
405 }
406
407 if (local_frame_id_.is_null()) { 403 if (local_frame_id_.is_null()) {
408 local_frame_id_ = id_allocator_->GenerateId(); 404 local_frame_id_ = id_allocator_->GenerateId();
409 surface_factory_->Create(local_frame_id_); 405 surface_factory_->Create(local_frame_id_);
410 406
411 cc::SurfaceSequence sequence = 407 cc::SurfaceSequence sequence =
412 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++); 408 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++);
413 // The renderer process will satisfy this dependency when it creates a 409 // The renderer process will satisfy this dependency when it creates a
414 // SurfaceLayer. 410 // SurfaceLayer.
415 cc::SurfaceManager* manager = GetSurfaceManager(); 411 cc::SurfaceManager* manager = GetSurfaceManager();
416 manager->GetSurfaceForId(cc::SurfaceId(frame_sink_id_, local_frame_id_)) 412 manager->GetSurfaceForId(cc::SurfaceId(frame_sink_id_, local_frame_id_))
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 } 719 }
724 720
725 BrowserAccessibilityManager* 721 BrowserAccessibilityManager*
726 RenderWidgetHostViewChildFrame::CreateBrowserAccessibilityManager( 722 RenderWidgetHostViewChildFrame::CreateBrowserAccessibilityManager(
727 BrowserAccessibilityDelegate* delegate, bool for_root_frame) { 723 BrowserAccessibilityDelegate* delegate, bool for_root_frame) {
728 return BrowserAccessibilityManager::Create( 724 return BrowserAccessibilityManager::Create(
729 BrowserAccessibilityManager::GetEmptyDocument(), delegate); 725 BrowserAccessibilityManager::GetEmptyDocument(), delegate);
730 } 726 }
731 727
732 void RenderWidgetHostViewChildFrame::ClearCompositorSurfaceIfNecessary() { 728 void RenderWidgetHostViewChildFrame::ClearCompositorSurfaceIfNecessary() {
733 if (surface_factory_ && !local_frame_id_.is_null()) 729 if (!local_frame_id_.is_null())
734 surface_factory_->Destroy(local_frame_id_); 730 surface_factory_->Destroy(local_frame_id_);
735 local_frame_id_ = cc::LocalFrameId(); 731 local_frame_id_ = cc::LocalFrameId();
736 } 732 }
737 733
738 bool RenderWidgetHostViewChildFrame::IsChildFrameForTesting() const { 734 bool RenderWidgetHostViewChildFrame::IsChildFrameForTesting() const {
739 return true; 735 return true;
740 } 736 }
741 737
742 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const { 738 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const {
743 return cc::SurfaceId(frame_sink_id_, local_frame_id_); 739 return cc::SurfaceId(frame_sink_id_, local_frame_id_);
744 }; 740 };
745 741
746 } // namespace content 742 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/render_widget_host_view_guest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698