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