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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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/display_compositor/compositor_overlay_candidate_validator_a
ndroid.h" |
50 #include "components/display_compositor/gl_helper.h" | 50 #include "components/display_compositor/gl_helper.h" |
51 #include "components/display_compositor/host_shared_bitmap_manager.h" | 51 #include "components/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/public/browser/android/compositor.h" | 58 #include "content/public/browser/android/compositor.h" |
58 #include "content/public/browser/android/compositor_client.h" | 59 #include "content/public/browser/android/compositor_client.h" |
59 #include "content/public/common/content_switches.h" | 60 #include "content/public/common/content_switches.h" |
60 #include "gpu/command_buffer/client/context_support.h" | 61 #include "gpu/command_buffer/client/context_support.h" |
61 #include "gpu/command_buffer/client/gles2_interface.h" | 62 #include "gpu/command_buffer/client/gles2_interface.h" |
62 #include "gpu/ipc/client/command_buffer_proxy_impl.h" | 63 #include "gpu/ipc/client/command_buffer_proxy_impl.h" |
63 #include "gpu/ipc/client/gpu_channel_host.h" | 64 #include "gpu/ipc/client/gpu_channel_host.h" |
64 #include "gpu/ipc/common/gpu_surface_tracker.h" | 65 #include "gpu/ipc/common/gpu_surface_tracker.h" |
65 #include "gpu/vulkan/features.h" | 66 #include "gpu/vulkan/features.h" |
66 #include "gpu/vulkan/vulkan_surface.h" | 67 #include "gpu/vulkan/vulkan_surface.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 197 |
197 void CreateContextProviderAfterGpuChannelEstablished( | 198 void CreateContextProviderAfterGpuChannelEstablished( |
198 gpu::SurfaceHandle handle, | 199 gpu::SurfaceHandle handle, |
199 gpu::gles2::ContextCreationAttribHelper attributes, | 200 gpu::gles2::ContextCreationAttribHelper attributes, |
200 gpu::SharedMemoryLimits shared_memory_limits, | 201 gpu::SharedMemoryLimits shared_memory_limits, |
201 Compositor::ContextProviderCallback callback, | 202 Compositor::ContextProviderCallback callback, |
202 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host) { | 203 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host) { |
203 if (!gpu_channel_host) | 204 if (!gpu_channel_host) |
204 callback.Run(nullptr); | 205 callback.Run(nullptr); |
205 | 206 |
| 207 int32_t stream_id = kGpuStreamIdDefault; |
| 208 gpu::SchedulingPriority stream_priority = kGpuStreamPriorityUI; |
| 209 |
206 constexpr bool automatic_flushes = false; | 210 constexpr bool automatic_flushes = false; |
207 constexpr bool support_locking = false; | 211 constexpr bool support_locking = false; |
| 212 |
208 scoped_refptr<ui::ContextProviderCommandBuffer> context_provider = | 213 scoped_refptr<ui::ContextProviderCommandBuffer> context_provider = |
209 new ui::ContextProviderCommandBuffer( | 214 new ui::ContextProviderCommandBuffer( |
210 std::move(gpu_channel_host), gpu::GPU_STREAM_DEFAULT, | 215 std::move(gpu_channel_host), stream_id, stream_priority, handle, |
211 gpu::GpuStreamPriority::NORMAL, handle, | |
212 GURL(std::string("chrome://gpu/Compositor::CreateContextProvider")), | 216 GURL(std::string("chrome://gpu/Compositor::CreateContextProvider")), |
213 automatic_flushes, support_locking, shared_memory_limits, attributes, | 217 automatic_flushes, support_locking, shared_memory_limits, attributes, |
214 nullptr /* shared_context */, | 218 nullptr /* shared_context */, |
215 ui::command_buffer_metrics::CONTEXT_TYPE_UNKNOWN); | 219 ui::command_buffer_metrics::CONTEXT_TYPE_UNKNOWN); |
216 callback.Run(std::move(context_provider)); | 220 callback.Run(std::move(context_provider)); |
217 } | 221 } |
218 | 222 |
219 class AndroidOutputSurface : public cc::OutputSurface { | 223 class AndroidOutputSurface : public cc::OutputSurface { |
220 public: | 224 public: |
221 AndroidOutputSurface( | 225 AndroidOutputSurface( |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 HandlePendingCompositorFrameSinkRequest(); | 716 HandlePendingCompositorFrameSinkRequest(); |
713 return; | 717 return; |
714 } | 718 } |
715 | 719 |
716 // We don't need the context anymore if we are invisible. | 720 // We don't need the context anymore if we are invisible. |
717 if (!host_->IsVisible()) | 721 if (!host_->IsVisible()) |
718 return; | 722 return; |
719 | 723 |
720 DCHECK(window_); | 724 DCHECK(window_); |
721 DCHECK_NE(surface_handle_, gpu::kNullSurfaceHandle); | 725 DCHECK_NE(surface_handle_, gpu::kNullSurfaceHandle); |
| 726 |
| 727 int32_t stream_id = kGpuStreamIdDefault; |
| 728 gpu::SchedulingPriority stream_priority = kGpuStreamPriorityUI; |
| 729 |
722 constexpr bool support_locking = false; | 730 constexpr bool support_locking = false; |
723 constexpr bool automatic_flushes = false; | 731 constexpr bool automatic_flushes = false; |
| 732 |
724 ui::ContextProviderCommandBuffer* shared_context = nullptr; | 733 ui::ContextProviderCommandBuffer* shared_context = nullptr; |
725 scoped_refptr<ui::ContextProviderCommandBuffer> context_provider = | 734 scoped_refptr<ui::ContextProviderCommandBuffer> context_provider = |
726 new ui::ContextProviderCommandBuffer( | 735 new ui::ContextProviderCommandBuffer( |
727 std::move(gpu_channel_host), gpu::GPU_STREAM_DEFAULT, | 736 std::move(gpu_channel_host), stream_id, stream_priority, |
728 gpu::GpuStreamPriority::NORMAL, surface_handle_, | 737 surface_handle_, |
729 GURL(std::string("chrome://gpu/CompositorImpl::") + | 738 GURL(std::string("chrome://gpu/CompositorImpl::") + |
730 std::string("CompositorContextProvider")), | 739 std::string("CompositorContextProvider")), |
731 automatic_flushes, support_locking, | 740 automatic_flushes, support_locking, |
732 GetCompositorContextSharedMemoryLimits(root_window_), | 741 GetCompositorContextSharedMemoryLimits(root_window_), |
733 GetCompositorContextAttributes(has_transparent_background_), | 742 GetCompositorContextAttributes(has_transparent_background_), |
734 shared_context, | 743 shared_context, |
735 ui::command_buffer_metrics::DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT); | 744 ui::command_buffer_metrics::DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT); |
736 if (!context_provider->BindToCurrentThread()) { | 745 if (!context_provider->BindToCurrentThread()) { |
737 LOG(ERROR) << "Failed to init ContextProvider for compositor."; | 746 LOG(ERROR) << "Failed to init ContextProvider for compositor."; |
738 LOG_IF(FATAL, ++num_successive_context_creation_failures_ >= 2) | 747 LOG_IF(FATAL, ++num_successive_context_creation_failures_ >= 2) |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 } | 882 } |
874 GetSurfaceManager()->UnregisterFrameSinkHierarchy(frame_sink_id_, | 883 GetSurfaceManager()->UnregisterFrameSinkHierarchy(frame_sink_id_, |
875 frame_sink_id); | 884 frame_sink_id); |
876 } | 885 } |
877 | 886 |
878 bool CompositorImpl::HavePendingReadbacks() { | 887 bool CompositorImpl::HavePendingReadbacks() { |
879 return !readback_layer_tree_->children().empty(); | 888 return !readback_layer_tree_->children().empty(); |
880 } | 889 } |
881 | 890 |
882 } // namespace content | 891 } // namespace content |
OLD | NEW |