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/common/gpu_stream_constants.h" | 57 #include "content/common/gpu_stream_constants.h" |
58 #include "content/public/browser/android/compositor.h" | 58 #include "content/public/browser/android/compositor.h" |
59 #include "content/public/browser/android/compositor_client.h" | 59 #include "content/public/browser/android/compositor_client.h" |
60 #include "content/public/common/content_switches.h" | 60 #include "content/public/common/content_switches.h" |
61 #include "gpu/command_buffer/client/context_support.h" | 61 #include "gpu/command_buffer/client/context_support.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 } | 221 } |
222 | 222 |
223 class AndroidOutputSurface : public cc::OutputSurface { | 223 class AndroidOutputSurface : public cc::OutputSurface { |
224 public: | 224 public: |
225 AndroidOutputSurface( | 225 AndroidOutputSurface( |
226 scoped_refptr<ui::ContextProviderCommandBuffer> context_provider, | 226 scoped_refptr<ui::ContextProviderCommandBuffer> context_provider, |
227 base::Closure swap_buffers_callback) | 227 base::Closure swap_buffers_callback) |
228 : cc::OutputSurface(std::move(context_provider)), | 228 : cc::OutputSurface(std::move(context_provider)), |
229 swap_buffers_callback_(std::move(swap_buffers_callback)), | 229 swap_buffers_callback_(std::move(swap_buffers_callback)), |
230 overlay_candidate_validator_( | 230 overlay_candidate_validator_( |
231 new display_compositor:: | 231 new viz::CompositorOverlayCandidateValidatorAndroid()), |
232 CompositorOverlayCandidateValidatorAndroid()), | |
233 weak_ptr_factory_(this) { | 232 weak_ptr_factory_(this) { |
234 capabilities_.max_frames_pending = kMaxDisplaySwapBuffers; | 233 capabilities_.max_frames_pending = kMaxDisplaySwapBuffers; |
235 } | 234 } |
236 | 235 |
237 ~AndroidOutputSurface() override = default; | 236 ~AndroidOutputSurface() override = default; |
238 | 237 |
239 void SwapBuffers(cc::OutputSurfaceFrame frame) override { | 238 void SwapBuffers(cc::OutputSurfaceFrame frame) override { |
240 GetCommandBufferProxy()->AddLatencyInfo(frame.latency_info); | 239 GetCommandBufferProxy()->AddLatencyInfo(frame.latency_info); |
241 if (frame.sub_buffer_rect) { | 240 if (frame.sub_buffer_rect) { |
242 DCHECK(frame.sub_buffer_rect->IsEmpty()); | 241 DCHECK(frame.sub_buffer_rect->IsEmpty()); |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 } else { | 771 } else { |
773 // TODO(danakj): Populate gpu_capabilities_ for VulkanContextProvider. | 772 // TODO(danakj): Populate gpu_capabilities_ for VulkanContextProvider. |
774 } | 773 } |
775 | 774 |
776 cc::SurfaceManager* manager = GetSurfaceManager(); | 775 cc::SurfaceManager* manager = GetSurfaceManager(); |
777 auto* task_runner = base::ThreadTaskRunnerHandle::Get().get(); | 776 auto* task_runner = base::ThreadTaskRunnerHandle::Get().get(); |
778 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( | 777 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( |
779 task_runner, display_output_surface->capabilities().max_frames_pending)); | 778 task_runner, display_output_surface->capabilities().max_frames_pending)); |
780 | 779 |
781 display_.reset(new cc::Display( | 780 display_.reset(new cc::Display( |
782 display_compositor::HostSharedBitmapManager::current(), | 781 viz::HostSharedBitmapManager::current(), |
783 BrowserGpuMemoryBufferManager::current(), | 782 BrowserGpuMemoryBufferManager::current(), |
784 host_->GetSettings().renderer_settings, frame_sink_id_, | 783 host_->GetSettings().renderer_settings, frame_sink_id_, |
785 root_window_->GetBeginFrameSource(), std::move(display_output_surface), | 784 root_window_->GetBeginFrameSource(), std::move(display_output_surface), |
786 std::move(scheduler), | 785 std::move(scheduler), |
787 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner))); | 786 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner))); |
788 | 787 |
789 auto compositor_frame_sink = | 788 auto compositor_frame_sink = |
790 vulkan_context_provider | 789 vulkan_context_provider |
791 ? base::MakeUnique<cc::DirectCompositorFrameSink>( | 790 ? base::MakeUnique<cc::DirectCompositorFrameSink>( |
792 frame_sink_id_, manager, display_.get(), | 791 frame_sink_id_, manager, display_.get(), |
793 vulkan_context_provider) | 792 vulkan_context_provider) |
794 : base::MakeUnique<cc::DirectCompositorFrameSink>( | 793 : base::MakeUnique<cc::DirectCompositorFrameSink>( |
795 frame_sink_id_, manager, display_.get(), context_provider, | 794 frame_sink_id_, manager, display_.get(), context_provider, |
796 nullptr, BrowserGpuMemoryBufferManager::current(), | 795 nullptr, BrowserGpuMemoryBufferManager::current(), |
797 display_compositor::HostSharedBitmapManager::current()); | 796 viz::HostSharedBitmapManager::current()); |
798 | 797 |
799 display_->SetVisible(true); | 798 display_->SetVisible(true); |
800 display_->Resize(size_); | 799 display_->Resize(size_); |
801 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); | 800 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); |
802 } | 801 } |
803 | 802 |
804 void CompositorImpl::DidSwapBuffers() { | 803 void CompositorImpl::DidSwapBuffers() { |
805 client_->DidSwapBuffers(); | 804 client_->DidSwapBuffers(); |
806 } | 805 } |
807 | 806 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 } | 881 } |
883 GetSurfaceManager()->UnregisterFrameSinkHierarchy(frame_sink_id_, | 882 GetSurfaceManager()->UnregisterFrameSinkHierarchy(frame_sink_id_, |
884 frame_sink_id); | 883 frame_sink_id); |
885 } | 884 } |
886 | 885 |
887 bool CompositorImpl::HavePendingReadbacks() { | 886 bool CompositorImpl::HavePendingReadbacks() { |
888 return !readback_layer_tree_->children().empty(); | 887 return !readback_layer_tree_->children().empty(); |
889 } | 888 } |
890 | 889 |
891 } // namespace content | 890 } // namespace content |
OLD | NEW |