OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/compositor/gpu_process_transport_factory.h" | 5 #include "content/browser/compositor/gpu_process_transport_factory.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "content/browser/compositor/browser_compositor_output_surface.h" | 35 #include "content/browser/compositor/browser_compositor_output_surface.h" |
36 #include "content/browser/compositor/frame_sink_manager_host.h" | 36 #include "content/browser/compositor/frame_sink_manager_host.h" |
37 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" | 37 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" |
38 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s
urface.h" | 38 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s
urface.h" |
39 #include "content/browser/compositor/offscreen_browser_compositor_output_surface
.h" | 39 #include "content/browser/compositor/offscreen_browser_compositor_output_surface
.h" |
40 #include "content/browser/compositor/reflector_impl.h" | 40 #include "content/browser/compositor/reflector_impl.h" |
41 #include "content/browser/compositor/software_browser_compositor_output_surface.
h" | 41 #include "content/browser/compositor/software_browser_compositor_output_surface.
h" |
42 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 42 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
43 #include "content/browser/gpu/gpu_data_manager_impl.h" | 43 #include "content/browser/gpu/gpu_data_manager_impl.h" |
44 #include "content/browser/renderer_host/render_widget_host_impl.h" | 44 #include "content/browser/renderer_host/render_widget_host_impl.h" |
45 #include "content/common/gpu_stream_constants.h" | |
46 #include "content/public/common/content_switches.h" | 45 #include "content/public/common/content_switches.h" |
47 #include "gpu/GLES2/gl2extchromium.h" | 46 #include "gpu/GLES2/gl2extchromium.h" |
48 #include "gpu/command_buffer/client/gles2_interface.h" | 47 #include "gpu/command_buffer/client/gles2_interface.h" |
49 #include "gpu/command_buffer/client/shared_memory_limits.h" | 48 #include "gpu/command_buffer/client/shared_memory_limits.h" |
50 #include "gpu/command_buffer/common/mailbox.h" | 49 #include "gpu/command_buffer/common/mailbox.h" |
51 #include "gpu/ipc/client/gpu_channel_host.h" | 50 #include "gpu/ipc/client/gpu_channel_host.h" |
52 #include "gpu/ipc/host/gpu_memory_buffer_support.h" | 51 #include "gpu/ipc/host/gpu_memory_buffer_support.h" |
53 #include "gpu/vulkan/features.h" | 52 #include "gpu/vulkan/features.h" |
54 #include "services/service_manager/runner/common/client_util.h" | 53 #include "services/service_manager/runner/common/client_util.h" |
55 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" | 54 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 gpu::SurfaceHandle surface_handle, | 126 gpu::SurfaceHandle surface_handle, |
128 bool need_alpha_channel, | 127 bool need_alpha_channel, |
129 bool need_stencil_bits, | 128 bool need_stencil_bits, |
130 bool support_locking, | 129 bool support_locking, |
131 ui::ContextProviderCommandBuffer* shared_context_provider, | 130 ui::ContextProviderCommandBuffer* shared_context_provider, |
132 ui::command_buffer_metrics::ContextType type) { | 131 ui::command_buffer_metrics::ContextType type) { |
133 DCHECK( | 132 DCHECK( |
134 content::GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()); | 133 content::GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()); |
135 DCHECK(gpu_channel_host); | 134 DCHECK(gpu_channel_host); |
136 | 135 |
137 // All browser contexts get the same stream id because we don't use sync | |
138 // tokens for browser surfaces. | |
139 int32_t stream_id = content::kGpuStreamIdDefault; | |
140 gpu::SchedulingPriority stream_priority = content::kGpuStreamPriorityUI; | |
141 | |
142 // This is called from a few places to create different contexts: | 136 // This is called from a few places to create different contexts: |
143 // - The shared main thread context (offscreen). | 137 // - The shared main thread context (offscreen). |
144 // - The compositor context, which is used by the browser compositor | 138 // - The compositor context, which is used by the browser compositor |
145 // (offscreen) for synchronization mostly, and by the display compositor | 139 // (offscreen) for synchronization mostly, and by the display compositor |
146 // (onscreen, except for with mus) for actual GL drawing. | 140 // (onscreen, except for with mus) for actual GL drawing. |
147 // - The compositor worker context (offscreen) used for GPU raster. | 141 // - The compositor worker context (offscreen) used for GPU raster. |
148 // So ask for capabilities needed by any of these cases (we can optimize by | 142 // So ask for capabilities needed by any of these cases (we can optimize by |
149 // branching on |surface_handle| being null if these needs diverge). | 143 // branching on |surface_handle| being null if these needs diverge). |
150 // | 144 // |
151 // The default framebuffer for an offscreen context is not used, so it does | 145 // The default framebuffer for an offscreen context is not used, so it does |
152 // not need alpha, stencil, depth, antialiasing. The display compositor does | 146 // not need alpha, stencil, depth, antialiasing. The display compositor does |
153 // not use these things either (except for alpha when using mus for | 147 // not use these things either (except for alpha when using mus for |
154 // non-opaque ui that overlaps the system's window borders or stencil bits | 148 // non-opaque ui that overlaps the system's window borders or stencil bits |
155 // for overdraw feedback), so we can request only that when needed. | 149 // for overdraw feedback), so we can request only that when needed. |
156 gpu::gles2::ContextCreationAttribHelper attributes; | 150 gpu::gles2::ContextCreationAttribHelper attributes; |
157 attributes.alpha_size = need_alpha_channel ? 8 : -1; | 151 attributes.alpha_size = need_alpha_channel ? 8 : -1; |
158 attributes.depth_size = 0; | 152 attributes.depth_size = 0; |
159 attributes.stencil_size = need_stencil_bits ? 8 : 0; | 153 attributes.stencil_size = need_stencil_bits ? 8 : 0; |
160 attributes.samples = 0; | 154 attributes.samples = 0; |
161 attributes.sample_buffers = 0; | 155 attributes.sample_buffers = 0; |
162 attributes.bind_generates_resource = false; | 156 attributes.bind_generates_resource = false; |
163 attributes.lose_context_when_out_of_memory = true; | 157 attributes.lose_context_when_out_of_memory = true; |
164 attributes.buffer_preserved = false; | 158 attributes.buffer_preserved = false; |
165 | 159 |
166 constexpr bool automatic_flushes = false; | 160 constexpr bool automatic_flushes = false; |
167 | 161 |
168 GURL url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon"); | 162 GURL url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon"); |
169 return make_scoped_refptr(new ui::ContextProviderCommandBuffer( | 163 return make_scoped_refptr(new ui::ContextProviderCommandBuffer( |
170 std::move(gpu_channel_host), stream_id, stream_priority, surface_handle, | 164 std::move(gpu_channel_host), gpu::GPU_STREAM_DEFAULT, |
171 url, automatic_flushes, support_locking, gpu::SharedMemoryLimits(), | 165 gpu::GpuStreamPriority::NORMAL, surface_handle, url, automatic_flushes, |
172 attributes, shared_context_provider, type)); | 166 support_locking, gpu::SharedMemoryLimits(), attributes, |
| 167 shared_context_provider, type)); |
173 } | 168 } |
174 | 169 |
175 #if defined(OS_MACOSX) | 170 #if defined(OS_MACOSX) |
176 bool IsCALayersDisabledFromCommandLine() { | 171 bool IsCALayersDisabledFromCommandLine() { |
177 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 172 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
178 return command_line->HasSwitch(switches::kDisableMacOverlays); | 173 return command_line->HasSwitch(switches::kDisableMacOverlays); |
179 } | 174 } |
180 #endif | 175 #endif |
181 | 176 |
182 } // namespace | 177 } // namespace |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 shared_vulkan_context_provider_ = | 943 shared_vulkan_context_provider_ = |
949 cc::VulkanInProcessContextProvider::Create(); | 944 cc::VulkanInProcessContextProvider::Create(); |
950 } | 945 } |
951 | 946 |
952 shared_vulkan_context_provider_initialized_ = true; | 947 shared_vulkan_context_provider_initialized_ = true; |
953 } | 948 } |
954 return shared_vulkan_context_provider_; | 949 return shared_vulkan_context_provider_; |
955 } | 950 } |
956 | 951 |
957 } // namespace content | 952 } // namespace content |
OLD | NEW |