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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
471 background_color_ = frame.metadata.root_background_color; | 471 background_color_ = frame.metadata.root_background_color; |
472 | 472 |
473 if (frame_size.IsEmpty()) { | 473 if (frame_size.IsEmpty()) { |
474 DCHECK(frame.resource_list.empty()); | 474 DCHECK(frame.resource_list.empty()); |
475 EvictDelegatedFrame(); | 475 EvictDelegatedFrame(); |
476 } else { | 476 } else { |
477 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 477 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
478 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 478 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
479 if (local_frame_id_.is_null() || frame_size != current_surface_size_ || | 479 if (local_frame_id_.is_null() || frame_size != current_surface_size_ || |
480 frame_size_in_dip != current_frame_size_in_dip_) { | 480 frame_size_in_dip != current_frame_size_in_dip_) { |
481 if (!local_frame_id_.is_null()) | |
482 surface_factory_->Destroy(local_frame_id_); | |
483 local_frame_id_ = id_allocator_->GenerateId(); | 481 local_frame_id_ = id_allocator_->GenerateId(); |
484 surface_factory_->Create(local_frame_id_); | 482 surface_factory_->SubmitCompositorFrame( |
Fady Samuel
2016/11/08 22:23:59
Remove this?
Saman Sami
2016/11/11 17:49:58
Done.
| |
483 local_frame_id_, cc::CompositorFrame(), | |
484 cc::SurfaceFactory::DrawCallback()); | |
485 // manager must outlive compositors using it. | 485 // manager must outlive compositors using it. |
486 client_->DelegatedFrameHostGetLayer()->SetShowSurface( | 486 client_->DelegatedFrameHostGetLayer()->SetShowSurface( |
487 cc::SurfaceId(frame_sink_id_, local_frame_id_), | 487 cc::SurfaceId(frame_sink_id_, local_frame_id_), |
488 base::Bind(&SatisfyCallback, base::Unretained(manager)), | 488 base::Bind(&SatisfyCallback, base::Unretained(manager)), |
489 base::Bind(&RequireCallback, base::Unretained(manager)), frame_size, | 489 base::Bind(&RequireCallback, base::Unretained(manager)), frame_size, |
490 frame_device_scale_factor, frame_size_in_dip); | 490 frame_device_scale_factor, frame_size_in_dip); |
491 current_surface_size_ = frame_size; | 491 current_surface_size_ = frame_size; |
492 current_scale_factor_ = frame_device_scale_factor; | 492 current_scale_factor_ = frame_device_scale_factor; |
493 } | 493 } |
494 | 494 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
586 } | 586 } |
587 | 587 |
588 void DelegatedFrameHost::SetBeginFrameSource( | 588 void DelegatedFrameHost::SetBeginFrameSource( |
589 cc::BeginFrameSource* begin_frame_source) { | 589 cc::BeginFrameSource* begin_frame_source) { |
590 client_->SetBeginFrameSource(begin_frame_source); | 590 client_->SetBeginFrameSource(begin_frame_source); |
591 } | 591 } |
592 | 592 |
593 void DelegatedFrameHost::EvictDelegatedFrame() { | 593 void DelegatedFrameHost::EvictDelegatedFrame() { |
594 client_->DelegatedFrameHostGetLayer()->SetShowSolidColorContent(); | 594 client_->DelegatedFrameHostGetLayer()->SetShowSolidColorContent(); |
595 if (!local_frame_id_.is_null()) { | 595 if (!local_frame_id_.is_null()) { |
596 surface_factory_->Destroy(local_frame_id_); | |
597 local_frame_id_ = cc::LocalFrameId(); | 596 local_frame_id_ = cc::LocalFrameId(); |
598 } | 597 } |
599 delegated_frame_evictor_->DiscardedFrame(); | 598 delegated_frame_evictor_->DiscardedFrame(); |
600 UpdateGutters(); | 599 UpdateGutters(); |
601 } | 600 } |
602 | 601 |
603 // static | 602 // static |
604 void DelegatedFrameHost::ReturnSubscriberTexture( | 603 void DelegatedFrameHost::ReturnSubscriberTexture( |
605 base::WeakPtr<DelegatedFrameHost> dfh, | 604 base::WeakPtr<DelegatedFrameHost> dfh, |
606 scoped_refptr<OwnedMailbox> subscriber_texture, | 605 scoped_refptr<OwnedMailbox> subscriber_texture, |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
821 } | 820 } |
822 | 821 |
823 //////////////////////////////////////////////////////////////////////////////// | 822 //////////////////////////////////////////////////////////////////////////////// |
824 // DelegatedFrameHost, private: | 823 // DelegatedFrameHost, private: |
825 | 824 |
826 DelegatedFrameHost::~DelegatedFrameHost() { | 825 DelegatedFrameHost::~DelegatedFrameHost() { |
827 DCHECK(!compositor_); | 826 DCHECK(!compositor_); |
828 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 827 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
829 factory->GetContextFactory()->RemoveObserver(this); | 828 factory->GetContextFactory()->RemoveObserver(this); |
830 | 829 |
831 if (!local_frame_id_.is_null()) | |
832 surface_factory_->Destroy(local_frame_id_); | |
833 factory->GetSurfaceManager()->UnregisterSurfaceFactoryClient(frame_sink_id_); | 830 factory->GetSurfaceManager()->UnregisterSurfaceFactoryClient(frame_sink_id_); |
834 factory->GetSurfaceManager()->InvalidateFrameSinkId(frame_sink_id_); | 831 factory->GetSurfaceManager()->InvalidateFrameSinkId(frame_sink_id_); |
835 | 832 |
836 DCHECK(!vsync_manager_.get()); | 833 DCHECK(!vsync_manager_.get()); |
837 } | 834 } |
838 | 835 |
839 void DelegatedFrameHost::SetCompositor(ui::Compositor* compositor) { | 836 void DelegatedFrameHost::SetCompositor(ui::Compositor* compositor) { |
840 DCHECK(!compositor_); | 837 DCHECK(!compositor_); |
841 if (!compositor) | 838 if (!compositor) |
842 return; | 839 return; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
881 std::move(request)); | 878 std::move(request)); |
882 } | 879 } |
883 } | 880 } |
884 | 881 |
885 void DelegatedFrameHost::UnlockResources() { | 882 void DelegatedFrameHost::UnlockResources() { |
886 DCHECK(!local_frame_id_.is_null()); | 883 DCHECK(!local_frame_id_.is_null()); |
887 delegated_frame_evictor_->UnlockFrame(); | 884 delegated_frame_evictor_->UnlockFrame(); |
888 } | 885 } |
889 | 886 |
890 } // namespace content | 887 } // namespace content |
OLD | NEW |