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

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: SetPreviousFrame lint 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 auto* manager = GetSurfaceManager(); 65 auto* manager = GetSurfaceManager();
66 manager->RegisterFrameSinkId(frame_sink_id_); 66 manager->RegisterFrameSinkId(frame_sink_id_);
67 surface_factory_ = 67 surface_factory_ =
68 base::MakeUnique<cc::SurfaceFactory>(frame_sink_id_, manager, this); 68 base::MakeUnique<cc::SurfaceFactory>(frame_sink_id_, manager, this);
69 } 69 }
70 70
71 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() { 71 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() {
72 if (local_frame_id_.is_valid()) 72 surface_factory_.reset();
Fady Samuel 2016/11/11 19:47:57 surface_factory_->EvictFrame();
73 surface_factory_->Destroy(local_frame_id_);
74
75 if (GetSurfaceManager()) 73 if (GetSurfaceManager())
76 GetSurfaceManager()->InvalidateFrameSinkId(frame_sink_id_); 74 GetSurfaceManager()->InvalidateFrameSinkId(frame_sink_id_);
77 } 75 }
78 76
79 void RenderWidgetHostViewChildFrame::Init() { 77 void RenderWidgetHostViewChildFrame::Init() {
80 RegisterFrameSinkId(); 78 RegisterFrameSinkId();
81 host_->SetView(this); 79 host_->SetView(this);
82 GetTextInputManager(); 80 GetTextInputManager();
83 } 81 }
84 82
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 ClearCompositorSurfaceIfNecessary(); 391 ClearCompositorSurfaceIfNecessary();
394 // If the renderer changed its frame sink, reset the surface factory to 392 // If the renderer changed its frame sink, reset the surface factory to
395 // avoid returning stale resources. 393 // avoid returning stale resources.
396 if (compositor_frame_sink_id != last_compositor_frame_sink_id_) 394 if (compositor_frame_sink_id != last_compositor_frame_sink_id_)
397 surface_factory_->Reset(); 395 surface_factory_->Reset();
398 last_compositor_frame_sink_id_ = compositor_frame_sink_id; 396 last_compositor_frame_sink_id_ = compositor_frame_sink_id;
399 current_surface_size_ = frame_size; 397 current_surface_size_ = frame_size;
400 current_surface_scale_factor_ = scale_factor; 398 current_surface_scale_factor_ = scale_factor;
401 } 399 }
402 400
401 bool allocated_new_local_frame_id = false;
403 if (!local_frame_id_.is_valid()) { 402 if (!local_frame_id_.is_valid()) {
404 local_frame_id_ = id_allocator_->GenerateId(); 403 local_frame_id_ = id_allocator_->GenerateId();
405 surface_factory_->Create(local_frame_id_); 404 allocated_new_local_frame_id = true;
405 }
406 406
407 cc::SurfaceFactory::DrawCallback ack_callback =
408 base::Bind(&RenderWidgetHostViewChildFrame::SurfaceDrawn, AsWeakPtr(),
409 compositor_frame_sink_id);
410 ack_pending_count_++;
411 // If this value grows very large, something is going wrong.
412 DCHECK_LT(ack_pending_count_, 1000U);
413 surface_factory_->SubmitCompositorFrame(local_frame_id_, std::move(frame),
414 ack_callback);
415
416 if (allocated_new_local_frame_id) {
407 cc::SurfaceSequence sequence = 417 cc::SurfaceSequence sequence =
408 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++); 418 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++);
409 // The renderer process will satisfy this dependency when it creates a 419 // The renderer process will satisfy this dependency when it creates a
410 // SurfaceLayer. 420 // SurfaceLayer.
411 cc::SurfaceManager* manager = GetSurfaceManager(); 421 cc::SurfaceManager* manager = GetSurfaceManager();
412 manager->GetSurfaceForId(cc::SurfaceId(frame_sink_id_, local_frame_id_)) 422 manager->GetSurfaceForId(cc::SurfaceId(frame_sink_id_, local_frame_id_))
413 ->AddDestructionDependency(sequence); 423 ->AddDestructionDependency(sequence);
414 frame_connector_->SetChildFrameSurface( 424 frame_connector_->SetChildFrameSurface(
415 cc::SurfaceId(frame_sink_id_, local_frame_id_), frame_size, 425 cc::SurfaceId(frame_sink_id_, local_frame_id_), frame_size,
416 scale_factor, sequence); 426 scale_factor, sequence);
417 } 427 }
418
419 cc::SurfaceFactory::DrawCallback ack_callback =
420 base::Bind(&RenderWidgetHostViewChildFrame::SurfaceDrawn, AsWeakPtr(),
421 compositor_frame_sink_id);
422 ack_pending_count_++;
423 // If this value grows very large, something is going wrong.
424 DCHECK_LT(ack_pending_count_, 1000U);
425 surface_factory_->SubmitCompositorFrame(local_frame_id_, std::move(frame),
426 ack_callback);
427
428 ProcessFrameSwappedCallbacks(); 428 ProcessFrameSwappedCallbacks();
429 } 429 }
430 430
431 void RenderWidgetHostViewChildFrame::ProcessFrameSwappedCallbacks() { 431 void RenderWidgetHostViewChildFrame::ProcessFrameSwappedCallbacks() {
432 // We only use callbacks once, therefore we make a new list for registration 432 // We only use callbacks once, therefore we make a new list for registration
433 // before we start, and discard the old list entries when we are done. 433 // before we start, and discard the old list entries when we are done.
434 FrameSwappedCallbackList process_callbacks; 434 FrameSwappedCallbackList process_callbacks;
435 process_callbacks.swap(frame_swapped_callbacks_); 435 process_callbacks.swap(frame_swapped_callbacks_);
436 for (std::unique_ptr<base::Closure>& callback : process_callbacks) 436 for (std::unique_ptr<base::Closure>& callback : process_callbacks)
437 callback->Run(); 437 callback->Run();
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 } 719 }
720 720
721 BrowserAccessibilityManager* 721 BrowserAccessibilityManager*
722 RenderWidgetHostViewChildFrame::CreateBrowserAccessibilityManager( 722 RenderWidgetHostViewChildFrame::CreateBrowserAccessibilityManager(
723 BrowserAccessibilityDelegate* delegate, bool for_root_frame) { 723 BrowserAccessibilityDelegate* delegate, bool for_root_frame) {
724 return BrowserAccessibilityManager::Create( 724 return BrowserAccessibilityManager::Create(
725 BrowserAccessibilityManager::GetEmptyDocument(), delegate); 725 BrowserAccessibilityManager::GetEmptyDocument(), delegate);
726 } 726 }
727 727
728 void RenderWidgetHostViewChildFrame::ClearCompositorSurfaceIfNecessary() { 728 void RenderWidgetHostViewChildFrame::ClearCompositorSurfaceIfNecessary() {
729 if (local_frame_id_.is_valid())
730 surface_factory_->Destroy(local_frame_id_);
Fady Samuel 2016/11/11 19:47:57 surface_factory_->EvictFrame();
731 local_frame_id_ = cc::LocalFrameId(); 729 local_frame_id_ = cc::LocalFrameId();
732 } 730 }
733 731
734 bool RenderWidgetHostViewChildFrame::IsChildFrameForTesting() const { 732 bool RenderWidgetHostViewChildFrame::IsChildFrameForTesting() const {
735 return true; 733 return true;
736 } 734 }
737 735
738 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const { 736 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const {
739 return cc::SurfaceId(frame_sink_id_, local_frame_id_); 737 return cc::SurfaceId(frame_sink_id_, local_frame_id_);
740 }; 738 };
741 739
742 } // namespace content 740 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698