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

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

Issue 2485473003: Remove SurfaceFactory::Create and SurfaceFactory::Destroy (Closed)
Patch Set: up 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
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_);
66 } 66 }
67 67
68 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() { 68 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() {
69 if (!local_frame_id_.is_null())
70 surface_factory_->Destroy(local_frame_id_);
71
72 if (GetSurfaceManager()) 69 if (GetSurfaceManager())
73 GetSurfaceManager()->InvalidateFrameSinkId(frame_sink_id_); 70 GetSurfaceManager()->InvalidateFrameSinkId(frame_sink_id_);
74 } 71 }
75 72
76 void RenderWidgetHostViewChildFrame::Init() { 73 void RenderWidgetHostViewChildFrame::Init() {
77 RegisterFrameSinkId(); 74 RegisterFrameSinkId();
78 host_->SetView(this); 75 host_->SetView(this);
79 GetTextInputManager(); 76 GetTextInputManager();
80 } 77 }
81 78
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 376
380 cc::RenderPass* root_pass = frame.render_pass_list.back().get(); 377 cc::RenderPass* root_pass = frame.render_pass_list.back().get();
381 378
382 gfx::Size frame_size = root_pass->output_rect.size(); 379 gfx::Size frame_size = root_pass->output_rect.size();
383 float scale_factor = frame.metadata.device_scale_factor; 380 float scale_factor = frame.metadata.device_scale_factor;
384 381
385 // Check whether we need to recreate the cc::Surface, which means the child 382 // 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. 383 // frame renderer has changed its output surface, or size, or scale factor.
387 if (compositor_frame_sink_id != last_compositor_frame_sink_id_ && 384 if (compositor_frame_sink_id != last_compositor_frame_sink_id_ &&
388 surface_factory_) { 385 surface_factory_) {
389 surface_factory_->Destroy(local_frame_id_);
390 surface_factory_.reset(); 386 surface_factory_.reset();
391 } 387 }
392 if (compositor_frame_sink_id != last_compositor_frame_sink_id_ || 388 if (compositor_frame_sink_id != last_compositor_frame_sink_id_ ||
393 frame_size != current_surface_size_ || 389 frame_size != current_surface_size_ ||
394 scale_factor != current_surface_scale_factor_) { 390 scale_factor != current_surface_scale_factor_) {
395 ClearCompositorSurfaceIfNecessary(); 391 ClearCompositorSurfaceIfNecessary();
396 last_compositor_frame_sink_id_ = compositor_frame_sink_id; 392 last_compositor_frame_sink_id_ = compositor_frame_sink_id;
397 current_surface_size_ = frame_size; 393 current_surface_size_ = frame_size;
398 current_surface_scale_factor_ = scale_factor; 394 current_surface_scale_factor_ = scale_factor;
399 } 395 }
400 396
401 if (!surface_factory_) { 397 if (!surface_factory_) {
402 cc::SurfaceManager* manager = GetSurfaceManager(); 398 cc::SurfaceManager* manager = GetSurfaceManager();
403 surface_factory_ = 399 surface_factory_ =
404 base::MakeUnique<cc::SurfaceFactory>(frame_sink_id_, manager, this); 400 base::MakeUnique<cc::SurfaceFactory>(frame_sink_id_, manager, this);
405 } 401 }
406 402
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_->SubmitCompositorFrame(local_frame_id_,
Fady Samuel 2016/11/08 22:23:59 Is this necessary? Just add the destruction depend
Saman Sami 2016/11/11 17:49:58 Done.
406 cc::CompositorFrame(),
407 cc::SurfaceFactory::DrawCallback());
410 408
411 cc::SurfaceSequence sequence = 409 cc::SurfaceSequence sequence =
412 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++); 410 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++);
413 // The renderer process will satisfy this dependency when it creates a 411 // The renderer process will satisfy this dependency when it creates a
414 // SurfaceLayer. 412 // SurfaceLayer.
415 cc::SurfaceManager* manager = GetSurfaceManager(); 413 cc::SurfaceManager* manager = GetSurfaceManager();
416 manager->GetSurfaceForId(cc::SurfaceId(frame_sink_id_, local_frame_id_)) 414 manager->GetSurfaceForId(cc::SurfaceId(frame_sink_id_, local_frame_id_))
417 ->AddDestructionDependency(sequence); 415 ->AddDestructionDependency(sequence);
418 frame_connector_->SetChildFrameSurface( 416 frame_connector_->SetChildFrameSurface(
419 cc::SurfaceId(frame_sink_id_, local_frame_id_), frame_size, 417 cc::SurfaceId(frame_sink_id_, local_frame_id_), frame_size,
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 } 721 }
724 722
725 BrowserAccessibilityManager* 723 BrowserAccessibilityManager*
726 RenderWidgetHostViewChildFrame::CreateBrowserAccessibilityManager( 724 RenderWidgetHostViewChildFrame::CreateBrowserAccessibilityManager(
727 BrowserAccessibilityDelegate* delegate, bool for_root_frame) { 725 BrowserAccessibilityDelegate* delegate, bool for_root_frame) {
728 return BrowserAccessibilityManager::Create( 726 return BrowserAccessibilityManager::Create(
729 BrowserAccessibilityManager::GetEmptyDocument(), delegate); 727 BrowserAccessibilityManager::GetEmptyDocument(), delegate);
730 } 728 }
731 729
732 void RenderWidgetHostViewChildFrame::ClearCompositorSurfaceIfNecessary() { 730 void RenderWidgetHostViewChildFrame::ClearCompositorSurfaceIfNecessary() {
733 if (surface_factory_ && !local_frame_id_.is_null())
734 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

Powered by Google App Engine
This is Rietveld 408576698