| 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> |
| 11 | 11 |
| 12 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/debug/stack_trace.h" |
| 14 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 15 #include "base/time/default_tick_clock.h" | 16 #include "base/time/default_tick_clock.h" |
| 16 #include "cc/output/compositor_frame.h" | 17 #include "cc/output/compositor_frame.h" |
| 17 #include "cc/output/copy_output_request.h" | 18 #include "cc/output/copy_output_request.h" |
| 18 #include "cc/resources/single_release_callback.h" | 19 #include "cc/resources/single_release_callback.h" |
| 19 #include "cc/resources/texture_mailbox.h" | 20 #include "cc/resources/texture_mailbox.h" |
| 20 #include "cc/surfaces/surface.h" | 21 #include "cc/surfaces/surface.h" |
| 21 #include "cc/surfaces/surface_factory.h" | 22 #include "cc/surfaces/surface_factory.h" |
| 22 #include "cc/surfaces/surface_hittest.h" | 23 #include "cc/surfaces/surface_hittest.h" |
| 23 #include "cc/surfaces/surface_manager.h" | 24 #include "cc/surfaces/surface_manager.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // DelegatedFrameHost | 64 // DelegatedFrameHost |
| 64 | 65 |
| 65 DelegatedFrameHost::DelegatedFrameHost(DelegatedFrameHostClient* client) | 66 DelegatedFrameHost::DelegatedFrameHost(DelegatedFrameHostClient* client) |
| 66 : client_(client), | 67 : client_(client), |
| 67 compositor_(nullptr), | 68 compositor_(nullptr), |
| 68 tick_clock_(new base::DefaultTickClock()), | 69 tick_clock_(new base::DefaultTickClock()), |
| 69 last_output_surface_id_(0), | 70 last_output_surface_id_(0), |
| 70 pending_delegated_ack_count_(0), | 71 pending_delegated_ack_count_(0), |
| 71 skipped_frames_(false), | 72 skipped_frames_(false), |
| 72 background_color_(SK_ColorRED), | 73 background_color_(SK_ColorRED), |
| 74 surface_client_id_(0), |
| 73 current_scale_factor_(1.f), | 75 current_scale_factor_(1.f), |
| 74 can_lock_compositor_(YES_CAN_LOCK), | 76 can_lock_compositor_(YES_CAN_LOCK), |
| 75 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) { | 77 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) { |
| 78 ImageTransportFactory* context_factory = ImageTransportFactory::GetInstance(); |
| 79 context_factory->GetContextFactory()->AddObserver(this); |
| 76 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 80 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 77 factory->GetContextFactory()->AddObserver(this); | 81 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
| 78 id_allocator_ = factory->GetContextFactory()->CreateSurfaceIdAllocator(); | 82 surface_client_id_ = factory->GetContextFactory()->AllocateSurfaceClientId(); |
| 79 factory->GetSurfaceManager()->RegisterSurfaceFactoryClient( | 83 surface_factory_ = base::WrapUnique( |
| 80 id_allocator_->client_id(), this); | 84 new cc::SurfaceFactory(surface_client_id_, manager, this)); |
| 81 } | 85 } |
| 82 | 86 |
| 83 void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) { | 87 void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) { |
| 84 delegated_frame_evictor_->SetVisible(true); | 88 delegated_frame_evictor_->SetVisible(true); |
| 85 | 89 |
| 86 if (surface_id_.is_null() && !released_front_lock_.get()) { | 90 if (surface_id_.is_null() && !released_front_lock_.get()) { |
| 87 if (compositor_) | 91 if (compositor_) |
| 88 released_front_lock_ = compositor_->GetCompositorLock(); | 92 released_front_lock_ = compositor_->GetCompositorLock(); |
| 89 } | 93 } |
| 90 | 94 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 std::unique_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { | 201 std::unique_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { |
| 198 frame_subscriber_ = std::move(subscriber); | 202 frame_subscriber_ = std::move(subscriber); |
| 199 } | 203 } |
| 200 | 204 |
| 201 void DelegatedFrameHost::EndFrameSubscription() { | 205 void DelegatedFrameHost::EndFrameSubscription() { |
| 202 idle_frame_subscriber_textures_.clear(); | 206 idle_frame_subscriber_textures_.clear(); |
| 203 frame_subscriber_.reset(); | 207 frame_subscriber_.reset(); |
| 204 } | 208 } |
| 205 | 209 |
| 206 uint32_t DelegatedFrameHost::GetSurfaceClientId() { | 210 uint32_t DelegatedFrameHost::GetSurfaceClientId() { |
| 207 return id_allocator_->client_id(); | 211 return surface_client_id_; |
| 208 } | 212 } |
| 209 | 213 |
| 210 cc::SurfaceId DelegatedFrameHost::SurfaceIdAtPoint( | 214 cc::SurfaceId DelegatedFrameHost::SurfaceIdAtPoint( |
| 211 cc::SurfaceHittestDelegate* delegate, | 215 cc::SurfaceHittestDelegate* delegate, |
| 212 const gfx::Point& point, | 216 const gfx::Point& point, |
| 213 gfx::Point* transformed_point) { | 217 gfx::Point* transformed_point) { |
| 214 if (surface_id_.is_null()) | 218 if (surface_id_.is_null()) |
| 215 return surface_id_; | 219 return surface_id_; |
| 216 cc::SurfaceHittest hittest(delegate, GetSurfaceManager()); | 220 cc::SurfaceHittest hittest(delegate, GetSurfaceManager()); |
| 217 gfx::Transform target_transform; | 221 gfx::Transform target_transform; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 // DelegatedFrameHost (e.g., a call to CopyFromCompositingSurface() for | 369 // DelegatedFrameHost (e.g., a call to CopyFromCompositingSurface() for |
| 366 // screenshots) since those copy requests do not specify |frame_subscriber()| | 370 // screenshots) since those copy requests do not specify |frame_subscriber()| |
| 367 // as a source. | 371 // as a source. |
| 368 request->set_source(frame_subscriber()); | 372 request->set_source(frame_subscriber()); |
| 369 if (subscriber_texture.get()) { | 373 if (subscriber_texture.get()) { |
| 370 request->SetTextureMailbox(cc::TextureMailbox( | 374 request->SetTextureMailbox(cc::TextureMailbox( |
| 371 subscriber_texture->mailbox(), subscriber_texture->sync_token(), | 375 subscriber_texture->mailbox(), subscriber_texture->sync_token(), |
| 372 subscriber_texture->target())); | 376 subscriber_texture->target())); |
| 373 } | 377 } |
| 374 | 378 |
| 375 if (surface_factory_.get()) { | 379 if (surface_factory_) { |
| 376 // To avoid unnecessary composites, go directly to the Surface rather than | 380 // To avoid unnecessary composites, go directly to the Surface rather than |
| 377 // through RequestCopyOfOutput (which goes through the browser | 381 // through RequestCopyOfOutput (which goes through the browser |
| 378 // compositor). | 382 // compositor). |
| 379 if (!request_copy_of_output_callback_for_testing_.is_null()) | 383 if (!request_copy_of_output_callback_for_testing_.is_null()) |
| 380 request_copy_of_output_callback_for_testing_.Run(std::move(request)); | 384 request_copy_of_output_callback_for_testing_.Run(std::move(request)); |
| 381 else | 385 else |
| 382 surface_factory_->RequestCopyOfSurface(surface_id_, std::move(request)); | 386 surface_factory_->RequestCopyOfSurface(surface_id_, std::move(request)); |
| 383 } else { | 387 } else { |
| 384 request->set_area(gfx::Rect(current_frame_size_in_dip_)); | 388 request->set_area(gfx::Rect(current_frame_size_in_dip_)); |
| 385 RequestCopyOfOutput(std::move(request)); | 389 RequestCopyOfOutput(std::move(request)); |
| 386 } | 390 } |
| 387 } | 391 } |
| 388 | 392 |
| 389 void DelegatedFrameHost::SwapDelegatedFrame(uint32_t output_surface_id, | 393 void DelegatedFrameHost::SwapDelegatedFrame(uint32_t output_surface_id, |
| 394 const cc::SurfaceId& surface_id, |
| 390 cc::CompositorFrame frame) { | 395 cc::CompositorFrame frame) { |
| 391 DCHECK(frame.delegated_frame_data.get()); | 396 DCHECK(frame.delegated_frame_data.get()); |
| 392 #if defined(OS_CHROMEOS) | 397 #if defined(OS_CHROMEOS) |
| 393 DCHECK(!resize_lock_ || !client_->IsAutoResizeEnabled()); | 398 DCHECK(!resize_lock_ || !client_->IsAutoResizeEnabled()); |
| 394 #endif | 399 #endif |
| 395 cc::DelegatedFrameData* frame_data = frame.delegated_frame_data.get(); | 400 cc::DelegatedFrameData* frame_data = frame.delegated_frame_data.get(); |
| 396 float frame_device_scale_factor = frame.metadata.device_scale_factor; | 401 float frame_device_scale_factor = frame.metadata.device_scale_factor; |
| 397 | 402 |
| 398 DCHECK(!frame_data->render_pass_list.empty()); | 403 DCHECK(!frame_data->render_pass_list.empty()); |
| 399 | 404 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 427 skipped_frames_ = false; | 432 skipped_frames_ = false; |
| 428 damage_rect = gfx::Rect(frame_size); | 433 damage_rect = gfx::Rect(frame_size); |
| 429 damage_rect_in_dip = gfx::Rect(frame_size_in_dip); | 434 damage_rect_in_dip = gfx::Rect(frame_size_in_dip); |
| 430 | 435 |
| 431 // Give the same damage rect to the compositor. | 436 // Give the same damage rect to the compositor. |
| 432 cc::RenderPass* root_pass = frame_data->render_pass_list.back().get(); | 437 cc::RenderPass* root_pass = frame_data->render_pass_list.back().get(); |
| 433 root_pass->damage_rect = damage_rect; | 438 root_pass->damage_rect = damage_rect; |
| 434 } | 439 } |
| 435 | 440 |
| 436 if (output_surface_id != last_output_surface_id_) { | 441 if (output_surface_id != last_output_surface_id_) { |
| 442 // The surface_id should change if we have a new output surface. If it |
| 443 // hasn't then the client is misbehaving and we should just ignore the swap. |
| 444 if (surface_id_ == surface_id) |
| 445 return; |
| 437 // Resource ids are scoped by the output surface. | 446 // Resource ids are scoped by the output surface. |
| 438 // If the originating output surface doesn't match the last one, it | 447 // If the originating output surface doesn't match the last one, it |
| 439 // indicates the renderer's output surface may have been recreated, in which | 448 // indicates the renderer's output surface may have been recreated, in which |
| 440 // case we should recreate the DelegatedRendererLayer, to avoid matching | 449 // case we should recreate the DelegatedRendererLayer, to avoid matching |
| 441 // resources from the old one with resources from the new one which would | 450 // resources from the old one with resources from the new one which would |
| 442 // have the same id. Changing the layer to showing painted content destroys | 451 // have the same id. Changing the layer to showing painted content destroys |
| 443 // the DelegatedRendererLayer. | 452 // the DelegatedRendererLayer. |
| 444 EvictDelegatedFrame(); | 453 EvictDelegatedFrame(); |
| 445 | 454 |
| 446 surface_factory_.reset(); | |
| 447 if (!surface_returned_resources_.empty()) { | 455 if (!surface_returned_resources_.empty()) { |
| 448 SendReclaimCompositorResources(last_output_surface_id_, | 456 SendReclaimCompositorResources(last_output_surface_id_, |
| 449 false /* is_swap_ack */); | 457 false /* is_swap_ack */); |
| 450 } | 458 } |
| 451 last_output_surface_id_ = output_surface_id; | 459 last_output_surface_id_ = output_surface_id; |
| 452 } | 460 } |
| 453 bool skip_frame = false; | 461 bool skip_frame = false; |
| 454 pending_delegated_ack_count_++; | 462 pending_delegated_ack_count_++; |
| 455 | 463 |
| 456 background_color_ = frame.metadata.root_background_color; | 464 background_color_ = frame.metadata.root_background_color; |
| 457 | 465 |
| 458 if (frame_size.IsEmpty()) { | 466 if (frame_size.IsEmpty()) { |
| 459 DCHECK(frame_data->resource_list.empty()); | 467 DCHECK(frame_data->resource_list.empty()); |
| 460 EvictDelegatedFrame(); | 468 EvictDelegatedFrame(); |
| 461 } else { | 469 } else { |
| 462 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 470 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 463 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 471 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
| 464 if (!surface_factory_) { | 472 |
| 465 surface_factory_ = | 473 if (surface_id_ != surface_id) { |
| 466 base::WrapUnique(new cc::SurfaceFactory(manager, this)); | |
| 467 } | |
| 468 if (surface_id_.is_null() || frame_size != current_surface_size_ || | |
| 469 frame_size_in_dip != current_frame_size_in_dip_) { | |
| 470 if (!surface_id_.is_null()) | 474 if (!surface_id_.is_null()) |
| 471 surface_factory_->Destroy(surface_id_); | 475 surface_factory_->Destroy(surface_id_); |
| 472 surface_id_ = id_allocator_->GenerateId(); | 476 surface_id_ = cc::SurfaceId(surface_client_id_, surface_id.local_id(), |
| 477 surface_id.nonce()); |
| 473 surface_factory_->Create(surface_id_); | 478 surface_factory_->Create(surface_id_); |
| 474 // manager must outlive compositors using it. | 479 // manager must outlive compositors using it. |
| 475 client_->DelegatedFrameHostGetLayer()->SetShowSurface( | 480 client_->DelegatedFrameHostGetLayer()->SetShowSurface( |
| 476 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), | 481 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), |
| 477 base::Bind(&RequireCallback, base::Unretained(manager)), frame_size, | 482 base::Bind(&RequireCallback, base::Unretained(manager)), frame_size, |
| 478 frame_device_scale_factor, frame_size_in_dip); | 483 frame_device_scale_factor, frame_size_in_dip); |
| 479 current_surface_size_ = frame_size; | |
| 480 current_scale_factor_ = frame_device_scale_factor; | |
| 481 } | 484 } |
| 482 | 485 |
| 483 frame.metadata.latency_info.insert(frame.metadata.latency_info.end(), | 486 frame.metadata.latency_info.insert(frame.metadata.latency_info.end(), |
| 484 skipped_latency_info_list_.begin(), | 487 skipped_latency_info_list_.begin(), |
| 485 skipped_latency_info_list_.end()); | 488 skipped_latency_info_list_.end()); |
| 486 skipped_latency_info_list_.clear(); | 489 skipped_latency_info_list_.clear(); |
| 487 | 490 |
| 488 gfx::Size desired_size = client_->DelegatedFrameHostDesiredSizeInDIP(); | 491 gfx::Size desired_size = client_->DelegatedFrameHostDesiredSizeInDIP(); |
| 489 if (desired_size != frame_size_in_dip && !desired_size.IsEmpty()) | 492 if (desired_size != frame_size_in_dip && !desired_size.IsEmpty()) |
| 490 skip_frame = true; | 493 skip_frame = true; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 void DelegatedFrameHost::SetBeginFrameSource( | 573 void DelegatedFrameHost::SetBeginFrameSource( |
| 571 cc::BeginFrameSource* begin_frame_source) { | 574 cc::BeginFrameSource* begin_frame_source) { |
| 572 client_->SetBeginFrameSource(begin_frame_source); | 575 client_->SetBeginFrameSource(begin_frame_source); |
| 573 } | 576 } |
| 574 | 577 |
| 575 void DelegatedFrameHost::EvictDelegatedFrame() { | 578 void DelegatedFrameHost::EvictDelegatedFrame() { |
| 576 client_->DelegatedFrameHostGetLayer()->SetShowSolidColorContent(); | 579 client_->DelegatedFrameHostGetLayer()->SetShowSolidColorContent(); |
| 577 if (!surface_id_.is_null()) { | 580 if (!surface_id_.is_null()) { |
| 578 surface_factory_->Destroy(surface_id_); | 581 surface_factory_->Destroy(surface_id_); |
| 579 surface_id_ = cc::SurfaceId(); | 582 surface_id_ = cc::SurfaceId(); |
| 583 |
| 584 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 585 surface_client_id_ = |
| 586 factory->GetContextFactory()->AllocateSurfaceClientId(); |
| 587 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
| 588 uint32_t parent = surface_factory_->parent_client_id(); |
| 589 surface_factory_.reset( |
| 590 new cc::SurfaceFactory(surface_client_id_, manager, this)); |
| 591 surface_factory_->SetParent(parent); |
| 580 } | 592 } |
| 581 delegated_frame_evictor_->DiscardedFrame(); | 593 delegated_frame_evictor_->DiscardedFrame(); |
| 582 UpdateGutters(); | 594 UpdateGutters(); |
| 583 } | 595 } |
| 584 | 596 |
| 585 // static | 597 // static |
| 586 void DelegatedFrameHost::ReturnSubscriberTexture( | 598 void DelegatedFrameHost::ReturnSubscriberTexture( |
| 587 base::WeakPtr<DelegatedFrameHost> dfh, | 599 base::WeakPtr<DelegatedFrameHost> dfh, |
| 588 scoped_refptr<OwnedMailbox> subscriber_texture, | 600 scoped_refptr<OwnedMailbox> subscriber_texture, |
| 589 const gpu::SyncToken& sync_token) { | 601 const gpu::SyncToken& sync_token) { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 video_frame->data(media::VideoFrame::kUPlane), | 752 video_frame->data(media::VideoFrame::kUPlane), |
| 741 video_frame->stride(media::VideoFrame::kVPlane), | 753 video_frame->stride(media::VideoFrame::kVPlane), |
| 742 video_frame->data(media::VideoFrame::kVPlane), region_in_frame.origin(), | 754 video_frame->data(media::VideoFrame::kVPlane), region_in_frame.origin(), |
| 743 finished_callback); | 755 finished_callback); |
| 744 media::LetterboxYUV(video_frame.get(), region_in_frame); | 756 media::LetterboxYUV(video_frame.get(), region_in_frame); |
| 745 } | 757 } |
| 746 | 758 |
| 747 //////////////////////////////////////////////////////////////////////////////// | 759 //////////////////////////////////////////////////////////////////////////////// |
| 748 // DelegatedFrameHost, ui::CompositorObserver implementation: | 760 // DelegatedFrameHost, ui::CompositorObserver implementation: |
| 749 | 761 |
| 762 void DelegatedFrameHost::OnCompositingInitialized(ui::Compositor* compositor) { |
| 763 uint32_t parent = compositor->surface_id_allocator()->client_id(); |
| 764 surface_factory_->SetParent(parent); |
| 765 } |
| 766 |
| 750 void DelegatedFrameHost::OnCompositingDidCommit(ui::Compositor* compositor) { | 767 void DelegatedFrameHost::OnCompositingDidCommit(ui::Compositor* compositor) { |
| 751 if (can_lock_compositor_ == NO_PENDING_COMMIT) { | 768 if (can_lock_compositor_ == NO_PENDING_COMMIT) { |
| 752 can_lock_compositor_ = YES_CAN_LOCK; | 769 can_lock_compositor_ = YES_CAN_LOCK; |
| 753 if (resize_lock_.get() && resize_lock_->GrabDeferredLock()) | 770 if (resize_lock_.get() && resize_lock_->GrabDeferredLock()) |
| 754 can_lock_compositor_ = YES_DID_LOCK; | 771 can_lock_compositor_ = YES_DID_LOCK; |
| 755 } | 772 } |
| 756 if (resize_lock_ && | 773 if (resize_lock_ && |
| 757 resize_lock_->expected_size() == current_frame_size_in_dip_) { | 774 resize_lock_->expected_size() == current_frame_size_in_dip_) { |
| 758 resize_lock_.reset(); | 775 resize_lock_.reset(); |
| 759 client_->DelegatedFrameHostResizeLockWasReleased(); | 776 client_->DelegatedFrameHostResizeLockWasReleased(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 //////////////////////////////////////////////////////////////////////////////// | 827 //////////////////////////////////////////////////////////////////////////////// |
| 811 // DelegatedFrameHost, private: | 828 // DelegatedFrameHost, private: |
| 812 | 829 |
| 813 DelegatedFrameHost::~DelegatedFrameHost() { | 830 DelegatedFrameHost::~DelegatedFrameHost() { |
| 814 DCHECK(!compositor_); | 831 DCHECK(!compositor_); |
| 815 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 832 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 816 factory->GetContextFactory()->RemoveObserver(this); | 833 factory->GetContextFactory()->RemoveObserver(this); |
| 817 | 834 |
| 818 if (!surface_id_.is_null()) | 835 if (!surface_id_.is_null()) |
| 819 surface_factory_->Destroy(surface_id_); | 836 surface_factory_->Destroy(surface_id_); |
| 820 factory->GetSurfaceManager()->UnregisterSurfaceFactoryClient( | |
| 821 id_allocator_->client_id()); | |
| 822 | 837 |
| 823 DCHECK(!vsync_manager_.get()); | 838 DCHECK(!vsync_manager_.get()); |
| 824 } | 839 } |
| 825 | 840 |
| 826 void DelegatedFrameHost::SetCompositor(ui::Compositor* compositor) { | 841 void DelegatedFrameHost::SetCompositor(ui::Compositor* compositor) { |
| 827 DCHECK(!compositor_); | 842 DCHECK(!compositor_); |
| 828 if (!compositor) | 843 if (!compositor) |
| 829 return; | 844 return; |
| 830 compositor_ = compositor; | 845 compositor_ = compositor; |
| 831 compositor_->AddObserver(this); | 846 compositor_->AddObserver(this); |
| 832 DCHECK(!vsync_manager_.get()); | 847 DCHECK(!vsync_manager_.get()); |
| 833 vsync_manager_ = compositor_->vsync_manager(); | 848 vsync_manager_ = compositor_->vsync_manager(); |
| 834 vsync_manager_->AddObserver(this); | 849 vsync_manager_->AddObserver(this); |
| 835 | 850 |
| 836 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 851 if (compositor->initialized()) { |
| 837 uint32_t parent = compositor->surface_id_allocator()->client_id(); | 852 uint32_t parent = compositor->surface_id_allocator()->client_id(); |
| 838 factory->GetSurfaceManager()->RegisterSurfaceNamespaceHierarchy( | 853 surface_factory_->SetParent(parent); |
| 839 parent, id_allocator_->client_id()); | 854 } |
| 840 } | 855 } |
| 841 | 856 |
| 842 void DelegatedFrameHost::ResetCompositor() { | 857 void DelegatedFrameHost::ResetCompositor() { |
| 843 if (!compositor_) | 858 if (!compositor_) |
| 844 return; | 859 return; |
| 845 if (resize_lock_) { | 860 if (resize_lock_) { |
| 846 resize_lock_.reset(); | 861 resize_lock_.reset(); |
| 847 client_->DelegatedFrameHostResizeLockWasReleased(); | 862 client_->DelegatedFrameHostResizeLockWasReleased(); |
| 848 } | 863 } |
| 849 if (compositor_->HasObserver(this)) | 864 if (compositor_->HasObserver(this)) |
| 850 compositor_->RemoveObserver(this); | 865 compositor_->RemoveObserver(this); |
| 851 if (vsync_manager_.get()) { | 866 if (vsync_manager_.get()) { |
| 852 vsync_manager_->RemoveObserver(this); | 867 vsync_manager_->RemoveObserver(this); |
| 853 vsync_manager_ = NULL; | 868 vsync_manager_ = NULL; |
| 854 } | 869 } |
| 855 | 870 |
| 856 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 871 surface_factory_->SetParent(0); |
| 857 uint32_t parent = compositor_->surface_id_allocator()->client_id(); | |
| 858 factory->GetSurfaceManager()->UnregisterSurfaceNamespaceHierarchy( | |
| 859 parent, id_allocator_->client_id()); | |
| 860 | 872 |
| 861 compositor_ = nullptr; | 873 compositor_ = nullptr; |
| 862 } | 874 } |
| 863 | 875 |
| 864 void DelegatedFrameHost::SetVSyncParameters(const base::TimeTicks& timebase, | 876 void DelegatedFrameHost::SetVSyncParameters(const base::TimeTicks& timebase, |
| 865 const base::TimeDelta& interval) { | 877 const base::TimeDelta& interval) { |
| 866 vsync_timebase_ = timebase; | 878 vsync_timebase_ = timebase; |
| 867 vsync_interval_ = interval; | 879 vsync_interval_ = interval; |
| 868 } | 880 } |
| 869 | 881 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 900 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 912 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
| 901 new_layer->SetShowSurface( | 913 new_layer->SetShowSurface( |
| 902 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), | 914 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), |
| 903 base::Bind(&RequireCallback, base::Unretained(manager)), | 915 base::Bind(&RequireCallback, base::Unretained(manager)), |
| 904 current_surface_size_, current_scale_factor_, | 916 current_surface_size_, current_scale_factor_, |
| 905 current_frame_size_in_dip_); | 917 current_frame_size_in_dip_); |
| 906 } | 918 } |
| 907 } | 919 } |
| 908 | 920 |
| 909 } // namespace content | 921 } // namespace content |
| OLD | NEW |