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

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

Issue 2369793002: WIP: Propagate SurfaceID up window tree hierarchy
Patch Set: Fix input events: EventDispatcher ignores container windows Created 4 years, 2 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 26 matching lines...) Expand all
37 #include "ui/gfx/geometry/dip_util.h" 37 #include "ui/gfx/geometry/dip_util.h"
38 38
39 namespace content { 39 namespace content {
40 40
41 namespace { 41 namespace {
42 42
43 void SatisfyCallback(cc::SurfaceManager* manager, 43 void SatisfyCallback(cc::SurfaceManager* manager,
44 const cc::SurfaceSequence& sequence) { 44 const cc::SurfaceSequence& sequence) {
45 std::vector<uint32_t> sequences; 45 std::vector<uint32_t> sequences;
46 sequences.push_back(sequence.sequence); 46 sequences.push_back(sequence.sequence);
47 manager->DidSatisfySequences(sequence.client_id, &sequences); 47 manager->DidSatisfySequences(sequence.frame_sink_id, &sequences);
48 } 48 }
49 49
50 void RequireCallback(cc::SurfaceManager* manager, 50 void RequireCallback(cc::SurfaceManager* manager,
51 const cc::SurfaceId& id, 51 const cc::SurfaceId& id,
52 const cc::SurfaceSequence& sequence) { 52 const cc::SurfaceSequence& sequence) {
53 cc::Surface* surface = manager->GetSurfaceForId(id); 53 cc::Surface* surface = manager->GetSurfaceForId(id);
54 if (!surface) { 54 if (!surface) {
55 LOG(ERROR) << "Attempting to require callback on nonexistent surface"; 55 LOG(ERROR) << "Attempting to require callback on nonexistent surface";
56 return; 56 return;
57 } 57 }
(...skipping 12 matching lines...) Expand all
70 last_compositor_frame_sink_id_(0), 70 last_compositor_frame_sink_id_(0),
71 pending_delegated_ack_count_(0), 71 pending_delegated_ack_count_(0),
72 skipped_frames_(false), 72 skipped_frames_(false),
73 background_color_(SK_ColorRED), 73 background_color_(SK_ColorRED),
74 current_scale_factor_(1.f), 74 current_scale_factor_(1.f),
75 can_lock_compositor_(YES_CAN_LOCK), 75 can_lock_compositor_(YES_CAN_LOCK),
76 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) { 76 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) {
77 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 77 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
78 factory->GetContextFactory()->AddObserver(this); 78 factory->GetContextFactory()->AddObserver(this);
79 id_allocator_.reset(new cc::SurfaceIdAllocator( 79 id_allocator_.reset(new cc::SurfaceIdAllocator(
80 factory->GetContextFactory()->AllocateSurfaceClientId())); 80 factory->GetContextFactory()->AllocateFrameSinkId()));
81 factory->GetSurfaceManager()->RegisterSurfaceClientId( 81 factory->GetSurfaceManager()->RegisterFrameSinkId(
82 id_allocator_->client_id()); 82 id_allocator_->frame_sink_id());
83 factory->GetSurfaceManager()->RegisterSurfaceFactoryClient( 83 factory->GetSurfaceManager()->RegisterSurfaceFactoryClient(
84 id_allocator_->client_id(), this); 84 id_allocator_->frame_sink_id(), this);
85 } 85 }
86 86
87 void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) { 87 void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) {
88 delegated_frame_evictor_->SetVisible(true); 88 delegated_frame_evictor_->SetVisible(true);
89 89
90 if (surface_id_.is_null() && !released_front_lock_.get()) { 90 if (surface_id_.is_null() && !released_front_lock_.get()) {
91 if (compositor_) 91 if (compositor_)
92 released_front_lock_ = compositor_->GetCompositorLock(); 92 released_front_lock_ = compositor_->GetCompositorLock();
93 } 93 }
94 94
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 void DelegatedFrameHost::BeginFrameSubscription( 200 void DelegatedFrameHost::BeginFrameSubscription(
201 std::unique_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { 201 std::unique_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) {
202 frame_subscriber_ = std::move(subscriber); 202 frame_subscriber_ = std::move(subscriber);
203 } 203 }
204 204
205 void DelegatedFrameHost::EndFrameSubscription() { 205 void DelegatedFrameHost::EndFrameSubscription() {
206 idle_frame_subscriber_textures_.clear(); 206 idle_frame_subscriber_textures_.clear();
207 frame_subscriber_.reset(); 207 frame_subscriber_.reset();
208 } 208 }
209 209
210 uint32_t DelegatedFrameHost::GetSurfaceClientId() { 210 cc::FrameSinkId DelegatedFrameHost::GetFrameSinkId() {
211 return id_allocator_->client_id(); 211 return id_allocator_->frame_sink_id();
212 } 212 }
213 213
214 cc::SurfaceId DelegatedFrameHost::SurfaceIdAtPoint( 214 cc::SurfaceId DelegatedFrameHost::SurfaceIdAtPoint(
215 cc::SurfaceHittestDelegate* delegate, 215 cc::SurfaceHittestDelegate* delegate,
216 const gfx::Point& point, 216 const gfx::Point& point,
217 gfx::Point* transformed_point) { 217 gfx::Point* transformed_point) {
218 if (surface_id_.is_null()) 218 if (surface_id_.is_null())
219 return surface_id_; 219 return surface_id_;
220 cc::SurfaceHittest hittest(delegate, GetSurfaceManager()); 220 cc::SurfaceHittest hittest(delegate, GetSurfaceManager());
221 gfx::Transform target_transform; 221 gfx::Transform target_transform;
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 // DelegatedFrameHost, private: 824 // DelegatedFrameHost, private:
825 825
826 DelegatedFrameHost::~DelegatedFrameHost() { 826 DelegatedFrameHost::~DelegatedFrameHost() {
827 DCHECK(!compositor_); 827 DCHECK(!compositor_);
828 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 828 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
829 factory->GetContextFactory()->RemoveObserver(this); 829 factory->GetContextFactory()->RemoveObserver(this);
830 830
831 if (!surface_id_.is_null()) 831 if (!surface_id_.is_null())
832 surface_factory_->Destroy(surface_id_); 832 surface_factory_->Destroy(surface_id_);
833 factory->GetSurfaceManager()->UnregisterSurfaceFactoryClient( 833 factory->GetSurfaceManager()->UnregisterSurfaceFactoryClient(
834 id_allocator_->client_id()); 834 id_allocator_->frame_sink_id());
835 factory->GetSurfaceManager()->InvalidateSurfaceClientId( 835 factory->GetSurfaceManager()->InvalidateFrameSinkId(
836 id_allocator_->client_id()); 836 id_allocator_->frame_sink_id());
837 837
838 DCHECK(!vsync_manager_.get()); 838 DCHECK(!vsync_manager_.get());
839 } 839 }
840 840
841 void DelegatedFrameHost::SetCompositor(ui::Compositor* compositor) { 841 void DelegatedFrameHost::SetCompositor(ui::Compositor* compositor) {
842 DCHECK(!compositor_); 842 DCHECK(!compositor_);
843 if (!compositor) 843 if (!compositor)
844 return; 844 return;
845 compositor_ = compositor; 845 compositor_ = compositor;
846 compositor_->AddObserver(this); 846 compositor_->AddObserver(this);
847 DCHECK(!vsync_manager_.get()); 847 DCHECK(!vsync_manager_.get());
848 vsync_manager_ = compositor_->vsync_manager(); 848 vsync_manager_ = compositor_->vsync_manager();
849 vsync_manager_->AddObserver(this); 849 vsync_manager_->AddObserver(this);
850 850
851 compositor_->AddSurfaceClient(id_allocator_->client_id()); 851 compositor_->AddFrameSink(id_allocator_->frame_sink_id());
852 } 852 }
853 853
854 void DelegatedFrameHost::ResetCompositor() { 854 void DelegatedFrameHost::ResetCompositor() {
855 if (!compositor_) 855 if (!compositor_)
856 return; 856 return;
857 if (resize_lock_) { 857 if (resize_lock_) {
858 resize_lock_.reset(); 858 resize_lock_.reset();
859 client_->DelegatedFrameHostResizeLockWasReleased(); 859 client_->DelegatedFrameHostResizeLockWasReleased();
860 } 860 }
861 if (compositor_->HasObserver(this)) 861 if (compositor_->HasObserver(this))
862 compositor_->RemoveObserver(this); 862 compositor_->RemoveObserver(this);
863 if (vsync_manager_) { 863 if (vsync_manager_) {
864 vsync_manager_->RemoveObserver(this); 864 vsync_manager_->RemoveObserver(this);
865 vsync_manager_ = nullptr; 865 vsync_manager_ = nullptr;
866 } 866 }
867 867
868 compositor_->RemoveSurfaceClient(id_allocator_->client_id()); 868 compositor_->RemoveFrameSink(id_allocator_->frame_sink_id());
869 compositor_ = nullptr; 869 compositor_ = nullptr;
870 } 870 }
871 871
872 void DelegatedFrameHost::LockResources() { 872 void DelegatedFrameHost::LockResources() {
873 DCHECK(!surface_id_.is_null()); 873 DCHECK(!surface_id_.is_null());
874 delegated_frame_evictor_->LockFrame(); 874 delegated_frame_evictor_->LockFrame();
875 } 875 }
876 876
877 void DelegatedFrameHost::RequestCopyOfOutput( 877 void DelegatedFrameHost::RequestCopyOfOutput(
878 std::unique_ptr<cc::CopyOutputRequest> request) { 878 std::unique_ptr<cc::CopyOutputRequest> request) {
(...skipping 23 matching lines...) Expand all
902 cc::SurfaceManager* manager = factory->GetSurfaceManager(); 902 cc::SurfaceManager* manager = factory->GetSurfaceManager();
903 new_layer->SetShowSurface( 903 new_layer->SetShowSurface(
904 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), 904 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)),
905 base::Bind(&RequireCallback, base::Unretained(manager)), 905 base::Bind(&RequireCallback, base::Unretained(manager)),
906 current_surface_size_, current_scale_factor_, 906 current_surface_size_, current_scale_factor_,
907 current_frame_size_in_dip_); 907 current_frame_size_in_dip_);
908 } 908 }
909 } 909 }
910 910
911 } // namespace content 911 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698