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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 tick_clock_(new base::DefaultTickClock()), | 71 tick_clock_(new base::DefaultTickClock()), |
72 last_compositor_frame_sink_id_(0), | 72 last_compositor_frame_sink_id_(0), |
73 pending_delegated_ack_count_(0), | 73 pending_delegated_ack_count_(0), |
74 skipped_frames_(false), | 74 skipped_frames_(false), |
75 background_color_(SK_ColorRED), | 75 background_color_(SK_ColorRED), |
76 current_scale_factor_(1.f), | 76 current_scale_factor_(1.f), |
77 can_lock_compositor_(YES_CAN_LOCK), | 77 can_lock_compositor_(YES_CAN_LOCK), |
78 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) { | 78 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) { |
79 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 79 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
80 factory->GetContextFactory()->AddObserver(this); | 80 factory->GetContextFactory()->AddObserver(this); |
81 id_allocator_.reset(new cc::SurfaceIdAllocator(frame_sink_id_)); | 81 id_allocator_.reset(new cc::SurfaceIdAllocator()); |
82 factory->GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_); | 82 factory->GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_); |
83 factory->GetSurfaceManager()->RegisterSurfaceFactoryClient(frame_sink_id_, | 83 factory->GetSurfaceManager()->RegisterSurfaceFactoryClient(frame_sink_id_, |
84 this); | 84 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 (local_frame_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 |
95 if (compositor_) { | 95 if (compositor_) { |
96 compositor_->SetLatencyInfo(latency_info); | 96 compositor_->SetLatencyInfo(latency_info); |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
100 bool DelegatedFrameHost::HasSavedFrame() { | 100 bool DelegatedFrameHost::HasSavedFrame() { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 } | 208 } |
209 | 209 |
210 cc::FrameSinkId DelegatedFrameHost::GetFrameSinkId() { | 210 cc::FrameSinkId DelegatedFrameHost::GetFrameSinkId() { |
211 return frame_sink_id_; | 211 return 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 cc::SurfaceId surface_id(frame_sink_id_, local_frame_id_); |
219 return surface_id_; | 219 if (surface_id.is_null()) |
| 220 return surface_id; |
220 cc::SurfaceHittest hittest(delegate, GetSurfaceManager()); | 221 cc::SurfaceHittest hittest(delegate, GetSurfaceManager()); |
221 gfx::Transform target_transform; | 222 gfx::Transform target_transform; |
222 cc::SurfaceId target_surface_id = | 223 cc::SurfaceId target_local_frame_id = |
223 hittest.GetTargetSurfaceAtPoint(surface_id_, point, &target_transform); | 224 hittest.GetTargetSurfaceAtPoint(surface_id, point, &target_transform); |
224 *transformed_point = point; | 225 *transformed_point = point; |
225 if (!target_surface_id.is_null()) | 226 if (!target_local_frame_id.is_null()) |
226 target_transform.TransformPoint(transformed_point); | 227 target_transform.TransformPoint(transformed_point); |
227 return target_surface_id; | 228 return target_local_frame_id; |
228 } | 229 } |
229 | 230 |
230 gfx::Point DelegatedFrameHost::TransformPointToLocalCoordSpace( | 231 gfx::Point DelegatedFrameHost::TransformPointToLocalCoordSpace( |
231 const gfx::Point& point, | 232 const gfx::Point& point, |
232 const cc::SurfaceId& original_surface) { | 233 const cc::SurfaceId& original_surface) { |
233 if (surface_id_.is_null() || original_surface == surface_id_) | 234 cc::SurfaceId surface_id(frame_sink_id_, local_frame_id_); |
| 235 if (surface_id.is_null() || original_surface == surface_id) |
234 return point; | 236 return point; |
235 | 237 |
236 gfx::Point transformed_point = point; | 238 gfx::Point transformed_point = point; |
237 cc::SurfaceHittest hittest(nullptr, GetSurfaceManager()); | 239 cc::SurfaceHittest hittest(nullptr, GetSurfaceManager()); |
238 hittest.TransformPointToTargetSurface(original_surface, surface_id_, | 240 hittest.TransformPointToTargetSurface(original_surface, surface_id, |
239 &transformed_point); | 241 &transformed_point); |
240 return transformed_point; | 242 return transformed_point; |
241 } | 243 } |
242 | 244 |
243 gfx::Point DelegatedFrameHost::TransformPointToCoordSpaceForView( | 245 gfx::Point DelegatedFrameHost::TransformPointToCoordSpaceForView( |
244 const gfx::Point& point, | 246 const gfx::Point& point, |
245 RenderWidgetHostViewBase* target_view) { | 247 RenderWidgetHostViewBase* target_view) { |
246 if (surface_id_.is_null()) | 248 if (local_frame_id_.is_null()) |
247 return point; | 249 return point; |
248 | 250 |
249 return target_view->TransformPointToLocalCoordSpace(point, surface_id_); | 251 return target_view->TransformPointToLocalCoordSpace( |
| 252 point, cc::SurfaceId(frame_sink_id_, local_frame_id_)); |
250 } | 253 } |
251 | 254 |
252 bool DelegatedFrameHost::ShouldSkipFrame(gfx::Size size_in_dip) const { | 255 bool DelegatedFrameHost::ShouldSkipFrame(gfx::Size size_in_dip) const { |
253 // Should skip a frame only when another frame from the renderer is guaranteed | 256 // Should skip a frame only when another frame from the renderer is guaranteed |
254 // to replace it. Otherwise may cause hangs when the renderer is waiting for | 257 // to replace it. Otherwise may cause hangs when the renderer is waiting for |
255 // the completion of latency infos (such as when taking a Snapshot.) | 258 // the completion of latency infos (such as when taking a Snapshot.) |
256 if (can_lock_compositor_ == NO_PENDING_RENDERER_FRAME || | 259 if (can_lock_compositor_ == NO_PENDING_RENDERER_FRAME || |
257 can_lock_compositor_ == NO_PENDING_COMMIT || !resize_lock_.get()) | 260 can_lock_compositor_ == NO_PENDING_COMMIT || !resize_lock_.get()) |
258 return false; | 261 return false; |
259 | 262 |
(...skipping 10 matching lines...) Expand all Loading... |
270 } | 273 } |
271 | 274 |
272 SkColor DelegatedFrameHost::GetGutterColor() const { | 275 SkColor DelegatedFrameHost::GetGutterColor() const { |
273 // In fullscreen mode resizing is uncommon, so it makes more sense to | 276 // In fullscreen mode resizing is uncommon, so it makes more sense to |
274 // make the initial switch to fullscreen mode look better by using black as | 277 // make the initial switch to fullscreen mode look better by using black as |
275 // the gutter color. | 278 // the gutter color. |
276 return client_->DelegatedFrameHostGetGutterColor(background_color_); | 279 return client_->DelegatedFrameHostGetGutterColor(background_color_); |
277 } | 280 } |
278 | 281 |
279 void DelegatedFrameHost::UpdateGutters() { | 282 void DelegatedFrameHost::UpdateGutters() { |
280 if (surface_id_.is_null()) { | 283 if (local_frame_id_.is_null()) { |
281 right_gutter_.reset(); | 284 right_gutter_.reset(); |
282 bottom_gutter_.reset(); | 285 bottom_gutter_.reset(); |
283 return; | 286 return; |
284 } | 287 } |
285 | 288 |
286 if (current_frame_size_in_dip_.width() < | 289 if (current_frame_size_in_dip_.width() < |
287 client_->DelegatedFrameHostDesiredSizeInDIP().width()) { | 290 client_->DelegatedFrameHostDesiredSizeInDIP().width()) { |
288 right_gutter_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); | 291 right_gutter_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); |
289 right_gutter_->SetColor(GetGutterColor()); | 292 right_gutter_->SetColor(GetGutterColor()); |
290 int width = client_->DelegatedFrameHostDesiredSizeInDIP().width() - | 293 int width = client_->DelegatedFrameHostDesiredSizeInDIP().width() - |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 subscriber_texture->target())); | 384 subscriber_texture->target())); |
382 } | 385 } |
383 | 386 |
384 if (surface_factory_.get()) { | 387 if (surface_factory_.get()) { |
385 // To avoid unnecessary composites, go directly to the Surface rather than | 388 // To avoid unnecessary composites, go directly to the Surface rather than |
386 // through RequestCopyOfOutput (which goes through the browser | 389 // through RequestCopyOfOutput (which goes through the browser |
387 // compositor). | 390 // compositor). |
388 if (!request_copy_of_output_callback_for_testing_.is_null()) | 391 if (!request_copy_of_output_callback_for_testing_.is_null()) |
389 request_copy_of_output_callback_for_testing_.Run(std::move(request)); | 392 request_copy_of_output_callback_for_testing_.Run(std::move(request)); |
390 else | 393 else |
391 surface_factory_->RequestCopyOfSurface(surface_id_, std::move(request)); | 394 surface_factory_->RequestCopyOfSurface(local_frame_id_, |
| 395 std::move(request)); |
392 } else { | 396 } else { |
393 request->set_area(gfx::Rect(current_frame_size_in_dip_)); | 397 request->set_area(gfx::Rect(current_frame_size_in_dip_)); |
394 RequestCopyOfOutput(std::move(request)); | 398 RequestCopyOfOutput(std::move(request)); |
395 } | 399 } |
396 } | 400 } |
397 | 401 |
398 void DelegatedFrameHost::SwapDelegatedFrame(uint32_t compositor_frame_sink_id, | 402 void DelegatedFrameHost::SwapDelegatedFrame(uint32_t compositor_frame_sink_id, |
399 cc::CompositorFrame frame) { | 403 cc::CompositorFrame frame) { |
400 DCHECK(frame.delegated_frame_data.get()); | 404 DCHECK(frame.delegated_frame_data.get()); |
401 #if defined(OS_CHROMEOS) | 405 #if defined(OS_CHROMEOS) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 if (frame_size.IsEmpty()) { | 471 if (frame_size.IsEmpty()) { |
468 DCHECK(frame_data->resource_list.empty()); | 472 DCHECK(frame_data->resource_list.empty()); |
469 EvictDelegatedFrame(); | 473 EvictDelegatedFrame(); |
470 } else { | 474 } else { |
471 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 475 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
472 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 476 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
473 if (!surface_factory_) { | 477 if (!surface_factory_) { |
474 surface_factory_ = | 478 surface_factory_ = |
475 base::MakeUnique<cc::SurfaceFactory>(frame_sink_id_, manager, this); | 479 base::MakeUnique<cc::SurfaceFactory>(frame_sink_id_, manager, this); |
476 } | 480 } |
477 if (surface_id_.is_null() || frame_size != current_surface_size_ || | 481 if (local_frame_id_.is_null() || frame_size != current_surface_size_ || |
478 frame_size_in_dip != current_frame_size_in_dip_) { | 482 frame_size_in_dip != current_frame_size_in_dip_) { |
479 if (!surface_id_.is_null()) | 483 if (!local_frame_id_.is_null()) |
480 surface_factory_->Destroy(surface_id_); | 484 surface_factory_->Destroy(local_frame_id_); |
481 surface_id_ = id_allocator_->GenerateId(); | 485 local_frame_id_ = id_allocator_->GenerateId(); |
482 surface_factory_->Create(surface_id_); | 486 surface_factory_->Create(local_frame_id_); |
483 // manager must outlive compositors using it. | 487 // manager must outlive compositors using it. |
484 client_->DelegatedFrameHostGetLayer()->SetShowSurface( | 488 client_->DelegatedFrameHostGetLayer()->SetShowSurface( |
485 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), | 489 cc::SurfaceId(frame_sink_id_, local_frame_id_), |
| 490 base::Bind(&SatisfyCallback, base::Unretained(manager)), |
486 base::Bind(&RequireCallback, base::Unretained(manager)), frame_size, | 491 base::Bind(&RequireCallback, base::Unretained(manager)), frame_size, |
487 frame_device_scale_factor, frame_size_in_dip); | 492 frame_device_scale_factor, frame_size_in_dip); |
488 current_surface_size_ = frame_size; | 493 current_surface_size_ = frame_size; |
489 current_scale_factor_ = frame_device_scale_factor; | 494 current_scale_factor_ = frame_device_scale_factor; |
490 } | 495 } |
491 | 496 |
492 gfx::Size desired_size = client_->DelegatedFrameHostDesiredSizeInDIP(); | 497 gfx::Size desired_size = client_->DelegatedFrameHostDesiredSizeInDIP(); |
493 if (desired_size != frame_size_in_dip && !desired_size.IsEmpty()) { | 498 if (desired_size != frame_size_in_dip && !desired_size.IsEmpty()) { |
494 skip_frame = true; | 499 skip_frame = true; |
495 skipped_latency_info_list_.insert(skipped_latency_info_list_.end(), | 500 skipped_latency_info_list_.insert(skipped_latency_info_list_.end(), |
496 frame.metadata.latency_info.begin(), | 501 frame.metadata.latency_info.begin(), |
497 frame.metadata.latency_info.end()); | 502 frame.metadata.latency_info.end()); |
498 frame.metadata.latency_info.clear(); | 503 frame.metadata.latency_info.clear(); |
499 } else { | 504 } else { |
500 frame.metadata.latency_info.insert(frame.metadata.latency_info.end(), | 505 frame.metadata.latency_info.insert(frame.metadata.latency_info.end(), |
501 skipped_latency_info_list_.begin(), | 506 skipped_latency_info_list_.begin(), |
502 skipped_latency_info_list_.end()); | 507 skipped_latency_info_list_.end()); |
503 skipped_latency_info_list_.clear(); | 508 skipped_latency_info_list_.clear(); |
504 } | 509 } |
505 | 510 |
506 cc::SurfaceFactory::DrawCallback ack_callback; | 511 cc::SurfaceFactory::DrawCallback ack_callback; |
507 if (compositor_ && !skip_frame) { | 512 if (compositor_ && !skip_frame) { |
508 ack_callback = base::Bind(&DelegatedFrameHost::SurfaceDrawn, AsWeakPtr(), | 513 ack_callback = base::Bind(&DelegatedFrameHost::SurfaceDrawn, AsWeakPtr(), |
509 compositor_frame_sink_id); | 514 compositor_frame_sink_id); |
510 } | 515 } |
511 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame), | 516 surface_factory_->SubmitCompositorFrame(local_frame_id_, std::move(frame), |
512 ack_callback); | 517 ack_callback); |
513 } | 518 } |
514 released_front_lock_ = NULL; | 519 released_front_lock_ = NULL; |
515 current_frame_size_in_dip_ = frame_size_in_dip; | 520 current_frame_size_in_dip_ = frame_size_in_dip; |
516 CheckResizeLock(); | 521 CheckResizeLock(); |
517 | 522 |
518 UpdateGutters(); | 523 UpdateGutters(); |
519 | 524 |
520 if (!damage_rect_in_dip.IsEmpty()) { | 525 if (!damage_rect_in_dip.IsEmpty()) { |
521 client_->DelegatedFrameHostGetLayer()->OnDelegatedFrameDamage( | 526 client_->DelegatedFrameHostGetLayer()->OnDelegatedFrameDamage( |
522 damage_rect_in_dip); | 527 damage_rect_in_dip); |
523 } | 528 } |
524 | 529 |
525 // Note that |compositor_| may be reset by SetShowSurface or | 530 // Note that |compositor_| may be reset by SetShowSurface or |
526 // SetShowDelegatedContent above. | 531 // SetShowDelegatedContent above. |
527 if (!compositor_ || skip_frame) { | 532 if (!compositor_ || skip_frame) { |
528 SendReclaimCompositorResources(compositor_frame_sink_id, | 533 SendReclaimCompositorResources(compositor_frame_sink_id, |
529 true /* is_swap_ack */); | 534 true /* is_swap_ack */); |
530 } else { | 535 } else { |
531 can_lock_compositor_ = NO_PENDING_COMMIT; | 536 can_lock_compositor_ = NO_PENDING_COMMIT; |
532 } | 537 } |
533 if (!surface_id_.is_null()) { | 538 if (!local_frame_id_.is_null()) { |
534 delegated_frame_evictor_->SwappedFrame( | 539 delegated_frame_evictor_->SwappedFrame( |
535 client_->DelegatedFrameHostIsVisible()); | 540 client_->DelegatedFrameHostIsVisible()); |
536 } | 541 } |
537 // Note: the frame may have been evicted immediately. | 542 // Note: the frame may have been evicted immediately. |
538 } | 543 } |
539 | 544 |
540 void DelegatedFrameHost::ClearDelegatedFrame() { | 545 void DelegatedFrameHost::ClearDelegatedFrame() { |
541 if (!surface_id_.is_null()) | 546 if (!local_frame_id_.is_null()) |
542 EvictDelegatedFrame(); | 547 EvictDelegatedFrame(); |
543 } | 548 } |
544 | 549 |
545 void DelegatedFrameHost::SendReclaimCompositorResources( | 550 void DelegatedFrameHost::SendReclaimCompositorResources( |
546 uint32_t compositor_frame_sink_id, | 551 uint32_t compositor_frame_sink_id, |
547 bool is_swap_ack) { | 552 bool is_swap_ack) { |
548 client_->DelegatedFrameHostSendReclaimCompositorResources( | 553 client_->DelegatedFrameHostSendReclaimCompositorResources( |
549 compositor_frame_sink_id, is_swap_ack, surface_returned_resources_); | 554 compositor_frame_sink_id, is_swap_ack, surface_returned_resources_); |
550 surface_returned_resources_.clear(); | 555 surface_returned_resources_.clear(); |
551 if (is_swap_ack) { | 556 if (is_swap_ack) { |
(...skipping 12 matching lines...) Expand all Loading... |
564 if (resources.empty()) | 569 if (resources.empty()) |
565 return; | 570 return; |
566 std::copy(resources.begin(), resources.end(), | 571 std::copy(resources.begin(), resources.end(), |
567 std::back_inserter(surface_returned_resources_)); | 572 std::back_inserter(surface_returned_resources_)); |
568 if (!pending_delegated_ack_count_) { | 573 if (!pending_delegated_ack_count_) { |
569 SendReclaimCompositorResources(last_compositor_frame_sink_id_, | 574 SendReclaimCompositorResources(last_compositor_frame_sink_id_, |
570 false /* is_swap_ack */); | 575 false /* is_swap_ack */); |
571 } | 576 } |
572 } | 577 } |
573 | 578 |
574 void DelegatedFrameHost::WillDrawSurface(const cc::SurfaceId& id, | 579 void DelegatedFrameHost::WillDrawSurface(const cc::LocalFrameId& id, |
575 const gfx::Rect& damage_rect) { | 580 const gfx::Rect& damage_rect) { |
576 // Frame subscribers are only interested in changes to the target surface, so | 581 // Frame subscribers are only interested in changes to the target surface, so |
577 // do not attempt capture if |damage_rect| is empty. This prevents the draws | 582 // do not attempt capture if |damage_rect| is empty. This prevents the draws |
578 // of parent surfaces from triggering extra frame captures, which can affect | 583 // of parent surfaces from triggering extra frame captures, which can affect |
579 // smoothness. | 584 // smoothness. |
580 if (id != surface_id_ || damage_rect.IsEmpty()) | 585 if (id != local_frame_id_ || damage_rect.IsEmpty()) |
581 return; | 586 return; |
582 AttemptFrameSubscriberCapture(damage_rect); | 587 AttemptFrameSubscriberCapture(damage_rect); |
583 } | 588 } |
584 | 589 |
585 void DelegatedFrameHost::SetBeginFrameSource( | 590 void DelegatedFrameHost::SetBeginFrameSource( |
586 cc::BeginFrameSource* begin_frame_source) { | 591 cc::BeginFrameSource* begin_frame_source) { |
587 client_->SetBeginFrameSource(begin_frame_source); | 592 client_->SetBeginFrameSource(begin_frame_source); |
588 } | 593 } |
589 | 594 |
590 void DelegatedFrameHost::EvictDelegatedFrame() { | 595 void DelegatedFrameHost::EvictDelegatedFrame() { |
591 client_->DelegatedFrameHostGetLayer()->SetShowSolidColorContent(); | 596 client_->DelegatedFrameHostGetLayer()->SetShowSolidColorContent(); |
592 if (!surface_id_.is_null()) { | 597 if (!local_frame_id_.is_null()) { |
593 surface_factory_->Destroy(surface_id_); | 598 surface_factory_->Destroy(local_frame_id_); |
594 surface_id_ = cc::SurfaceId(); | 599 local_frame_id_ = cc::LocalFrameId(); |
595 } | 600 } |
596 delegated_frame_evictor_->DiscardedFrame(); | 601 delegated_frame_evictor_->DiscardedFrame(); |
597 UpdateGutters(); | 602 UpdateGutters(); |
598 } | 603 } |
599 | 604 |
600 // static | 605 // static |
601 void DelegatedFrameHost::ReturnSubscriberTexture( | 606 void DelegatedFrameHost::ReturnSubscriberTexture( |
602 base::WeakPtr<DelegatedFrameHost> dfh, | 607 base::WeakPtr<DelegatedFrameHost> dfh, |
603 scoped_refptr<OwnedMailbox> subscriber_texture, | 608 scoped_refptr<OwnedMailbox> subscriber_texture, |
604 const gpu::SyncToken& sync_token) { | 609 const gpu::SyncToken& sync_token) { |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 void DelegatedFrameHost::OnUpdateVSyncParameters(base::TimeTicks timebase, | 811 void DelegatedFrameHost::OnUpdateVSyncParameters(base::TimeTicks timebase, |
807 base::TimeDelta interval) { | 812 base::TimeDelta interval) { |
808 vsync_timebase_ = timebase; | 813 vsync_timebase_ = timebase; |
809 vsync_interval_ = interval; | 814 vsync_interval_ = interval; |
810 } | 815 } |
811 | 816 |
812 //////////////////////////////////////////////////////////////////////////////// | 817 //////////////////////////////////////////////////////////////////////////////// |
813 // DelegatedFrameHost, ImageTransportFactoryObserver implementation: | 818 // DelegatedFrameHost, ImageTransportFactoryObserver implementation: |
814 | 819 |
815 void DelegatedFrameHost::OnLostResources() { | 820 void DelegatedFrameHost::OnLostResources() { |
816 if (!surface_id_.is_null()) | 821 if (!local_frame_id_.is_null()) |
817 EvictDelegatedFrame(); | 822 EvictDelegatedFrame(); |
818 idle_frame_subscriber_textures_.clear(); | 823 idle_frame_subscriber_textures_.clear(); |
819 yuv_readback_pipeline_.reset(); | 824 yuv_readback_pipeline_.reset(); |
820 | 825 |
821 client_->DelegatedFrameHostOnLostCompositorResources(); | 826 client_->DelegatedFrameHostOnLostCompositorResources(); |
822 } | 827 } |
823 | 828 |
824 //////////////////////////////////////////////////////////////////////////////// | 829 //////////////////////////////////////////////////////////////////////////////// |
825 // DelegatedFrameHost, private: | 830 // DelegatedFrameHost, private: |
826 | 831 |
827 DelegatedFrameHost::~DelegatedFrameHost() { | 832 DelegatedFrameHost::~DelegatedFrameHost() { |
828 DCHECK(!compositor_); | 833 DCHECK(!compositor_); |
829 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 834 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
830 factory->GetContextFactory()->RemoveObserver(this); | 835 factory->GetContextFactory()->RemoveObserver(this); |
831 | 836 |
832 if (!surface_id_.is_null()) | 837 if (!local_frame_id_.is_null()) |
833 surface_factory_->Destroy(surface_id_); | 838 surface_factory_->Destroy(local_frame_id_); |
834 factory->GetSurfaceManager()->UnregisterSurfaceFactoryClient(frame_sink_id_); | 839 factory->GetSurfaceManager()->UnregisterSurfaceFactoryClient(frame_sink_id_); |
835 factory->GetSurfaceManager()->InvalidateFrameSinkId(frame_sink_id_); | 840 factory->GetSurfaceManager()->InvalidateFrameSinkId(frame_sink_id_); |
836 | 841 |
837 DCHECK(!vsync_manager_.get()); | 842 DCHECK(!vsync_manager_.get()); |
838 } | 843 } |
839 | 844 |
840 void DelegatedFrameHost::SetCompositor(ui::Compositor* compositor) { | 845 void DelegatedFrameHost::SetCompositor(ui::Compositor* compositor) { |
841 DCHECK(!compositor_); | 846 DCHECK(!compositor_); |
842 if (!compositor) | 847 if (!compositor) |
843 return; | 848 return; |
(...skipping 18 matching lines...) Expand all Loading... |
862 if (vsync_manager_) { | 867 if (vsync_manager_) { |
863 vsync_manager_->RemoveObserver(this); | 868 vsync_manager_->RemoveObserver(this); |
864 vsync_manager_ = nullptr; | 869 vsync_manager_ = nullptr; |
865 } | 870 } |
866 | 871 |
867 compositor_->RemoveFrameSink(frame_sink_id_); | 872 compositor_->RemoveFrameSink(frame_sink_id_); |
868 compositor_ = nullptr; | 873 compositor_ = nullptr; |
869 } | 874 } |
870 | 875 |
871 void DelegatedFrameHost::LockResources() { | 876 void DelegatedFrameHost::LockResources() { |
872 DCHECK(!surface_id_.is_null()); | 877 DCHECK(!local_frame_id_.is_null()); |
873 delegated_frame_evictor_->LockFrame(); | 878 delegated_frame_evictor_->LockFrame(); |
874 } | 879 } |
875 | 880 |
876 void DelegatedFrameHost::RequestCopyOfOutput( | 881 void DelegatedFrameHost::RequestCopyOfOutput( |
877 std::unique_ptr<cc::CopyOutputRequest> request) { | 882 std::unique_ptr<cc::CopyOutputRequest> request) { |
878 if (!request_copy_of_output_callback_for_testing_.is_null()) { | 883 if (!request_copy_of_output_callback_for_testing_.is_null()) { |
879 request_copy_of_output_callback_for_testing_.Run(std::move(request)); | 884 request_copy_of_output_callback_for_testing_.Run(std::move(request)); |
880 } else { | 885 } else { |
881 client_->DelegatedFrameHostGetLayer()->RequestCopyOfOutput( | 886 client_->DelegatedFrameHostGetLayer()->RequestCopyOfOutput( |
882 std::move(request)); | 887 std::move(request)); |
883 } | 888 } |
884 } | 889 } |
885 | 890 |
886 void DelegatedFrameHost::UnlockResources() { | 891 void DelegatedFrameHost::UnlockResources() { |
887 DCHECK(!surface_id_.is_null()); | 892 DCHECK(!local_frame_id_.is_null()); |
888 delegated_frame_evictor_->UnlockFrame(); | 893 delegated_frame_evictor_->UnlockFrame(); |
889 } | 894 } |
890 | 895 |
891 //////////////////////////////////////////////////////////////////////////////// | 896 //////////////////////////////////////////////////////////////////////////////// |
892 // DelegatedFrameHost, ui::LayerOwnerDelegate implementation: | 897 // DelegatedFrameHost, ui::LayerOwnerDelegate implementation: |
893 | 898 |
894 void DelegatedFrameHost::OnLayerRecreated(ui::Layer* old_layer, | 899 void DelegatedFrameHost::OnLayerRecreated(ui::Layer* old_layer, |
895 ui::Layer* new_layer) { | 900 ui::Layer* new_layer) { |
896 // The new_layer is the one that will be used by our Window, so that's the one | 901 // The new_layer is the one that will be used by our Window, so that's the one |
897 // that should keep our frame. old_layer will be returned to the | 902 // that should keep our frame. old_layer will be returned to the |
898 // RecreateLayer caller, and should have a copy. | 903 // RecreateLayer caller, and should have a copy. |
899 if (!surface_id_.is_null()) { | 904 if (!local_frame_id_.is_null()) { |
900 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 905 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
901 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 906 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
902 new_layer->SetShowSurface( | 907 new_layer->SetShowSurface( |
903 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), | 908 cc::SurfaceId(frame_sink_id_, local_frame_id_), |
| 909 base::Bind(&SatisfyCallback, base::Unretained(manager)), |
904 base::Bind(&RequireCallback, base::Unretained(manager)), | 910 base::Bind(&RequireCallback, base::Unretained(manager)), |
905 current_surface_size_, current_scale_factor_, | 911 current_surface_size_, current_scale_factor_, |
906 current_frame_size_in_dip_); | 912 current_frame_size_in_dip_); |
907 } | 913 } |
908 } | 914 } |
909 | 915 |
910 } // namespace content | 916 } // namespace content |
OLD | NEW |