| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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/surfaces/frame_sink_id_allocator.h" | 46 #include "cc/surfaces/frame_sink_id_allocator.h" |
| 47 #include "cc/trees/layer_tree_host.h" | 47 #include "cc/trees/layer_tree_host.h" |
| 48 #include "cc/trees/layer_tree_settings.h" | 48 #include "cc/trees/layer_tree_settings.h" |
| 49 #include "components/viz/display_compositor/compositor_overlay_candidate_validat
or_android.h" | 49 #include "components/viz/display_compositor/compositor_overlay_candidate_validat
or_android.h" |
| 50 #include "components/viz/display_compositor/gl_helper.h" | 50 #include "components/viz/display_compositor/gl_helper.h" |
| 51 #include "components/viz/display_compositor/host_shared_bitmap_manager.h" | 51 #include "components/viz/display_compositor/host_shared_bitmap_manager.h" |
| 52 #include "components/viz/host/frame_sink_manager_host.h" | 52 #include "components/viz/host/frame_sink_manager_host.h" |
| 53 #include "content/browser/browser_main_loop.h" |
| 53 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 54 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 54 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 55 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
| 55 #include "content/browser/gpu/compositor_util.h" | 56 #include "content/browser/gpu/compositor_util.h" |
| 56 #include "content/browser/renderer_host/render_widget_host_impl.h" | 57 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 57 #include "content/common/gpu_stream_constants.h" | 58 #include "content/common/gpu_stream_constants.h" |
| 58 #include "content/public/browser/android/compositor.h" | 59 #include "content/public/browser/android/compositor.h" |
| 59 #include "content/public/browser/android/compositor_client.h" | 60 #include "content/public/browser/android/compositor_client.h" |
| 60 #include "content/public/common/content_switches.h" | 61 #include "content/public/common/content_switches.h" |
| 61 #include "gpu/command_buffer/client/context_support.h" | 62 #include "gpu/command_buffer/client/context_support.h" |
| 62 #include "gpu/command_buffer/client/gles2_interface.h" | 63 #include "gpu/command_buffer/client/gles2_interface.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 90 public: | 91 public: |
| 91 SingleThreadTaskGraphRunner() { | 92 SingleThreadTaskGraphRunner() { |
| 92 Start("CompositorTileWorker1", base::SimpleThread::Options()); | 93 Start("CompositorTileWorker1", base::SimpleThread::Options()); |
| 93 } | 94 } |
| 94 | 95 |
| 95 ~SingleThreadTaskGraphRunner() override { Shutdown(); } | 96 ~SingleThreadTaskGraphRunner() override { Shutdown(); } |
| 96 }; | 97 }; |
| 97 | 98 |
| 98 struct CompositorDependencies { | 99 struct CompositorDependencies { |
| 99 CompositorDependencies() : frame_sink_id_allocator(kDefaultClientId) { | 100 CompositorDependencies() : frame_sink_id_allocator(kDefaultClientId) { |
| 100 frame_sink_manager_host.ConnectToFrameSinkManager(); | |
| 101 } | 101 } |
| 102 | 102 |
| 103 SingleThreadTaskGraphRunner task_graph_runner; | 103 SingleThreadTaskGraphRunner task_graph_runner; |
| 104 viz::FrameSinkManagerHost frame_sink_manager_host; | |
| 105 cc::FrameSinkIdAllocator frame_sink_id_allocator; | 104 cc::FrameSinkIdAllocator frame_sink_id_allocator; |
| 106 | 105 |
| 107 #if BUILDFLAG(ENABLE_VULKAN) | 106 #if BUILDFLAG(ENABLE_VULKAN) |
| 108 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider; | 107 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider; |
| 109 #endif | 108 #endif |
| 110 }; | 109 }; |
| 111 | 110 |
| 112 base::LazyInstance<CompositorDependencies>::DestructorAtExit | 111 base::LazyInstance<CompositorDependencies>::DestructorAtExit |
| 113 g_compositor_dependencies = LAZY_INSTANCE_INITIALIZER; | 112 g_compositor_dependencies = LAZY_INSTANCE_INITIALIZER; |
| 114 | 113 |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 gpu::gles2::ContextCreationAttribHelper attributes, | 394 gpu::gles2::ContextCreationAttribHelper attributes, |
| 396 gpu::SharedMemoryLimits shared_memory_limits, | 395 gpu::SharedMemoryLimits shared_memory_limits, |
| 397 ContextProviderCallback callback) { | 396 ContextProviderCallback callback) { |
| 398 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( | 397 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( |
| 399 base::Bind(&CreateContextProviderAfterGpuChannelEstablished, handle, | 398 base::Bind(&CreateContextProviderAfterGpuChannelEstablished, handle, |
| 400 attributes, shared_memory_limits, callback)); | 399 attributes, shared_memory_limits, callback)); |
| 401 } | 400 } |
| 402 | 401 |
| 403 // static | 402 // static |
| 404 cc::SurfaceManager* CompositorImpl::GetSurfaceManager() { | 403 cc::SurfaceManager* CompositorImpl::GetSurfaceManager() { |
| 405 return g_compositor_dependencies.Get() | 404 return BrowserMainLoop::GetInstance() |
| 406 .frame_sink_manager_host.surface_manager(); | 405 ->frame_sink_manager_host() |
| 406 ->surface_manager(); |
| 407 } | 407 } |
| 408 | 408 |
| 409 // static | 409 // static |
| 410 viz::FrameSinkManagerHost* CompositorImpl::GetFrameSinkManagerHost() { | |
| 411 return &g_compositor_dependencies.Get().frame_sink_manager_host; | |
| 412 } | |
| 413 | |
| 414 // static | |
| 415 cc::FrameSinkId CompositorImpl::AllocateFrameSinkId() { | 410 cc::FrameSinkId CompositorImpl::AllocateFrameSinkId() { |
| 416 return g_compositor_dependencies.Get() | 411 return g_compositor_dependencies.Get() |
| 417 .frame_sink_id_allocator.NextFrameSinkId(); | 412 .frame_sink_id_allocator.NextFrameSinkId(); |
| 418 } | 413 } |
| 419 | 414 |
| 420 // static | 415 // static |
| 421 bool CompositorImpl::IsInitialized() { | 416 bool CompositorImpl::IsInitialized() { |
| 422 return g_initialized; | 417 return g_initialized; |
| 423 } | 418 } |
| 424 | 419 |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 } | 876 } |
| 882 GetSurfaceManager()->UnregisterFrameSinkHierarchy(frame_sink_id_, | 877 GetSurfaceManager()->UnregisterFrameSinkHierarchy(frame_sink_id_, |
| 883 frame_sink_id); | 878 frame_sink_id); |
| 884 } | 879 } |
| 885 | 880 |
| 886 bool CompositorImpl::HavePendingReadbacks() { | 881 bool CompositorImpl::HavePendingReadbacks() { |
| 887 return !readback_layer_tree_->children().empty(); | 882 return !readback_layer_tree_->children().empty(); |
| 888 } | 883 } |
| 889 | 884 |
| 890 } // namespace content | 885 } // namespace content |
| OLD | NEW |