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/renderer_host/delegated_frame_host.cc

Issue 2485473003: Remove SurfaceFactory::Create and SurfaceFactory::Destroy (Closed)
Patch Set: fixed windows compile error Created 4 years 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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 subscriber_texture->target())); 389 subscriber_texture->target()));
390 } 390 }
391 391
392 if (local_frame_id_.is_valid()) { 392 if (local_frame_id_.is_valid()) {
393 // To avoid unnecessary composites, go directly to the Surface rather than 393 // To avoid unnecessary composites, go directly to the Surface rather than
394 // through RequestCopyOfOutput (which goes through the browser 394 // through RequestCopyOfOutput (which goes through the browser
395 // compositor). 395 // compositor).
396 if (!request_copy_of_output_callback_for_testing_.is_null()) 396 if (!request_copy_of_output_callback_for_testing_.is_null())
397 request_copy_of_output_callback_for_testing_.Run(std::move(request)); 397 request_copy_of_output_callback_for_testing_.Run(std::move(request));
398 else 398 else
399 surface_factory_->RequestCopyOfSurface(local_frame_id_, 399 surface_factory_->RequestCopyOfSurface(std::move(request));
400 std::move(request));
401 } else { 400 } else {
402 request->set_area(gfx::Rect(current_frame_size_in_dip_)); 401 request->set_area(gfx::Rect(current_frame_size_in_dip_));
403 RequestCopyOfOutput(std::move(request)); 402 RequestCopyOfOutput(std::move(request));
404 } 403 }
405 } 404 }
406 405
407 void DelegatedFrameHost::SwapDelegatedFrame(uint32_t compositor_frame_sink_id, 406 void DelegatedFrameHost::SwapDelegatedFrame(uint32_t compositor_frame_sink_id,
408 cc::CompositorFrame frame) { 407 cc::CompositorFrame frame) {
409 #if defined(OS_CHROMEOS) 408 #if defined(OS_CHROMEOS)
410 DCHECK(!resize_lock_ || !client_->IsAutoResizeEnabled()); 409 DCHECK(!resize_lock_ || !client_->IsAutoResizeEnabled());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 background_color_ = frame.metadata.root_background_color; 470 background_color_ = frame.metadata.root_background_color;
472 471
473 if (frame_size.IsEmpty()) { 472 if (frame_size.IsEmpty()) {
474 DCHECK(frame.resource_list.empty()); 473 DCHECK(frame.resource_list.empty());
475 EvictDelegatedFrame(); 474 EvictDelegatedFrame();
476 } else { 475 } else {
477 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 476 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
478 cc::SurfaceManager* manager = factory->GetSurfaceManager(); 477 cc::SurfaceManager* manager = factory->GetSurfaceManager();
479 if (!local_frame_id_.is_valid() || frame_size != current_surface_size_ || 478 if (!local_frame_id_.is_valid() || frame_size != current_surface_size_ ||
480 frame_size_in_dip != current_frame_size_in_dip_) { 479 frame_size_in_dip != current_frame_size_in_dip_) {
481 if (local_frame_id_.is_valid())
482 surface_factory_->Destroy(local_frame_id_);
483 local_frame_id_ = id_allocator_->GenerateId(); 480 local_frame_id_ = id_allocator_->GenerateId();
484 surface_factory_->Create(local_frame_id_); 481 surface_factory_->SubmitCompositorFrame(
Fady Samuel 2016/11/21 21:00:16 Please don't land this. This is not the correct fi
482 local_frame_id_, cc::CompositorFrame(),
483 cc::SurfaceFactory::DrawCallback());
485 // manager must outlive compositors using it. 484 // manager must outlive compositors using it.
486 client_->DelegatedFrameHostGetLayer()->SetShowSurface( 485 client_->DelegatedFrameHostGetLayer()->SetShowSurface(
487 cc::SurfaceId(frame_sink_id_, local_frame_id_), 486 cc::SurfaceId(frame_sink_id_, local_frame_id_),
488 base::Bind(&SatisfyCallback, base::Unretained(manager)), 487 base::Bind(&SatisfyCallback, base::Unretained(manager)),
489 base::Bind(&RequireCallback, base::Unretained(manager)), frame_size, 488 base::Bind(&RequireCallback, base::Unretained(manager)), frame_size,
490 frame_device_scale_factor, frame_size_in_dip); 489 frame_device_scale_factor, frame_size_in_dip);
491 current_surface_size_ = frame_size; 490 current_surface_size_ = frame_size;
492 current_scale_factor_ = frame_device_scale_factor; 491 current_scale_factor_ = frame_device_scale_factor;
493 } 492 }
494 493
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 } 585 }
587 586
588 void DelegatedFrameHost::SetBeginFrameSource( 587 void DelegatedFrameHost::SetBeginFrameSource(
589 cc::BeginFrameSource* begin_frame_source) { 588 cc::BeginFrameSource* begin_frame_source) {
590 client_->SetBeginFrameSource(begin_frame_source); 589 client_->SetBeginFrameSource(begin_frame_source);
591 } 590 }
592 591
593 void DelegatedFrameHost::EvictDelegatedFrame() { 592 void DelegatedFrameHost::EvictDelegatedFrame() {
594 client_->DelegatedFrameHostGetLayer()->SetShowSolidColorContent(); 593 client_->DelegatedFrameHostGetLayer()->SetShowSolidColorContent();
595 if (local_frame_id_.is_valid()) { 594 if (local_frame_id_.is_valid()) {
596 surface_factory_->Destroy(local_frame_id_); 595 surface_factory_->EvictSurface();
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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 yuv_readback_pipeline_.reset(); 819 yuv_readback_pipeline_.reset();
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 surface_factory_->EvictSurface();
831 if (local_frame_id_.is_valid())
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
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_valid()); 883 DCHECK(local_frame_id_.is_valid());
887 delegated_frame_evictor_->UnlockFrame(); 884 delegated_frame_evictor_->UnlockFrame();
888 } 885 }
889 886
890 } // namespace content 887 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698