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

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

Powered by Google App Engine
This is Rietveld 408576698