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

Side by Side Diff: content/browser/renderer_host/delegated_frame_host.cc

Issue 2811083002: Move frame eviction into components (Closed)
Patch Set: Rebase Created 3 years, 8 months 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/renderer_host/delegated_frame_host.h" 5 #include "content/browser/renderer_host/delegated_frame_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 DelegatedFrameHost::DelegatedFrameHost(const cc::FrameSinkId& frame_sink_id, 44 DelegatedFrameHost::DelegatedFrameHost(const cc::FrameSinkId& frame_sink_id,
45 DelegatedFrameHostClient* client) 45 DelegatedFrameHostClient* client)
46 : frame_sink_id_(frame_sink_id), 46 : frame_sink_id_(frame_sink_id),
47 client_(client), 47 client_(client),
48 compositor_(nullptr), 48 compositor_(nullptr),
49 tick_clock_(new base::DefaultTickClock()), 49 tick_clock_(new base::DefaultTickClock()),
50 skipped_frames_(false), 50 skipped_frames_(false),
51 background_color_(SK_ColorRED), 51 background_color_(SK_ColorRED),
52 current_scale_factor_(1.f), 52 current_scale_factor_(1.f),
53 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) { 53 frame_evictor_(new viz::FrameEvictor(this)) {
54 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 54 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
55 factory->GetContextFactory()->AddObserver(this); 55 factory->GetContextFactory()->AddObserver(this);
56 factory->GetContextFactoryPrivate()->GetSurfaceManager()->RegisterFrameSinkId( 56 factory->GetContextFactoryPrivate()->GetSurfaceManager()->RegisterFrameSinkId(
57 frame_sink_id_); 57 frame_sink_id_);
58 CreateCompositorFrameSinkSupport(); 58 CreateCompositorFrameSinkSupport();
59 } 59 }
60 60
61 void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) { 61 void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) {
62 delegated_frame_evictor_->SetVisible(true); 62 frame_evictor_->SetVisible(true);
63 63
64 if (!has_frame_ && !released_front_lock_.get()) { 64 if (!has_frame_ && !released_front_lock_.get()) {
65 if (compositor_) 65 if (compositor_)
66 released_front_lock_ = compositor_->GetCompositorLock(nullptr); 66 released_front_lock_ = compositor_->GetCompositorLock(nullptr);
67 } 67 }
68 68
69 if (compositor_) { 69 if (compositor_) {
70 compositor_->SetLatencyInfo(latency_info); 70 compositor_->SetLatencyInfo(latency_info);
71 } 71 }
72 } 72 }
73 73
74 bool DelegatedFrameHost::HasSavedFrame() { 74 bool DelegatedFrameHost::HasSavedFrame() {
75 return delegated_frame_evictor_->HasFrame(); 75 return frame_evictor_->HasFrame();
76 } 76 }
77 77
78 void DelegatedFrameHost::WasHidden() { 78 void DelegatedFrameHost::WasHidden() {
79 delegated_frame_evictor_->SetVisible(false); 79 frame_evictor_->SetVisible(false);
80 released_front_lock_ = NULL; 80 released_front_lock_ = NULL;
81 } 81 }
82 82
83 void DelegatedFrameHost::MaybeCreateResizeLock() { 83 void DelegatedFrameHost::MaybeCreateResizeLock() {
84 DCHECK(!resize_lock_); 84 DCHECK(!resize_lock_);
85 85
86 if (!compositor_) 86 if (!compositor_)
87 return; 87 return;
88 88
89 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 89 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 CheckResizeLock(); 475 CheckResizeLock();
476 476
477 UpdateGutters(); 477 UpdateGutters();
478 478
479 if (!damage_rect_in_dip.IsEmpty()) { 479 if (!damage_rect_in_dip.IsEmpty()) {
480 client_->DelegatedFrameHostGetLayer()->OnDelegatedFrameDamage( 480 client_->DelegatedFrameHostGetLayer()->OnDelegatedFrameDamage(
481 damage_rect_in_dip); 481 damage_rect_in_dip);
482 } 482 }
483 483
484 if (has_frame_) { 484 if (has_frame_) {
485 delegated_frame_evictor_->SwappedFrame( 485 frame_evictor_->SwappedFrame(client_->DelegatedFrameHostIsVisible());
486 client_->DelegatedFrameHostIsVisible());
487 } 486 }
488 // Note: the frame may have been evicted immediately. 487 // Note: the frame may have been evicted immediately.
489 488
490 DidFinishFrame(ack); 489 DidFinishFrame(ack);
491 } 490 }
492 491
493 void DelegatedFrameHost::ClearDelegatedFrame() { 492 void DelegatedFrameHost::ClearDelegatedFrame() {
494 EvictDelegatedFrame(); 493 EvictDelegatedFrame();
495 } 494 }
496 495
(...skipping 21 matching lines...) Expand all
518 void DelegatedFrameHost::OnBeginFrame(const cc::BeginFrameArgs& args) { 517 void DelegatedFrameHost::OnBeginFrame(const cc::BeginFrameArgs& args) {
519 client_->OnBeginFrame(args); 518 client_->OnBeginFrame(args);
520 } 519 }
521 520
522 void DelegatedFrameHost::EvictDelegatedFrame() { 521 void DelegatedFrameHost::EvictDelegatedFrame() {
523 if (!has_frame_) 522 if (!has_frame_)
524 return; 523 return;
525 client_->DelegatedFrameHostGetLayer()->SetShowSolidColorContent(); 524 client_->DelegatedFrameHostGetLayer()->SetShowSolidColorContent();
526 support_->EvictFrame(); 525 support_->EvictFrame();
527 has_frame_ = false; 526 has_frame_ = false;
528 delegated_frame_evictor_->DiscardedFrame(); 527 frame_evictor_->DiscardedFrame();
529 UpdateGutters(); 528 UpdateGutters();
530 } 529 }
531 530
532 // static 531 // static
533 void DelegatedFrameHost::ReturnSubscriberTexture( 532 void DelegatedFrameHost::ReturnSubscriberTexture(
534 base::WeakPtr<DelegatedFrameHost> dfh, 533 base::WeakPtr<DelegatedFrameHost> dfh,
535 scoped_refptr<OwnedMailbox> subscriber_texture, 534 scoped_refptr<OwnedMailbox> subscriber_texture,
536 const gpu::SyncToken& sync_token) { 535 const gpu::SyncToken& sync_token) {
537 if (!subscriber_texture.get()) 536 if (!subscriber_texture.get())
538 return; 537 return;
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 vsync_manager_->RemoveObserver(this); 803 vsync_manager_->RemoveObserver(this);
805 vsync_manager_ = nullptr; 804 vsync_manager_ = nullptr;
806 } 805 }
807 806
808 compositor_->RemoveFrameSink(frame_sink_id_); 807 compositor_->RemoveFrameSink(frame_sink_id_);
809 compositor_ = nullptr; 808 compositor_ = nullptr;
810 } 809 }
811 810
812 void DelegatedFrameHost::LockResources() { 811 void DelegatedFrameHost::LockResources() {
813 DCHECK(local_surface_id_.is_valid()); 812 DCHECK(local_surface_id_.is_valid());
814 delegated_frame_evictor_->LockFrame(); 813 frame_evictor_->LockFrame();
815 } 814 }
816 815
817 void DelegatedFrameHost::RequestCopyOfOutput( 816 void DelegatedFrameHost::RequestCopyOfOutput(
818 std::unique_ptr<cc::CopyOutputRequest> request) { 817 std::unique_ptr<cc::CopyOutputRequest> request) {
819 // If a specific area has not been requested, set one to ensure correct 818 // If a specific area has not been requested, set one to ensure correct
820 // clipping occurs. 819 // clipping occurs.
821 if (!request->has_area()) 820 if (!request->has_area())
822 request->set_area(gfx::Rect(current_frame_size_in_dip_)); 821 request->set_area(gfx::Rect(current_frame_size_in_dip_));
823 822
824 if (request_copy_of_output_callback_for_testing_.is_null()) { 823 if (request_copy_of_output_callback_for_testing_.is_null()) {
825 client_->DelegatedFrameHostGetLayer()->RequestCopyOfOutput( 824 client_->DelegatedFrameHostGetLayer()->RequestCopyOfOutput(
826 std::move(request)); 825 std::move(request));
827 } else { 826 } else {
828 request_copy_of_output_callback_for_testing_.Run(std::move(request)); 827 request_copy_of_output_callback_for_testing_.Run(std::move(request));
829 } 828 }
830 } 829 }
831 830
832 void DelegatedFrameHost::UnlockResources() { 831 void DelegatedFrameHost::UnlockResources() {
833 DCHECK(local_surface_id_.is_valid()); 832 DCHECK(local_surface_id_.is_valid());
834 delegated_frame_evictor_->UnlockFrame(); 833 frame_evictor_->UnlockFrame();
835 } 834 }
836 835
837 void DelegatedFrameHost::CreateCompositorFrameSinkSupport() { 836 void DelegatedFrameHost::CreateCompositorFrameSinkSupport() {
838 DCHECK(!support_); 837 DCHECK(!support_);
839 constexpr bool is_root = false; 838 constexpr bool is_root = false;
840 constexpr bool handles_frame_sink_id_invalidation = false; 839 constexpr bool handles_frame_sink_id_invalidation = false;
841 constexpr bool needs_sync_points = true; 840 constexpr bool needs_sync_points = true;
842 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 841 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
843 support_ = cc::CompositorFrameSinkSupport::Create( 842 support_ = cc::CompositorFrameSinkSupport::Create(
844 this, factory->GetContextFactoryPrivate()->GetSurfaceManager(), 843 this, factory->GetContextFactoryPrivate()->GetSurfaceManager(),
(...skipping 21 matching lines...) Expand all
866 } 865 }
867 866
868 if (!skipped_frames_) { 867 if (!skipped_frames_) {
869 latest_confirmed_begin_frame_source_id_ = ack.source_id; 868 latest_confirmed_begin_frame_source_id_ = ack.source_id;
870 latest_confirmed_begin_frame_sequence_number_ = 869 latest_confirmed_begin_frame_sequence_number_ =
871 ack.latest_confirmed_sequence_number; 870 ack.latest_confirmed_sequence_number;
872 } 871 }
873 } 872 }
874 873
875 } // namespace content 874 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/delegated_frame_host.h ('k') | content/browser/renderer_host/render_widget_host_view_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698