| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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/common/gl_helper.h" | 49 #include "components/viz/common/gl_helper.h" |
| 50 #include "components/viz/host/host_frame_sink_manager.h" | 50 #include "components/viz/host/host_frame_sink_manager.h" |
| 51 #include "components/viz/service/display_embedder/compositor_overlay_candidate_v
alidator_android.h" | 51 #include "components/viz/service/display_embedder/compositor_overlay_candidate_v
alidator_android.h" |
| 52 #include "components/viz/service/display_embedder/server_shared_bitmap_manager.h
" | 52 #include "components/viz/service/display_embedder/server_shared_bitmap_manager.h
" |
| 53 #include "components/viz/service/frame_sinks/frame_sink_manager_impl.h" | 53 #include "components/viz/service/frame_sinks/frame_sink_manager_impl.h" |
| 54 #include "content/browser/browser_main_loop.h" |
| 54 #include "content/browser/compositor/surface_utils.h" | 55 #include "content/browser/compositor/surface_utils.h" |
| 55 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | |
| 56 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 56 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
| 57 #include "content/browser/gpu/compositor_util.h" | 57 #include "content/browser/gpu/compositor_util.h" |
| 58 #include "content/browser/renderer_host/render_widget_host_impl.h" | 58 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 59 #include "content/common/gpu_stream_constants.h" | 59 #include "content/common/gpu_stream_constants.h" |
| 60 #include "content/public/browser/android/compositor.h" | 60 #include "content/public/browser/android/compositor.h" |
| 61 #include "content/public/browser/android/compositor_client.h" | 61 #include "content/public/browser/android/compositor_client.h" |
| 62 #include "content/public/browser/browser_thread.h" | 62 #include "content/public/browser/browser_thread.h" |
| 63 #include "content/public/common/content_switches.h" | 63 #include "content/public/common/content_switches.h" |
| 64 #include "gpu/command_buffer/client/context_support.h" | 64 #include "gpu/command_buffer/client/context_support.h" |
| 65 #include "gpu/command_buffer/client/gles2_interface.h" | 65 #include "gpu/command_buffer/client/gles2_interface.h" |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 g_initialized = true; | 404 g_initialized = true; |
| 405 } | 405 } |
| 406 | 406 |
| 407 // static | 407 // static |
| 408 void Compositor::CreateContextProvider( | 408 void Compositor::CreateContextProvider( |
| 409 gpu::SurfaceHandle handle, | 409 gpu::SurfaceHandle handle, |
| 410 gpu::gles2::ContextCreationAttribHelper attributes, | 410 gpu::gles2::ContextCreationAttribHelper attributes, |
| 411 gpu::SharedMemoryLimits shared_memory_limits, | 411 gpu::SharedMemoryLimits shared_memory_limits, |
| 412 ContextProviderCallback callback) { | 412 ContextProviderCallback callback) { |
| 413 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 413 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 414 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( | 414 BrowserMainLoop::GetInstance() |
| 415 base::Bind(&CreateContextProviderAfterGpuChannelEstablished, handle, | 415 ->gpu_channel_establish_factory() |
| 416 attributes, shared_memory_limits, callback)); | 416 ->EstablishGpuChannel( |
| 417 base::Bind(&CreateContextProviderAfterGpuChannelEstablished, handle, |
| 418 attributes, shared_memory_limits, callback)); |
| 417 } | 419 } |
| 418 | 420 |
| 419 // static | 421 // static |
| 420 cc::SurfaceManager* CompositorImpl::GetSurfaceManager() { | 422 cc::SurfaceManager* CompositorImpl::GetSurfaceManager() { |
| 421 return g_compositor_dependencies.Get().frame_sink_manager->surface_manager(); | 423 return g_compositor_dependencies.Get().frame_sink_manager->surface_manager(); |
| 422 } | 424 } |
| 423 | 425 |
| 424 // static | 426 // static |
| 425 viz::HostFrameSinkManager* CompositorImpl::GetHostFrameSinkManager() { | 427 viz::HostFrameSinkManager* CompositorImpl::GetHostFrameSinkManager() { |
| 426 return &g_compositor_dependencies.Get().host_frame_sink_manager; | 428 return &g_compositor_dependencies.Get().host_frame_sink_manager; |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 const int64_t kGpuChannelTimeoutInSeconds = 20; | 682 const int64_t kGpuChannelTimeoutInSeconds = 20; |
| 681 #endif | 683 #endif |
| 682 | 684 |
| 683 // Start the timer first, if the result comes synchronously, we want it to | 685 // Start the timer first, if the result comes synchronously, we want it to |
| 684 // stop in the callback. | 686 // stop in the callback. |
| 685 establish_gpu_channel_timeout_.Start( | 687 establish_gpu_channel_timeout_.Start( |
| 686 FROM_HERE, base::TimeDelta::FromSeconds(kGpuChannelTimeoutInSeconds), | 688 FROM_HERE, base::TimeDelta::FromSeconds(kGpuChannelTimeoutInSeconds), |
| 687 this, &CompositorImpl::OnGpuChannelTimeout); | 689 this, &CompositorImpl::OnGpuChannelTimeout); |
| 688 | 690 |
| 689 DCHECK(surface_handle_ != gpu::kNullSurfaceHandle); | 691 DCHECK(surface_handle_ != gpu::kNullSurfaceHandle); |
| 690 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel(base::Bind( | 692 BrowserMainLoop::GetInstance() |
| 691 &CompositorImpl::OnGpuChannelEstablished, weak_factory_.GetWeakPtr())); | 693 ->gpu_channel_establish_factory() |
| 694 ->EstablishGpuChannel(base::Bind(&CompositorImpl::OnGpuChannelEstablished, |
| 695 weak_factory_.GetWeakPtr())); |
| 692 } | 696 } |
| 693 | 697 |
| 694 void CompositorImpl::OnGpuChannelTimeout() { | 698 void CompositorImpl::OnGpuChannelTimeout() { |
| 695 LOG(FATAL) << "Timed out waiting for GPU channel."; | 699 LOG(FATAL) << "Timed out waiting for GPU channel."; |
| 696 } | 700 } |
| 697 | 701 |
| 698 #if BUILDFLAG(ENABLE_VULKAN) | 702 #if BUILDFLAG(ENABLE_VULKAN) |
| 699 void CompositorImpl::CreateVulkanOutputSurface() { | 703 void CompositorImpl::CreateVulkanOutputSurface() { |
| 700 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 704 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 701 switches::kEnableVulkan)) | 705 switches::kEnableVulkan)) |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 } | 912 } |
| 909 GetSurfaceManager()->UnregisterFrameSinkHierarchy(frame_sink_id_, | 913 GetSurfaceManager()->UnregisterFrameSinkHierarchy(frame_sink_id_, |
| 910 frame_sink_id); | 914 frame_sink_id); |
| 911 } | 915 } |
| 912 | 916 |
| 913 bool CompositorImpl::HavePendingReadbacks() { | 917 bool CompositorImpl::HavePendingReadbacks() { |
| 914 return !readback_layer_tree_->children().empty(); | 918 return !readback_layer_tree_->children().empty(); |
| 915 } | 919 } |
| 916 | 920 |
| 917 } // namespace content | 921 } // namespace content |
| OLD | NEW |