| 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 28 matching lines...) Expand all Loading... |
| 39 #include "cc/output/texture_mailbox_deleter.h" | 39 #include "cc/output/texture_mailbox_deleter.h" |
| 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/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/display_compositor/compositor_overlay_candidate_validator_a
ndroid.h" | 49 #include "components/viz/display_compositor/compositor_overlay_candidate_validat
or_android.h" |
| 50 #include "components/display_compositor/gl_helper.h" | 50 #include "components/viz/display_compositor/gl_helper.h" |
| 51 #include "components/display_compositor/host_shared_bitmap_manager.h" | 51 #include "components/viz/display_compositor/host_shared_bitmap_manager.h" |
| 52 #include "content/browser/compositor/frame_sink_manager_host.h" | 52 #include "content/browser/compositor/frame_sink_manager_host.h" |
| 53 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 53 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 54 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 54 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
| 55 #include "content/browser/gpu/compositor_util.h" | 55 #include "content/browser/gpu/compositor_util.h" |
| 56 #include "content/browser/renderer_host/render_widget_host_impl.h" | 56 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 57 #include "content/public/browser/android/compositor.h" | 57 #include "content/public/browser/android/compositor.h" |
| 58 #include "content/public/browser/android/compositor_client.h" | 58 #include "content/public/browser/android/compositor_client.h" |
| 59 #include "content/public/common/content_switches.h" | 59 #include "content/public/common/content_switches.h" |
| 60 #include "gpu/command_buffer/client/context_support.h" | 60 #include "gpu/command_buffer/client/context_support.h" |
| 61 #include "gpu/command_buffer/client/gles2_interface.h" | 61 #include "gpu/command_buffer/client/gles2_interface.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 } | 217 } |
| 218 | 218 |
| 219 class AndroidOutputSurface : public cc::OutputSurface { | 219 class AndroidOutputSurface : public cc::OutputSurface { |
| 220 public: | 220 public: |
| 221 AndroidOutputSurface( | 221 AndroidOutputSurface( |
| 222 scoped_refptr<ui::ContextProviderCommandBuffer> context_provider, | 222 scoped_refptr<ui::ContextProviderCommandBuffer> context_provider, |
| 223 base::Closure swap_buffers_callback) | 223 base::Closure swap_buffers_callback) |
| 224 : cc::OutputSurface(std::move(context_provider)), | 224 : cc::OutputSurface(std::move(context_provider)), |
| 225 swap_buffers_callback_(std::move(swap_buffers_callback)), | 225 swap_buffers_callback_(std::move(swap_buffers_callback)), |
| 226 overlay_candidate_validator_( | 226 overlay_candidate_validator_( |
| 227 new display_compositor:: | 227 new viz::CompositorOverlayCandidateValidatorAndroid()), |
| 228 CompositorOverlayCandidateValidatorAndroid()), | |
| 229 weak_ptr_factory_(this) { | 228 weak_ptr_factory_(this) { |
| 230 capabilities_.max_frames_pending = kMaxDisplaySwapBuffers; | 229 capabilities_.max_frames_pending = kMaxDisplaySwapBuffers; |
| 231 } | 230 } |
| 232 | 231 |
| 233 ~AndroidOutputSurface() override = default; | 232 ~AndroidOutputSurface() override = default; |
| 234 | 233 |
| 235 void SwapBuffers(cc::OutputSurfaceFrame frame) override { | 234 void SwapBuffers(cc::OutputSurfaceFrame frame) override { |
| 236 GetCommandBufferProxy()->AddLatencyInfo(frame.latency_info); | 235 GetCommandBufferProxy()->AddLatencyInfo(frame.latency_info); |
| 237 if (frame.sub_buffer_rect) { | 236 if (frame.sub_buffer_rect) { |
| 238 DCHECK(frame.sub_buffer_rect->IsEmpty()); | 237 DCHECK(frame.sub_buffer_rect->IsEmpty()); |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 } else { | 762 } else { |
| 764 // TODO(danakj): Populate gpu_capabilities_ for VulkanContextProvider. | 763 // TODO(danakj): Populate gpu_capabilities_ for VulkanContextProvider. |
| 765 } | 764 } |
| 766 | 765 |
| 767 cc::SurfaceManager* manager = GetSurfaceManager(); | 766 cc::SurfaceManager* manager = GetSurfaceManager(); |
| 768 auto* task_runner = base::ThreadTaskRunnerHandle::Get().get(); | 767 auto* task_runner = base::ThreadTaskRunnerHandle::Get().get(); |
| 769 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( | 768 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( |
| 770 task_runner, display_output_surface->capabilities().max_frames_pending)); | 769 task_runner, display_output_surface->capabilities().max_frames_pending)); |
| 771 | 770 |
| 772 display_.reset(new cc::Display( | 771 display_.reset(new cc::Display( |
| 773 display_compositor::HostSharedBitmapManager::current(), | 772 viz::HostSharedBitmapManager::current(), |
| 774 BrowserGpuMemoryBufferManager::current(), | 773 BrowserGpuMemoryBufferManager::current(), |
| 775 host_->GetSettings().renderer_settings, frame_sink_id_, | 774 host_->GetSettings().renderer_settings, frame_sink_id_, |
| 776 root_window_->GetBeginFrameSource(), std::move(display_output_surface), | 775 root_window_->GetBeginFrameSource(), std::move(display_output_surface), |
| 777 std::move(scheduler), | 776 std::move(scheduler), |
| 778 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner))); | 777 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner))); |
| 779 | 778 |
| 780 auto compositor_frame_sink = | 779 auto compositor_frame_sink = |
| 781 vulkan_context_provider | 780 vulkan_context_provider |
| 782 ? base::MakeUnique<cc::DirectCompositorFrameSink>( | 781 ? base::MakeUnique<cc::DirectCompositorFrameSink>( |
| 783 frame_sink_id_, manager, display_.get(), | 782 frame_sink_id_, manager, display_.get(), |
| 784 vulkan_context_provider) | 783 vulkan_context_provider) |
| 785 : base::MakeUnique<cc::DirectCompositorFrameSink>( | 784 : base::MakeUnique<cc::DirectCompositorFrameSink>( |
| 786 frame_sink_id_, manager, display_.get(), context_provider, | 785 frame_sink_id_, manager, display_.get(), context_provider, |
| 787 nullptr, BrowserGpuMemoryBufferManager::current(), | 786 nullptr, BrowserGpuMemoryBufferManager::current(), |
| 788 display_compositor::HostSharedBitmapManager::current()); | 787 viz::HostSharedBitmapManager::current()); |
| 789 | 788 |
| 790 display_->SetVisible(true); | 789 display_->SetVisible(true); |
| 791 display_->Resize(size_); | 790 display_->Resize(size_); |
| 792 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); | 791 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); |
| 793 } | 792 } |
| 794 | 793 |
| 795 void CompositorImpl::DidSwapBuffers() { | 794 void CompositorImpl::DidSwapBuffers() { |
| 796 client_->DidSwapBuffers(); | 795 client_->DidSwapBuffers(); |
| 797 } | 796 } |
| 798 | 797 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 } | 872 } |
| 874 GetSurfaceManager()->UnregisterFrameSinkHierarchy(frame_sink_id_, | 873 GetSurfaceManager()->UnregisterFrameSinkHierarchy(frame_sink_id_, |
| 875 frame_sink_id); | 874 frame_sink_id); |
| 876 } | 875 } |
| 877 | 876 |
| 878 bool CompositorImpl::HavePendingReadbacks() { | 877 bool CompositorImpl::HavePendingReadbacks() { |
| 879 return !readback_layer_tree_->children().empty(); | 878 return !readback_layer_tree_->children().empty(); |
| 880 } | 879 } |
| 881 | 880 |
| 882 } // namespace content | 881 } // namespace content |
| OLD | NEW |