| OLD | NEW |
| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 last_compositor_frame_sink_id_(0), | 72 last_compositor_frame_sink_id_(0), |
| 73 pending_delegated_ack_count_(0), | 73 pending_delegated_ack_count_(0), |
| 74 skipped_frames_(false), | 74 skipped_frames_(false), |
| 75 background_color_(SK_ColorRED), | 75 background_color_(SK_ColorRED), |
| 76 current_scale_factor_(1.f), | 76 current_scale_factor_(1.f), |
| 77 can_lock_compositor_(YES_CAN_LOCK), | 77 can_lock_compositor_(YES_CAN_LOCK), |
| 78 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) { | 78 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) { |
| 79 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 79 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 80 factory->GetContextFactory()->AddObserver(this); | 80 factory->GetContextFactory()->AddObserver(this); |
| 81 id_allocator_.reset(new cc::SurfaceIdAllocator()); | 81 id_allocator_.reset(new cc::SurfaceIdAllocator()); |
| 82 factory->GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_); | 82 factory->GetContextFactory()->GetSurfaceManager()->RegisterFrameSinkId( |
| 83 factory->GetSurfaceManager()->RegisterSurfaceFactoryClient(frame_sink_id_, | 83 frame_sink_id_); |
| 84 this); | 84 factory->GetContextFactory() |
| 85 ->GetSurfaceManager() |
| 86 ->RegisterSurfaceFactoryClient(frame_sink_id_, this); |
| 85 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>( | 87 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>( |
| 86 frame_sink_id_, factory->GetSurfaceManager(), this); | 88 frame_sink_id_, factory->GetContextFactory()->GetSurfaceManager(), this); |
| 87 } | 89 } |
| 88 | 90 |
| 89 void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) { | 91 void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) { |
| 90 delegated_frame_evictor_->SetVisible(true); | 92 delegated_frame_evictor_->SetVisible(true); |
| 91 | 93 |
| 92 if (!local_frame_id_.is_valid() && !released_front_lock_.get()) { | 94 if (!local_frame_id_.is_valid() && !released_front_lock_.get()) { |
| 93 if (compositor_) | 95 if (compositor_) |
| 94 released_front_lock_ = compositor_->GetCompositorLock(); | 96 released_front_lock_ = compositor_->GetCompositorLock(); |
| 95 } | 97 } |
| 96 | 98 |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 pending_delegated_ack_count_++; | 470 pending_delegated_ack_count_++; |
| 469 | 471 |
| 470 background_color_ = frame.metadata.root_background_color; | 472 background_color_ = frame.metadata.root_background_color; |
| 471 | 473 |
| 472 bool did_send_ack_callback = false; | 474 bool did_send_ack_callback = false; |
| 473 if (frame_size.IsEmpty()) { | 475 if (frame_size.IsEmpty()) { |
| 474 DCHECK(frame.resource_list.empty()); | 476 DCHECK(frame.resource_list.empty()); |
| 475 EvictDelegatedFrame(); | 477 EvictDelegatedFrame(); |
| 476 } else { | 478 } else { |
| 477 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 479 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 478 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 480 cc::SurfaceManager* manager = |
| 481 factory->GetContextFactory()->GetSurfaceManager(); |
| 479 bool allocated_new_local_frame_id = false; | 482 bool allocated_new_local_frame_id = false; |
| 480 if (!local_frame_id_.is_valid() || frame_size != current_surface_size_ || | 483 if (!local_frame_id_.is_valid() || frame_size != current_surface_size_ || |
| 481 frame_size_in_dip != current_frame_size_in_dip_) { | 484 frame_size_in_dip != current_frame_size_in_dip_) { |
| 482 local_frame_id_ = id_allocator_->GenerateId(); | 485 local_frame_id_ = id_allocator_->GenerateId(); |
| 483 allocated_new_local_frame_id = true; | 486 allocated_new_local_frame_id = true; |
| 484 } | 487 } |
| 485 | 488 |
| 486 gfx::Size desired_size = client_->DelegatedFrameHostDesiredSizeInDIP(); | 489 gfx::Size desired_size = client_->DelegatedFrameHostDesiredSizeInDIP(); |
| 487 if (desired_size != frame_size_in_dip && !desired_size.IsEmpty()) { | 490 if (desired_size != frame_size_in_dip && !desired_size.IsEmpty()) { |
| 488 skip_frame = true; | 491 skip_frame = true; |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 } | 826 } |
| 824 | 827 |
| 825 //////////////////////////////////////////////////////////////////////////////// | 828 //////////////////////////////////////////////////////////////////////////////// |
| 826 // DelegatedFrameHost, private: | 829 // DelegatedFrameHost, private: |
| 827 | 830 |
| 828 DelegatedFrameHost::~DelegatedFrameHost() { | 831 DelegatedFrameHost::~DelegatedFrameHost() { |
| 829 DCHECK(!compositor_); | 832 DCHECK(!compositor_); |
| 830 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 833 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 831 factory->GetContextFactory()->RemoveObserver(this); | 834 factory->GetContextFactory()->RemoveObserver(this); |
| 832 surface_factory_->EvictSurface(); | 835 surface_factory_->EvictSurface(); |
| 833 factory->GetSurfaceManager()->UnregisterSurfaceFactoryClient(frame_sink_id_); | 836 factory->GetContextFactory() |
| 834 factory->GetSurfaceManager()->InvalidateFrameSinkId(frame_sink_id_); | 837 ->GetSurfaceManager() |
| 838 ->UnregisterSurfaceFactoryClient(frame_sink_id_); |
| 839 factory->GetContextFactory()->GetSurfaceManager()->InvalidateFrameSinkId( |
| 840 frame_sink_id_); |
| 835 | 841 |
| 836 DCHECK(!vsync_manager_.get()); | 842 DCHECK(!vsync_manager_.get()); |
| 837 } | 843 } |
| 838 | 844 |
| 839 void DelegatedFrameHost::SetCompositor(ui::Compositor* compositor) { | 845 void DelegatedFrameHost::SetCompositor(ui::Compositor* compositor) { |
| 840 DCHECK(!compositor_); | 846 DCHECK(!compositor_); |
| 841 if (!compositor) | 847 if (!compositor) |
| 842 return; | 848 return; |
| 843 compositor_ = compositor; | 849 compositor_ = compositor; |
| 844 compositor_->AddObserver(this); | 850 compositor_->AddObserver(this); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 std::move(request)); | 887 std::move(request)); |
| 882 } | 888 } |
| 883 } | 889 } |
| 884 | 890 |
| 885 void DelegatedFrameHost::UnlockResources() { | 891 void DelegatedFrameHost::UnlockResources() { |
| 886 DCHECK(local_frame_id_.is_valid()); | 892 DCHECK(local_frame_id_.is_valid()); |
| 887 delegated_frame_evictor_->UnlockFrame(); | 893 delegated_frame_evictor_->UnlockFrame(); |
| 888 } | 894 } |
| 889 | 895 |
| 890 } // namespace content | 896 } // namespace content |
| OLD | NEW |