| 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 26 matching lines...) Expand all Loading... |
| 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.id_namespace, &sequences); | 47 manager->DidSatisfySequences(sequence.client_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 13 matching lines...) Expand all Loading... |
| 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_ = factory->GetContextFactory()->CreateSurfaceIdAllocator(); | 79 id_allocator_ = factory->GetContextFactory()->CreateSurfaceIdAllocator(); |
| 80 factory->GetSurfaceManager()->RegisterSurfaceFactoryClient( | 80 factory->GetSurfaceManager()->RegisterSurfaceFactoryClient( |
| 81 id_allocator_->id_namespace(), this); | 81 id_allocator_->client_id(), this); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) { | 84 void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) { |
| 85 delegated_frame_evictor_->SetVisible(true); | 85 delegated_frame_evictor_->SetVisible(true); |
| 86 | 86 |
| 87 if (surface_id_.is_null() && !released_front_lock_.get()) { | 87 if (surface_id_.is_null() && !released_front_lock_.get()) { |
| 88 if (compositor_) | 88 if (compositor_) |
| 89 released_front_lock_ = compositor_->GetCompositorLock(); | 89 released_front_lock_ = compositor_->GetCompositorLock(); |
| 90 } | 90 } |
| 91 | 91 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 void DelegatedFrameHost::BeginFrameSubscription( | 197 void DelegatedFrameHost::BeginFrameSubscription( |
| 198 std::unique_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { | 198 std::unique_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { |
| 199 frame_subscriber_ = std::move(subscriber); | 199 frame_subscriber_ = std::move(subscriber); |
| 200 } | 200 } |
| 201 | 201 |
| 202 void DelegatedFrameHost::EndFrameSubscription() { | 202 void DelegatedFrameHost::EndFrameSubscription() { |
| 203 idle_frame_subscriber_textures_.clear(); | 203 idle_frame_subscriber_textures_.clear(); |
| 204 frame_subscriber_.reset(); | 204 frame_subscriber_.reset(); |
| 205 } | 205 } |
| 206 | 206 |
| 207 uint32_t DelegatedFrameHost::GetSurfaceIdNamespace() { | 207 uint32_t DelegatedFrameHost::GetSurfaceClientId() { |
| 208 return id_allocator_->id_namespace(); | 208 return id_allocator_->client_id(); |
| 209 } | 209 } |
| 210 | 210 |
| 211 cc::SurfaceId DelegatedFrameHost::SurfaceIdAtPoint( | 211 cc::SurfaceId DelegatedFrameHost::SurfaceIdAtPoint( |
| 212 cc::SurfaceHittestDelegate* delegate, | 212 cc::SurfaceHittestDelegate* delegate, |
| 213 const gfx::Point& point, | 213 const gfx::Point& point, |
| 214 gfx::Point* transformed_point) { | 214 gfx::Point* transformed_point) { |
| 215 if (surface_id_.is_null()) | 215 if (surface_id_.is_null()) |
| 216 return surface_id_; | 216 return surface_id_; |
| 217 cc::SurfaceHittest hittest(delegate, GetSurfaceManager()); | 217 cc::SurfaceHittest hittest(delegate, GetSurfaceManager()); |
| 218 gfx::Transform target_transform; | 218 gfx::Transform target_transform; |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 // DelegatedFrameHost, private: | 810 // DelegatedFrameHost, private: |
| 811 | 811 |
| 812 DelegatedFrameHost::~DelegatedFrameHost() { | 812 DelegatedFrameHost::~DelegatedFrameHost() { |
| 813 DCHECK(!compositor_); | 813 DCHECK(!compositor_); |
| 814 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 814 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 815 factory->GetContextFactory()->RemoveObserver(this); | 815 factory->GetContextFactory()->RemoveObserver(this); |
| 816 | 816 |
| 817 if (!surface_id_.is_null()) | 817 if (!surface_id_.is_null()) |
| 818 surface_factory_->Destroy(surface_id_); | 818 surface_factory_->Destroy(surface_id_); |
| 819 factory->GetSurfaceManager()->UnregisterSurfaceFactoryClient( | 819 factory->GetSurfaceManager()->UnregisterSurfaceFactoryClient( |
| 820 id_allocator_->id_namespace()); | 820 id_allocator_->client_id()); |
| 821 | 821 |
| 822 DCHECK(!vsync_manager_.get()); | 822 DCHECK(!vsync_manager_.get()); |
| 823 } | 823 } |
| 824 | 824 |
| 825 void DelegatedFrameHost::SetCompositor(ui::Compositor* compositor) { | 825 void DelegatedFrameHost::SetCompositor(ui::Compositor* compositor) { |
| 826 DCHECK(!compositor_); | 826 DCHECK(!compositor_); |
| 827 if (!compositor) | 827 if (!compositor) |
| 828 return; | 828 return; |
| 829 compositor_ = compositor; | 829 compositor_ = compositor; |
| 830 compositor_->AddObserver(this); | 830 compositor_->AddObserver(this); |
| 831 DCHECK(!vsync_manager_.get()); | 831 DCHECK(!vsync_manager_.get()); |
| 832 vsync_manager_ = compositor_->vsync_manager(); | 832 vsync_manager_ = compositor_->vsync_manager(); |
| 833 vsync_manager_->AddObserver(this); | 833 vsync_manager_->AddObserver(this); |
| 834 | 834 |
| 835 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 835 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 836 uint32_t parent = compositor->surface_id_allocator()->id_namespace(); | 836 uint32_t parent = compositor->surface_id_allocator()->client_id(); |
| 837 factory->GetSurfaceManager()->RegisterSurfaceNamespaceHierarchy( | 837 factory->GetSurfaceManager()->RegisterSurfaceNamespaceHierarchy( |
| 838 parent, id_allocator_->id_namespace()); | 838 parent, id_allocator_->client_id()); |
| 839 } | 839 } |
| 840 | 840 |
| 841 void DelegatedFrameHost::ResetCompositor() { | 841 void DelegatedFrameHost::ResetCompositor() { |
| 842 if (!compositor_) | 842 if (!compositor_) |
| 843 return; | 843 return; |
| 844 if (resize_lock_) { | 844 if (resize_lock_) { |
| 845 resize_lock_.reset(); | 845 resize_lock_.reset(); |
| 846 client_->DelegatedFrameHostResizeLockWasReleased(); | 846 client_->DelegatedFrameHostResizeLockWasReleased(); |
| 847 } | 847 } |
| 848 if (compositor_->HasObserver(this)) | 848 if (compositor_->HasObserver(this)) |
| 849 compositor_->RemoveObserver(this); | 849 compositor_->RemoveObserver(this); |
| 850 if (vsync_manager_.get()) { | 850 if (vsync_manager_.get()) { |
| 851 vsync_manager_->RemoveObserver(this); | 851 vsync_manager_->RemoveObserver(this); |
| 852 vsync_manager_ = NULL; | 852 vsync_manager_ = NULL; |
| 853 } | 853 } |
| 854 | 854 |
| 855 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 855 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 856 uint32_t parent = compositor_->surface_id_allocator()->id_namespace(); | 856 uint32_t parent = compositor_->surface_id_allocator()->client_id(); |
| 857 factory->GetSurfaceManager()->UnregisterSurfaceNamespaceHierarchy( | 857 factory->GetSurfaceManager()->UnregisterSurfaceNamespaceHierarchy( |
| 858 parent, id_allocator_->id_namespace()); | 858 parent, id_allocator_->client_id()); |
| 859 | 859 |
| 860 compositor_ = nullptr; | 860 compositor_ = nullptr; |
| 861 } | 861 } |
| 862 | 862 |
| 863 void DelegatedFrameHost::SetVSyncParameters(const base::TimeTicks& timebase, | 863 void DelegatedFrameHost::SetVSyncParameters(const base::TimeTicks& timebase, |
| 864 const base::TimeDelta& interval) { | 864 const base::TimeDelta& interval) { |
| 865 vsync_timebase_ = timebase; | 865 vsync_timebase_ = timebase; |
| 866 vsync_interval_ = interval; | 866 vsync_interval_ = interval; |
| 867 } | 867 } |
| 868 | 868 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 899 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 899 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
| 900 new_layer->SetShowSurface( | 900 new_layer->SetShowSurface( |
| 901 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), | 901 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), |
| 902 base::Bind(&RequireCallback, base::Unretained(manager)), | 902 base::Bind(&RequireCallback, base::Unretained(manager)), |
| 903 current_surface_size_, current_scale_factor_, | 903 current_surface_size_, current_scale_factor_, |
| 904 current_frame_size_in_dip_); | 904 current_frame_size_in_dip_); |
| 905 } | 905 } |
| 906 } | 906 } |
| 907 | 907 |
| 908 } // namespace content | 908 } // namespace content |
| OLD | NEW |