OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/compositor_impl_android.h" | 5 #include "content/browser/renderer_host/compositor_impl_android.h" |
6 | 6 |
7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
8 #include <android/native_window_jni.h> | 8 #include <android/native_window_jni.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <unordered_set> | 10 #include <unordered_set> |
(...skipping 29 matching lines...) Expand all Loading... | |
40 #include "cc/output/vulkan_in_process_context_provider.h" | 40 #include "cc/output/vulkan_in_process_context_provider.h" |
41 #include "cc/raster/single_thread_task_graph_runner.h" | 41 #include "cc/raster/single_thread_task_graph_runner.h" |
42 #include "cc/resources/ui_resource_manager.h" | 42 #include "cc/resources/ui_resource_manager.h" |
43 #include "cc/surfaces/direct_compositor_frame_sink.h" | 43 #include "cc/surfaces/direct_compositor_frame_sink.h" |
44 #include "cc/surfaces/display.h" | 44 #include "cc/surfaces/display.h" |
45 #include "cc/surfaces/display_scheduler.h" | 45 #include "cc/surfaces/display_scheduler.h" |
46 #include "cc/trees/layer_tree_host.h" | 46 #include "cc/trees/layer_tree_host.h" |
47 #include "cc/trees/layer_tree_settings.h" | 47 #include "cc/trees/layer_tree_settings.h" |
48 #include "components/display_compositor/compositor_overlay_candidate_validator_a ndroid.h" | 48 #include "components/display_compositor/compositor_overlay_candidate_validator_a ndroid.h" |
49 #include "components/display_compositor/gl_helper.h" | 49 #include "components/display_compositor/gl_helper.h" |
50 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | |
50 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 51 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
51 #include "content/browser/gpu/compositor_util.h" | 52 #include "content/browser/gpu/compositor_util.h" |
52 #include "content/browser/renderer_host/context_provider_factory_impl_android.h" | |
53 #include "content/browser/renderer_host/render_widget_host_impl.h" | 53 #include "content/browser/renderer_host/render_widget_host_impl.h" |
54 #include "content/common/host_shared_bitmap_manager.h" | 54 #include "content/common/host_shared_bitmap_manager.h" |
55 #include "content/public/browser/android/compositor.h" | 55 #include "content/public/browser/android/compositor.h" |
56 #include "content/public/browser/android/compositor_client.h" | 56 #include "content/public/browser/android/compositor_client.h" |
57 #include "content/public/common/content_switches.h" | 57 #include "content/public/common/content_switches.h" |
58 #include "gpu/command_buffer/client/context_support.h" | 58 #include "gpu/command_buffer/client/context_support.h" |
59 #include "gpu/command_buffer/client/gles2_interface.h" | 59 #include "gpu/command_buffer/client/gles2_interface.h" |
60 #include "gpu/ipc/client/command_buffer_proxy_impl.h" | 60 #include "gpu/ipc/client/command_buffer_proxy_impl.h" |
61 #include "gpu/ipc/client/gpu_channel_host.h" | 61 #include "gpu/ipc/client/gpu_channel_host.h" |
62 #include "gpu/ipc/common/gpu_surface_tracker.h" | 62 #include "gpu/ipc/common/gpu_surface_tracker.h" |
63 #include "gpu/vulkan/vulkan_surface.h" | 63 #include "gpu/vulkan/vulkan_surface.h" |
64 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" | 64 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" |
65 #include "third_party/khronos/GLES2/gl2.h" | 65 #include "third_party/khronos/GLES2/gl2.h" |
66 #include "third_party/khronos/GLES2/gl2ext.h" | 66 #include "third_party/khronos/GLES2/gl2ext.h" |
67 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 67 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
68 #include "ui/android/window_android.h" | 68 #include "ui/android/window_android.h" |
69 #include "ui/display/display.h" | 69 #include "ui/display/display.h" |
70 #include "ui/display/screen.h" | 70 #include "ui/display/screen.h" |
71 #include "ui/gfx/swap_result.h" | 71 #include "ui/gfx/swap_result.h" |
72 | 72 |
73 namespace gpu { | 73 namespace gpu { |
74 struct GpuProcessHostedCALayerTreeParamsMac; | 74 struct GpuProcessHostedCALayerTreeParamsMac; |
75 } | 75 } |
76 | 76 |
77 namespace content { | 77 namespace content { |
78 | 78 |
79 namespace { | 79 namespace { |
80 | 80 |
81 base::LazyInstance<cc::SurfaceManager> g_surface_manager = | |
boliu
2017/02/10 22:23:02
all the global state should be shoved into a singl
Khushal
2017/02/13 21:07:13
Good idea. Done.
| |
82 LAZY_INSTANCE_INITIALIZER; | |
83 | |
84 uint32_t g_next_sink_id = 1u; | |
85 | |
81 const unsigned int kMaxDisplaySwapBuffers = 1U; | 86 const unsigned int kMaxDisplaySwapBuffers = 1U; |
82 | 87 |
88 #if defined(ENABLE_VULKAN) | |
89 | |
90 base::LazyInstance<scoped_refptr<cc::VulkanContextProvider>> | |
91 g_shared_vulkan_context_provider = LAZY_INSTANCE_INITIALIZER; | |
92 | |
93 scoped_refptr<cc::VulkanContextProvider> GetSharedVulkanContextProvider() { | |
94 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
95 switches::kEnableVulkan)) { | |
96 scoped_refptr<cc::VulkanContextProvider>* context_provider = | |
97 g_shared_vulkan_context_provider.Pointer(); | |
98 if (!*context_provider) | |
99 *context_provider = cc::VulkanInProcessContextProvider::Create(); | |
100 return *context_provider; | |
101 } | |
102 return nullptr; | |
103 } | |
104 | |
105 #endif | |
106 | |
83 gpu::SharedMemoryLimits GetCompositorContextSharedMemoryLimits( | 107 gpu::SharedMemoryLimits GetCompositorContextSharedMemoryLimits( |
84 gfx::NativeWindow window) { | 108 gfx::NativeWindow window) { |
85 constexpr size_t kBytesPerPixel = 4; | 109 constexpr size_t kBytesPerPixel = 4; |
86 const gfx::Size size = display::Screen::GetScreen() | 110 const gfx::Size size = display::Screen::GetScreen() |
87 ->GetDisplayNearestWindow(window) | 111 ->GetDisplayNearestWindow(window) |
88 .GetSizeInPixel(); | 112 .GetSizeInPixel(); |
89 const size_t full_screen_texture_size_in_bytes = | 113 const size_t full_screen_texture_size_in_bytes = |
90 size.width() * size.height() * kBytesPerPixel; | 114 size.width() * size.height() * kBytesPerPixel; |
91 | 115 |
92 gpu::SharedMemoryLimits limits; | 116 gpu::SharedMemoryLimits limits; |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 return client ? new CompositorImpl(client, root_window) : NULL; | 337 return client ? new CompositorImpl(client, root_window) : NULL; |
314 } | 338 } |
315 | 339 |
316 // static | 340 // static |
317 void Compositor::Initialize() { | 341 void Compositor::Initialize() { |
318 DCHECK(!CompositorImpl::IsInitialized()); | 342 DCHECK(!CompositorImpl::IsInitialized()); |
319 g_initialized = true; | 343 g_initialized = true; |
320 } | 344 } |
321 | 345 |
322 // static | 346 // static |
347 cc::SurfaceManager* CompositorImpl::GetSurfaceManager() { | |
348 return g_surface_manager.Pointer(); | |
349 } | |
350 | |
351 // static | |
352 cc::FrameSinkId CompositorImpl::AllocateFrameSinkId() { | |
353 return cc::FrameSinkId(0 /* client_id */, g_next_sink_id++); | |
boliu
2017/02/10 22:23:02
copy over the comment about being unique
Khushal
2017/02/13 21:07:13
Done.
| |
354 } | |
355 | |
356 // static | |
323 bool CompositorImpl::IsInitialized() { | 357 bool CompositorImpl::IsInitialized() { |
324 return g_initialized; | 358 return g_initialized; |
325 } | 359 } |
326 | 360 |
327 CompositorImpl::CompositorImpl(CompositorClient* client, | 361 CompositorImpl::CompositorImpl(CompositorClient* client, |
328 gfx::NativeWindow root_window) | 362 gfx::NativeWindow root_window) |
329 : frame_sink_id_( | 363 : frame_sink_id_(AllocateFrameSinkId()), |
330 ui::ContextProviderFactory::GetInstance()->AllocateFrameSinkId()), | |
331 resource_manager_(root_window), | 364 resource_manager_(root_window), |
332 window_(NULL), | 365 window_(NULL), |
333 surface_handle_(gpu::kNullSurfaceHandle), | 366 surface_handle_(gpu::kNullSurfaceHandle), |
334 client_(client), | 367 client_(client), |
335 root_window_(root_window), | 368 root_window_(root_window), |
336 needs_animate_(false), | 369 needs_animate_(false), |
337 pending_swapbuffers_(0U), | 370 pending_swapbuffers_(0U), |
338 num_successive_context_creation_failures_(0), | 371 num_successive_context_creation_failures_(0), |
339 compositor_frame_sink_request_pending_(false), | 372 compositor_frame_sink_request_pending_(false), |
340 weak_factory_(this) { | 373 weak_factory_(this) { |
341 ui::ContextProviderFactory::GetInstance() | 374 GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_); |
342 ->GetSurfaceManager() | |
343 ->RegisterFrameSinkId(frame_sink_id_); | |
344 DCHECK(client); | 375 DCHECK(client); |
345 DCHECK(root_window); | 376 DCHECK(root_window); |
346 DCHECK(root_window->GetLayer() == nullptr); | 377 DCHECK(root_window->GetLayer() == nullptr); |
347 root_window->SetLayer(cc::Layer::Create()); | 378 root_window->SetLayer(cc::Layer::Create()); |
348 readback_layer_tree_ = cc::Layer::Create(); | 379 readback_layer_tree_ = cc::Layer::Create(); |
349 readback_layer_tree_->SetHideLayerAndSubtree(true); | 380 readback_layer_tree_->SetHideLayerAndSubtree(true); |
350 root_window->GetLayer()->AddChild(readback_layer_tree_); | 381 root_window->GetLayer()->AddChild(readback_layer_tree_); |
351 root_window->AttachCompositor(this); | 382 root_window->AttachCompositor(this); |
352 CreateLayerTreeHost(); | 383 CreateLayerTreeHost(); |
353 resource_manager_.Init(host_->GetUIResourceManager()); | 384 resource_manager_.Init(host_->GetUIResourceManager()); |
354 } | 385 } |
355 | 386 |
356 CompositorImpl::~CompositorImpl() { | 387 CompositorImpl::~CompositorImpl() { |
357 root_window_->DetachCompositor(); | 388 root_window_->DetachCompositor(); |
358 root_window_->SetLayer(nullptr); | 389 root_window_->SetLayer(nullptr); |
359 // Clean-up any surface references. | 390 // Clean-up any surface references. |
360 SetSurface(NULL); | 391 SetSurface(NULL); |
361 ui::ContextProviderFactory::GetInstance() | 392 GetSurfaceManager()->InvalidateFrameSinkId(frame_sink_id_); |
362 ->GetSurfaceManager() | |
363 ->InvalidateFrameSinkId(frame_sink_id_); | |
364 } | 393 } |
365 | 394 |
366 ui::UIResourceProvider& CompositorImpl::GetUIResourceProvider() { | 395 ui::UIResourceProvider& CompositorImpl::GetUIResourceProvider() { |
367 return *this; | 396 return *this; |
368 } | 397 } |
369 | 398 |
370 ui::ResourceManager& CompositorImpl::GetResourceManager() { | 399 ui::ResourceManager& CompositorImpl::GetResourceManager() { |
371 return resource_manager_; | 400 return resource_manager_; |
372 } | 401 } |
373 | 402 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
553 if (!host_->IsVisible()) | 582 if (!host_->IsVisible()) |
554 return; | 583 return; |
555 | 584 |
556 #if defined(ENABLE_VULKAN) | 585 #if defined(ENABLE_VULKAN) |
557 CreateVulkanOutputSurface() | 586 CreateVulkanOutputSurface() |
558 if (display_) | 587 if (display_) |
559 return; | 588 return; |
560 #endif | 589 #endif |
561 | 590 |
562 DCHECK(surface_handle_ != gpu::kNullSurfaceHandle); | 591 DCHECK(surface_handle_ != gpu::kNullSurfaceHandle); |
563 ContextProviderFactoryImpl::GetInstance()->RequestGpuChannelHost(base::Bind( | 592 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel(base::Bind( |
boliu
2017/02/10 22:23:02
the gpu timeout got dropped afaict?
Khushal
2017/02/13 21:07:13
Oops, sorry. Added back here.
| |
564 &CompositorImpl::OnGpuChannelEstablished, weak_factory_.GetWeakPtr())); | 593 &CompositorImpl::OnGpuChannelEstablished, weak_factory_.GetWeakPtr())); |
565 } | 594 } |
566 | 595 |
567 #if defined(ENABLE_VULKAN) | 596 #if defined(ENABLE_VULKAN) |
568 void CompositorImpl::CreateVulkanOutputSurface() { | 597 void CompositorImpl::CreateVulkanOutputSurface() { |
569 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 598 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
570 switches::kEnableVulkan)) | 599 switches::kEnableVulkan)) |
571 return; | 600 return; |
572 | 601 |
573 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider = | 602 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider = |
574 ui::ContextProviderFactory::GetInstance() | 603 GetSharedVulkanContextProvider(); |
575 ->GetSharedVulkanContextProvider(); | |
576 if (!vulkan_context_provider) | 604 if (!vulkan_context_provider) |
577 return; | 605 return; |
578 | 606 |
579 auto vulkan_surface = base::MakeUnique<VulkanOutputSurface>( | 607 auto vulkan_surface = base::MakeUnique<VulkanOutputSurface>( |
580 vulkan_context_provider, base::ThreadTaskRunnerHandle::Get()); | 608 vulkan_context_provider, base::ThreadTaskRunnerHandle::Get()); |
581 if (!vulkan_surface->Initialize(window_)) | 609 if (!vulkan_surface->Initialize(window_)) |
582 return; | 610 return; |
583 | 611 |
584 InitializeDisplay(std::move(vulkan_surface), | 612 InitializeDisplay(std::move(vulkan_surface), |
585 std::move(vulkan_context_provider), nullptr); | 613 std::move(vulkan_context_provider), nullptr); |
586 } | 614 } |
587 #endif | 615 #endif |
588 | 616 |
589 void CompositorImpl::OnGpuChannelEstablished( | 617 void CompositorImpl::OnGpuChannelEstablished( |
590 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, | 618 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host) { |
591 ui::ContextProviderFactory::GpuChannelHostResult result) { | |
592 // We might end up queing multiple GpuChannel requests for the same | 619 // We might end up queing multiple GpuChannel requests for the same |
593 // CompositorFrameSink request as the visibility of the compositor changes, so | 620 // CompositorFrameSink request as the visibility of the compositor changes, so |
594 // the CompositorFrameSink request could have been handled already. | 621 // the CompositorFrameSink request could have been handled already. |
595 if (!compositor_frame_sink_request_pending_) | 622 if (!compositor_frame_sink_request_pending_) |
596 return; | 623 return; |
597 | 624 |
598 switch (result) { | 625 if (!gpu_channel_host) { |
599 // Don't retry if we are shutting down. | 626 HandlePendingCompositorFrameSinkRequest(); |
600 case ui::ContextProviderFactory::GpuChannelHostResult:: | 627 return; |
601 FAILURE_FACTORY_SHUTDOWN: | 628 } |
602 break; | |
603 case ui::ContextProviderFactory::GpuChannelHostResult:: | |
604 FAILURE_GPU_PROCESS_INITIALIZATION_FAILED: | |
605 HandlePendingCompositorFrameSinkRequest(); | |
606 break; | |
607 case ui::ContextProviderFactory::GpuChannelHostResult::SUCCESS: | |
608 // We don't need the context anymore if we are invisible. | |
609 if (!host_->IsVisible()) | |
610 return; | |
611 | 629 |
612 DCHECK(window_); | 630 // We don't need the context anymore if we are invisible. |
613 DCHECK_NE(surface_handle_, gpu::kNullSurfaceHandle); | 631 if (!host_->IsVisible()) |
614 scoped_refptr<cc::ContextProvider> context_provider = | 632 return; |
615 ContextProviderFactoryImpl::GetInstance() | |
616 ->CreateDisplayContextProvider( | |
617 surface_handle_, | |
618 GetCompositorContextSharedMemoryLimits(root_window_), | |
619 GetCompositorContextAttributes(has_transparent_background_), | |
620 false /*support_locking*/, false /*automatic_flushes*/, | |
621 std::move(gpu_channel_host)); | |
622 if (!context_provider->BindToCurrentThread()) { | |
623 LOG(ERROR) << "Failed to init ContextProvider for compositor."; | |
624 LOG_IF(FATAL, ++num_successive_context_creation_failures_ >= 2) | |
625 << "Too many context creation failures. Giving up... "; | |
626 HandlePendingCompositorFrameSinkRequest(); | |
627 break; | |
628 } | |
629 | 633 |
630 scoped_refptr<ui::ContextProviderCommandBuffer> | 634 DCHECK(window_); |
631 context_provider_command_buffer = | 635 DCHECK_NE(surface_handle_, gpu::kNullSurfaceHandle); |
632 static_cast<ui::ContextProviderCommandBuffer*>( | 636 bool support_locking = false; |
boliu
2017/02/10 22:23:02
nit: constexpr
Khushal
2017/02/13 21:07:13
Done.
| |
633 context_provider.get()); | 637 bool automatic_flushes = false; |
634 auto display_output_surface = base::MakeUnique<AndroidOutputSurface>( | 638 ui::ContextProviderCommandBuffer* shared_context = nullptr; |
635 std::move(context_provider_command_buffer)); | 639 scoped_refptr<cc::ContextProvider> context_provider = |
636 InitializeDisplay(std::move(display_output_surface), nullptr, | 640 new ui::ContextProviderCommandBuffer( |
637 std::move(context_provider)); | 641 std::move(gpu_channel_host), gpu::GPU_STREAM_DEFAULT, |
638 break; | 642 gpu::GpuStreamPriority::NORMAL, surface_handle_, |
643 GURL(std::string("chrome://gpu/CompositorImpl::") + | |
644 std::string("CompositorContextProvider")), | |
645 automatic_flushes, support_locking, | |
646 GetCompositorContextSharedMemoryLimits(root_window_), | |
647 GetCompositorContextAttributes(has_transparent_background_), | |
648 shared_context, | |
649 ui::command_buffer_metrics::DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT); | |
650 if (!context_provider->BindToCurrentThread()) { | |
651 LOG(ERROR) << "Failed to init ContextProvider for compositor."; | |
652 LOG_IF(FATAL, ++num_successive_context_creation_failures_ >= 2) | |
653 << "Too many context creation failures. Giving up... "; | |
654 HandlePendingCompositorFrameSinkRequest(); | |
639 } | 655 } |
656 | |
657 scoped_refptr<ui::ContextProviderCommandBuffer> | |
658 context_provider_command_buffer = | |
659 static_cast<ui::ContextProviderCommandBuffer*>( | |
boliu
2017/02/10 22:23:02
just declare context_provider as the subtype, so d
Khushal
2017/02/13 21:07:13
Done.
| |
660 context_provider.get()); | |
661 auto display_output_surface = base::MakeUnique<AndroidOutputSurface>( | |
662 std::move(context_provider_command_buffer)); | |
663 InitializeDisplay(std::move(display_output_surface), nullptr, | |
664 std::move(context_provider)); | |
640 } | 665 } |
641 | 666 |
642 void CompositorImpl::InitializeDisplay( | 667 void CompositorImpl::InitializeDisplay( |
643 std::unique_ptr<cc::OutputSurface> display_output_surface, | 668 std::unique_ptr<cc::OutputSurface> display_output_surface, |
644 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, | 669 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, |
645 scoped_refptr<cc::ContextProvider> context_provider) { | 670 scoped_refptr<cc::ContextProvider> context_provider) { |
646 DCHECK(compositor_frame_sink_request_pending_); | 671 DCHECK(compositor_frame_sink_request_pending_); |
647 | 672 |
648 pending_swapbuffers_ = 0; | 673 pending_swapbuffers_ = 0; |
649 num_successive_context_creation_failures_ = 0; | 674 num_successive_context_creation_failures_ = 0; |
650 | 675 |
651 if (context_provider) { | 676 if (context_provider) { |
652 gpu_capabilities_ = context_provider->ContextCapabilities(); | 677 gpu_capabilities_ = context_provider->ContextCapabilities(); |
653 } else { | 678 } else { |
654 // TODO(danakj): Populate gpu_capabilities_ for VulkanContextProvider. | 679 // TODO(danakj): Populate gpu_capabilities_ for VulkanContextProvider. |
655 } | 680 } |
656 | 681 |
657 cc::SurfaceManager* manager = | 682 cc::SurfaceManager* manager = GetSurfaceManager(); |
658 ui::ContextProviderFactory::GetInstance()->GetSurfaceManager(); | |
659 auto* task_runner = base::ThreadTaskRunnerHandle::Get().get(); | 683 auto* task_runner = base::ThreadTaskRunnerHandle::Get().get(); |
660 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( | 684 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( |
661 task_runner, display_output_surface->capabilities().max_frames_pending)); | 685 task_runner, display_output_surface->capabilities().max_frames_pending)); |
662 | 686 |
663 display_.reset(new cc::Display( | 687 display_.reset(new cc::Display( |
664 HostSharedBitmapManager::current(), | 688 HostSharedBitmapManager::current(), |
665 BrowserGpuMemoryBufferManager::current(), | 689 BrowserGpuMemoryBufferManager::current(), |
666 host_->GetSettings().renderer_settings, frame_sink_id_, | 690 host_->GetSettings().renderer_settings, frame_sink_id_, |
667 root_window_->GetBeginFrameSource(), std::move(display_output_surface), | 691 root_window_->GetBeginFrameSource(), std::move(display_output_surface), |
668 std::move(scheduler), | 692 std::move(scheduler), |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
737 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); | 761 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); |
738 host_->SetNeedsAnimate(); | 762 host_->SetNeedsAnimate(); |
739 } | 763 } |
740 | 764 |
741 cc::FrameSinkId CompositorImpl::GetFrameSinkId() { | 765 cc::FrameSinkId CompositorImpl::GetFrameSinkId() { |
742 return frame_sink_id_; | 766 return frame_sink_id_; |
743 } | 767 } |
744 | 768 |
745 void CompositorImpl::AddChildFrameSink(const cc::FrameSinkId& frame_sink_id) { | 769 void CompositorImpl::AddChildFrameSink(const cc::FrameSinkId& frame_sink_id) { |
746 if (has_compositor_frame_sink_) { | 770 if (has_compositor_frame_sink_) { |
747 ui::ContextProviderFactory::GetInstance() | 771 GetSurfaceManager()->RegisterFrameSinkHierarchy(frame_sink_id_, |
748 ->GetSurfaceManager() | 772 frame_sink_id); |
749 ->RegisterFrameSinkHierarchy(frame_sink_id_, frame_sink_id); | |
750 } else { | 773 } else { |
751 pending_child_frame_sink_ids_.insert(frame_sink_id); | 774 pending_child_frame_sink_ids_.insert(frame_sink_id); |
752 } | 775 } |
753 } | 776 } |
754 | 777 |
755 void CompositorImpl::RemoveChildFrameSink( | 778 void CompositorImpl::RemoveChildFrameSink( |
756 const cc::FrameSinkId& frame_sink_id) { | 779 const cc::FrameSinkId& frame_sink_id) { |
757 auto it = pending_child_frame_sink_ids_.find(frame_sink_id); | 780 auto it = pending_child_frame_sink_ids_.find(frame_sink_id); |
758 if (it != pending_child_frame_sink_ids_.end()) { | 781 if (it != pending_child_frame_sink_ids_.end()) { |
759 pending_child_frame_sink_ids_.erase(it); | 782 pending_child_frame_sink_ids_.erase(it); |
760 return; | 783 return; |
761 } | 784 } |
762 ui::ContextProviderFactory::GetInstance() | 785 GetSurfaceManager()->UnregisterFrameSinkHierarchy(frame_sink_id_, |
763 ->GetSurfaceManager() | 786 frame_sink_id); |
764 ->UnregisterFrameSinkHierarchy(frame_sink_id_, frame_sink_id); | |
765 } | 787 } |
766 | 788 |
767 bool CompositorImpl::HavePendingReadbacks() { | 789 bool CompositorImpl::HavePendingReadbacks() { |
768 return !readback_layer_tree_->children().empty(); | 790 return !readback_layer_tree_->children().empty(); |
769 } | 791 } |
770 | 792 |
771 } // namespace content | 793 } // namespace content |
OLD | NEW |