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/compositor/delegated_frame_host.h" | 5 #include "content/browser/compositor/delegated_frame_host.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
10 #include "cc/output/compositor_frame_ack.h" | 10 #include "cc/output/compositor_frame_ack.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 void DelegatedFrameHostClient::RequestCopyOfOutput( | 72 void DelegatedFrameHostClient::RequestCopyOfOutput( |
73 scoped_ptr<cc::CopyOutputRequest> request) { | 73 scoped_ptr<cc::CopyOutputRequest> request) { |
74 GetDelegatedFrameHost()->RequestCopyOfOutput(request.Pass()); | 74 GetDelegatedFrameHost()->RequestCopyOfOutput(request.Pass()); |
75 } | 75 } |
76 | 76 |
77 //////////////////////////////////////////////////////////////////////////////// | 77 //////////////////////////////////////////////////////////////////////////////// |
78 // DelegatedFrameHost | 78 // DelegatedFrameHost |
79 | 79 |
80 DelegatedFrameHost::DelegatedFrameHost(DelegatedFrameHostClient* client) | 80 DelegatedFrameHost::DelegatedFrameHost(DelegatedFrameHostClient* client) |
81 : client_(client), | 81 : client_(client), |
| 82 compositor_(nullptr), |
82 use_surfaces_(UseSurfacesEnabled()), | 83 use_surfaces_(UseSurfacesEnabled()), |
83 last_output_surface_id_(0), | 84 last_output_surface_id_(0), |
84 pending_delegated_ack_count_(0), | 85 pending_delegated_ack_count_(0), |
85 skipped_frames_(false), | 86 skipped_frames_(false), |
86 current_scale_factor_(1.f), | 87 current_scale_factor_(1.f), |
87 can_lock_compositor_(YES_CAN_LOCK), | 88 can_lock_compositor_(YES_CAN_LOCK), |
88 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) { | 89 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) { |
89 ImageTransportFactory::GetInstance()->AddObserver(this); | 90 ImageTransportFactory::GetInstance()->AddObserver(this); |
90 } | 91 } |
91 | 92 |
92 void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) { | 93 void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) { |
93 delegated_frame_evictor_->SetVisible(true); | 94 delegated_frame_evictor_->SetVisible(true); |
94 | 95 |
95 if (surface_id_.is_null() && !frame_provider_.get() && | 96 if (surface_id_.is_null() && !frame_provider_.get() && |
96 !released_front_lock_.get()) { | 97 !released_front_lock_.get()) { |
97 ui::Compositor* compositor = client_->GetCompositor(); | 98 if (compositor_) |
98 if (compositor) | 99 released_front_lock_ = compositor_->GetCompositorLock(); |
99 released_front_lock_ = compositor->GetCompositorLock(); | |
100 } | 100 } |
101 | 101 |
102 ui::Compositor* compositor = client_->GetCompositor(); | 102 if (compositor_) { |
103 if (compositor) { | 103 compositor_->SetLatencyInfo(latency_info); |
104 compositor->SetLatencyInfo(latency_info); | |
105 } | 104 } |
106 } | 105 } |
107 | 106 |
108 bool DelegatedFrameHost::HasSavedFrame() { | 107 bool DelegatedFrameHost::HasSavedFrame() { |
109 return delegated_frame_evictor_->HasFrame(); | 108 return delegated_frame_evictor_->HasFrame(); |
110 } | 109 } |
111 | 110 |
112 void DelegatedFrameHost::WasHidden() { | 111 void DelegatedFrameHost::WasHidden() { |
113 delegated_frame_evictor_->SetVisible(false); | 112 delegated_frame_evictor_->SetVisible(false); |
114 released_front_lock_ = NULL; | 113 released_front_lock_ = NULL; |
115 } | 114 } |
116 | 115 |
117 void DelegatedFrameHost::MaybeCreateResizeLock() { | 116 void DelegatedFrameHost::MaybeCreateResizeLock() { |
118 if (!client_->ShouldCreateResizeLock()) | 117 if (!client_->ShouldCreateResizeLock()) |
119 return; | 118 return; |
120 DCHECK(client_->GetCompositor()); | 119 DCHECK(compositor_); |
121 | |
122 // Listen to changes in the compositor lock state. | |
123 ui::Compositor* compositor = client_->GetCompositor(); | |
124 if (!compositor->HasObserver(this)) | |
125 compositor->AddObserver(this); | |
126 | 120 |
127 bool defer_compositor_lock = | 121 bool defer_compositor_lock = |
128 can_lock_compositor_ == NO_PENDING_RENDERER_FRAME || | 122 can_lock_compositor_ == NO_PENDING_RENDERER_FRAME || |
129 can_lock_compositor_ == NO_PENDING_COMMIT; | 123 can_lock_compositor_ == NO_PENDING_COMMIT; |
130 | 124 |
131 if (can_lock_compositor_ == YES_CAN_LOCK) | 125 if (can_lock_compositor_ == YES_CAN_LOCK) |
132 can_lock_compositor_ = YES_DID_LOCK; | 126 can_lock_compositor_ = YES_DID_LOCK; |
133 | 127 |
134 resize_lock_ = client_->CreateResizeLock(defer_compositor_lock); | 128 resize_lock_ = client_->CreateResizeLock(defer_compositor_lock); |
135 } | 129 } |
136 | 130 |
137 bool DelegatedFrameHost::ShouldCreateResizeLock() { | 131 bool DelegatedFrameHost::ShouldCreateResizeLock() { |
138 RenderWidgetHostImpl* host = client_->GetHost(); | 132 RenderWidgetHostImpl* host = client_->GetHost(); |
139 | 133 |
140 if (resize_lock_) | 134 if (resize_lock_) |
141 return false; | 135 return false; |
142 | 136 |
143 if (host->auto_resize_enabled()) | 137 if (host->auto_resize_enabled()) |
144 return false; | 138 return false; |
145 | 139 |
146 gfx::Size desired_size = client_->DesiredFrameSize(); | 140 gfx::Size desired_size = client_->DesiredFrameSize(); |
147 if (desired_size == current_frame_size_in_dip_ || desired_size.IsEmpty()) | 141 if (desired_size == current_frame_size_in_dip_ || desired_size.IsEmpty()) |
148 return false; | 142 return false; |
149 | 143 |
150 ui::Compositor* compositor = client_->GetCompositor(); | 144 if (!compositor_) |
151 if (!compositor) | |
152 return false; | 145 return false; |
153 | 146 |
154 return true; | 147 return true; |
155 } | 148 } |
156 | 149 |
157 void DelegatedFrameHost::RequestCopyOfOutput( | 150 void DelegatedFrameHost::RequestCopyOfOutput( |
158 scoped_ptr<cc::CopyOutputRequest> request) { | 151 scoped_ptr<cc::CopyOutputRequest> request) { |
159 client_->GetLayer()->RequestCopyOfOutput(request.Pass()); | 152 client_->GetLayer()->RequestCopyOfOutput(request.Pass()); |
160 } | 153 } |
161 | 154 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 if (subscriber_texture.get()) { | 211 if (subscriber_texture.get()) { |
219 request->SetTextureMailbox( | 212 request->SetTextureMailbox( |
220 cc::TextureMailbox(subscriber_texture->mailbox(), | 213 cc::TextureMailbox(subscriber_texture->mailbox(), |
221 subscriber_texture->target(), | 214 subscriber_texture->target(), |
222 subscriber_texture->sync_point())); | 215 subscriber_texture->sync_point())); |
223 } | 216 } |
224 client_->RequestCopyOfOutput(request.Pass()); | 217 client_->RequestCopyOfOutput(request.Pass()); |
225 } | 218 } |
226 | 219 |
227 bool DelegatedFrameHost::CanCopyToBitmap() const { | 220 bool DelegatedFrameHost::CanCopyToBitmap() const { |
228 return client_->GetCompositor() && | 221 return compositor_ && client_->GetLayer()->has_external_content(); |
229 client_->GetLayer()->has_external_content(); | |
230 } | 222 } |
231 | 223 |
232 bool DelegatedFrameHost::CanCopyToVideoFrame() const { | 224 bool DelegatedFrameHost::CanCopyToVideoFrame() const { |
233 return client_->GetCompositor() && | 225 return compositor_ && client_->GetLayer()->has_external_content(); |
234 client_->GetLayer()->has_external_content(); | |
235 } | 226 } |
236 | 227 |
237 bool DelegatedFrameHost::CanSubscribeFrame() const { | 228 bool DelegatedFrameHost::CanSubscribeFrame() const { |
238 return true; | 229 return true; |
239 } | 230 } |
240 | 231 |
241 void DelegatedFrameHost::BeginFrameSubscription( | 232 void DelegatedFrameHost::BeginFrameSubscription( |
242 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { | 233 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { |
243 frame_subscriber_ = subscriber.Pass(); | 234 frame_subscriber_ = subscriber.Pass(); |
244 } | 235 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 | 267 |
277 void DelegatedFrameHost::CheckResizeLock() { | 268 void DelegatedFrameHost::CheckResizeLock() { |
278 if (!resize_lock_ || | 269 if (!resize_lock_ || |
279 resize_lock_->expected_size() != current_frame_size_in_dip_) | 270 resize_lock_->expected_size() != current_frame_size_in_dip_) |
280 return; | 271 return; |
281 | 272 |
282 // Since we got the size we were looking for, unlock the compositor. But delay | 273 // Since we got the size we were looking for, unlock the compositor. But delay |
283 // the release of the lock until we've kicked a frame with the new texture, to | 274 // the release of the lock until we've kicked a frame with the new texture, to |
284 // avoid resizing the UI before we have a chance to draw a "good" frame. | 275 // avoid resizing the UI before we have a chance to draw a "good" frame. |
285 resize_lock_->UnlockCompositor(); | 276 resize_lock_->UnlockCompositor(); |
286 ui::Compositor* compositor = client_->GetCompositor(); | |
287 if (compositor) { | |
288 if (!compositor->HasObserver(this)) | |
289 compositor->AddObserver(this); | |
290 } | |
291 } | 277 } |
292 | 278 |
293 void DelegatedFrameHost::DidReceiveFrameFromRenderer( | 279 void DelegatedFrameHost::DidReceiveFrameFromRenderer( |
294 const gfx::Rect& damage_rect) { | 280 const gfx::Rect& damage_rect) { |
295 if (!frame_subscriber() || !CanCopyToVideoFrame()) | 281 if (!frame_subscriber() || !CanCopyToVideoFrame()) |
296 return; | 282 return; |
297 | 283 |
298 const base::TimeTicks now = gfx::FrameTime::Now(); | 284 const base::TimeTicks now = gfx::FrameTime::Now(); |
299 base::TimeTicks present_time; | 285 base::TimeTicks present_time; |
300 if (vsync_timebase_.is_null() || vsync_interval_ <= base::TimeDelta()) { | 286 if (vsync_timebase_.is_null() || vsync_interval_ <= base::TimeDelta()) { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 if (resource_collection_.get()) { | 364 if (resource_collection_.get()) { |
379 resource_collection_->SetClient(NULL); | 365 resource_collection_->SetClient(NULL); |
380 | 366 |
381 if (resource_collection_->LoseAllResources()) | 367 if (resource_collection_->LoseAllResources()) |
382 SendReturnedDelegatedResources(last_output_surface_id_); | 368 SendReturnedDelegatedResources(last_output_surface_id_); |
383 | 369 |
384 resource_collection_ = NULL; | 370 resource_collection_ = NULL; |
385 } | 371 } |
386 last_output_surface_id_ = output_surface_id; | 372 last_output_surface_id_ = output_surface_id; |
387 } | 373 } |
388 ui::Compositor* compositor = client_->GetCompositor(); | 374 bool immediate_ack = !compositor_; |
389 bool immediate_ack = !compositor; | |
390 if (frame_size.IsEmpty()) { | 375 if (frame_size.IsEmpty()) { |
391 DCHECK(frame_data->resource_list.empty()); | 376 DCHECK(frame_data->resource_list.empty()); |
392 EvictDelegatedFrame(); | 377 EvictDelegatedFrame(); |
393 } else { | 378 } else { |
394 if (use_surfaces_) { | 379 if (use_surfaces_) { |
395 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 380 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
396 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 381 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
397 if (!surface_factory_) { | 382 if (!surface_factory_) { |
398 id_allocator_ = | 383 id_allocator_ = |
399 factory->GetContextFactory()->CreateSurfaceIdAllocator(); | 384 factory->GetContextFactory()->CreateSurfaceIdAllocator(); |
(...skipping 23 matching lines...) Expand all Loading... |
423 compositor_frame->metadata.latency_info.insert( | 408 compositor_frame->metadata.latency_info.insert( |
424 compositor_frame->metadata.latency_info.end(), | 409 compositor_frame->metadata.latency_info.end(), |
425 latency_info.begin(), | 410 latency_info.begin(), |
426 latency_info.end()); | 411 latency_info.end()); |
427 | 412 |
428 gfx::Size desired_size = client_->DesiredFrameSize(); | 413 gfx::Size desired_size = client_->DesiredFrameSize(); |
429 if (desired_size != frame_size_in_dip && !desired_size.IsEmpty()) | 414 if (desired_size != frame_size_in_dip && !desired_size.IsEmpty()) |
430 immediate_ack = true; | 415 immediate_ack = true; |
431 | 416 |
432 cc::SurfaceFactory::DrawCallback ack_callback; | 417 cc::SurfaceFactory::DrawCallback ack_callback; |
433 if (compositor && !immediate_ack) { | 418 if (compositor_ && !immediate_ack) { |
434 ack_callback = base::Bind(&DelegatedFrameHost::SurfaceDrawn, | 419 ack_callback = base::Bind(&DelegatedFrameHost::SurfaceDrawn, |
435 AsWeakPtr(), output_surface_id); | 420 AsWeakPtr(), output_surface_id); |
436 } | 421 } |
437 surface_factory_->SubmitFrame( | 422 surface_factory_->SubmitFrame( |
438 surface_id_, compositor_frame.Pass(), ack_callback); | 423 surface_id_, compositor_frame.Pass(), ack_callback); |
439 } else { | 424 } else { |
440 if (!resource_collection_.get()) { | 425 if (!resource_collection_.get()) { |
441 resource_collection_ = new cc::DelegatedFrameResourceCollection; | 426 resource_collection_ = new cc::DelegatedFrameResourceCollection; |
442 resource_collection_->SetClient(this); | 427 resource_collection_->SetClient(this); |
443 } | 428 } |
(...skipping 21 matching lines...) Expand all Loading... |
465 if (!damage_rect_in_dip.IsEmpty()) | 450 if (!damage_rect_in_dip.IsEmpty()) |
466 client_->GetLayer()->OnDelegatedFrameDamage(damage_rect_in_dip); | 451 client_->GetLayer()->OnDelegatedFrameDamage(damage_rect_in_dip); |
467 | 452 |
468 pending_delegated_ack_count_++; | 453 pending_delegated_ack_count_++; |
469 | 454 |
470 if (immediate_ack) { | 455 if (immediate_ack) { |
471 SendDelegatedFrameAck(output_surface_id); | 456 SendDelegatedFrameAck(output_surface_id); |
472 } else if (!use_surfaces_) { | 457 } else if (!use_surfaces_) { |
473 std::vector<ui::LatencyInfo>::const_iterator it; | 458 std::vector<ui::LatencyInfo>::const_iterator it; |
474 for (it = latency_info.begin(); it != latency_info.end(); ++it) | 459 for (it = latency_info.begin(); it != latency_info.end(); ++it) |
475 compositor->SetLatencyInfo(*it); | 460 compositor_->SetLatencyInfo(*it); |
476 // If we've previously skipped any latency infos add them. | 461 // If we've previously skipped any latency infos add them. |
477 for (it = skipped_latency_info_list_.begin(); | 462 for (it = skipped_latency_info_list_.begin(); |
478 it != skipped_latency_info_list_.end(); | 463 it != skipped_latency_info_list_.end(); |
479 ++it) | 464 ++it) |
480 compositor->SetLatencyInfo(*it); | 465 compositor_->SetLatencyInfo(*it); |
481 skipped_latency_info_list_.clear(); | 466 skipped_latency_info_list_.clear(); |
482 AddOnCommitCallbackAndDisableLocks( | 467 AddOnCommitCallbackAndDisableLocks( |
483 base::Bind(&DelegatedFrameHost::SendDelegatedFrameAck, | 468 base::Bind(&DelegatedFrameHost::SendDelegatedFrameAck, |
484 AsWeakPtr(), | 469 AsWeakPtr(), |
485 output_surface_id)); | 470 output_surface_id)); |
486 } else { | 471 } else { |
487 AddOnCommitCallbackAndDisableLocks(base::Closure()); | 472 AddOnCommitCallbackAndDisableLocks(base::Closure()); |
488 } | 473 } |
489 DidReceiveFrameFromRenderer(damage_rect); | 474 DidReceiveFrameFromRenderer(damage_rect); |
490 if (frame_provider_.get() || !surface_id_.is_null()) | 475 if (frame_provider_.get() || !surface_id_.is_null()) |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 | 902 |
918 void DelegatedFrameHost::OnCompositingLockStateChanged( | 903 void DelegatedFrameHost::OnCompositingLockStateChanged( |
919 ui::Compositor* compositor) { | 904 ui::Compositor* compositor) { |
920 // A compositor lock that is part of a resize lock timed out. We | 905 // A compositor lock that is part of a resize lock timed out. We |
921 // should display a renderer frame. | 906 // should display a renderer frame. |
922 if (!compositor->IsLocked() && can_lock_compositor_ == YES_DID_LOCK) { | 907 if (!compositor->IsLocked() && can_lock_compositor_ == YES_DID_LOCK) { |
923 can_lock_compositor_ = NO_PENDING_RENDERER_FRAME; | 908 can_lock_compositor_ = NO_PENDING_RENDERER_FRAME; |
924 } | 909 } |
925 } | 910 } |
926 | 911 |
| 912 void DelegatedFrameHost::OnCompositingShuttingDown(ui::Compositor* compositor) { |
| 913 DCHECK_EQ(compositor, compositor_); |
| 914 ResetCompositor(); |
| 915 DCHECK(!compositor_); |
| 916 } |
| 917 |
927 void DelegatedFrameHost::OnUpdateVSyncParameters( | 918 void DelegatedFrameHost::OnUpdateVSyncParameters( |
928 base::TimeTicks timebase, | 919 base::TimeTicks timebase, |
929 base::TimeDelta interval) { | 920 base::TimeDelta interval) { |
930 vsync_timebase_ = timebase; | 921 vsync_timebase_ = timebase; |
931 vsync_interval_ = interval; | 922 vsync_interval_ = interval; |
932 RenderWidgetHostImpl* host = client_->GetHost(); | 923 RenderWidgetHostImpl* host = client_->GetHost(); |
933 if (client_->IsVisible()) | 924 if (client_->IsVisible()) |
934 host->UpdateVSyncParameters(timebase, interval); | 925 host->UpdateVSyncParameters(timebase, interval); |
935 } | 926 } |
936 | 927 |
937 //////////////////////////////////////////////////////////////////////////////// | 928 //////////////////////////////////////////////////////////////////////////////// |
938 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: | 929 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: |
939 | 930 |
940 void DelegatedFrameHost::OnLostResources() { | 931 void DelegatedFrameHost::OnLostResources() { |
941 RenderWidgetHostImpl* host = client_->GetHost(); | 932 RenderWidgetHostImpl* host = client_->GetHost(); |
942 if (frame_provider_.get() || !surface_id_.is_null()) | 933 if (frame_provider_.get() || !surface_id_.is_null()) |
943 EvictDelegatedFrame(); | 934 EvictDelegatedFrame(); |
944 idle_frame_subscriber_textures_.clear(); | 935 idle_frame_subscriber_textures_.clear(); |
945 yuv_readback_pipeline_.reset(); | 936 yuv_readback_pipeline_.reset(); |
946 | 937 |
947 host->ScheduleComposite(); | 938 host->ScheduleComposite(); |
948 } | 939 } |
949 | 940 |
950 //////////////////////////////////////////////////////////////////////////////// | 941 //////////////////////////////////////////////////////////////////////////////// |
951 // DelegatedFrameHost, private: | 942 // DelegatedFrameHost, private: |
952 | 943 |
953 DelegatedFrameHost::~DelegatedFrameHost() { | 944 DelegatedFrameHost::~DelegatedFrameHost() { |
| 945 DCHECK(!compositor_); |
954 ImageTransportFactory::GetInstance()->RemoveObserver(this); | 946 ImageTransportFactory::GetInstance()->RemoveObserver(this); |
955 | 947 |
956 if (!surface_id_.is_null()) | 948 if (!surface_id_.is_null()) |
957 surface_factory_->Destroy(surface_id_); | 949 surface_factory_->Destroy(surface_id_); |
958 if (resource_collection_.get()) | 950 if (resource_collection_.get()) |
959 resource_collection_->SetClient(NULL); | 951 resource_collection_->SetClient(NULL); |
960 | 952 |
961 DCHECK(!vsync_manager_.get()); | 953 DCHECK(!vsync_manager_.get()); |
962 } | 954 } |
963 | 955 |
964 void DelegatedFrameHost::RunOnCommitCallbacks() { | 956 void DelegatedFrameHost::RunOnCommitCallbacks() { |
965 for (std::vector<base::Closure>::const_iterator | 957 for (std::vector<base::Closure>::const_iterator |
966 it = on_compositing_did_commit_callbacks_.begin(); | 958 it = on_compositing_did_commit_callbacks_.begin(); |
967 it != on_compositing_did_commit_callbacks_.end(); ++it) { | 959 it != on_compositing_did_commit_callbacks_.end(); ++it) { |
968 it->Run(); | 960 it->Run(); |
969 } | 961 } |
970 on_compositing_did_commit_callbacks_.clear(); | 962 on_compositing_did_commit_callbacks_.clear(); |
971 } | 963 } |
972 | 964 |
973 void DelegatedFrameHost::AddOnCommitCallbackAndDisableLocks( | 965 void DelegatedFrameHost::AddOnCommitCallbackAndDisableLocks( |
974 const base::Closure& callback) { | 966 const base::Closure& callback) { |
975 ui::Compositor* compositor = client_->GetCompositor(); | 967 DCHECK(compositor_); |
976 DCHECK(compositor); | |
977 | |
978 if (!compositor->HasObserver(this)) | |
979 compositor->AddObserver(this); | |
980 | 968 |
981 can_lock_compositor_ = NO_PENDING_COMMIT; | 969 can_lock_compositor_ = NO_PENDING_COMMIT; |
982 if (!callback.is_null()) | 970 if (!callback.is_null()) |
983 on_compositing_did_commit_callbacks_.push_back(callback); | 971 on_compositing_did_commit_callbacks_.push_back(callback); |
984 } | 972 } |
985 | 973 |
986 void DelegatedFrameHost::AddedToWindow() { | 974 void DelegatedFrameHost::SetCompositor(ui::Compositor* compositor) { |
987 ui::Compositor* compositor = client_->GetCompositor(); | 975 DCHECK(!compositor_); |
988 if (compositor) { | 976 if (!compositor) |
989 DCHECK(!vsync_manager_.get()); | 977 return; |
990 vsync_manager_ = compositor->vsync_manager(); | 978 compositor_ = compositor; |
991 vsync_manager_->AddObserver(this); | 979 compositor_->AddObserver(this); |
992 } | 980 DCHECK(!vsync_manager_.get()); |
| 981 vsync_manager_ = compositor_->vsync_manager(); |
| 982 vsync_manager_->AddObserver(this); |
993 } | 983 } |
994 | 984 |
995 void DelegatedFrameHost::RemovingFromWindow() { | 985 void DelegatedFrameHost::ResetCompositor() { |
| 986 if (!compositor_) |
| 987 return; |
996 RunOnCommitCallbacks(); | 988 RunOnCommitCallbacks(); |
997 resize_lock_.reset(); | 989 resize_lock_.reset(); |
998 client_->GetHost()->WasResized(); | 990 client_->GetHost()->WasResized(); |
999 ui::Compositor* compositor = client_->GetCompositor(); | 991 if (compositor_->HasObserver(this)) |
1000 if (compositor && compositor->HasObserver(this)) | 992 compositor_->RemoveObserver(this); |
1001 compositor->RemoveObserver(this); | |
1002 | |
1003 if (vsync_manager_.get()) { | 993 if (vsync_manager_.get()) { |
1004 vsync_manager_->RemoveObserver(this); | 994 vsync_manager_->RemoveObserver(this); |
1005 vsync_manager_ = NULL; | 995 vsync_manager_ = NULL; |
1006 } | 996 } |
| 997 compositor_ = nullptr; |
1007 } | 998 } |
1008 | 999 |
1009 void DelegatedFrameHost::LockResources() { | 1000 void DelegatedFrameHost::LockResources() { |
1010 DCHECK(frame_provider_.get() || !surface_id_.is_null()); | 1001 DCHECK(frame_provider_.get() || !surface_id_.is_null()); |
1011 delegated_frame_evictor_->LockFrame(); | 1002 delegated_frame_evictor_->LockFrame(); |
1012 } | 1003 } |
1013 | 1004 |
1014 void DelegatedFrameHost::UnlockResources() { | 1005 void DelegatedFrameHost::UnlockResources() { |
1015 DCHECK(frame_provider_.get() || !surface_id_.is_null()); | 1006 DCHECK(frame_provider_.get() || !surface_id_.is_null()); |
1016 delegated_frame_evictor_->UnlockFrame(); | 1007 delegated_frame_evictor_->UnlockFrame(); |
(...skipping 16 matching lines...) Expand all Loading... |
1033 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 1024 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
1034 new_layer->SetShowSurface( | 1025 new_layer->SetShowSurface( |
1035 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), | 1026 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), |
1036 base::Bind(&RequireCallback, base::Unretained(manager)), | 1027 base::Bind(&RequireCallback, base::Unretained(manager)), |
1037 current_surface_size_, current_scale_factor_, | 1028 current_surface_size_, current_scale_factor_, |
1038 current_frame_size_in_dip_); | 1029 current_frame_size_in_dip_); |
1039 } | 1030 } |
1040 } | 1031 } |
1041 | 1032 |
1042 } // namespace content | 1033 } // namespace content |
OLD | NEW |